SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
unicodestring.h
Go to the documentation of this file.
1 // Unicode-Definition
3 class TUnicodeDef{
4 private:
6 private:
9 public:
10  TUnicodeDef(): Unicode(NULL){}
11  ~TUnicodeDef(){if (Unicode!=NULL){delete Unicode;} Unicode=NULL;}
12 
13  // files
14  static TStr GetDfFNm();
15  static void Load(){
16  Load(GetDfFNm());}
17  static void Load(const TStr& FNm){
18  UnicodeDef.Unicode=new TUnicode(FNm);}
19 
20  // status
21  static bool IsDef(){
22  return UnicodeDef.Unicode!=NULL;}
23  static TUnicode* GetDef(){
24  Assert(UnicodeDef.Unicode!=NULL); return UnicodeDef.Unicode;}
25 };
26 
28 // Unicode-String
29 class TUStr;
30 typedef TVec<TUStr> TUStrV;
31 
32 class TUStr{
33 private:
35  static void AssertUnicodeDefOk(){
36  EAssertR(TUnicodeDef::IsDef(), "Unicode-Definition-File not loaded!");}
37 public:
39  TUStr(const TUStr& UStr): UniChV(UStr.UniChV){AssertUnicodeDefOk();}
40  TUStr(const TIntV& _UniChV): UniChV(_UniChV){AssertUnicodeDefOk();}
41  TUStr(const TStr& Str);
42  ~TUStr(){}
44  void Save(TSOut& SOut) const {UniChV.Save(SOut);}
45  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
46  void SaveXml(TSOut& SOut, const TStr& Nm) const;
47 
48  TUStr& operator=(const TUStr& UStr){
49  if (this!=&UStr){UniChV=UStr.UniChV;} return *this;}
50  bool operator==(const TUStr& UStr) const {return UniChV==UStr.UniChV;}
51 
52  TUStr& operator+=(const TUStr& UStr){UniChV.AddV(UStr.UniChV); return *this;}
53  int operator[](const int& UniChN) const {return UniChV[UniChN];}
54 
55  // basic operations
56  void Clr(){UniChV.Clr();}
57  int Len() const {return UniChV.Len();}
58  bool Empty() const {return UniChV.Empty();}
59 
60  // transformations
61  void ToLowerCase();
62  void ToUpperCase();
63  void ToStarterCase();
64 
65  // word boundaries
66  void GetWordBoundPV(TBoolV& WordBoundPV);
67  void GetWordUStrV(TUStrV& UStrV);
68 
69  // conversions to string
70  TStr GetStr() const;
71  TStr GetStarterStr() const;
73 
74  // scripts
75  static int GetScriptId(const TStr& ScriptNm);
76  static TStr GetScriptNm(const int& ScriptId);
77  static int GetChScriptId(const int& UniCh);
78  static TStr GetChScriptNm(const int& UniCh);
79 
80  // characters
81  static TStr GetChNm(const int& UniCh);
82  static TStr GetChTypeStr(const int& UniCh);
83  static bool IsCase(const int& UniCh);
84  static bool IsUpperCase(const int& UniCh);
85  static bool IsLowerCase(const int& UniCh);
86  static bool IsAlphabetic(const int& UniCh);
87  static bool IsMath(const int& UniCh);
88 
89  // converstions to/from UTF8
90  static TStr EncodeUtf8(const int& UniCh);
91 };
TUnicode * Unicode
Definition: unicodestring.h:7
static bool IsAlphabetic(const int &UniCh)
void ToStarterCase()
static void Load()
Definition: unicodestring.h:15
static TUnicodeDef UnicodeDef
Definition: unicodestring.h:5
TUStr & operator=(const TUStr &UStr)
Definition: unicodestring.h:48
static TStr GetChNm(const int &UniCh)
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
void ToUpperCase()
static TUnicode * GetDef()
Definition: unicodestring.h:23
TStr GetStarterLowerCaseStr() const
static TStr GetChScriptNm(const int &UniCh)
static TStr GetDfFNm()
bool Empty() const
Definition: unicodestring.h:58
static TStr GetChTypeStr(const int &UniCh)
Definition: fl.h:58
void Save(TSOut &SOut) const
Definition: ds.h:954
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:570
TUStr & operator+=(const TUStr &UStr)
Definition: unicodestring.h:52
TUStr(const TIntV &_UniChV)
Definition: unicodestring.h:40
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
static bool IsLowerCase(const int &UniCh)
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
int operator[](const int &UniChN) const
Definition: unicodestring.h:53
UndefCopyAssign(TUnicodeDef)
void Save(TSOut &SOut) const
Definition: unicodestring.h:44
static bool IsMath(const int &UniCh)
#define Assert(Cond)
Definition: bd.h:251
static int GetChScriptId(const int &UniCh)
static bool IsUpperCase(const int &UniCh)
void Clr()
Definition: unicodestring.h:56
Definition: fl.h:128
TUStr(const TUStr &UStr)
Definition: unicodestring.h:39
static int GetScriptId(const TStr &ScriptNm)
TVec< TUStr > TUStrV
Definition: unicodestring.h:29
void GetWordUStrV(TUStrV &UStrV)
void GetWordBoundPV(TBoolV &WordBoundPV)
Definition: dt.h:412
static bool IsDef()
Definition: unicodestring.h:21
TIntV UniChV
Definition: unicodestring.h:34
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
TUStr(TSIn &SIn)
Definition: unicodestring.h:43
static TStr GetScriptNm(const int &ScriptId)
Definition: bd.h:196
void SaveXml(TSOut &SOut, const TStr &Nm) const
void ToLowerCase()
static void Load(const TStr &FNm)
Definition: unicodestring.h:17
TStr GetStarterStr() const
static TStr EncodeUtf8(const int &UniCh)
static void AssertUnicodeDefOk()
Definition: unicodestring.h:35
int Len() const
Definition: unicodestring.h:57
bool operator==(const TUStr &UStr) const
Definition: unicodestring.h:50
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:430
TStr GetStr() const
TSizeTy AddV(const TVec< TVal, TSizeTy > &ValV)
Adds the elements of the vector ValV to the to end of the vector.
Definition: ds.h:1110
static bool IsCase(const int &UniCh)