SNAP Library 6.0, Developer Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
dt.h
Go to the documentation of this file.
1 #include "bd.h"
2 
4 // Forward
5 class TILx;
6 class TOLx;
8 
10 // Random
11 class TRnd{
12 public:
13  static const int RndSeed;
14 private:
15  static const int a, m, q, r;
16  int Seed;
17  int GetNextSeed(){
18  if ((Seed=a*(Seed%q)-r*(Seed/q))>0){return Seed;} else {return Seed+=m;}}
19 public:
20  TRnd(const int& _Seed=1, const int& Steps=0){
21  PutSeed(_Seed); Move(Steps);}
22  explicit TRnd(TSIn& SIn){SIn.Load(Seed);}
23  void Save(TSOut& SOut) const {SOut.Save(Seed);}
24  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
25  void SaveXml(TSOut& SOut, const TStr& Nm) const;
26 
27  TRnd& operator=(const TRnd& Rnd){Seed=Rnd.Seed; return *this;}
28  bool operator==(const TRnd&) const {Fail; return false;}
29 
30  double GetUniDev(){return GetNextSeed()/double(m);}
31  int GetUniDevInt(const int& Range=0);
32  int GetUniDevInt(const int& MnVal, const int& MxVal){
33  IAssert(MnVal<=MxVal); return MnVal+GetUniDevInt(MxVal-MnVal+1);}
34  uint GetUniDevUInt(const uint& Range=0);
35  int64 GetUniDevInt64(const int64& Range=0);
36  uint64 GetUniDevUInt64(const uint64& Range=0);
37  double GetNrmDev();
38  double GetNrmDev(
39  const double& Mean, const double& SDev, const double& Mn, const double& Mx);
40  double GetExpDev();
41  double GetExpDev(const double& Lambda); // mean=1/lambda
42  double GetGammaDev(const int& Order);
43  double GetPoissonDev(const double& Mean);
44  double GetBinomialDev(const double& Prb, const int& Trials);
45  int GetGeoDev(const double& Prb){
46  return 1+(int)floor(log(1.0-GetUniDev())/log(1.0-Prb));}
47  double GetPowerDev(const double& AlphaSlope){ // power-law degree distribution (AlphaSlope>0)
48  IAssert(AlphaSlope>1.0);
49  return pow(1.0-GetUniDev(), -1.0/(AlphaSlope-1.0));}
50  double GetRayleigh(const double& Sigma) { // 1/sqrt(alpha) = sigma
51  IAssert(Sigma>0.0);
52  return Sigma*sqrt(-2*log(1-GetUniDev()));}
53  double GetWeibull(const double& K, const double& Lambda) { // 1/alpha = lambda
54  IAssert(Lambda>0.0 && K>0.0);
55  return Lambda*pow(-log(1-GetUniDev()), 1.0/K);}
56  //void GetSphereDev(const int& Dim, TFltV& ValV);
57 
58  void PutSeed(const int& _Seed);
59  int GetSeed() const {return Seed;}
60  void Randomize(){PutSeed(RndSeed);}
61  void Move(const int& Steps);
62  bool Check();
63 
64  static double GetUniDevStep(const int& Seed, const int& Steps){
65  TRnd Rnd(Seed); Rnd.Move(Steps); return Rnd.GetUniDev();}
66  static double GetNrmDevStep(const int& Seed, const int& Steps){
67  TRnd Rnd(Seed); Rnd.Move(Steps); return Rnd.GetNrmDev();}
68  static double GetExpDevStep(const int& Seed, const int& Steps){
69  TRnd Rnd(Seed); Rnd.Move(Steps); return Rnd.GetExpDev();}
70 
71  static TRnd LoadTxt(TILx& Lx);
72  void SaveTxt(TOLx& Lx) const;
73 };
74 
76 // Memory
78 private:
79  int MxBfL, BfL;
80  char* Bf;
81  void Resize(const int& _MxBfL);
82  bool DoFitLen(const int& LBfL) const {return BfL+LBfL<=MxBfL;}
83 public:
84  TMem(const int& _MxBfL=0):
85  MxBfL(_MxBfL), BfL(0), Bf(NULL){ IAssert(BfL>=0);
86  if (MxBfL>0){Bf=new char[MxBfL]; IAssert(Bf!=NULL);}}
87  static PMem New(const int& MxBfL=0){return new TMem(MxBfL);}
88  TMem(const void* _Bf, const int& _BfL):
89  MxBfL(_BfL), BfL(_BfL), Bf(NULL){ IAssert(BfL>=0);
90  if (BfL>0){Bf=new char[BfL]; IAssert(Bf!=NULL); memcpy(Bf, _Bf, BfL);}}
91  static PMem New(const void* Bf, const int& BfL){return new TMem(Bf, BfL);}
92  TMem(const TMem& Mem):
93  MxBfL(Mem.MxBfL), BfL(Mem.BfL), Bf(NULL){
94  if (MxBfL>0){Bf=new char[MxBfL]; memcpy(Bf, Mem.Bf, BfL);}}
95  static PMem New(const TMem& Mem){return new TMem(Mem);}
96  static PMem New(const PMem& Mem){return new TMem(*Mem);}
97  TMem(const TStr& Str);
98  static PMem New(const TStr& Str){return new TMem(Str);}
99  ~TMem(){if (Bf!=NULL){delete[] Bf;}}
100  explicit TMem(TSIn& SIn){
101  SIn.Load(MxBfL); SIn.Load(BfL);
102  Bf=new char[MxBfL=BfL]; SIn.LoadBf(Bf, BfL);}
103  void Save(TSOut& SOut) const {
104  SOut.Save(MxBfL); SOut.Save(BfL); SOut.SaveBf(Bf, BfL);}
105  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
106  void SaveXml(TSOut& SOut, const TStr& Nm) const;
107 
108  TMem& operator=(const TMem& Mem){
109  if (this!=&Mem){
110  if (Bf!=NULL){delete[] Bf;}
111  MxBfL=Mem.MxBfL; BfL=Mem.BfL; Bf=NULL;
112  if (MxBfL>0){Bf=new char[MxBfL]; memcpy(Bf, Mem.Bf, BfL);}}
113  return *this;}
114  char* operator()() const {return Bf;}
115  TMem& operator+=(const char& Ch);
116  TMem& operator+=(const TMem& Mem);
117  TMem& operator+=(const TStr& Str);
118  TMem& operator+=(const PSIn& SIn);
119  char& operator[](const int& ChN) const {
120  Assert((0<=ChN)&&(ChN<BfL)); return Bf[ChN];}
121  int GetMemUsed() const {return int(2*sizeof(int)+sizeof(char*)+MxBfL);}
122 
123  void Gen(const int& _BfL){
124  Clr(); Resize(_BfL); BfL=_BfL;}
125  void GenZeros(const int& _BfL){
126  Clr(false); Resize(_BfL); BfL=_BfL;
127  if (BfL > 0) memset(Bf, 0, BfL);}
128  void Reserve(const int& _MxBfL, const bool& DoClr = true){
129  if (DoClr){ Clr(); } Resize(_MxBfL);}
130  void Del(const int& BChN, const int& EChN);
131  void Clr(const bool& DoDel=true){
132  if (DoDel){if (Bf!=NULL){delete[] Bf;} MxBfL=0; BfL=0; Bf=NULL;}
133  else {BfL=0;}}
134  int Len() const {return BfL;}
135  bool Empty() const {return BfL==0;}
136  void Trunc(const int& _BfL){
137  if ((0<=_BfL)&&(_BfL<=BfL)){BfL=_BfL;}}
138  void Push(const char& Ch){operator+=(Ch);}
139  char Pop(){IAssert(BfL>0); BfL--; return Bf[BfL];}
140 
141  bool DoFitStr(const TStr& Str) const;
142  //int AddStr(const TStr& Str);
143  void AddBf(const void* Bf, const int& BfL);
144  char* GetBf() const {return Bf;}
145  TStr GetAsStr(const char& NewNullCh='\0') const;
146  PSIn GetSIn() const {
147  TMOut MOut(BfL); MOut.SaveBf(Bf, BfL); return MOut.GetSIn();}
148 
149  static void LoadMem(const PSIn& SIn, TMem& Mem){
150  Mem.Clr(); Mem.Gen(SIn->Len()); SIn->GetBf(Mem.Bf, SIn->Len());}
151  static void LoadMem(const PSIn& SIn, const PMem& Mem){
152  Mem->Clr(); Mem->Gen(SIn->Len()); SIn->GetBf(Mem->Bf, SIn->Len());}
153  void SaveMem(const PSOut& SOut) const {SOut->SaveBf(Bf, Len());}
154 };
155 
157 // Input-Memory
158 class TMemIn: public TSIn{
159 private:
161  const char* Bf;
162  int BfC, BfL;
163 public:
164  TMemIn(const TMem& _Mem, const int& _BfC=0);
165  static PSIn New(const TMem& Mem){
166  return PSIn(new TMemIn(Mem));}
167  static PSIn New(const PMem& Mem){
168  TMemIn* MemIn=new TMemIn(*Mem); MemIn->Mem=Mem; return PSIn(MemIn);}
170 
171  bool Eof(){return BfC==BfL;}
172  int Len() const {return BfL-BfC;}
173  char GetCh(){Assert(BfC<BfL); return Bf[BfC++];}
174  char PeekCh(){Assert(BfC<BfL); return Bf[BfC];}
175  int GetBf(const void* LBf, const TSize& LBfL);
176  void Reset(){Cs=TCs(); BfC=0;}
177  bool GetNextLnBf(TChA& LnChA);
178 };
179 
181 // Output-Memory
182 class TMemOut: public TSOut{
183 private:
185 private:
186  void FlushBf();
187 public:
188  TMemOut(const PMem& _Mem);
189  static PSOut New(const PMem& Mem){
190  return new TMemOut(Mem);}
192 
193  int PutCh(const char& Ch){
194  Mem->operator+=(Ch); return Ch;}
195  int PutBf(const void* LBf, const TSize& LBfL);
196  void Flush(){}
197 };
198 
200 // Char-Array
201 class TChA{
202 private:
203  int MxBfL, BfL;
204  char* Bf;
205  void Resize(const int& _MxBfL);
206 public:
207  explicit TChA(const int& _MxBfL=256){
208  Bf=new char[(MxBfL=_MxBfL)+1]; Bf[BfL=0]=0;}
209  TChA(const char* CStr){
210  Bf=new char[(MxBfL=BfL=int(strlen(CStr)))+1]; strcpy(Bf, CStr);}
211  TChA(const char* CStr, const int& StrLen) : MxBfL(StrLen), BfL(StrLen) {
212  Bf=new char[StrLen+1]; strncpy(Bf, CStr, StrLen); Bf[StrLen]=0;}
213  TChA(const TChA& ChA){
214  Bf=new char[(MxBfL=ChA.MxBfL)+1]; BfL=ChA.BfL; strcpy(Bf, ChA.CStr());}
215  TChA(const TStr& Str);
216  TChA(const TMem& Mem){
217  Bf=new char[(MxBfL=BfL=Mem.Len())+1]; Bf[MxBfL]=0;
218  memcpy(CStr(), Mem(), Mem.Len());}
219  ~TChA(){delete[] Bf;}
220  explicit TChA(TSIn& SIn){
221  SIn.Load(MxBfL); SIn.Load(BfL); SIn.Load(Bf, MxBfL, BfL);}
222  void Load(TSIn& SIn){ delete[] Bf;
223  SIn.Load(MxBfL); SIn.Load(BfL); SIn.Load(Bf, MxBfL, BfL);}
224  void Save(TSOut& SOut, const bool& SaveCompact=true) const { //J:
225  SOut.Save(SaveCompact?BfL:MxBfL); SOut.Save(BfL); SOut.Save(Bf, BfL);}
226  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
227  void SaveXml(TSOut& SOut, const TStr& Nm) const;
228 
229  TChA& operator=(const TChA& ChA);
230  TChA& operator=(const TStr& Str);
231  TChA& operator=(const char* CStr);
232  bool operator==(const TChA& ChA) const {return strcmp(CStr(), ChA.CStr())==0;}
233  bool operator==(const char* _CStr) const {return strcmp(CStr(), _CStr)==0;}
234  bool operator==(const char& Ch) const {return (BfL==1)&&(Bf[0]==Ch);}
235  bool operator!=(const TChA& ChA) const {return strcmp(CStr(), ChA.CStr())!=0;}
236  bool operator!=(const char* _CStr) const {return strcmp(CStr(), _CStr)!=0;}
237  bool operator!=(const char& Ch) const {return !((BfL==1)&&(Bf[0]==Ch));}
238  bool operator<(const TChA& ChA) const {return strcmp(CStr(), ChA.CStr())<0;}
239 
240  TChA& operator+=(const TMem& Mem);
241  TChA& operator+=(const TChA& ChA);
242  TChA& operator+=(const TStr& Str);
243  TChA& operator+=(const char* CStr);
244  TChA& operator+=(const char& Ch){
245  if (BfL==MxBfL){Resize(BfL+1);}
246  Bf[BfL]=Ch; BfL++; Bf[BfL]=0; return *this;}
247  char operator[](const int& ChN) const {
248  Assert((0<=ChN)&&(ChN<BfL)); return Bf[ChN];}
249  char& operator[](const int& ChN){
250  Assert((0<=ChN)&&(ChN<BfL)); return Bf[ChN];}
251  int GetMemUsed() const {return int(2*sizeof(int)+sizeof(char*)+sizeof(char)*MxBfL);}
252 
253  char* operator ()(){return Bf;}
254  const char* operator ()() const {return Bf;}
255  char* CStr() {return Bf;}
256  const char* CStr() const {return Bf;}
257 
258  void Clr(){Bf[BfL=0]=0;}
259  int Len() const {return BfL;}
260  bool Empty() const {return BfL==0;}
261  void Ins(const int& BChN, const char* CStr);
262  void Del(const int& ChN);
263  void DelLastCh(){Pop();}
264  void Push(const char& Ch){operator+=(Ch);}
265  char Pop(){IAssert(BfL>0); BfL--; char Ch=Bf[BfL]; Bf[BfL]=0; return Ch;}
266  void Trunc();
267  void Trunc(const int& _BfL){
268  if ((0<=_BfL)&&(_BfL<=BfL)){Bf[BfL=_BfL]=0;}}
269  void Reverse();
270 
271  void AddCh(const char& Ch, const int& MxLen=-1){
272  if ((MxLen==-1)||(BfL<MxLen)){operator+=(Ch);}}
273  void AddChTo(const char& Ch, const int& ToChN){
274  while (Len()<ToChN){AddCh(Ch);}}
275  void AddBf(char *NewBf, const int& BfS){
276  if ((BfL+BfS+1)>MxBfL){Resize(BfL+BfS+1);}
277  strncpy(Bf+BfL,NewBf,BfS); BfL+=BfS; Bf[BfL]=0;}
278  void PutCh(const int& ChN, const char& Ch){
279  Assert((0<=ChN)&&(ChN<BfL)); Bf[ChN]=Ch;}
280  char GetCh(const int& ChN) const {return operator[](ChN);}
281  char LastCh() const { Assert(1<=BfL); return Bf[BfL-1]; }
282  char LastLastCh() const { Assert(2<=BfL); return Bf[BfL-2]; }
283 
284  TChA GetSubStr(const int& BChN, const int& EChN) const;
285 
286  int CountCh(const char& Ch, const int& BChN=0) const;
287  int SearchCh(const char& Ch, const int& BChN=0) const;
288  int SearchChBack(const char& Ch, int BChN=-1) const;
289  int SearchStr(const TChA& Str, const int& BChN=0) const;
290  int SearchStr(const TStr& Str, const int& BChN=0) const;
291  int SearchStr(const char* CStr, const int& BChN=0) const;
292  bool IsStrIn(const TStr& Str) const {return SearchStr(Str)!=-1;}
293  bool IsPrefix(const char* CStr, const int& BChN=0) const;
294  bool IsPrefix(const TStr& Str) const;
295  bool IsPrefix(const TChA& Str) const;
296  bool IsSuffix(const char* CStr) const;
297  bool IsSuffix(const TStr& Str) const;
298  bool IsSuffix(const TChA& Str) const;
299 
300  bool IsChIn(const char& Ch) const {return SearchCh(Ch)!=-1;}
301  void ChangeCh(const char& SrcCh, const char& DstCh);
302  TChA& ToUc();
303  TChA& ToLc();
304  TChA& ToTrunc();
305  void CompressWs();
306  void Swap(const int& ChN1, const int& ChN2);
307  void Swap(TChA& ChA);
308 
309  int GetPrimHashCd() const;
310  int GetSecHashCd() const;
311 
312  static void LoadTxt(const PSIn& SIn, TChA& ChA);
313  void SaveTxt(const PSOut& SOut) const;
314 
315  //friend TChA operator+(const TChA& LStr, const TChA& RStr);
316  //friend TChA operator+(const TChA& LStr, const TStr& RStr);
317  //friend TChA operator+(const TChA& LStr, const char* RCStr);
318 };
319 
321 // Input-Char-Array
322 class TChAIn: public TSIn{
323 private:
324  const char* Bf;
325  int BfC, BfL;
326 private:
327  TChAIn();
328  TChAIn(const TChAIn&);
329  TChAIn& operator=(const TChAIn&);
330 public:
331  TChAIn(const TChA& ChA, const int& _BfC=0);
332  static PSIn New(const TChA& ChA){return PSIn(new TChAIn(ChA));}
334 
335  bool Eof(){return BfC==BfL;}
336  int Len() const {return BfL-BfC;}
337  char GetCh(){Assert(BfC<BfL); return Bf[BfC++];}
338  char PeekCh(){Assert(BfC<BfL); return Bf[BfC];}
339  int GetBf(const void* LBf, const TSize& LBfL);
340  void Reset(){Cs=TCs(); BfC=0;}
341  bool GetNextLnBf(TChA& LnChA);
342 };
343 
345 // Ref-String
346 class TRStr{
347 public:
348  char* Bf;
349  int Refs;
350 public:
351  TRStr(){Refs=1; Bf=new char[0+1]; Bf[0]=0;}
352  TRStr(const int& Len){
353  IAssert(Len>=0); Refs=0; Bf=new char[Len+1]; Bf[Len]=0;}
354  TRStr(const char* CStr){
355  Refs=0; Bf=new char[strlen(CStr)+1]; strcpy(Bf, CStr);}
356  TRStr(const char* CStr, const int& MxLen){
357  Refs=0; Bf=new char[MxLen+1]; strncpy(Bf, CStr, MxLen); Bf[MxLen]=0;}
358  TRStr(const char* CStr1, const char* CStr2){
359  Refs=0; int CStr1Len=int(strlen(CStr1)); Bf=new char[CStr1Len+int(strlen(CStr2))+1];
360  strcpy(Bf, CStr1); strcpy(Bf+CStr1Len, CStr2);}
361  TRStr(const char& Ch){
362  Refs=0; Bf=new char[1+1]; Bf[0]=Ch; Bf[1]=0;}
363  TRStr(const char& Ch1, const char& Ch2){
364  Refs=0; Bf=new char[2+1]; Bf[0]=Ch1; Bf[1]=Ch2; Bf[2]=0;}
366  Assert(((this!=GetNullRStr())&&(Refs==0))||((this==GetNullRStr())&&(Refs==1)));
367  delete[] Bf;}
368  explicit TRStr(TSIn& SIn, const bool& IsSmall){
369  if (IsSmall){Refs=0; SIn.Load(Bf);}
370  else {Refs=0; int BfL; SIn.Load(BfL); SIn.Load(Bf, BfL, BfL);}}
371  void Save(TSOut& SOut, const bool& IsSmall) const {
372  if (IsSmall){SOut.Save(Bf);}
373  else {int BfL=int(strlen(Bf)); SOut.Save(BfL); SOut.Save(Bf, BfL);}}
374 
375  TRStr& operator=(const TRStr&){Fail; return *this;}
376  int GetMemUsed() const {return int(sizeof(int))+int(strlen(Bf));}
377 
378  void MkRef(){Refs++;}
379  void UnRef(){Assert(Refs>0); if (--Refs==0){delete this;}}
380 
381  const char* CStr() const {return Bf;}
382  char* CStr() {return Bf;}
383  bool Empty() const {return Bf[0]==0;}
384  int Len() const {return int(strlen(Bf));}
385 
386  void PutCh(const int& ChN, const char& Ch){
387  Assert((0<=ChN)&&(ChN<Len())); Bf[ChN]=Ch;}
388  char GetCh(const int& ChN) const {
389  Assert((0<=ChN)&&(ChN<Len())); return Bf[ChN];}
390 
391  bool IsUc() const;
392  void ToUc();
393  bool IsLc() const;
394  void ToLc();
395  void ToCap();
396  void ConvUsFromYuAscii();
397  static int CmpI(const char* CStr1, const char* CStr2);
398 
399  int GetPrimHashCd() const;
400  int GetSecHashCd() const;
401 
402  static TRStr* GetNullRStr(){
403  static TRStr NullRStr; Assert(NullRStr.Bf!=NULL); return &NullRStr;}
404 };
405 
407 // String
408 class TStr;
409 template <class TVal, class TSizeTy> class TVec;
410 typedef TVec<TStr, int> TStrV;
411 
412 class TStr{
413 private:
415 private:
416  TStr(const char& Ch, bool){
417  RStr=new TRStr(Ch); RStr->MkRef();}
418  TStr(const char& Ch1, const char& Ch2, bool){
419  RStr=new TRStr(Ch1, Ch2); RStr->MkRef();}
420  static TRStr* GetRStr(const char* CStr);
421  void Optimize();
422 public:
423  TStr(){RStr=TRStr::GetNullRStr(); RStr->MkRef();}
424  TStr(const TStr& Str){RStr=Str.RStr; RStr->MkRef();}
425  TStr(const TChA& ChA){RStr=GetRStr(ChA.CStr()); RStr->MkRef();}
426  TStr(const TSStr& SStr){RStr=GetRStr(SStr.CStr()); RStr->MkRef();}
427  TStr(const char* CStr){RStr=GetRStr(CStr); RStr->MkRef();}
428  explicit TStr(const char& Ch){RStr=GetChStr(Ch).RStr; RStr->MkRef();}
429  TStr(const TMem& Mem){
430  RStr=new TRStr(Mem.Len()); RStr->MkRef();
431  memcpy(CStr(), Mem(), Mem.Len()); Optimize();}
432  explicit TStr(const PSIn& SIn){
433  int SInLen=SIn->Len(); RStr=new TRStr(SInLen); RStr->MkRef();
434  SIn->GetBf(CStr(), SInLen); Optimize();}
435  ~TStr(){RStr->UnRef();}
436  explicit TStr(TSIn& SIn, const bool& IsSmall=false):
437  RStr(new TRStr(SIn, IsSmall)){RStr->MkRef(); Optimize();}
438  void Load(TSIn& SIn, const bool& IsSmall=false){
439  *this=TStr(SIn, IsSmall);}
440  void Save(TSOut& SOut, const bool& IsSmall=false) const {
441  RStr->Save(SOut, IsSmall);}
442  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
443  void SaveXml(TSOut& SOut, const TStr& Nm) const;
444 
445  TStr& operator=(const TStr& Str){
446  if (this!=&Str){RStr->UnRef(); RStr=Str.RStr; RStr->MkRef();} return *this;}
447  TStr& operator=(const TChA& ChA){
448  RStr->UnRef(); RStr=GetRStr(ChA.CStr()); RStr->MkRef(); return *this;}
449  TStr& operator=(const char* CStr){
450  RStr->UnRef(); RStr=GetRStr(CStr); RStr->MkRef(); return *this;}
451  TStr& operator=(const char& Ch){
452  RStr->UnRef(); RStr=GetChStr(Ch).RStr; RStr->MkRef(); return *this;}
453  TStr& operator+=(const TStr& Str){
454  TRStr* NewRStr=new TRStr(RStr->CStr(), Str.RStr->CStr());
455  RStr->UnRef(); RStr=NewRStr; RStr->MkRef();
456  Optimize(); return *this;}
457  TStr& operator+=(const char* CStr){
458  TRStr* NewRStr=new TRStr(RStr->CStr(), CStr);
459  RStr->UnRef(); RStr=NewRStr; RStr->MkRef();
460  Optimize(); return *this;}
461  TStr& operator/(const int& N){
462  // no-op, this definition is required by the aaMean table aggregation
463  return *this;}
464  bool operator==(const TStr& Str) const {
465  return (RStr==Str.RStr)||(strcmp(RStr->CStr(), Str.RStr->CStr())==0);}
466  bool operator==(const char* CStr) const {
467  return strcmp(RStr->CStr(), CStr)==0;}
468 // bool operator!=(const TStr& Str) const {
469 // return strcmp(RStr->CStr(), Str.RStr->CStr())!=0;}
470  bool operator!=(const char* CStr) const {
471  return strcmp(RStr->CStr(), CStr)!=0;}
472  bool operator<(const TStr& Str) const {
473  return strcmp(RStr->CStr(), Str.RStr->CStr())<0;}
474  char operator[](const int& ChN) const {return RStr->GetCh(ChN);}
475  int GetMemUsed() const {return int(sizeof(TRStr*)+RStr->GetMemUsed());}
476 
477  char* operator()(){return RStr->CStr();}
478  const char* operator()() const {return RStr->CStr();}
479  char* CStr() {return RStr->CStr();}
480  const char* CStr() const {return RStr->CStr();}
481 
482  void PutCh(const int& ChN, const char& Ch){
483  TRStr* NewRStr=new TRStr(RStr->CStr());
484  RStr->UnRef(); RStr=NewRStr; RStr->MkRef();
485  RStr->PutCh(ChN, Ch); Optimize();}
486  char GetCh(const int& ChN) const {return RStr->GetCh(ChN);}
487  char LastCh() const {return GetCh(Len()-1);}
488 
489  void Clr(){RStr->UnRef(); RStr=TRStr::GetNullRStr(); RStr->MkRef();}
490  int Len() const {return RStr->Len();}
491  bool Empty() const {return RStr->Empty();}
492 
493  // upper-case
494  bool IsUc() const {return RStr->IsUc();}
495  TStr& ToUc();
496  TStr GetUc() const {return TStr(*this).ToUc();}
497  int CmpI(const TStr& Str) const {return TRStr::CmpI(CStr(), Str.CStr());}
498  bool EqI(const TStr& Str) const {return TRStr::CmpI(CStr(), Str.CStr())==0;}
499  // lower-case
500  bool IsLc() const {return RStr->IsLc();}
501  TStr& ToLc();
502  TStr GetLc() const {return TStr(*this).ToLc();}
503  // capitalize
504  TStr& ToCap();
505  TStr GetCap() const {return TStr(*this).ToCap();}
506 
507  // truncate
508  TStr& ToTrunc();
509  TStr GetTrunc() const {return TStr(*this).ToTrunc();}
510  // Yu-Ascii to Us-Ascii
512  TStr GetUsFromYuAscii() const {return TStr(*this).ConvUsFromYuAscii();}
513  // hex
514  TStr& ToHex();
515  TStr GetHex() const {return TStr(*this).ToHex();}
516  TStr& FromHex();
517  TStr GetFromHex() const {return TStr(*this).FromHex();}
518 
519  TStr GetSubStr(const int& BChN, const int& EChN) const;
520  TStr GetSubStr(const int& BChN) const { return GetSubStr(BChN, Len()-1); }
521  void InsStr(const int& BChN, const TStr& Str);
522  void DelChAll(const char& Ch);
523  void DelSubStr(const int& BChN, const int& EChN);
524  bool DelStr(const TStr& Str);
525  TStr LeftOf(const char& SplitCh) const;
526  TStr LeftOfLast(const char& SplitCh) const;
527  TStr RightOf(const char& SplitCh) const;
528  TStr RightOfLast(const char& SplitCh) const;
529  void SplitOnCh(TStr& LStr, const char& SplitCh, TStr& RStr) const;
530  void SplitOnLastCh(TStr& LStr, const char& SplitCh, TStr& RStr) const;
531  void SplitOnAllCh(
532  const char& SplitCh, TStrV& StrV, const bool& SkipEmpty=true) const;
533  void SplitOnAllAnyCh(
534  const TStr& SplitChStr, TStrV& StrV, const bool& SkipEmpty=true) const;
535  void SplitOnWs(TStrV& StrV) const;
536  void SplitOnNonAlNum(TStrV& StrV) const;
537  void SplitOnStr(const TStr& SplitStr, TStrV& StrV) const;
538  void SplitOnStr(TStr& LeftStr, const TStr& MidStr, TStr& RightStr) const;
539 
540  //TStr Left(const int& Chs) const { return Chs>0 ? GetSubStr(0, Chs-1) : GetSubStr(0, Len()-Chs-1);}
541  //TStr Right(const int& Chs) const {return GetSubStr(Len()-Chs, Len()-1);}
542  TStr Mid(const int& BChN, const int& Chs) const { return GetSubStr(BChN, BChN+Chs-1); }
543  TStr Mid(const int& BChN) const {return GetSubStr(BChN, Len()-1); }
544  //TStr Slice(const int& BChN, const int& EChNP1) const {return GetSubStr(BChN, EChNP1-1);}
545  //TStr operator()(const int& BChN, const int& EChNP1) const {return Slice(BChN, EChNP1);}
546  //J: as in python or matlab: position 1 is 1st character, -1 is last character
547  TStr Left(const int& EChN) const { return EChN>0 ? GetSubStr(0, EChN-1) : GetSubStr(0, Len()+EChN-1);}
548  TStr Right(const int& BChN) const {return BChN>=0 ? GetSubStr(BChN, Len()-1) : GetSubStr(Len()+BChN, Len()-1);}
549  TStr Slice(int BChN, int EChNP1) const { if(BChN<0){BChN=Len()+BChN;} if(EChNP1<=0){EChNP1=Len()+EChNP1;} return GetSubStr(BChN, EChNP1-1); }
550  TStr operator()(const int& BChN, const int& EChNP1) const {return Slice(BChN, EChNP1);}
551 
552  int CountCh(const char& Ch, const int& BChN=0) const;
553  int SearchCh(const char& Ch, const int& BChN=0) const;
554  int SearchChBack(const char& Ch, int BChN=-1) const;
555  int SearchStr(const TStr& Str, const int& BChN=0) const;
556  bool IsChIn(const char& Ch) const {return SearchCh(Ch)!=-1;}
557  bool IsStrIn(const TStr& Str) const {return SearchStr(Str)!=-1;}
558  bool IsPrefix(const char *Str) const;
559  bool IsPrefix(const TStr& Str) const {
560  return IsPrefix(Str.CStr());}
561  bool IsSuffix(const char *Str) const;
562  bool IsSuffix(const TStr& Str) const {
563  return IsSuffix(Str.CStr());}
564 
565  int ChangeCh(const char& SrcCh, const char& DstCh, const int& BChN=0);
566  int ChangeChAll(const char& SrcCh, const char& DstCh);
567  int ChangeStr(const TStr& SrcStr, const TStr& DstStr, const int& BChN=0);
568  int ChangeStrAll(const TStr& SrcStr, const TStr& DstStr, const bool& FromStartP=false);
569  TStr Reverse() const {
570  TChA ChA(*this); ChA.Reverse(); return ChA;}
571 
572  int GetPrimHashCd() const {return RStr->GetPrimHashCd();}
573  int GetSecHashCd() const {return RStr->GetSecHashCd();}
574 
575  bool IsBool(bool& Val) const;
576 
577  bool IsInt(
578  const bool& Check, const int& MnVal, const int& MxVal, int& Val) const;
579  bool IsInt(int& Val) const {return IsInt(false, 0, 0, Val);}
580  bool IsInt() const {int Val; return IsInt(false, 0, 0, Val);}
581  int GetInt() const {int Val; IAssertR(IsInt(false, 0, 0, Val), *this); return Val;}
582  int GetInt(const int& DfVal) const {
583  int Val; if (IsInt(false, 0, 0, Val)){return Val;} else {return DfVal;}}
584 
585  bool IsUInt(
586  const bool& Check, const uint& MnVal, const uint& MxVal, uint& Val) const;
587  bool IsUInt(uint& Val) const {return IsUInt(false, 0, 0, Val);}
588  bool IsUInt() const {uint Val; return IsUInt(false, 0, 0, Val);}
589  uint GetUInt() const {uint Val; IAssert(IsUInt(false, 0, 0, Val)); return Val;}
590  uint GetUInt(const uint& DfVal) const {
591  uint Val; if (IsUInt(false, 0, 0, Val)){return Val;} else {return DfVal;}}
592 
593  bool IsInt64(
594  const bool& Check, const int64& MnVal, const int64& MxVal, int64& Val) const;
595  bool IsInt64(int64& Val) const {return IsInt64(false, 0, 0, Val);}
596  bool IsInt64() const {int64 Val; return IsInt64(false, 0, 0, Val);}
597  int64 GetInt64() const {
598  int64 Val; IAssert(IsInt64(false, 0, 0, Val)); return Val;}
599  int64 GetInt64(const int64& DfVal) const {
600  int64 Val; if (IsInt64(false, 0, 0, Val)){return Val;} else {return DfVal;}}
601 
602  bool IsUInt64(
603  const bool& Check, const uint64& MnVal, const uint64& MxVal, uint64& Val) const;
604  bool IsUInt64(uint64& Val) const {return IsUInt64(false, 0, 0, Val);}
605  bool IsUInt64() const {uint64 Val; return IsUInt64(false, 0, 0, Val);}
606  uint64 GetUInt64() const {
607  uint64 Val; IAssert(IsUInt64(false, 0, 0, Val)); return Val;}
608  uint64 GetUInt64(const uint64& DfVal) const {
609  uint64 Val; if (IsUInt64(false, 0, 0, Val)){return Val;} else {return DfVal;}}
610 
611  bool IsHexInt(const bool& Check, const int& MnVal, const int& MxVal, int& Val) const;
612  bool IsHexInt(int& Val) const {return IsHexInt(false, 0, 0, Val);}
613  bool IsHexInt() const {int Val; return IsHexInt(false, 0, 0, Val);}
614  int GetHexInt() const {
615  int Val; IAssert(IsHexInt(false, 0, 0, Val)); return Val;}
616  int GetHexInt(const int& DfVal) const {
617  int Val; if (IsHexInt(false, 0, 0, Val)){return Val;} else {return DfVal;}}
618 
619  bool IsHexInt64(const bool& Check, const int64& MnVal, const int64& MxVal, int64& Val) const;
620  bool IsHexInt64(int64& Val) const {return IsHexInt64(false, 0, 0, Val);}
621  bool IsHexInt64() const {int64 Val; return IsHexInt64(false, 0, 0, Val);}
622  int64 GetHexInt64() const {
623  int64 Val; IAssert(IsHexInt64(false, 0, 0, Val)); return Val;}
624  int64 GetHexInt64(const int64& DfVal) const {
625  int64 Val; if (IsHexInt64(false, 0, 0, Val)){return Val;} else {return DfVal;}}
626 
627  bool IsFlt(const bool& Check, const double& MnVal, const double& MxVal,
628  double& Val, const char& DecDelimCh='.') const;
629  bool IsFlt(double& Val) const {return IsFlt(false, 0, 0, Val);}
630  bool IsFlt() const {double Val; return IsFlt(false, 0, 0, Val);}
631  double GetFlt() const {
632  double Val; IAssert(IsFlt(false, 0, 0, Val)); return Val;}
633  double GetFlt(const double& DfVal) const {
634  double Val; if (IsFlt(false, 0, 0, Val)){return Val;} else {return DfVal;}}
635 
636  bool IsWord(const bool& WsPrefixP=true, const bool& FirstUcAllowedP=true) const;
637  bool IsWs() const;
638 
639  bool IsWcMatch(
640  const int& StrBChN, const TStr& WcStr, const int& WcStrBChN, TStrV& StarStrV,
641  const char& StarCh='*', const char& QuestCh='?') const;
642  bool IsWcMatch(
643  const TStr& WcStr, TStrV& StarStrV,
644  const char& StarCh='*', const char& QuestCh='?') const;
645  bool IsWcMatch(const TStr& WcStr, const char& StarCh, const char& QuestCh) const;
646  bool IsWcMatch(const TStr& WcStr, const int& StarStrN, TStr& StarStr) const;
647  bool IsWcMatch(const TStr& WcStr) const;
648  TStr GetWcMatch(const TStr& WcStr, const int& StarStrN=0) const;
649 
650  TStr GetFPath() const;
651  TStr GetFBase() const;
652  TStr GetFMid() const;
653  TStr GetFExt() const;
654  static TStr GetNrFPath(const TStr& FPath);
655  static TStr GetNrFMid(const TStr& FMid);
656  static TStr GetNrFExt(const TStr& FExt);
657  static TStr GetNrNumFExt(const int& FExtN);
658  static TStr GetNrFNm(const TStr& FNm);
659  static TStr GetNrAbsFPath(const TStr& FPath, const TStr& BaseFPath=TStr());
660  static bool IsAbsFPath(const TStr& FPath);
661  static TStr PutFExt(const TStr& FNm, const TStr& FExt);
662  static TStr PutFExtIfEmpty(const TStr& FNm, const TStr& FExt);
663  static TStr PutFBase(const TStr& FNm, const TStr& FBase);
664  static TStr PutFBaseIfEmpty(const TStr& FNm, const TStr& FBase);
665  static TStr AddToFMid(const TStr& FNm, const TStr& ExtFMid);
666  static TStr GetNumFNm(const TStr& FNm, const int& Num);
667  static TStr GetFNmStr(const TStr& Str, const bool& AlNumOnlyP=true);
668 
669  static TStr LoadTxt(const PSIn& SIn){
670  return TStr(SIn);}
671  static TStr LoadTxt(const TStr& FNm){
672  PSIn SIn=TFIn::New(FNm); return LoadTxt(SIn);}
673  void SaveTxt(const PSOut& SOut) const {
674  SOut->SaveBf(CStr(), Len());}
675  void SaveTxt(const TStr& FNm) const {
676  PSOut SOut=TFOut::New(FNm); SaveTxt(SOut);}
677 
678  static TStr& GetChStr(const char& Ch);
679  static TStr& GetDChStr(const char& Ch1, const char& Ch2);
680 
681  TStr GetStr() const {return *this;}
682  static TStr GetStr(const TStr& Str, const char* FmtStr);
683  static TStr GetStr(const TStr& Str, const TStr& FmtStr){
684  return GetStr(Str, FmtStr.CStr());}
685  static TStr GetStr(const TStrV& StrV, const TStr& DelimiterStr);
686  static TStr Fmt(const char *FmtStr, ...);
687  static TStr GetSpaceStr(const int& Spaces);
688  char* GetCStr() const {
689  char* Bf=new char[Len()+1]; strcpy(Bf, CStr()); return Bf;}
690 
691  static TStr MkClone(const TStr& Str){return TStr(Str.CStr());}
692  static TStr GetNullStr();
693 
694  friend TStr operator+(const TStr& LStr, const TStr& RStr);
695  friend TStr operator+(const TStr& LStr, const char* RCStr);
696 };
697 
699 // Input-String
700 class TStrIn: public TSIn{
701 private:
703  char* Bf;
704  int BfC, BfL;
705 private:
706  TStrIn();
707  TStrIn(const TStrIn&);
708  TStrIn& operator = (const TStrIn&);
709 public:
710  TStrIn(const TStr& _Str);
711  static PSIn New(const TStr& Str){return PSIn(new TStrIn(Str));}
713 
714  bool Eof(){return BfC==BfL;}
715  int Len() const {return BfL-BfC;}
716  char GetCh(){Assert(BfC<BfL); return Bf[BfC++];}
717  char PeekCh(){Assert(BfC<BfL); return Bf[BfC];}
718  int GetBf(const void* LBf, const TSize& LBfL);
719  void Reset(){Cs=TCs(); BfC=0;}
720  bool GetNextLnBf(TChA& LnChA);
721 };
722 
724 // Double-String
725 class TDbStr{
726 public:
729 public:
730  TDbStr(): Str1(), Str2(){}
731  TDbStr(const TDbStr& DbStr): Str1(DbStr.Str1), Str2(DbStr.Str2){}
732  TDbStr(const TStr& _Str1): Str1(_Str1), Str2(){}
733  TDbStr(const TStr& _Str1, const TStr& _Str2): Str1(_Str1), Str2(_Str2){}
734  explicit TDbStr(TSIn& SIn): Str1(SIn), Str2(SIn){}
735  void Save(TSOut& SOut) const {Str1.Save(SOut); Str2.Save(SOut);}
736 
737  TDbStr& operator=(const TDbStr& DbStr){
738  if (this!=&DbStr){Str1=DbStr.Str1; Str2=DbStr.Str2;} return *this;}
739  bool operator==(const TDbStr& DbStr) const {
740  return (Str1==DbStr.Str1)&&(Str2==DbStr.Str2);}
741  bool operator<(const TDbStr& DbStr) const {
742  return (Str1<DbStr.Str1)||((Str1==DbStr.Str1)&&(Str2<DbStr.Str2));}
743 
744  TStr GetStr(const TStr& MidStr=TStr()) const {
745  if (Filled()){return Str1+MidStr+Str2;} else {return Str1+Str2;}}
746  int GetPrimHashCd() const {
747  return Str1.GetPrimHashCd()+Str2.GetPrimHashCd();}
748  int GetSecHashCd() const {
749  return Str1.GetSecHashCd()+Str2.GetSecHashCd();}
750 
751  bool Empty() const {return (Str1.Empty())&&(Str2.Empty());}
752  bool Filled() const {return (!Str2.Empty())&&(!Str1.Empty());}
753 };
754 
756 // Simple-String-Pool
757 //ClassTP(TSStrPool, PSStrPool)//{
758 //private:
759 // TMem Bf;
760 //public:
761 // TSStrPool(const int& MxLen=0): Bf(MxLen){}
762 // TSStrPool(TSStrPool& StrPool): Bf(StrPool.Bf){}
763 // TSStrPool(TSIn& SIn): Bf(SIn){}
764 // void Save(TSOut& SOut) const {Bf.Save(SOut);}
765 //
766 // TSStrPool& operator=(const TSStrPool& StrPool){
767 // Bf=StrPool.Bf; return *this;}
768 //
769 // int Len() const {return Bf.Len();}
770 // void Clr(){Bf.Clr();}
771 // int AddStr(const TStr& Str){
772 // if (Str.Empty()){return -1;}
773 // else {int StrId=Bf.Len(); Bf+=Str; Bf+=char(0); return StrId;}}
774 // TStr GetStr(const int& StrId) const {
775 // if (StrId==-1){return "";}
776 // else {return TStr(Bf()+StrId);}}
777 //};
778 
780 // String-Pool
782 private:
783  uint MxBfL, BfL, GrowBy;
784  char *Bf;
785 private:
786  void Resize(const uint& _MxBfL);
787 public:
788  TStrPool(const uint& MxBfLen = 0, const uint& _GrowBy = 16*1024*1024);
789  TStrPool(TSIn& SIn, bool LoadCompact = true);
790  TStrPool(const TStrPool& Pool) : MxBfL(Pool.MxBfL), BfL(Pool.BfL), GrowBy(Pool.GrowBy) {
791  Bf = (char *) malloc(Pool.MxBfL); IAssertR(Bf, TStr::Fmt("Can not resize buffer to %u bytes. [Program failed to allocate more memory. Solution: Get a bigger machine.]", MxBfL).CStr()); memcpy(Bf, Pool.Bf, Pool.BfL); }
792  ~TStrPool() { if (Bf) free(Bf); else IAssertR(MxBfL == 0, TStr::Fmt("size: %u, expected size: 0", MxBfL).CStr()); Bf = 0; MxBfL = 0; BfL = 0; }
793 
794  static PStrPool New(const uint& _MxBfLen = 0, const uint& _GrowBy = 16*1024*1024) { return PStrPool(new TStrPool(_MxBfLen, _GrowBy)); }
795  static PStrPool New(TSIn& SIn) { return new TStrPool(SIn); }
796  static PStrPool New(const TStr& fileName) { PSIn SIn = TFIn::New(fileName); return new TStrPool(*SIn); }
797  static PStrPool Load(TSIn& SIn, bool LoadCompacted = true) { return PStrPool(new TStrPool(SIn, LoadCompacted)); }
798  void Save(TSOut& SOut) const;
799  void Save(const TStr& FNm){PSOut SOut=TFOut::New(FNm); Save(*SOut);}
800 
801  uint Len() const { return BfL; }
802  uint Size() const { return MxBfL; }
803  bool Empty() const { return ! Len(); }
804  char* operator () () const { return Bf; }
805  TStrPool& operator = (const TStrPool& Pool);
806  ::TSize GetMemUsed(){ return 4 * sizeof(int) + MxBfL;}
807 
808  uint AddStr(const char *Str, const uint& Len);
809  uint AddStr(const char *Str) { return AddStr(Str, uint(strlen(Str)) + 1); }
810  uint AddStr(const TStr& Str) { return AddStr(Str.CStr(), Str.Len() + 1); }
811 
812  TStr GetStr(const uint& Offset) const { Assert(Offset < BfL);
813  if (Offset == 0) return TStr::GetNullStr(); else return TStr(Bf + Offset); }
814  const char *GetCStr(const uint& Offset) const { Assert(Offset < BfL);
815  if (Offset == 0) return TStr::GetNullStr().CStr(); else return Bf + Offset; }
816 
817  // Clr() removes the empty string at the start.
818  // Call AddStr("") after Clr(), if you want to use the pool again.
819  void Clr(bool DoDel = false) { BfL = 0; if (DoDel && Bf) { free(Bf); Bf = 0; MxBfL = 0; } }
820  int Cmp(const uint& Offset, const char *Str) const { Assert(Offset < BfL);
821  if (Offset != 0) return strcmp(Bf + Offset, Str); else return strcmp("", Str); }
822 
823  static int GetPrimHashCd(const char *CStr);
824  static int GetSecHashCd(const char *CStr);
825  int GetPrimHashCd(const uint& Offset) { Assert(Offset < BfL);
826  if (Offset != 0) return GetPrimHashCd(Bf + Offset); else return GetPrimHashCd(""); }
827  int GetSecHashCd(const uint& Offset) { Assert(Offset < BfL);
828  if (Offset != 0) return GetSecHashCd(Bf + Offset); else return GetSecHashCd(""); }
829  static PStrPool LoadShM(TSIn& SIn){ return new TStrPool(SIn); }
830 };
831 
833 // String-Pool-64bit
835 private:
836  ::TSize MxBfL, BfL, GrowBy;
837  char *Bf;
838 private:
839  void Resize(const ::TSize& _MxBfL);
840 public:
841  TStrPool64(::TSize _MxBfL = 0, ::TSize _GrowBy = 16*1024*1024);
842  TStrPool64(const TStrPool64& StrPool);
843  TStrPool64(TSIn& SIn, bool LoadCompact = true);
844  ~TStrPool64() { Clr(true); }
845  void Save(TSOut& SOut) const;
846 
847  static PStrPool64 New(::TSize MxBfL = 0, ::TSize GrowBy = 16*1024*1024) {
848  return PStrPool64(new TStrPool64(MxBfL, GrowBy)); }
849  static PStrPool64 Load(TSIn& SIn, bool LoadCompact = true) {
850  return PStrPool64(new TStrPool64(SIn, LoadCompact)); }
851 
852  TStrPool64& operator=(const TStrPool64& StrPool);
853 
854  uint64 GetMemUsed() const { return 3*sizeof(::TSize) + uint64(MxBfL); }
855 
856  bool Empty() const { return (BfL == 0); }
857  uint64 Len() const {return BfL;}
858  uint64 Reserved() const { return MxBfL; }
859  void Clr(bool DoDel = false);
860  int Cmp(uint64 Offset, const char *Str) const { Assert(Offset < BfL);
861  if (Offset != 0) return strcmp(Bf + Offset, Str); else return strcmp("", Str); }
862 
863  uint64 AddStr(const TStr& Str);
864  TStr GetStr(const uint64& StrId) const;
865 };
866 
868 // Number Base Template
869 template <class Base> class TNum{
870 public:
871  Base Val;
872  TNum() : Val(0){}
873  TNum(const Base& _Val) : Val(_Val){}
874  operator Base() const { return Val; }
875  explicit TNum(TSIn& SIn){ SIn.Load(Val); }
876  void Load(TSIn& SIn){ SIn.Load(Val); }
877  void Save(TSOut& SOut) const { SOut.Save(Val); }
878 
879  TNum& operator=(const TNum& Other){ Val = Other.Val; return *this; }
880  TNum& operator=(const Base& _Val){ Val = _Val; return *this; }
881  TNum& operator++(){ ++Val; return *this; } // prefix
882  TNum& operator--(){ --Val; return *this; } // prefix
883  TNum operator++(int){ TNum oldVal = Val; Val++; return oldVal; } // postfix
884  TNum operator--(int){ TNum oldVal = Val; Val--; return oldVal; } // postfix
885  Base& operator()() { return Val; }
886 
887  int GetMemUsed() const { return sizeof(TNum); }
888 };
889 
891 // Signed-Integer-64Bit
893 template<>
894 class TNum<int64>{
895 public:
897 public:
898  static const int64 Mn;
899  static const int64 Mx;
900 
901  TNum() : Val(0){}
902  TNum(const TNum& Int) : Val(Int.Val){}
903  TNum(const int64& Int) : Val(Int){}
904  operator int64() const { return Val; }
905  explicit TNum(TSIn& SIn){ SIn.Load(Val); }
906  void Load(TSIn& SIn){ SIn.Load(Val); }
907  void Save(TSOut& SOut) const { SOut.Save(Val); }
908  TNum& operator=(const TNum& Int){ Val = Int.Val; return *this; }
909  TNum& operator+=(const TNum& Int){ Val += Int.Val; return *this; }
910  TNum& operator-=(const TNum& Int){ Val -= Int.Val; return *this; }
911  TNum& operator++(){ ++Val; return *this; } // prefix
912  TNum& operator--(){ --Val; return *this; } // prefix
913  TNum operator++(int){ TNum oldVal = Val; Val++; return oldVal; } // postfix
914  TNum operator--(int){ TNum oldVal = Val; Val--; return oldVal; } // postfix
915  int GetMemUsed() const { return sizeof(TNum); }
916 
917 #ifdef GLib_WIN
918  TStr GetStr() const { return TStr::Fmt("%I64", Val); }
919  static TStr GetStr(const TNum& Int){ return TStr::Fmt("%I64", Int.Val); }
920  static TStr GetHexStr(const TNum& Int){ return TStr::Fmt("%I64X", Int.Val); }
921 #else
922  TStr GetStr() const { return TStr::Fmt("%ll", Val); }
923  static TStr GetStr(const TNum& Int){ return TStr::Fmt("%ll", Int.Val); }
924  static TStr GetHexStr(const TNum& Int){ return TStr::Fmt("%ll", Int.Val); }
925 #endif
926 
927  static TStr GetKiloStr(const int64& Val){
928  if (Val>100 * 1000){ return GetStr(Val / 1000) + "K"; }
929  else if (Val>1000){ return GetStr(Val / 1000) + "." + GetStr((Val % 1000) / 100) + "K"; }
930  else { return GetStr(Val); }
931  }
932  static TStr GetMegaStr(const int64& Val){
933  if (Val>100 * 1000000){ return GetStr(Val / 1000000) + "M"; }
934  else if (Val>1000000){
935  return GetStr(Val / 1000000) + "." + GetStr((Val % 1000000) / 100000) + "M";
936  }
937  else { return GetKiloStr(Val); }
938  }
939  /*static TStr GetGigaStr(const int64& Val){
940  * if (Val>100*1000000000){return GetStr(Val/1000000000)+"G";}
941  * else if (Val>1000000000){
942  * return GetStr(Val/1000000000)+"."+GetStr((Val%1000000000)/100000000)+"G";}
943  * else {return GetMegaStr(Val);}}*/
944 
945  static int64 GetFromBufSafe(const char * Bf) {
946 #ifdef ARM
947  int64 Val;
948  memcpy(&Val, Bf, sizeof(int64)); //we cannot use a cast on ARM (needs 8byte memory aligned doubles)
949  return Val;
950 #else
951  return *((int64*)Bf);
952 #endif
953  }
954 };
955 
957 // Void
958 class TVoid{
959 public:
960  TVoid(){}
962  void Save(TSOut&) const {}
963  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
964  void SaveXml(TSOut& SOut, const TStr& Nm) const;
965 
966  TVoid& operator=(const TVoid&){return *this;}
967  bool operator==(const TVoid&) const {return true;}
968  bool operator<(const TVoid&) const {Fail; return false;}
969  int GetMemUsed() const {return sizeof(TVoid);}
970 };
971 
973 // Boolean
974 class TBool{
975 public:
976  bool Val;
977 public:
978  static const bool Mn;
979  static const bool Mx;
980  static const int Vals;
981  static TRnd Rnd;
982 
983  static const TStr FalseStr;
984  static const TStr TrueStr;
985  static const TStr NStr;
986  static const TStr YStr;
987  static const TStr NoStr;
988  static const TStr YesStr;
989 
990  TBool(): Val(false){}
991  TBool(const bool& _Val): Val(_Val){}
992  operator bool() const {return Val;}
993  explicit TBool(TSIn& SIn){SIn.Load(Val);}
994  void Load(TSIn& SIn){SIn.Load(Val);}
995  void Save(TSOut& SOut) const {SOut.Save(Val);}
996  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
997  void SaveXml(TSOut& SOut, const TStr& Nm) const;
998 
999  TBool& operator=(const TBool& Bool){Val=Bool.Val; return *this;}
1000  bool operator==(const TBool& Bool) const {return Val==Bool.Val;}
1001  bool operator<(const TBool& Bool) const {//return Val<Bool.Val;
1002  return (Val==false)&&(Bool.Val==true);}
1003  bool operator()() const {return Val;}
1004  int GetMemUsed() const {return sizeof(TBool);}
1005 
1006  int GetPrimHashCd() const {return Val;}
1007  int GetSecHashCd() const {return Val;}
1008 
1009  static bool GetRnd(){return Rnd.GetUniDevInt(2)==1;}
1010 
1011  static TStr GetStr(const bool& Val){
1012  if (Val){return TrueStr;} else {return FalseStr;}}
1013  static TStr GetStr(const TBool& Bool){
1014  return GetStr(Bool.Val);}
1015  static TStr GetYNStr(const bool& Val){
1016  if (Val){return YStr;} else {return NStr;}}
1017  static TStr GetYesNoStr(const bool& Val){
1018  if (Val){return YesStr;} else {return NoStr;}}
1019  static TStr Get01Str(const bool& Val){
1020  if (Val){return "1";} else {return "0";}}
1021  static bool IsValStr(const TStr& Str);
1022  static bool GetValFromStr(const TStr& Str);
1023  static bool GetValFromStr(const TStr& Str, const bool& DfVal);
1024 };
1025 
1027 // Char
1028 class TCh{
1029 public:
1030  char Val;
1031 public:
1032  static const char Mn;
1033  static const char Mx;
1034  static const int Vals;
1035 
1036  static const char NullCh;
1037  static const char TabCh;
1038  static const char LfCh;
1039  static const char CrCh;
1040  static const char EofCh;
1041  static const char HashCh;
1042 
1043  TCh(): Val(TCh::NullCh){}
1044  TCh(const char& _Val): Val(_Val){}
1045  operator char() const {return Val;}
1046  explicit TCh(TSIn& SIn){SIn.Load(Val);}
1047  void Load(TSIn& SIn) {SIn.Load(Val);}
1048  void Save(TSOut& SOut) const {SOut.Save(Val);}
1049  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1050  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1051 
1052  TCh& operator=(const TCh& Ch){Val=Ch.Val; return *this;}
1053  bool operator==(const TCh& Ch) const {return Val==Ch.Val;}
1054  bool operator<(const TCh& Ch) const {return Val<Ch.Val;}
1055  char operator()() const {return Val;}
1056  int GetMemUsed() const {return sizeof(TCh);}
1057 
1058  int GetPrimHashCd() const {return Val;}
1059  int GetSecHashCd() const {return Val;}
1060 
1061  static bool IsHashCh(const char& Ch){
1062  return (Ch==HashCh);}
1063  static bool IsWs(const char& Ch){
1064  return (Ch==' ')||(Ch==TabCh)||(Ch==CrCh)||(Ch==LfCh);}
1065  static bool IsAlpha(const char& Ch){
1066  return (('A'<=Ch)&&(Ch<='Z'))||(('a'<=Ch)&&(Ch<='z'));}
1067  static bool IsNum(const char& Ch){return ('0'<=Ch)&&(Ch<='9');}
1068  static bool IsAlNum(const char& Ch){return IsAlpha(Ch)||IsNum(Ch);}
1069  static int GetNum(const char& Ch){Assert(IsNum(Ch)); return Ch-'0';}
1070  static bool IsHex(const char& Ch){return
1071  (('0'<=Ch)&&(Ch<='9'))||(('A'<=Ch)&&(Ch<='F'))||(('a'<=Ch)&&(Ch<='f'));}
1072  static int GetHex(const char& Ch){
1073  if (('0'<=Ch)&&(Ch<='9')){return Ch-'0';}
1074  else if (('A'<=Ch)&&(Ch<='F')){return Ch-'A'+10;}
1075  else if (('a'<=Ch)&&(Ch<='f')){return Ch-'a'+10;}
1076  else Fail; return 0;}
1077  static char GetHexCh(const int& Val){
1078  if ((0<=Val)&&(Val<=9)){return char('0'+char(Val));}
1079  else if ((10<=Val)&&(Val<=15)){return char('A'+char(Val-10));}
1080  else Fail; return 0;}
1081  static char IsUc(const char& Ch){
1082  return ('A'<=Ch)&&(Ch<='Z');}
1083  static char GetUc(const char& Ch){
1084  if (('a'<=Ch)&&(Ch<='z')){return Ch-'a'+'A';} else {return Ch;}}
1085  static char GetUsFromYuAscii(const char& Ch);
1086 
1087  static TStr GetStr(const TCh& Ch){
1088  return TStr(Ch.Val);}
1089 };
1090 
1092 // Unsigned-Char
1093 class TUCh{
1094 public:
1096 public:
1097  static const uchar Mn;
1098  static const uchar Mx;
1099  static const int Vals;
1100 
1101  TUCh(): Val(TCh::NullCh){}
1102  TUCh(const uchar& _Val): Val(_Val){}
1103  operator uchar() const {return Val;}
1104  explicit TUCh(TSIn& SIn){SIn.Load(Val);}
1105  void Save(TSOut& SOut) const {SOut.Save(Val);}
1106  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1107  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1108 
1109  TUCh& operator=(const TUCh& UCh){Val=UCh.Val; return *this;}
1110  bool operator==(const TUCh& UCh) const {return Val==UCh.Val;}
1111  bool operator<(const TUCh& UCh) const {return Val<UCh.Val;}
1112  uchar operator()() const {return Val;}
1113  int GetMemUsed() const {return sizeof(TUCh);}
1114 
1115  int GetPrimHashCd() const {return Val;}
1116  int GetSecHashCd() const {return Val;}
1117 };
1118 
1120 // Short-Integer
1121 class TSInt{
1122 public:
1124 public:
1125  TSInt(): Val(0){}
1126  TSInt(const int16& _Val): Val(_Val){}
1127  operator int16() const {return Val;}
1128  explicit TSInt(TSIn& SIn){SIn.Load(Val);}
1129  void Load(TSIn& SIn){SIn.Load(Val);}
1130  void Save(TSOut& SOut) const {SOut.Save(Val);}
1131  int GetPrimHashCd() const {return Val;}
1132  int GetSecHashCd() const {return Val/0x10;}
1133 };
1134 
1136 // Integer
1137 class TInt{
1138 public:
1139  int Val;
1140 public:
1141  static const int Mn;
1142  static const int Mx;
1143  static const int Kilo;
1144  static const int Mega;
1145  static const int Giga;
1146  static TRnd Rnd;
1147 
1148  TInt(): Val(0){}
1149  TInt(const int& _Val): Val(_Val){}
1150  operator int() const {return Val;}
1151  explicit TInt(TSIn& SIn){SIn.Load(Val);}
1152  void Load(TSIn& SIn){SIn.Load(Val);}
1153  void Save(TSOut& SOut) const {SOut.Save(Val);}
1154  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1155  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1156 
1157  TInt& operator=(const TInt& Int){Val=Int.Val; return *this;}
1158  TInt& operator=(const int& Int){Val=Int; return *this;}
1159  bool operator==(const TInt& Int) const {return Val==Int.Val;}
1160  bool operator==(const int& Int) const {return Val==Int;}
1161  bool operator!=(const int& Int) const {return Val!=Int;}
1162  bool operator<(const TInt& Int) const {return Val<Int.Val;}
1163  bool operator<(const int& Int) const {return Val<Int;}
1164  int operator()() const {return Val;}
1165  TInt& operator+=(const int& Int){Val+=Int; return *this;}
1166  TInt& operator-=(const int& Int){Val-=Int; return *this;}
1167  TInt operator++(int){Val++; return *this;}
1168  TInt operator--(int){Val--; return *this;}
1169  int GetMemUsed() const {return sizeof(TInt);}
1170 
1171  int GetPrimHashCd() const {return Val;}
1172  int GetSecHashCd() const {return Val/0x10;}
1173 
1174  static int Abs(const int& Int){return Int<0?-Int:Int;}
1175  static int Sign(const int& Int){return Int<0?-1:(Int>0?1:0);}
1176  static void Swap(int& Int1, int& Int2){
1177  int SwapInt1=Int1; Int1=Int2; Int2=SwapInt1;}
1178  static int GetRnd(const int& Range=0){return Rnd.GetUniDevInt(Range);}
1179 
1180  static bool IsOdd(const int& Int){return ((Int%2)==1);}
1181  static bool IsEven(const int& Int){return ((Int%2)==0);}
1182 
1183  static int GetMn(const int& Int1, const int& Int2){
1184  return Int1<Int2?Int1:Int2;}
1185  static int GetMx(const int& Int1, const int& Int2){
1186  return Int1>Int2?Int1:Int2;}
1187  static int GetMn(const int& Int1, const int& Int2, const int& Int3){
1188  return GetMn(Int1, GetMn(Int2, Int3));}
1189  static int GetMn(const int& Int1, const int& Int2,
1190  const int& Int3, const int& Int4){
1191  return GetMn(GetMn(Int1, Int2), GetMn(Int3, Int4));}
1192  static int GetMx(const int& Int1, const int& Int2, const int& Int3){
1193  return GetMx(Int1, GetMx(Int2, Int3));}
1194  static int GetMx(const int& Int1, const int& Int2,
1195  const int& Int3, const int& Int4){
1196  return GetMx(GetMx(Int1, Int2), GetMx(Int3, Int4));}
1197  static int GetInRng(const int& Val, const int& Mn, const int& Mx){
1198  IAssert(Mn<=Mx); return Val<Mn?Mn:(Val>Mx?Mx:Val);}
1199 
1200  TStr GetStr() const {return TInt::GetStr(Val);}
1201 
1202  static TStr GetStr(const int& Val){ return TStr::Fmt("%d", Val); }
1203  static TStr GetStr(const TInt& Int){ return GetStr(Int.Val);}
1204  static TStr GetStr(const int& Val, const char* FmtStr);
1205  static TStr GetStr(const int& Val, const TStr& FmtStr){ return GetStr(Val, FmtStr.CStr());}
1206 
1207  //J: So that TInt can convert any kind of integer to a string
1208  static TStr GetStr(const uint& Val){ return TStr::Fmt("%u", Val); }
1209  #ifdef GLib_WIN
1210  static TStr GetStr(const int64& Val) {return TStr::Fmt("%I64d", Val);}
1211  static TStr GetStr(const uint64& Val) {return TStr::Fmt("%I64u", Val);}
1212  #else
1213  static TStr GetStr(const int64& Val) {return TStr::Fmt("%lld", Val);}
1214  static TStr GetStr(const uint64& Val) {return TStr::Fmt("%llu", Val);}
1215  #endif
1216 
1217  static TStr GetHexStr(const int& Val){
1218  char Bf[255]; sprintf(Bf, "%X", Val); return TStr(Bf);}
1219  static TStr GetHexStr(const TInt& Int){
1220  return GetHexStr(Int.Val);}
1221 
1222  static TStr GetKiloStr(const int& Val){
1223  if (Val>=100*1000){return GetStr(Val/1000)+"K";}
1224  else if (Val>=1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";}
1225  else {return GetStr(Val);}}
1226  static TStr GetMegaStr(const int& Val){
1227  if (Val>=100*1000000){return GetStr(Val/1000000)+"M";}
1228  else if (Val>=1000000){
1229  return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";}
1230  else {return GetKiloStr(Val);}}
1231 
1232  // frugal
1233  static char* SaveFrugalInt(char *pDest, int i);
1234  static char* LoadFrugalInt(char *pSrc, int& i);
1235  static void TestFrugalInt();
1236  static void SaveFrugalIntV(TSOut& SOut, const TVec<TInt, int>& IntV);
1237  static void LoadFrugalIntV(TSIn& SIn, TVec<TInt, int>& IntV, bool ClrP=true);
1238 };
1239 
1241 // Unsigned-Integer
1242 class TUInt{
1243 public:
1245 public:
1246  static const uint Mn;
1247  static const uint Mx;
1248  static TRnd Rnd;
1249 
1250  TUInt(): Val(0){}
1251  TUInt(const uint& _Val): Val(_Val){}
1252  operator uint() const {return Val;}
1253  explicit TUInt(TSIn& SIn){SIn.Load(Val);}
1254  void Load(TSIn& SIn){SIn.Load(Val);}
1255  void Save(TSOut& SOut) const {SOut.Save(Val);}
1256  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1257  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1258 
1259  TUInt& operator=(const TUInt& UInt){Val=UInt.Val; return *this;}
1260  TUInt& operator=(const uint& _Val){Val=_Val; return *this;}
1261  TUInt operator++(int){Val++; return *this;}
1262  TUInt operator--(int){Val--; return *this;}
1263  //bool operator==(const TUInt& UInt) const {return Val==UInt.Val;}
1264  //bool operator==(const uint& UInt) const {return Val==UInt;}
1265  //bool operator!=(const uint& UInt) const {return Val!=UInt;}
1266  //bool operator<(const TUInt& UInt) const {return Val<UInt.Val;}
1267  uint operator()() const {return Val;}
1268  uint& operator()() {return Val;}
1269  TUInt& operator~(){Val=~Val; return *this;}
1270  TUInt& operator&=(const TUInt& UInt){Val&=UInt.Val; return *this;}
1271  TUInt& operator|=(const TUInt& UInt){Val|=UInt.Val; return *this;}
1272  TUInt& operator^=(const TUInt& UInt){Val^=UInt.Val; return *this;}
1273  TUInt& operator>>=(const int& ShiftBits){Val>>=ShiftBits; return *this;}
1274  TUInt& operator<<=(const int& ShiftBits){Val<<=ShiftBits; return *this;}
1275  int GetMemUsed() const {return sizeof(TUInt);}
1276 
1277  int GetPrimHashCd() const {return int(Val);}
1278  int GetSecHashCd() const {return Val/0x10;}
1279 
1280  static uint GetRnd(const uint& Range=0){return Rnd.GetUniDevUInt(Range);}
1281 
1282  TStr GetStr() const {return TUInt::GetStr(Val);}
1283  static TStr GetStr(const uint& Val){
1284  char Bf[255]; sprintf(Bf, "%u", Val); return TStr(Bf);}
1285  static TStr GetStr(const TUInt& UInt){
1286  return GetStr(UInt.Val);}
1287  static TStr GetStr(const uint& Val, const char* FmtStr);
1288  static TStr GetStr(const uint& Val, const TStr& FmtStr){
1289  return GetStr(Val, FmtStr.CStr());}
1290 
1291  static TStr GetKiloStr(const uint& Val){
1292  if (Val>100*1000){return GetStr(Val/1000)+"K";}
1293  else if (Val>1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";}
1294  else {return GetStr(Val);}}
1295  static TStr GetMegaStr(const uint& Val){
1296  if (Val>100*1000000){return GetStr(Val/1000000)+"M";}
1297  else if (Val>1000000){
1298  return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";}
1299  else {return GetKiloStr(Val);}}
1300 
1301  static uint JavaUIntToCppUInt(const uint& JavaUInt){
1302  uint B1=(JavaUInt & 0xFF000000) >> 24;
1303  uint B2=(JavaUInt & 0x00FF0000) >> 16;
1304  uint B3=(JavaUInt & 0x0000FF00) >> 8;
1305  uint B4=(JavaUInt & 0x000000FF) >> 0;
1306  uint CppUInt=(B4<<24)+(B3<<16)+(B2<<8)+(B1<<0);
1307  return CppUInt;}
1308 
1309  static bool IsIpStr(const TStr& IpStr, uint& Ip, const char& SplitCh = '.');
1310  static bool IsIpStr(const TStr& IpStr, const char& SplitCh = '.') { uint Ip; return IsIpStr(IpStr, Ip, SplitCh); }
1311  static uint GetUIntFromIpStr(const TStr& IpStr, const char& SplitCh = '.');
1312  static TStr GetStrFromIpUInt(const uint& Ip);
1313  static bool IsIpv6Str(const TStr& IpStr, const char& SplitCh = ':');
1314 };
1315 
1317 // Unsigned-Integer-64Bit
1318 class TUInt64{
1319 public:
1321 public:
1322  static const TUInt64 Mn;
1323  static const TUInt64 Mx;
1324 
1325  TUInt64(): Val(0){}
1326  TUInt64(const TUInt64& Int): Val(Int.Val){}
1327  TUInt64(const uint64& Int): Val(Int){}
1328  TUInt64(const uint& MsVal, const uint& LsVal): Val(0){
1329  Val=(((uint64)MsVal) << 32) | ((uint64)LsVal);}
1330  explicit TUInt64(void* Pt): Val(0){
1331  TConv_Pt64Ints32 Conv(Pt); Val=Conv.GetUInt64();}
1332  operator uint64() const {return Val;}
1333  explicit TUInt64(TSIn& SIn){SIn.Load(Val);}
1334  void Load(TSIn& SIn){SIn.Load(Val);}
1335  void Save(TSOut& SOut) const {SOut.Save(Val);}
1336  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1337  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1338 
1339  TUInt64& operator=(const TUInt64& Int){Val=Int.Val; return *this;}
1340  TUInt64& operator+=(const TUInt64& Int){Val+=Int.Val; return *this;}
1341  TUInt64& operator-=(const TUInt64& Int){Val-=Int.Val; return *this;}
1342  TUInt64& operator*=(const TUInt64& Int){Val*=Int.Val; return *this;}
1343  TUInt64 operator++(int){Val++; return *this;}
1344  TUInt64 operator--(int){Val--; return *this;}
1345  int GetMemUsed() const {return sizeof(TUInt64);}
1346 
1347  int GetPrimHashCd() const { return (int)GetMsVal() + (int)GetLsVal(); } //TODO: to check
1348  int GetSecHashCd() const { return ((int)GetMsVal() + (int)GetLsVal()) / 0x10; } //TODO: to check
1349 
1350  uint GetMsVal() const {
1351  return (uint)(Val >> 32);}
1352  uint GetLsVal() const {
1353  return (uint)(Val & 0xffffffff);}
1354 
1355  //TStr GetStr() const {return TStr::Fmt("%Lu", Val);}
1356  //static TStr GetStr(const TUInt64& Int){return TStr::Fmt("%Lu", Int.Val);}
1357  //static TStr GetHexStr(const TUInt64& Int){return TStr::Fmt("%LX", Int.Val);}
1358  #ifdef GLib_WIN
1359  TStr GetStr() const {return TStr::Fmt("%I64u", Val);}
1360  static TStr GetStr(const TUInt64& Int){return TStr::Fmt("%I64u", Int.Val);}
1361  static TStr GetHexStr(const TUInt64& Int){return TStr::Fmt("%I64X", Int.Val);}
1362  #else
1363  TStr GetStr() const {return TStr::Fmt("%llu", Val);}
1364  static TStr GetStr(const TUInt64& Int){return TStr::Fmt("%llu", Int.Val);}
1365  static TStr GetHexStr(const TUInt64& Int){return TStr::Fmt("%llX", Int.Val);}
1366  #endif
1367 
1368  static TStr GetKiloStr(const uint64& Val){
1369  if (Val>100*1000){return GetStr(Val/1000)+"K";}
1370  else if (Val>1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";}
1371  else {return GetStr(Val);}}
1372  static TStr GetMegaStr(const uint64& Val){
1373  if (Val>100*1000000){return GetStr(Val/1000000)+"M";}
1374  else if (Val>1000000){
1375  return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";}
1376  else {return GetKiloStr(Val);}}
1377  /*static TStr GetGigaStr(const uint64& Val){
1378  if (Val>100*1000000000){return GetStr(Val/1000000000)+"G";}
1379  else if (Val>1000000000){
1380  return GetStr(Val/1000000000)+"."+GetStr((Val%1000000000)/100000000)+"G";}
1381  else {return GetMegaStr(Val);}}*/
1382 };
1383 
1385 // Float
1386 class TFlt{
1387 public:
1388  double Val;
1389 public:
1390  static const double Mn;
1391  static const double Mx;
1392  static const double NInf;
1393  static const double PInf;
1394  static const double Eps;
1395  static const double EpsHalf;
1396  static TRnd Rnd;
1397 
1398  TFlt(): Val(0){}
1399  TFlt(const double& _Val): Val(_Val){}
1400  operator double() const {return Val;}
1401  explicit TFlt(TSIn& SIn){SIn.Load(Val);}
1402  void Save(TSOut& SOut) const {SOut.Save(Val);}
1403  explicit TFlt(TSIn& SIn, const bool& IsTxt){
1404  if (IsTxt){TStr Str(SIn, true); Val=Str.GetFlt(0);} else {SIn.Load(Val);}}
1405  void Load(TSIn& SIn){SIn.Load(Val);}
1406  void Save(TSOut& SOut, const bool& IsTxt) const {
1407  if (IsTxt){GetStr(Val).Save(SOut, true);} else {SOut.Save(Val);}}
1408  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1409  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1410 
1411  TFlt& operator=(const TFlt& Flt){Val=Flt.Val; return *this;}
1412  TFlt& operator=(const double& Flt){Val=Flt; return *this;}
1413  bool operator==(const TFlt& Flt) const _CMPWARN {return Val==Flt.Val;}
1414  bool operator==(const double& Flt) const _CMPWARN {return Val==Flt;}
1415  bool operator!=(const double& Flt) const _CMPWARN {return Val!=Flt;}
1416  double operator()() const {return Val;}
1417  TFlt& operator+=(const double& Flt){Val+=Flt; return *this;}
1418  TFlt& operator-=(const double& Flt){Val-=Flt; return *this;}
1419  TFlt& operator*=(const double& Flt){Val*=Flt; return *this;}
1420  TFlt& operator/=(const double& Flt){Val/=Flt; return *this;}
1421  TFlt operator++(int){Val++; return *this;}
1422  TFlt operator--(int){Val--; return *this;}
1423  int GetMemUsed() const {return sizeof(TFlt);}
1424 
1425  int GetPrimHashCd() const {
1426  int Expn; return int((frexp(Val, &Expn)-0.5)*double(TInt::Mx));}
1427  int GetSecHashCd() const {
1428  int Expn; frexp(Val, &Expn); return Expn;}
1429 
1430  static double Abs(const double& Flt){return Flt<0?-Flt:Flt;}
1431  static int Sign(const double& Flt){return Flt<0?-1:(Flt>0?1:0);}
1432  static int Round(const double& Flt){return int(floor(Flt+0.5));}
1433  static double GetRnd(){return Rnd.GetUniDev();}
1434  static bool Eq6(const double& LFlt, const double& RFlt){
1435  return fabs(LFlt-RFlt)<0.000001;}
1436 
1437  static double GetMn(const double& Flt1, const double& Flt2){
1438  return Flt1<Flt2?Flt1:Flt2;}
1439  static double GetMn(const double& Flt1, const double& Flt2, const double& Flt3){
1440  return GetMn(GetMn(Flt1, Flt2), Flt3); }
1441  static double GetMn(const double& Flt1, const double& Flt2, const double& Flt3, const double& Flt4){
1442  return GetMn(GetMn(Flt1, Flt2), GetMn(Flt3, Flt4)); }
1443 
1444  static double GetMx(const double& Flt1, const double& Flt2){
1445  return Flt1>Flt2?Flt1:Flt2;}
1446  static double GetMx(const double& Flt1, const double& Flt2, const double Flt3){
1447  return GetMx(GetMx(Flt1, Flt2), Flt3); }
1448  static double GetMx(const double& Flt1, const double& Flt2, const double Flt3, const double& Flt4){
1449  return GetMx(GetMx(Flt1, Flt2), GetMx(Flt3, Flt4)); }
1450 
1451  static double GetInRng(const double& Val, const double& Mn, const double& Mx){
1452  IAssert(Mn<=Mx); return Val<Mn?Mn:(Val>Mx?Mx:Val);}
1453 
1454  static bool IsNum(const double& Val){
1455  return (Mn<=Val)&&(Val<=Mx);}
1456  static bool IsNan(const double& Val){
1457  return (Val!=Val);}
1458 
1459  bool IsNum() const { return IsNum(Val); }
1460  bool IsNan() const { return IsNan(Val); }
1461 
1462  TStr GetStr() const {return TFlt::GetStr(Val);}
1463  static TStr GetStr(const double& Val, const int& Width=-1, const int& Prec=-1);
1464  static TStr GetStr(const TFlt& Flt, const int& Width=-1, const int& Prec=-1){
1465  return GetStr(Flt.Val, Width, Prec);}
1466  static TStr GetStr(const double& Val, const char* FmtStr);
1467  static TStr GetStr(const double& Val, const TStr& FmtStr){
1468  return GetStr(Val, FmtStr.CStr());}
1469  static TStr GetPrcStr(const double& RelVal, const double& FullVal){
1470  return GetStr(100*RelVal/FullVal, "%3.0f%%");}
1471 
1472  static TStr GetKiloStr(const double& Val){
1473  if (fabs(Val)>100*1000){return TStr::Fmt("%.0fK", Val/1000);}
1474  else if (fabs(Val)>1000){return TStr::Fmt("%.1fK", Val/1000);}
1475  else {return TStr::Fmt("%.0f", Val);}}
1476  static TStr GetMegaStr(const double& Val){
1477  if (fabs(Val)>100*1000000){return TStr::Fmt("%.0fM", Val/1000000);}
1478  else if (fabs(Val)>1000000){return TStr::Fmt("%.1fM", Val/1000000);}
1479  else {return GetKiloStr(Val);}}
1480  static TStr GetGigaStr(const double& Val){
1481  if (fabs(Val)>100*1000000000.0){return TStr::Fmt("%.0fG", Val/1000000000.0);}
1482  else if (fabs(Val)>1000000000.0){return TStr::Fmt("%.1fG", Val/1000000000.0);}
1483  else {return GetMegaStr(Val);}}
1484 };
1485 
1487 // Ascii-Float
1488 class TAscFlt: public TFlt{
1489 public:
1490  TAscFlt(): TFlt(){}
1491  TAscFlt(const double& Val): TFlt(Val){}
1492  explicit TAscFlt(TSIn& SIn): TFlt(SIn, true){}
1493  void Save(TSOut& SOut) const {TFlt::Save(SOut, true);}
1494 };
1495 
1497 // Short-Float
1498 class TSFlt{
1499 public:
1501 public:
1502  static const sdouble Mn;
1503  static const sdouble Mx;
1504 
1505  TSFlt(): Val(0){}
1506  TSFlt(const sdouble& _Val): Val(sdouble(_Val)){}
1507  //TSFlt(const double& _Val): Val(sdouble(_Val)){}
1508  operator sdouble() const {return Val;}
1509  //operator double() const {return Val;}
1510  explicit TSFlt(TSIn& SIn){SIn.Load(Val);}
1511  void Save(TSOut& SOut) const {SOut.Save(Val);}
1512  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1513  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1514 
1515  TSFlt& operator=(const TSFlt& SFlt){Val=SFlt.Val; return *this;}
1516  bool operator==(const TSFlt& SFlt) const _CMPWARN {return Val==SFlt.Val;}
1517  bool operator==(const double& Flt) const _CMPWARN {return Val==Flt;}
1518  bool operator!=(const double& Flt) const _CMPWARN {return Val!=Flt;}
1519  bool operator<(const TSFlt& SFlt) const {return Val<SFlt.Val;}
1520  sdouble operator()() const {return Val;}
1521  TSFlt& operator+=(const double& SFlt){Val+=sdouble(SFlt); return *this;}
1522  TSFlt& operator-=(const double& SFlt){Val-=sdouble(SFlt); return *this;}
1523  TSFlt& operator*=(const double& SFlt){Val*=sdouble(SFlt); return *this;}
1524  TSFlt& operator/=(const double& SFlt){Val/=sdouble(SFlt); return *this;}
1525  TSFlt operator++(int){Val++; return *this;}
1526  TSFlt operator--(int){Val--; return *this;}
1527  int GetMemUsed() const {return sizeof(TSFlt);}
1528 
1529  int GetPrimHashCd() const {
1530  int Expn; return int((frexp(Val, &Expn)-0.5)*double(TInt::Mx));}
1531  int GetSecHashCd() const {
1532  int Expn; frexp(Val, &Expn); return Expn;}
1533 };
1534 
1536 // Long-Float
1537 class TLFlt{
1538 public:
1540 public:
1541  static const ldouble Mn;
1542  static const ldouble Mx;
1543 
1544  TLFlt(): Val(0){}
1545  TLFlt(const ldouble& _Val): Val(_Val){}
1546  operator ldouble() const {return Val;}
1547  explicit TLFlt(TSIn& SIn){SIn.Load(Val);}
1548  void Save(TSOut& SOut) const {SOut.Save(Val);}
1549  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1550  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1551 
1552  TLFlt& operator=(const TLFlt& LFlt){Val=LFlt.Val; return *this;}
1553  bool operator==(const TLFlt& LFlt) const _CMPWARN {return Val==LFlt.Val;}
1554  bool operator==(const ldouble& LFlt) const _CMPWARN {return Val==LFlt;}
1555  bool operator!=(const ldouble& LFlt) const _CMPWARN {return Val!=LFlt;}
1556  bool operator<(const TLFlt& LFlt) const {return Val<LFlt.Val;}
1557  ldouble operator()() const {return Val;}
1558  TLFlt& operator+=(const ldouble& LFlt){Val+=LFlt; return *this;}
1559  TLFlt& operator-=(const ldouble& LFlt){Val-=LFlt; return *this;}
1560  int GetMemUsed() const {return sizeof(TLFlt);}
1561 
1562  int GetPrimHashCd() const {Fail; return 0;}
1563  int GetSecHashCd() const {Fail; return 0;}
1564 
1565  static TStr GetStr(const ldouble& Val, const int& Width=-1, const int& Prec=-1);
1566  static TStr GetStr(const TLFlt& LFlt, const int& Width=-1, const int& Prec=-1){
1567  return GetStr(LFlt.Val, Width, Prec);}
1568  static TStr GetStr(const ldouble& Val, const char* FmtStr);
1569  static TStr GetStr(const ldouble& Val, const TStr& FmtStr){
1570  return GetStr(Val, FmtStr.CStr());}
1571 };
1572 
1574 // Float-Rectangle
1575 class TFltRect{
1576 public:
1578 public:
1580  MnX(), MnY(), MxX(), MxY(){}
1581  TFltRect(const TFltRect& FltRect):
1582  MnX(FltRect.MnX), MnY(FltRect.MnY), MxX(FltRect.MxX), MxY(FltRect.MxY){}
1584  const double& _MnX, const double& _MnY,
1585  const double& _MxX, const double& _MxY):
1586  MnX(_MnX), MnY(_MnY), MxX(_MxX), MxY(_MxY){}
1588  MnX(SIn), MnY(SIn), MxX(SIn), MxY(SIn){}
1589  void Save(TSOut& SOut) const {
1590  MnX.Save(SOut); MnY.Save(SOut); MxX.Save(SOut); MxY.Save(SOut);}
1591  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1592  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1593 
1594  TFltRect& operator=(const TFltRect& FltRect){
1595  MnX=FltRect.MnX; MnY=FltRect.MnY; MxX=FltRect.MxX; MxY=FltRect.MxY;
1596  return *this;}
1597 
1598  // get coordinates
1599  double GetMnX() const {return MnX;}
1600  double GetMnY() const {return MnY;}
1601  double GetMxX() const {return MxX;}
1602  double GetMxY() const {return MxY;}
1603 
1604  // get lengths
1605  double GetXLen() const {return MxX-MnX;}
1606  double GetYLen() const {return MxY-MnY;}
1607 
1608  // get centers
1609  double GetXCenter() const {return MnX+(MxX-MnX)/2;}
1610  double GetYCenter() const {return MnY+(MxY-MnY)/2;}
1611 
1612  // tests
1613  bool IsXYIn(const double& X, const double& Y) const {
1614  return (MnX<=X)&&(X<=MxX)&&(MnY<=Y)&&(Y<=MxY);}
1615  static bool Intersection(const TFltRect& Rect1, const TFltRect& Rect2);
1616 
1617  // string
1618  TStr GetStr() const;
1619 };
1620 
TSFlt & operator/=(const double &SFlt)
Definition: dt.h:1524
#define IAssert(Cond)
Definition: bd.h:262
TChAIn & operator=(const TChAIn &)
int GetPrimHashCd() const
Definition: dt.h:1171
static int CmpI(const char *CStr1, const char *CStr2)
Definition: dt.cpp:699
bool operator==(const double &Flt) const _CMPWARN
Definition: dt.h:1414
static bool IsHex(const char &Ch)
Definition: dt.h:1070
int GetInt() const
Definition: dt.h:581
Definition: bd.h:514
char * GetCStr() const
Definition: dt.h:688
bool IsUInt() const
Definition: dt.h:588
bool operator==(const TDbStr &DbStr) const
Definition: dt.h:739
TStr(const PSIn &SIn)
Definition: dt.h:432
bool IsLc() const
Definition: dt.cpp:672
void Load(TSIn &SIn, const bool &IsSmall=false)
Definition: dt.h:438
static TStr PutFExtIfEmpty(const TStr &FNm, const TStr &FExt)
Definition: dt.cpp:1503
TUInt operator++(int)
Definition: dt.h:1261
TStr(const char &Ch, bool)
Definition: dt.h:416
TFlt & operator*=(const double &Flt)
Definition: dt.h:1419
void Save(TSOut &SOut) const
Definition: dt.h:1493
int SearchCh(const char &Ch, const int &BChN=0) const
Definition: dt.cpp:1043
static TStr GetHexStr(const int &Val)
Definition: dt.h:1217
TStr GetFromHex() const
Definition: dt.h:517
int GetBf(const void *LBf, const TSize &LBfL)
Definition: dt.cpp:1646
TRStr * RStr
Definition: dt.h:414
static const double NInf
Definition: dt.h:1392
ldouble operator()() const
Definition: dt.h:1557
TMemOut(const PMem &_Mem)
Definition: dt.cpp:334
TUInt()
Definition: dt.h:1250
virtual int Len() const =0
static TStr GetPrcStr(const double &RelVal, const double &FullVal)
Definition: dt.h:1469
void Randomize()
Definition: dt.h:60
TStr GetSubStr(const int &BChN) const
Definition: dt.h:520
char GetCh()
Definition: dt.h:173
TLFlt & operator=(const TLFlt &LFlt)
Definition: dt.h:1552
TUInt64 operator--(int)
Definition: dt.h:1344
void Gen(const int &_BfL)
Definition: dt.h:123
char * CStr()
Definition: bd.h:531
static double GetMx(const double &Flt1, const double &Flt2, const double Flt3, const double &Flt4)
Definition: dt.h:1448
static PMem New(const PMem &Mem)
Definition: dt.h:96
static const uint Mn
Definition: dt.h:1246
TStr GetStr() const
Definition: dt.h:1200
#define IAssertR(Cond, Reason)
Definition: bd.h:265
static const int Kilo
Definition: dt.h:1143
static TStr GetSpaceStr(const int &Spaces)
Definition: dt.cpp:1608
char Pop()
Definition: dt.h:139
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:1910
static const int r
Definition: dt.h:15
int GetSecHashCd() const
Definition: dt.h:1059
bool IsInt64() const
Definition: dt.h:596
TLFlt(const ldouble &_Val)
Definition: dt.h:1545
TStr(const TChA &ChA)
Definition: dt.h:425
TSFlt(TSIn &SIn)
Definition: dt.h:1510
uint GetLsVal() const
Definition: dt.h:1352
static PSOut New(const TStr &FNm, const bool &Append=false)
Definition: fl.cpp:442
static uint JavaUIntToCppUInt(const uint &JavaUInt)
Definition: dt.h:1301
int Len() const
Definition: dt.h:490
void ToLc()
Definition: dt.cpp:679
const char * CStr() const
Definition: dt.h:381
#define ClassHdTP(TNm, PNm)
Definition: bd.h:135
TStr GetFMid() const
Definition: dt.cpp:1403
bool operator==(const char *_CStr) const
Definition: dt.h:233
TNum operator--(int)
Definition: dt.h:884
bool Eof()
Definition: dt.h:335
int GetMemUsed() const
Definition: dt.h:887
void Resize(const int &_MxBfL)
Definition: dt.cpp:348
void Reset()
Definition: dt.h:176
static TStr GetHexStr(const TUInt64 &Int)
Definition: dt.h:1365
void Save(TSOut &SOut) const
Definition: dt.h:735
int GetPrimHashCd() const
Definition: dt.h:1058
TStr Right(const int &BChN) const
Definition: dt.h:548
TNum & operator=(const TNum &Int)
Definition: dt.h:908
TRStr()
Definition: dt.h:351
bool operator!=(const char *_CStr) const
Definition: dt.h:236
TUCh(TSIn &SIn)
Definition: dt.h:1104
static TStr GetMegaStr(const int &Val)
Definition: dt.h:1226
void Save(TSOut &SOut) const
Definition: dt.h:1589
void SaveMem(const PSOut &SOut) const
Definition: dt.h:153
static void LoadTxt(const PSIn &SIn, TChA &ChA)
Definition: dt.cpp:616
bool IsHexInt64(int64 &Val) const
Definition: dt.h:620
TStr & FromHex()
Definition: dt.cpp:798
int64 GetUniDevInt64(const int64 &Range=0)
Definition: dt.cpp:51
void Ins(const int &BChN, const char *CStr)
Definition: dt.cpp:407
double GetMnY() const
Definition: dt.h:1600
static TStr GetStr(const uint64 &Val)
Definition: dt.h:1214
static int GetInRng(const int &Val, const int &Mn, const int &Mx)
Definition: dt.h:1197
int GetNextSeed()
Definition: dt.h:17
static TStr GetKiloStr(const uint64 &Val)
Definition: dt.h:1368
static bool IsNum(const char &Ch)
Definition: dt.h:1067
int BfC
Definition: dt.h:704
bool IsPrefix(const char *Str) const
Definition: dt.cpp:1081
static PSIn New(const TChA &ChA)
Definition: dt.h:332
Definition: dt.h:11
TStr & operator+=(const char *CStr)
Definition: dt.h:457
Definition: dt.h:1575
TSInt(TSIn &SIn)
Definition: dt.h:1128
static const sdouble Mn
Definition: dt.h:1502
static PStrPool Load(TSIn &SIn, bool LoadCompacted=true)
Definition: dt.h:797
bool IsFlt() const
Definition: dt.h:630
static TStr GetStr(const int &Val, const TStr &FmtStr)
Definition: dt.h:1205
TSFlt & operator-=(const double &SFlt)
Definition: dt.h:1522
static const TStr NoStr
Definition: dt.h:987
TStr(const char &Ch1, const char &Ch2, bool)
Definition: dt.h:418
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:2280
static TStr GetStrFromIpUInt(const uint &Ip)
Definition: dt.cpp:2117
static int GetMn(const int &Int1, const int &Int2, const int &Int3, const int &Int4)
Definition: dt.h:1189
TStr GetFPath() const
Definition: dt.cpp:1389
TFltRect & operator=(const TFltRect &FltRect)
Definition: dt.h:1594
static PSIn New(const TMem &Mem)
Definition: dt.h:165
void Del(const int &ChN)
Definition: dt.cpp:414
int GetPrimHashCd() const
Definition: dt.cpp:709
bool IsHexInt64() const
Definition: dt.h:621
int Val
Definition: dt.h:1139
sdouble Val
Definition: dt.h:1500
static const uint Mx
Definition: dt.h:1247
static TRnd Rnd
Definition: dt.h:981
int SearchChBack(const char &Ch, int BChN=-1) const
Definition: dt.cpp:1053
long double ldouble
Definition: bd.h:16
char * Bf
Definition: dt.h:80
static TRnd LoadTxt(TILx &Lx)
Definition: dt.cpp:215
uint64 GetUInt64() const
Definition: bd.h:558
TFlt & operator/=(const double &Flt)
Definition: dt.h:1420
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:1833
void Save(TSOut &SOut) const
Definition: dt.h:1153
bool IsFlt(double &Val) const
Definition: dt.h:629
static double GetMx(const double &Flt1, const double &Flt2)
Definition: dt.h:1444
bool operator!=(const char *CStr) const
Definition: dt.h:470
TDbStr(const TStr &_Str1, const TStr &_Str2)
Definition: dt.h:733
void FlushBf()
bool IsLc() const
Definition: dt.h:500
int Len() const
Definition: dt.h:134
TUCh(const uchar &_Val)
Definition: dt.h:1102
unsigned int uint
Definition: bd.h:11
TNum< int64 > TInt64
Definition: dt.h:892
bool IsXYIn(const double &X, const double &Y) const
Definition: dt.h:1613
TMem & operator=(const TMem &Mem)
Definition: dt.h:108
bool IsHexInt() const
Definition: dt.h:613
PSIn GetSIn(const bool &IsCut=true, const int &CutBfL=-1)
Definition: fl.cpp:881
static TStr GetStr(const double &Val, const TStr &FmtStr)
Definition: dt.h:1467
static TStr GetStr(const TUInt64 &Int)
Definition: dt.h:1364
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1185
TUInt64(const TUInt64 &Int)
Definition: dt.h:1326
Base & operator()()
Definition: dt.h:885
static const int RndSeed
Definition: dt.h:13
bool operator==(const TChA &ChA) const
Definition: dt.h:232
bool Empty() const
Definition: dt.h:260
static const int Mx
Definition: dt.h:1142
TRnd(TSIn &SIn)
Definition: dt.h:22
#define Fail
Definition: bd.h:238
bool operator!=(const double &Flt) const _CMPWARN
Definition: dt.h:1518
bool EqI(const TStr &Str) const
Definition: dt.h:498
TStr(const TStr &Str)
Definition: dt.h:424
bool operator!=(const ldouble &LFlt) const _CMPWARN
Definition: dt.h:1555
void ToCap()
Definition: dt.cpp:685
const char * GetCStr(const uint &Offset) const
Definition: dt.h:814
TPt< TStrPool64 > PStrPool64
Definition: dt.h:834
int BfL
Definition: dt.h:325
TStr GetUc() const
Definition: dt.h:496
static const char NullCh
Definition: dt.h:1036
static bool IsHashCh(const char &Ch)
Definition: dt.h:1061
static char * SaveFrugalInt(char *pDest, int i)
Definition: dt.cpp:1954
TSFlt & operator*=(const double &SFlt)
Definition: dt.h:1523
void PutCh(const int &ChN, const char &Ch)
Definition: dt.h:278
static char GetHexCh(const int &Val)
Definition: dt.h:1077
TFlt(TSIn &SIn)
Definition: dt.h:1401
TStr Str2
Definition: dt.h:728
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:1923
static PMem New(const TMem &Mem)
Definition: dt.h:95
void Clr()
Definition: dt.h:258
void Load(TSIn &SIn)
Definition: dt.h:994
void Save(TSOut &SOut) const
Definition: dt.h:1105
double Val
Definition: dt.h:1388
TStr GetStr() const
Definition: dt.h:922
void AddCh(const char &Ch, const int &MxLen=-1)
Definition: dt.h:271
int GetUniDevInt(const int &MnVal, const int &MxVal)
Definition: dt.h:32
TVoid & operator=(const TVoid &)
Definition: dt.h:966
static const double EpsHalf
Definition: dt.h:1395
TUInt64 operator++(int)
Definition: dt.h:1343
TCh(const char &_Val)
Definition: dt.h:1044
bool IsPrefix(const TStr &Str) const
Definition: dt.h:559
int GetPrimHashCd() const
Definition: dt.h:1562
TFlt & operator=(const double &Flt)
Definition: dt.h:1412
static PStrPool New(const uint &_MxBfLen=0, const uint &_GrowBy=16 *1024 *1024)
Definition: dt.h:794
bool IsChIn(const char &Ch) const
Definition: dt.h:300
static bool IsNum(const double &Val)
Definition: dt.h:1454
static void SaveFrugalIntV(TSOut &SOut, const TVec< TInt, int > &IntV)
Definition: dt.cpp:2018
static TStr GetMegaStr(const double &Val)
Definition: dt.h:1476
TInt & operator-=(const int &Int)
Definition: dt.h:1166
uint Size() const
Definition: dt.h:802
int GetPrimHashCd() const
Definition: dt.h:572
TRStr(const char *CStr, const int &MxLen)
Definition: dt.h:356
static TStr GetYesNoStr(const bool &Val)
Definition: dt.h:1017
TUCh & operator=(const TUCh &UCh)
Definition: dt.h:1109
uint64 GetUniDevUInt64(const uint64 &Range=0)
Definition: dt.cpp:57
int GetMemUsed() const
Definition: dt.h:915
bool Empty() const
Definition: dt.h:751
TInt operator--(int)
Definition: dt.h:1168
void Save(TSOut &SOut) const
Definition: dt.h:1130
static const bool Mx
Definition: dt.h:979
TSFlt()
Definition: dt.h:1505
int CmpI(const TStr &Str) const
Definition: dt.h:497
static PSOut New(const PMem &Mem)
Definition: dt.h:189
void DelChAll(const char &Ch)
Definition: dt.cpp:840
TChA & operator+=(const char &Ch)
Definition: dt.h:244
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:14
TUInt64(const uint64 &Int)
Definition: dt.h:1327
virtual int GetBf(const void *Bf, const TSize &BfL)=0
static int GetHex(const char &Ch)
Definition: dt.h:1072
double GetMxY() const
Definition: dt.h:1602
Base Val
Definition: dt.h:871
double GetRayleigh(const double &Sigma)
Definition: dt.h:50
TStr(const TMem &Mem)
Definition: dt.h:429
const char * Bf
Definition: dt.h:161
static TStr GetNrFMid(const TStr &FMid)
Definition: dt.cpp:1445
int Len() const
Definition: dt.h:259
TStr GetSubStr(const int &BChN, const int &EChN) const
Definition: dt.cpp:811
bool DelStr(const TStr &Str)
Definition: dt.cpp:863
int GetBf(const void *LBf, const TSize &LBfL)
Definition: dt.cpp:318
TFlt & operator+=(const double &Flt)
Definition: dt.h:1417
TDbStr & operator=(const TDbStr &DbStr)
Definition: dt.h:737
static bool GetRnd()
Definition: dt.h:1009
static TStr GetNrFNm(const TStr &FNm)
Definition: dt.cpp:1467
TStr & ToHex()
Definition: dt.cpp:785
void Save(TSOut &SOut) const
Definition: dt.h:995
TUInt & operator|=(const TUInt &UInt)
Definition: dt.h:1271
int Cmp(uint64 Offset, const char *Str) const
Definition: dt.h:860
int GetSecHashCd() const
Definition: dt.h:573
int GetMemUsed() const
Definition: dt.h:1056
int SearchStr(const TChA &Str, const int &BChN=0) const
Definition: dt.cpp:485
static bool IsIpv6Str(const TStr &IpStr, const char &SplitCh= ':')
Definition: dt.cpp:2122
sdouble operator()() const
Definition: dt.h:1520
static double GetMn(const double &Flt1, const double &Flt2, const double &Flt3)
Definition: dt.h:1439
bool operator==(const char &Ch) const
Definition: dt.h:234
bool operator==(const TSFlt &SFlt) const _CMPWARN
Definition: dt.h:1516
TStr & operator=(const char &Ch)
Definition: dt.h:451
bool operator==(const TInt &Int) const
Definition: dt.h:1159
int64 GetHexInt64() const
Definition: dt.h:622
TStr GetFExt() const
Definition: dt.cpp:1421
bool IsInt64(int64 &Val) const
Definition: dt.h:595
int GetSecHashCd() const
Definition: dt.h:1116
static TStr GetKiloStr(const uint &Val)
Definition: dt.h:1291
TPt< TStrPool > PStrPool
Definition: dt.h:781
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
TStr Str
Definition: dt.h:702
void Load(TSIn &SIn)
Definition: dt.h:1334
TNum(TSIn &SIn)
Definition: dt.h:905
static bool IsIpStr(const TStr &IpStr, uint &Ip, const char &SplitCh= '.')
Definition: dt.cpp:2096
const char * CStr() const
Definition: dt.h:256
char * Bf
Definition: dt.h:204
TVec< TStr, int > TStrV
Definition: dt.h:409
TChA & ToUc()
Definition: dt.cpp:560
void Clr()
Definition: dt.h:489
TFlt MnX
Definition: dt.h:1577
uint & operator()()
Definition: dt.h:1268
static const int q
Definition: dt.h:15
void UnRef()
Definition: dt.h:379
static TStr GetStr(const uint &Val, const TStr &FmtStr)
Definition: dt.h:1288
TNum & operator++()
Definition: dt.h:881
bool operator==(const TRnd &) const
Definition: dt.h:28
TNum operator--(int)
Definition: dt.h:914
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:2077
static TRnd Rnd
Definition: dt.h:1146
TStr & ToCap()
Definition: dt.cpp:764
bool operator!=(const int &Int) const
Definition: dt.h:1161
TLFlt & operator+=(const ldouble &LFlt)
Definition: dt.h:1558
TLFlt & operator-=(const ldouble &LFlt)
Definition: dt.h:1559
static TStr GetStr(const uint &Val)
Definition: dt.h:1283
static const double Mx
Definition: dt.h:1391
int ChangeChAll(const char &SrcCh, const char &DstCh)
Definition: dt.cpp:1113
double GetXCenter() const
Definition: dt.h:1609
TDbStr(const TDbStr &DbStr)
Definition: dt.h:731
int MxBfL
Definition: dt.h:203
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:2263
void Reset()
Definition: dt.h:719
Definition: dt.h:834
bool IsHexInt(int &Val) const
Definition: dt.h:612
TBool & operator=(const TBool &Bool)
Definition: dt.h:999
static PSIn New(const PMem &Mem)
Definition: dt.h:167
TAscFlt()
Definition: dt.h:1490
TCh(TSIn &SIn)
Definition: dt.h:1046
static const TStr YStr
Definition: dt.h:986
Definition: dt.h:1537
int GetSecHashCd() const
Definition: dt.h:748
static double GetMx(const double &Flt1, const double &Flt2, const double Flt3)
Definition: dt.h:1446
static bool GetValFromStr(const TStr &Str)
Definition: dt.cpp:1850
PMem Mem
Definition: dt.h:184
static double GetExpDevStep(const int &Seed, const int &Steps)
Definition: dt.h:68
Definition: dt.h:1386
friend TStr operator+(const TStr &LStr, const TStr &RStr)
Definition: dt.cpp:1631
TRStr(const char &Ch)
Definition: dt.h:361
uint64 GetUInt64() const
Definition: dt.h:606
static const ldouble Mn
Definition: dt.h:1541
bool operator==(const TCh &Ch) const
Definition: dt.h:1053
bool IsStrIn(const TStr &Str) const
Definition: dt.h:292
int PutCh(const char &Ch)
Definition: dt.h:193
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:746
void Save(TSOut &SOut) const
Definition: dt.h:877
int GetMemUsed() const
Definition: dt.h:1345
Definition: fl.h:58
TInt & operator=(const TInt &Int)
Definition: dt.h:1157
int GetPrimHashCd() const
Definition: dt.h:1425
static const int Giga
Definition: dt.h:1145
TUInt64(TSIn &SIn)
Definition: dt.h:1333
char GetCh()
Definition: dt.h:337
Definition: dt.h:182
int GetSecHashCd() const
Definition: dt.h:1531
double GetFlt() const
Definition: dt.h:631
double GetGammaDev(const int &Order)
Definition: dt.cpp:95
char * operator()()
Definition: dt.h:253
static TStr GetStr(const TUInt &UInt)
Definition: dt.h:1285
static TStr GetMegaStr(const uint &Val)
Definition: dt.h:1295
Definition: dt.h:77
TStr GetWcMatch(const TStr &WcStr, const int &StarStrN=0) const
Definition: dt.cpp:1379
Definition: dt.h:869
TFltRect(const TFltRect &FltRect)
Definition: dt.h:1581
void SplitOnCh(TStr &LStr, const char &SplitCh, TStr &RStr) const
Definition: dt.cpp:901
TInt(TSIn &SIn)
Definition: dt.h:1151
void Optimize()
Definition: dt.cpp:729
void Save(TSOut &SOut, const bool &IsTxt) const
Definition: dt.h:1406
static const TStr FalseStr
Definition: dt.h:983
int GetPrimHashCd() const
Definition: dt.h:1115
char LastLastCh() const
Definition: dt.h:282
static const char EofCh
Definition: dt.h:1040
#define ClassTP(TNm, PNm)
Definition: bd.h:126
static const int Mega
Definition: dt.h:1144
static const char Mx
Definition: dt.h:1033
int64 GetInt64() const
Definition: dt.h:597
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:2232
static int Sign(const int &Int)
Definition: dt.h:1175
void DelLastCh()
Definition: dt.h:263
TSFlt & operator+=(const double &SFlt)
Definition: dt.h:1521
void Reverse()
Definition: dt.cpp:440
static TStr GetMegaStr(const uint64 &Val)
Definition: dt.h:1372
bool Empty() const
Definition: dt.h:803
char * Bf
Definition: dt.h:348
bool IsUInt64(uint64 &Val) const
Definition: dt.h:604
int GetSecHashCd() const
Definition: dt.h:1007
void Clr(bool DoDel=false)
Definition: dt.h:819
void Save(TSOut &SOut) const
Definition: dt.h:1255
uint GetUInt() const
Definition: dt.h:589
bool IsInt(int &Val) const
Definition: dt.h:579
TAscFlt(const double &Val)
Definition: dt.h:1491
int GetSecHashCd() const
Definition: dt.h:1563
bool IsWs() const
Definition: dt.cpp:1304
char * CStr()
Definition: dt.h:382
void Save(TSOut &SOut) const
Definition: dt.h:23
Definition: dt.h:781
bool Empty() const
Definition: dt.h:383
static PSIn New(const TStr &FNm)
Definition: fl.cpp:290
TDbStr(TSIn &SIn)
Definition: dt.h:734
void Trunc(const int &_BfL)
Definition: dt.h:267
PSIn GetSIn() const
Definition: dt.h:146
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:1876
char GetCh()
Definition: dt.h:716
void Load(TSIn &SIn)
Definition: dt.h:1047
static double GetMn(const double &Flt1, const double &Flt2, const double &Flt3, const double &Flt4)
Definition: dt.h:1441
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:1811
static const int Mn
Definition: dt.h:1141
TNum & operator=(const TNum &Other)
Definition: dt.h:879
uint64 GetUInt64(const uint64 &DfVal) const
Definition: dt.h:608
void Push(const char &Ch)
Definition: dt.h:138
static TStr GetKiloStr(const double &Val)
Definition: dt.h:1472
int BfL
Definition: dt.h:79
TUInt & operator<<=(const int &ShiftBits)
Definition: dt.h:1274
int SearchChBack(const char &Ch, int BChN=-1) const
Definition: dt.cpp:477
static bool IsWs(const char &Ch)
Definition: dt.h:1063
static TStr AddToFMid(const TStr &FNm, const TStr &ExtFMid)
Definition: dt.cpp:1523
#define _CMPWARN
Definition: base.h:31
double GetWeibull(const double &K, const double &Lambda)
Definition: dt.h:53
int PutBf(const void *LBf, const TSize &LBfL)
Definition: dt.cpp:336
int GetPrimHashCd() const
Definition: dt.h:1006
int ChangeStrAll(const TStr &SrcStr, const TStr &DstStr, const bool &FromStartP=false)
Definition: dt.cpp:1141
int GetPrimHashCd() const
Definition: dt.h:746
int GetPrimHashCd() const
Definition: dt.h:1347
TStr GetStr(const TStr &MidStr=TStr()) const
Definition: dt.h:744
TRStr(const char *CStr)
Definition: dt.h:354
void Load(TSIn &SIn)
Definition: dt.h:906
static PStrPool LoadShM(TSIn &SIn)
Definition: dt.h:829
int GetPrimHashCd() const
Definition: dt.h:1131
int GetMemUsed() const
Definition: dt.h:1423
TUInt(const uint &_Val)
Definition: dt.h:1251
TStr(const TSStr &SStr)
Definition: dt.h:426
static const int a
Definition: dt.h:15
TStr GetUsFromYuAscii() const
Definition: dt.h:512
static TStr & GetDChStr(const char &Ch1, const char &Ch2)
Definition: dt.cpp:1564
static int GetMn(const int &Int1, const int &Int2)
Definition: dt.h:1183
Definition: dt.h:700
void Save(TSOut &SOut) const
Definition: dt.h:1511
double GetExpDev()
Definition: dt.cpp:83
char * CStr()
Definition: dt.h:255
void Save(TSOut &SOut) const
Definition: dt.h:103
static TStr GetNrAbsFPath(const TStr &FPath, const TStr &BaseFPath=TStr())
Definition: dt.cpp:1471
bool IsPrefix(const char *CStr, const int &BChN=0) const
Definition: dt.cpp:499
bool IsBool(bool &Val) const
Definition: dt.cpp:1153
TUInt & operator=(const TUInt &UInt)
Definition: dt.h:1259
TMem(const void *_Bf, const int &_BfL)
Definition: dt.h:88
TInt()
Definition: dt.h:1148
int GetSecHashCd() const
Definition: dt.h:1172
void Save(TSOut &SOut, const bool &IsSmall=false) const
Definition: dt.h:440
TFlt MnY
Definition: dt.h:1577
void Flush()
Definition: dt.h:196
Definition: dt.h:1028
Definition: dt.h:958
unsigned long long uint64
Definition: bd.h:38
bool IsInt() const
Definition: dt.h:580
static const char TabCh
Definition: dt.h:1037
static const char Mn
Definition: dt.h:1032
TFlt(const double &_Val)
Definition: dt.h:1399
void Save(TSOut &SOut) const
Definition: dt.h:907
~TMem()
Definition: dt.h:99
TSFlt & operator=(const TSFlt &SFlt)
Definition: dt.h:1515
TNum & operator--()
Definition: dt.h:912
static TStr Get01Str(const bool &Val)
Definition: dt.h:1019
bool operator==(const TFlt &Flt) const _CMPWARN
Definition: dt.h:1413
void Load(bool &Bool)
Definition: fl.h:84
TSFlt(const sdouble &_Val)
Definition: dt.h:1506
int64 GetHexInt64(const int64 &DfVal) const
Definition: dt.h:624
int CountCh(const char &Ch, const int &BChN=0) const
Definition: dt.cpp:462
static double GetNrmDevStep(const int &Seed, const int &Steps)
Definition: dt.h:66
TStr GetStr(const uint &Offset) const
Definition: dt.h:812
void Load(TSIn &SIn)
Definition: dt.h:1129
void SaveTxt(const PSOut &SOut) const
Definition: dt.cpp:622
TNum operator++(int)
Definition: dt.h:913
int SearchStr(const TStr &Str, const int &BChN=0) const
Definition: dt.cpp:1065
bool IsSuffix(const char *Str) const
Definition: dt.cpp:1093
bool IsWcMatch(const int &StrBChN, const TStr &WcStr, const int &WcStrBChN, TStrV &StarStrV, const char &StarCh='*', const char &QuestCh='?') const
Definition: dt.cpp:1311
TChA(const int &_MxBfL=256)
Definition: dt.h:207
static PSIn New(const TStr &Str)
Definition: dt.h:711
void MkRef()
Definition: dt.h:378
TNum()
Definition: dt.h:872
TUInt & operator~()
Definition: dt.h:1269
const char * Bf
Definition: dt.h:324
char GetCh(const int &ChN) const
Definition: dt.h:388
Definition: lx.h:129
static TStr GetHexStr(const TInt &Int)
Definition: dt.h:1219
TFlt MxY
Definition: dt.h:1577
TMemIn(const TMem &_Mem, const int &_BfC=0)
Definition: dt.cpp:315
static bool IsIpStr(const TStr &IpStr, const char &SplitCh= '.')
Definition: dt.h:1310
static int GetNum(const char &Ch)
Definition: dt.h:1069
static TStr GetStr(const TLFlt &LFlt, const int &Width=-1, const int &Prec=-1)
Definition: dt.h:1566
TStr GetStr() const
Definition: dt.h:1282
uint GetUniDevUInt(const uint &Range=0)
Definition: dt.cpp:45
TUInt64 & operator=(const TUInt64 &Int)
Definition: dt.h:1339
TStr Str1
Definition: dt.h:727
char PeekCh()
Definition: dt.h:174
int GetSecHashCd(const uint &Offset)
Definition: dt.h:827
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:740
void Load(TSIn &SIn)
Definition: dt.h:1152
size_t TSize
Definition: bd.h:58
char LastCh() const
Definition: dt.h:281
TStr Mid(const int &BChN, const int &Chs) const
Definition: dt.h:542
static TRStr * GetNullRStr()
Definition: dt.h:402
static PStrPool New(TSIn &SIn)
Definition: dt.h:795
~TChAIn()
Definition: dt.h:333
static void TestFrugalInt()
Definition: dt.cpp:1998
#define Assert(Cond)
Definition: bd.h:251
char operator[](const int &ChN) const
Definition: dt.h:474
char & operator[](const int &ChN)
Definition: dt.h:249
static bool IsOdd(const int &Int)
Definition: dt.h:1180
Definition: lx.h:251
void Save(TSOut &SOut) const
Definition: dt.h:1548
TStr RightOf(const char &SplitCh) const
Definition: dt.cpp:887
void Save(TSOut &SOut, const bool &SaveCompact=true) const
Definition: dt.h:224
void Save(TSOut &SOut) const
Definition: dt.h:1335
Definition: dt.h:1498
TStr & ConvUsFromYuAscii()
Definition: dt.cpp:779
int GetSecHashCd() const
Definition: dt.cpp:611
int GetMemUsed() const
Definition: dt.h:1560
TMem(const TMem &Mem)
Definition: dt.h:92
const char * CStr() const
Definition: dt.h:480
bool Eof()
Definition: dt.h:171
char LastCh() const
Definition: dt.h:487
TVoid(TSIn &)
Definition: dt.h:961
bool operator==(const char *CStr) const
Definition: dt.h:466
TFlt operator--(int)
Definition: dt.h:1422
TChA GetSubStr(const int &BChN, const int &EChN) const
Definition: dt.cpp:448
static const char HashCh
Definition: dt.h:1041
TRStr(const char *CStr1, const char *CStr2)
Definition: dt.h:358
uchar operator()() const
Definition: dt.h:1112
TFlt(TSIn &SIn, const bool &IsTxt)
Definition: dt.h:1403
TCh()
Definition: dt.h:1043
TUInt & operator&=(const TUInt &UInt)
Definition: dt.h:1270
bool operator==(const TVoid &) const
Definition: dt.h:967
void Load(TSIn &SIn)
Definition: dt.h:1254
static TStr & GetChStr(const char &Ch)
Definition: dt.cpp:1551
~TMemIn()
Definition: dt.h:169
static TStr PutFBaseIfEmpty(const TStr &FNm, const TStr &FBase)
Definition: dt.cpp:1515
bool IsWord(const bool &WsPrefixP=true, const bool &FirstUcAllowedP=true) const
Definition: dt.cpp:1292
TStr GetLc() const
Definition: dt.h:502
bool Val
Definition: dt.h:976
TNum & operator++()
Definition: dt.h:911
static TStr LoadTxt(const TStr &FNm)
Definition: dt.h:671
static const int Vals
Definition: dt.h:1099
bool operator<(const int &Int) const
Definition: dt.h:1163
TStr & operator=(const TStr &Str)
Definition: dt.h:445
double GetYLen() const
Definition: dt.h:1606
void Trunc(const int &_BfL)
Definition: dt.h:136
TInt(const int &_Val)
Definition: dt.h:1149
bool operator<(const TCh &Ch) const
Definition: dt.h:1054
bool operator!=(const double &Flt) const _CMPWARN
Definition: dt.h:1415
bool operator<(const TUCh &UCh) const
Definition: dt.h:1111
uint GetUInt(const uint &DfVal) const
Definition: dt.h:590
TNum & operator-=(const TNum &Int)
Definition: dt.h:910
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:1928
int GetPrimHashCd(const uint &Offset)
Definition: dt.h:825
static PStrPool64 Load(TSIn &SIn, bool LoadCompact=true)
Definition: dt.h:849
int Len() const
Definition: dt.h:715
static TStr GetNrFPath(const TStr &FPath)
Definition: dt.cpp:1430
TChA(const TMem &Mem)
Definition: dt.h:216
int GetMemUsed() const
Definition: dt.h:376
void SaveTxt(const TStr &FNm) const
Definition: dt.h:675
static TStr GetNrFExt(const TStr &FExt)
Definition: dt.cpp:1455
void Save(TSOut &) const
Definition: dt.h:962
::TSize GetMemUsed()
Definition: dt.h:806
static TStr GetNullStr()
Definition: dt.cpp:1626
TStr & ToLc()
Definition: dt.cpp:758
static const sdouble Mx
Definition: dt.h:1503
bool operator<(const TChA &ChA) const
Definition: dt.h:238
TDbStr()
Definition: dt.h:730
static TStr GetStr(const int &Val)
Definition: dt.h:1202
int GetMemUsed() const
Definition: dt.h:1527
TUInt64 & operator-=(const TUInt64 &Int)
Definition: dt.h:1341
void Load(TSIn &SIn)
Definition: dt.h:222
char * operator()()
Definition: dt.h:477
int Len() const
Definition: dt.h:384
bool IsNum() const
Definition: dt.h:1459
static TRStr * GetRStr(const char *CStr)
Definition: dt.cpp:719
int GetMemUsed() const
Definition: dt.h:121
static TStr GetGigaStr(const double &Val)
Definition: dt.h:1480
TCh & operator=(const TCh &Ch)
Definition: dt.h:1052
TLFlt()
Definition: dt.h:1544
unsigned char uchar
Definition: bd.h:10
TChA(TSIn &SIn)
Definition: dt.h:220
double GetMxX() const
Definition: dt.h:1601
void SaveBf(const void *Bf, const TSize &BfL)
Definition: fl.h:172
char GetCh(const int &ChN) const
Definition: dt.h:486
uint64 Len() const
Definition: dt.h:857
TChA & operator+=(const TMem &Mem)
Definition: dt.cpp:387
TUInt64(const uint &MsVal, const uint &LsVal)
Definition: dt.h:1328
char GetCh(const int &ChN) const
Definition: dt.h:280
int BfL
Definition: dt.h:203
bool operator==(const TLFlt &LFlt) const _CMPWARN
Definition: dt.h:1553
int GetMemUsed() const
Definition: dt.h:1275
void Trunc()
Definition: dt.cpp:420
bool operator<(const TVoid &) const
Definition: dt.h:968
TFlt()
Definition: dt.h:1398
Definition: fl.h:128
TBool(TSIn &SIn)
Definition: dt.h:993
char & operator[](const int &ChN) const
Definition: dt.h:119
int BfC
Definition: dt.h:162
int GetMemUsed() const
Definition: dt.h:1113
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:1838
TStr(TSIn &SIn, const bool &IsSmall=false)
Definition: dt.h:436
TStr & operator/(const int &N)
Definition: dt.h:461
void DelSubStr(const int &BChN, const int &EChN)
Definition: dt.cpp:850
int GetSecHashCd() const
Definition: dt.cpp:713
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:2227
Definition: dt.h:1121
static const char LfCh
Definition: dt.h:1038
int64 GetInt64(const int64 &DfVal) const
Definition: dt.h:599
char operator[](const int &ChN) const
Definition: dt.h:247
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:2275
TStr GetStr() const
Definition: dt.h:681
void Save(const bool &Bool)
Definition: fl.h:173
static uint GetRnd(const uint &Range=0)
Definition: dt.h:1280
TDbStr(const TStr &_Str1)
Definition: dt.h:732
int GetSecHashCd() const
Definition: dt.h:1132
TNum & operator=(const Base &_Val)
Definition: dt.h:880
TRnd(const int &_Seed=1, const int &Steps=0)
Definition: dt.h:20
static double Abs(const double &Flt)
Definition: dt.h:1430
static double GetUniDevStep(const int &Seed, const int &Steps)
Definition: dt.h:64
static int Round(const double &Flt)
Definition: dt.h:1432
TFlt operator++(int)
Definition: dt.h:1421
Definition: dt.h:1137
bool GetNextLnBf(TChA &LnChA)
Definition: dt.cpp:326
TStr Left(const int &EChN) const
Definition: dt.h:547
static TStr PutFBase(const TStr &FNm, const TStr &FBase)
Definition: dt.cpp:1511
TSFlt operator--(int)
Definition: dt.h:1526
char PeekCh()
Definition: dt.h:717
Definition: xml.h:198
double GetPoissonDev(const double &Mean)
Definition: dt.cpp:121
TChA & ToLc()
Definition: dt.cpp:552
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:2082
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:1881
static void LoadMem(const PSIn &SIn, TMem &Mem)
Definition: dt.h:149
TNum & operator+=(const TNum &Int)
Definition: dt.h:909
void Move(const int &Steps)
Definition: dt.cpp:29
Definition: fl.h:495
static PStrPool New(const TStr &fileName)
Definition: dt.h:796
void SaveTxt(TOLx &Lx) const
Definition: dt.cpp:219
TUInt & operator=(const uint &_Val)
Definition: dt.h:1260
static const TStr YesStr
Definition: dt.h:988
Definition: dt.h:201
TUInt operator--(int)
Definition: dt.h:1262
static TStr GetNumFNm(const TStr &FNm, const int &Num)
Definition: dt.cpp:1527
uchar Val
Definition: dt.h:1095
void Save(TSOut &SOut) const
Definition: dt.h:1048
static int Abs(const int &Int)
Definition: dt.h:1174
TUInt64()
Definition: dt.h:1325
static const bool Mn
Definition: dt.h:978
void Save(const TStr &FNm)
Definition: dt.h:799
uint64 Reserved() const
Definition: dt.h:858
bool operator<(const TLFlt &LFlt) const
Definition: dt.h:1556
Definition: dt.h:1242
TFltRect()
Definition: dt.h:1579
bool IsNan() const
Definition: dt.h:1460
static const TStr NStr
Definition: dt.h:985
double GetNrmDev()
Definition: dt.cpp:63
TStr GetTrunc() const
Definition: dt.h:509
int Seed
Definition: dt.h:16
static int GetRnd(const int &Range=0)
Definition: dt.h:1178
Definition: dt.h:725
Definition: dt.h:158
TStr & ToUc()
Definition: dt.cpp:752
void ConvUsFromYuAscii()
Definition: dt.cpp:693
void PutSeed(const int &_Seed)
Definition: dt.cpp:18
void PutCh(const int &ChN, const char &Ch)
Definition: dt.h:386
static bool IsAlNum(const char &Ch)
Definition: dt.h:1068
static int GetMx(const int &Int1, const int &Int2, const int &Int3, const int &Int4)
Definition: dt.h:1194
void Save(TSOut &SOut, const bool &IsSmall) const
Definition: dt.h:371
float sdouble
Definition: bd.h:15
TFlt MxX
Definition: dt.h:1577
TStr LeftOf(const char &SplitCh) const
Definition: dt.cpp:873
TInt & operator=(const int &Int)
Definition: dt.h:1158
void SplitOnNonAlNum(TStrV &StrV) const
Definition: dt.cpp:990
int SearchCh(const char &Ch, const int &BChN=0) const
Definition: dt.cpp:470
double GetYCenter() const
Definition: dt.h:1610
TInt operator++(int)
Definition: dt.h:1167
static char * LoadFrugalInt(char *pSrc, int &i)
Definition: dt.cpp:1975
uint AddStr(const char *Str)
Definition: dt.h:809
static bool IsValStr(const TStr &Str)
Definition: dt.cpp:1842
double GetBinomialDev(const double &Prb, const int &Trials)
Definition: dt.cpp:154
void AddBf(char *NewBf, const int &BfS)
Definition: dt.h:275
TNum & operator--()
Definition: dt.h:882
static double GetMn(const double &Flt1, const double &Flt2)
Definition: dt.h:1437
TStr GetStr() const
Definition: dt.h:1363
void Reset()
Definition: dt.h:340
int ChangeCh(const char &SrcCh, const char &DstCh, const int &BChN=0)
Definition: dt.cpp:1107
TUInt(TSIn &SIn)
Definition: dt.h:1253
TStr & operator+=(const TStr &Str)
Definition: dt.h:453
TFltRect(TSIn &SIn)
Definition: dt.h:1587
TBool()
Definition: dt.h:990
static const ldouble Mx
Definition: dt.h:1542
long long int64
Definition: bd.h:27
TStr(const char *CStr)
Definition: dt.h:427
TStr Mid(const int &BChN) const
Definition: dt.h:543
TSFlt operator++(int)
Definition: dt.h:1525
~TStrPool()
Definition: dt.h:792
TMem(TSIn &SIn)
Definition: dt.h:100
static TStr GetYNStr(const bool &Val)
Definition: dt.h:1015
static bool IsAlpha(const char &Ch)
Definition: dt.h:1065
int64 Val
Definition: dt.h:896
Definition: dt.h:412
TSInt()
Definition: dt.h:1125
TChA & operator=(const TChA &ChA)
Definition: dt.cpp:366
TNum(const TNum &Int)
Definition: dt.h:902
int GetMemUsed() const
Definition: dt.h:1169
TRnd & operator=(const TRnd &Rnd)
Definition: dt.h:27
bool Empty() const
Definition: dt.h:491
static PMem New(const int &MxBfL=0)
Definition: dt.h:87
~TStr()
Definition: dt.h:435
uint64 Val
Definition: dt.h:1320
bool IsChIn(const char &Ch) const
Definition: dt.h:556
static TStr GetMegaStr(const int64 &Val)
Definition: dt.h:932
TStr & ToTrunc()
Definition: dt.cpp:770
TStr GetCap() const
Definition: dt.h:505
static double GetRnd()
Definition: dt.h:1433
TStr LeftOfLast(const char &SplitCh) const
Definition: dt.cpp:880
static TStr GetStr(const TNum &Int)
Definition: dt.h:923
bool operator<(const TInt &Int) const
Definition: dt.h:1162
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
char PeekCh()
Definition: dt.h:338
static TStr MkClone(const TStr &Str)
Definition: dt.h:691
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:2151
static bool IsNan(const double &Val)
Definition: dt.h:1456
double operator()() const
Definition: dt.h:1416
void Swap(const int &ChN1, const int &ChN2)
Definition: dt.cpp:595
int GetHexInt(const int &DfVal) const
Definition: dt.h:616
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:9
void SplitOnAllCh(const char &SplitCh, TStrV &StrV, const bool &SkipEmpty=true) const
Definition: dt.cpp:926
static TRnd Rnd
Definition: dt.h:1248
int BfC
Definition: dt.h:325
TStr GetStr() const
Definition: dt.cpp:2325
bool Eof()
Definition: dt.h:714
void LoadBf(const void *Bf, const TSize &BfL)
Definition: fl.h:81
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:361
TAscFlt(TSIn &SIn)
Definition: dt.h:1492
void ToUc()
Definition: dt.cpp:667
TStr & operator=(const TChA &ChA)
Definition: dt.h:447
static TStr LoadTxt(const PSIn &SIn)
Definition: dt.h:669
int MxBfL
Definition: dt.h:79
static int64 GetFromBufSafe(const char *Bf)
Definition: dt.h:945
const char * operator()() const
Definition: dt.h:478
double GetFlt(const double &DfVal) const
Definition: dt.h:633
bool IsSuffix(const char *CStr) const
Definition: dt.cpp:518
void Load(TSIn &SIn)
Definition: dt.h:1405
bool IsUInt(uint &Val) const
Definition: dt.h:587
TSInt(const int16 &_Val)
Definition: dt.h:1126
TNum(const int64 &Int)
Definition: dt.h:903
TStr & operator=(const char *CStr)
Definition: dt.h:449
TStr GetHex() const
Definition: dt.h:515
static const char CrCh
Definition: dt.h:1039
TUInt64 & operator*=(const TUInt64 &Int)
Definition: dt.h:1342
static char GetUsFromYuAscii(const char &Ch)
Definition: dt.cpp:1885
static bool Intersection(const TFltRect &Rect1, const TFltRect &Rect2)
Definition: dt.cpp:2317
int Cmp(const uint &Offset, const char *Str) const
Definition: dt.h:820
static PStrPool64 New(::TSize MxBfL=0,::TSize GrowBy=16 *1024 *1024)
Definition: dt.h:847
static TStr GetNrNumFExt(const int &FExtN)
Definition: dt.cpp:1460
double GetUniDev()
Definition: dt.h:30
static TStr GetStr(const TStr &Str, const TStr &FmtStr)
Definition: dt.h:683
void GenZeros(const int &_BfL)
Definition: dt.h:125
bool operator<(const TStr &Str) const
Definition: dt.h:472
TRStr(TSIn &SIn, const bool &IsSmall)
Definition: dt.h:368
static TStr GetStr(const bool &Val)
Definition: dt.h:1011
uint Len() const
Definition: dt.h:801
TStrIn & operator=(const TStrIn &)
Definition: dt.h:322
TRStr & operator=(const TRStr &)
Definition: dt.h:375
void Reserve(const int &_MxBfL, const bool &DoClr=true)
Definition: dt.h:128
void Push(const char &Ch)
Definition: dt.h:264
static PMem New(const void *Bf, const int &BfL)
Definition: dt.h:91
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:1815
void AddChTo(const char &Ch, const int &ToChN)
Definition: dt.h:273
TChA(const TChA &ChA)
Definition: dt.h:213
int GetMemUsed() const
Definition: dt.h:969
static int Sign(const double &Flt)
Definition: dt.h:1431
TNum operator++(int)
Definition: dt.h:883
int GetSecHashCd() const
Definition: dt.h:1278
bool operator<(const TBool &Bool) const
Definition: dt.h:1001
Definition: bd.h:196
static const double PInf
Definition: dt.h:1393
static TStr GetStr(const int64 &Val)
Definition: dt.h:1213
static TStr GetStr(const TCh &Ch)
Definition: dt.h:1087
static double GetInRng(const double &Val, const double &Mn, const double &Mx)
Definition: dt.h:1451
static TStr GetKiloStr(const int64 &Val)
Definition: dt.h:927
uint Val
Definition: dt.h:1244
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:2311
static void LoadFrugalIntV(TSIn &SIn, TVec< TInt, int > &IntV, bool ClrP=true)
Definition: dt.cpp:2043
bool operator==(const int &Int) const
Definition: dt.h:1160
TNum(const Base &_Val)
Definition: dt.h:873
bool operator==(const TBool &Bool) const
Definition: dt.h:1000
TStr GetStr() const
Definition: dt.h:1462
TUInt & operator^=(const TUInt &UInt)
Definition: dt.h:1272
bool Filled() const
Definition: dt.h:752
void CompressWs()
Definition: dt.cpp:581
TStr Reverse() const
Definition: dt.h:569
TPt< TSIn > PSIn
Definition: fl.h:119
bool operator==(const TStr &Str) const
Definition: dt.h:464
short int16
Definition: bd.h:20
ldouble Val
Definition: dt.h:1539
TMem(const int &_MxBfL=0)
Definition: dt.h:84
TUInt & operator>>=(const int &ShiftBits)
Definition: dt.h:1273
int Len() const
Definition: dt.h:172
bool operator==(const double &Flt) const _CMPWARN
Definition: dt.h:1517
static const uchar Mx
Definition: dt.h:1098
char * GetBf() const
Definition: dt.h:144
static const TUInt64 Mn
Definition: dt.h:1322
bool Empty() const
Definition: dt.h:856
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:1905
int GetUniDevInt(const int &Range=0)
Definition: dt.cpp:39
static TStr PutFExt(const TStr &FNm, const TStr &FExt)
Definition: dt.cpp:1499
static const int Vals
Definition: dt.h:1034
TInt & operator+=(const int &Int)
Definition: dt.h:1165
void SplitOnStr(const TStr &SplitStr, TStrV &StrV) const
Definition: dt.cpp:1008
bool Empty() const
Definition: dt.h:135
bool GetNextLnBf(TChA &LnChA)
Definition: dt.cpp:1654
bool Check()
Definition: dt.cpp:33
void PutCh(const int &ChN, const char &Ch)
Definition: dt.h:482
int Len() const
Definition: dt.h:336
~TMemOut()
Definition: dt.h:191
static TStr GetStr(const ldouble &Val, const int &Width=-1, const int &Prec=-1)
Definition: dt.cpp:2284
void SplitOnWs(TStrV &StrV) const
Definition: dt.cpp:972
bool IsUc() const
Definition: dt.cpp:660
int GetGeoDev(const double &Prb)
Definition: dt.h:45
bool operator==(const ldouble &LFlt) const _CMPWARN
Definition: dt.h:1554
TUInt64 & operator+=(const TUInt64 &Int)
Definition: dt.h:1340
static char IsUc(const char &Ch)
Definition: dt.h:1081
TChA & ToTrunc()
Definition: dt.cpp:568
bool operator!=(const TChA &ChA) const
Definition: dt.h:235
TFlt & operator=(const TFlt &Flt)
Definition: dt.h:1411
static bool Eq6(const double &LFlt, const double &RFlt)
Definition: dt.h:1434
static const int Vals
Definition: dt.h:980
char * Bf
Definition: dt.h:703
static const int m
Definition: dt.h:15
char * CStr()
Definition: dt.h:479
char Pop()
Definition: dt.h:265
int GetPrimHashCd() const
Definition: dt.h:1277
int BfL
Definition: dt.h:162
TFltRect(const double &_MnX, const double &_MnY, const double &_MxX, const double &_MxY)
Definition: dt.h:1583
TLFlt(TSIn &SIn)
Definition: dt.h:1547
int GetHexInt() const
Definition: dt.h:614
int Refs
Definition: dt.h:349
~TChA()
Definition: dt.h:219
TStr()
Definition: dt.h:423
char operator()() const
Definition: dt.h:1055
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:2303
int GetBf(const void *LBf, const TSize &LBfL)
Definition: dt.cpp:644
uint GetMsVal() const
Definition: dt.h:1350
void SplitOnLastCh(TStr &LStr, const char &SplitCh, TStr &RStr) const
Definition: dt.cpp:912
double GetMnX() const
Definition: dt.h:1599
TChA(const char *CStr, const int &StrLen)
Definition: dt.h:211
static TStr GetStr(const uint &Val)
Definition: dt.h:1208
PMem Mem
Definition: dt.h:160
static TStr GetStr(const ldouble &Val, const TStr &FmtStr)
Definition: dt.h:1569
Definition: dt.h:974
char * operator()() const
Definition: dt.h:114
static char GetUc(const char &Ch)
Definition: dt.h:1083
TRStr(const char &Ch1, const char &Ch2)
Definition: dt.h:363
TStr Slice(int BChN, int EChNP1) const
Definition: dt.h:549
bool IsStrIn(const TStr &Str) const
Definition: dt.h:557
TVoid()
Definition: dt.h:960
Definition: fl.h:11
TStr GetFBase() const
Definition: dt.cpp:1396
static uint GetUIntFromIpStr(const TStr &IpStr, const char &SplitCh= '.')
Definition: dt.cpp:2107
static void Swap(int &Int1, int &Int2)
Definition: dt.h:1176
static TStr GetHexStr(const TNum &Int)
Definition: dt.h:924
static TStr GetStr(const TBool &Bool)
Definition: dt.h:1013
uint64 GetMemUsed() const
Definition: dt.h:854
int GetPrimHashCd() const
Definition: dt.cpp:607
bool IsSuffix(const TStr &Str) const
Definition: dt.h:562
TStr operator()(const int &BChN, const int &EChNP1) const
Definition: dt.h:550
void SplitOnAllAnyCh(const TStr &SplitChStr, TStrV &StrV, const bool &SkipEmpty=true) const
Definition: dt.cpp:944
TBool(const bool &_Val)
Definition: dt.h:991
uint AddStr(const TStr &Str)
Definition: dt.h:810
int GetSecHashCd() const
Definition: dt.h:1348
void InsStr(const int &BChN, const TStr &Str)
Definition: dt.cpp:825
static TStr GetStr(const TFlt &Flt, const int &Width=-1, const int &Prec=-1)
Definition: dt.h:1464
int16 Val
Definition: dt.h:1123
int BfL
Definition: dt.h:704
int CountCh(const char &Ch, const int &BChN=0) const
Definition: dt.cpp:1033
static const TStr TrueStr
Definition: dt.h:984
TUInt64(void *Pt)
Definition: dt.h:1330
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:2258
TNum(TSIn &SIn)
Definition: dt.h:875
int GetMemUsed() const
Definition: dt.h:475
int GetPrimHashCd() const
Definition: dt.h:1529
static const int64 Mn
Definition: dt.h:898
bool IsUc() const
Definition: dt.h:494
static int GetMn(const int &Int1, const int &Int2, const int &Int3)
Definition: dt.h:1187
bool operator!=(const char &Ch) const
Definition: dt.h:237
uint operator()() const
Definition: dt.h:1267
bool GetNextLnBf(TChA &LnChA)
Definition: dt.cpp:652
static TStr GetStr(const TInt &Int)
Definition: dt.h:1203
Definition: dt.h:1488
TChA(const char *CStr)
Definition: dt.h:209
bool operator<(const TSFlt &SFlt) const
Definition: dt.h:1519
bool operator==(const TUCh &UCh) const
Definition: dt.h:1110
TStr RightOfLast(const char &SplitCh) const
Definition: dt.cpp:894
TCs Cs
Definition: fl.h:44
static const TUInt64 Mx
Definition: dt.h:1323
int GetSeed() const
Definition: dt.h:59
int GetSecHashCd() const
Definition: dt.h:1427
static const uchar Mn
Definition: dt.h:1097
int GetMemUsed() const
Definition: dt.h:1004
void Save(TSOut &SOut) const
Definition: dt.h:1402
TNum()
Definition: dt.h:901
bool operator<(const TDbStr &DbStr) const
Definition: dt.h:741
static bool IsAbsFPath(const TStr &FPath)
Definition: dt.cpp:1491
TStr(const char &Ch)
Definition: dt.h:428
static const int64 Mx
Definition: dt.h:899
TFlt & operator-=(const double &Flt)
Definition: dt.h:1418
TUCh()
Definition: dt.h:1101
static bool IsEven(const int &Int)
Definition: dt.h:1181
double GetPowerDev(const double &AlphaSlope)
Definition: dt.h:47
Definition: dt.h:1318
bool operator()() const
Definition: dt.h:1003
static const double Eps
Definition: dt.h:1394
bool IsUInt64() const
Definition: dt.h:605
static PMem New(const TStr &Str)
Definition: dt.h:98
int ChangeStr(const TStr &SrcStr, const TStr &DstStr, const int &BChN=0)
Definition: dt.cpp:1130
TRStr(const int &Len)
Definition: dt.h:352
static TRnd Rnd
Definition: dt.h:1396
static const double Mn
Definition: dt.h:1390
int operator()() const
Definition: dt.h:1164
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:430
Definition: dt.h:346
~TStrIn()
Definition: dt.h:712
char Val
Definition: dt.h:1030
Definition: dt.h:1093
double GetXLen() const
Definition: dt.h:1605
static void LoadMem(const PSIn &SIn, const PMem &Mem)
Definition: dt.h:151
void ChangeCh(const char &SrcCh, const char &DstCh)
Definition: dt.cpp:537
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:2156
static TStr GetKiloStr(const int &Val)
Definition: dt.h:1222
void Load(TSIn &SIn)
Definition: dt.h:876
void SaveTxt(const PSOut &SOut) const
Definition: dt.h:673
static TStr GetFNmStr(const TStr &Str, const bool &AlNumOnlyP=true)
Definition: dt.cpp:1531
int GetInt(const int &DfVal) const
Definition: dt.h:582
int GetMemUsed() const
Definition: dt.h:251
void Clr(const bool &DoDel=true)
Definition: dt.h:131
~TRStr()
Definition: dt.h:365
static int GetMx(const int &Int1, const int &Int2, const int &Int3)
Definition: dt.h:1192