SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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;}
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:
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  bool operator==(const TStr& Str) const {
462  return (RStr==Str.RStr)||(strcmp(RStr->CStr(), Str.RStr->CStr())==0);}
463  bool operator==(const char* CStr) const {
464  return strcmp(RStr->CStr(), CStr)==0;}
465 // bool operator!=(const TStr& Str) const {
466 // return strcmp(RStr->CStr(), Str.RStr->CStr())!=0;}
467  bool operator!=(const char* CStr) const {
468  return strcmp(RStr->CStr(), CStr)!=0;}
469  bool operator<(const TStr& Str) const {
470  return strcmp(RStr->CStr(), Str.RStr->CStr())<0;}
471  char operator[](const int& ChN) const {return RStr->GetCh(ChN);}
472  int GetMemUsed() const {return int(sizeof(TRStr*)+RStr->GetMemUsed());}
473 
474  char* operator()(){return RStr->CStr();}
475  const char* operator()() const {return RStr->CStr();}
476  char* CStr() {return RStr->CStr();}
477  const char* CStr() const {return RStr->CStr();}
478 
479  void PutCh(const int& ChN, const char& Ch){
480  TRStr* NewRStr=new TRStr(RStr->CStr());
481  RStr->UnRef(); RStr=NewRStr; RStr->MkRef();
482  RStr->PutCh(ChN, Ch); Optimize();}
483  char GetCh(const int& ChN) const {return RStr->GetCh(ChN);}
484  char LastCh() const {return GetCh(Len()-1);}
485 
487  int Len() const {return RStr->Len();}
488  bool Empty() const {return RStr->Empty();}
489 
490  // upper-case
491  bool IsUc() const {return RStr->IsUc();}
492  TStr& ToUc();
493  TStr GetUc() const {return TStr(*this).ToUc();}
494  int CmpI(const TStr& Str) const {return TRStr::CmpI(CStr(), Str.CStr());}
495  bool EqI(const TStr& Str) const {return TRStr::CmpI(CStr(), Str.CStr())==0;}
496  // lower-case
497  bool IsLc() const {return RStr->IsLc();}
498  TStr& ToLc();
499  TStr GetLc() const {return TStr(*this).ToLc();}
500  // capitalize
501  TStr& ToCap();
502  TStr GetCap() const {return TStr(*this).ToCap();}
503 
504  // truncate
505  TStr& ToTrunc();
506  TStr GetTrunc() const {return TStr(*this).ToTrunc();}
507  // Yu-Ascii to Us-Ascii
509  TStr GetUsFromYuAscii() const {return TStr(*this).ConvUsFromYuAscii();}
510  // hex
511  TStr& ToHex();
512  TStr GetHex() const {return TStr(*this).ToHex();}
513  TStr& FromHex();
514  TStr GetFromHex() const {return TStr(*this).FromHex();}
515 
516  TStr GetSubStr(const int& BChN, const int& EChN) const;
517  TStr GetSubStr(const int& BChN) const { return GetSubStr(BChN, Len()-1); }
518  void InsStr(const int& BChN, const TStr& Str);
519  void DelChAll(const char& Ch);
520  void DelSubStr(const int& BChN, const int& EChN);
521  bool DelStr(const TStr& Str);
522  TStr LeftOf(const char& SplitCh) const;
523  TStr LeftOfLast(const char& SplitCh) const;
524  TStr RightOf(const char& SplitCh) const;
525  TStr RightOfLast(const char& SplitCh) const;
526  void SplitOnCh(TStr& LStr, const char& SplitCh, TStr& RStr) const;
527  void SplitOnLastCh(TStr& LStr, const char& SplitCh, TStr& RStr) const;
528  void SplitOnAllCh(
529  const char& SplitCh, TStrV& StrV, const bool& SkipEmpty=true) const;
530  void SplitOnAllAnyCh(
531  const TStr& SplitChStr, TStrV& StrV, const bool& SkipEmpty=true) const;
532  void SplitOnWs(TStrV& StrV) const;
533  void SplitOnNonAlNum(TStrV& StrV) const;
534  void SplitOnStr(const TStr& SplitStr, TStrV& StrV) const;
535  void SplitOnStr(TStr& LeftStr, const TStr& MidStr, TStr& RightStr) const;
536 
537  //TStr Left(const int& Chs) const { return Chs>0 ? GetSubStr(0, Chs-1) : GetSubStr(0, Len()-Chs-1);}
538  //TStr Right(const int& Chs) const {return GetSubStr(Len()-Chs, Len()-1);}
539  TStr Mid(const int& BChN, const int& Chs) const { return GetSubStr(BChN, BChN+Chs-1); }
540  TStr Mid(const int& BChN) const {return GetSubStr(BChN, Len()-1); }
541  //TStr Slice(const int& BChN, const int& EChNP1) const {return GetSubStr(BChN, EChNP1-1);}
542  //TStr operator()(const int& BChN, const int& EChNP1) const {return Slice(BChN, EChNP1);}
543  //J: as in python or matlab: position 1 is 1st character, -1 is last character
544  TStr Left(const int& EChN) const { return EChN>0 ? GetSubStr(0, EChN-1) : GetSubStr(0, Len()+EChN-1);}
545  TStr Right(const int& BChN) const {return BChN>=0 ? GetSubStr(BChN, Len()-1) : GetSubStr(Len()+BChN, Len()-1);}
546  TStr Slice(int BChN, int EChNP1) const { if(BChN<0){BChN=Len()+BChN;} if(EChNP1<=0){EChNP1=Len()+EChNP1;} return GetSubStr(BChN, EChNP1-1); }
547  TStr operator()(const int& BChN, const int& EChNP1) const {return Slice(BChN, EChNP1);}
548 
549  int CountCh(const char& Ch, const int& BChN=0) const;
550  int SearchCh(const char& Ch, const int& BChN=0) const;
551  int SearchChBack(const char& Ch, int BChN=-1) const;
552  int SearchStr(const TStr& Str, const int& BChN=0) const;
553  bool IsChIn(const char& Ch) const {return SearchCh(Ch)!=-1;}
554  bool IsStrIn(const TStr& Str) const {return SearchStr(Str)!=-1;}
555  bool IsPrefix(const char *Str) const;
556  bool IsPrefix(const TStr& Str) const {
557  return IsPrefix(Str.CStr());}
558  bool IsSuffix(const char *Str) const;
559  bool IsSuffix(const TStr& Str) const {
560  return IsSuffix(Str.CStr());}
561 
562  int ChangeCh(const char& SrcCh, const char& DstCh, const int& BChN=0);
563  int ChangeChAll(const char& SrcCh, const char& DstCh);
564  int ChangeStr(const TStr& SrcStr, const TStr& DstStr, const int& BChN=0);
565  int ChangeStrAll(const TStr& SrcStr, const TStr& DstStr, const bool& FromStartP=false);
566  TStr Reverse() const {
567  TChA ChA(*this); ChA.Reverse(); return ChA;}
568 
569  int GetPrimHashCd() const {return RStr->GetPrimHashCd();}
570  int GetSecHashCd() const {return RStr->GetSecHashCd();}
571 
572  bool IsBool(bool& Val) const;
573 
574  bool IsInt(
575  const bool& Check, const int& MnVal, const int& MxVal, int& Val) const;
576  bool IsInt(int& Val) const {return IsInt(false, 0, 0, Val);}
577  bool IsInt() const {int Val; return IsInt(false, 0, 0, Val);}
578  int GetInt() const {int Val; IAssertR(IsInt(false, 0, 0, Val), *this); return Val;}
579  int GetInt(const int& DfVal) const {
580  int Val; if (IsInt(false, 0, 0, Val)){return Val;} else {return DfVal;}}
581 
582  bool IsUInt(
583  const bool& Check, const uint& MnVal, const uint& MxVal, uint& Val) const;
584  bool IsUInt(uint& Val) const {return IsUInt(false, 0, 0, Val);}
585  bool IsUInt() const {uint Val; return IsUInt(false, 0, 0, Val);}
586  uint GetUInt() const {uint Val; IAssert(IsUInt(false, 0, 0, Val)); return Val;}
587  uint GetUInt(const uint& DfVal) const {
588  uint Val; if (IsUInt(false, 0, 0, Val)){return Val;} else {return DfVal;}}
589 
590  bool IsInt64(
591  const bool& Check, const int64& MnVal, const int64& MxVal, int64& Val) const;
592  bool IsInt64(int64& Val) const {return IsInt64(false, 0, 0, Val);}
593  bool IsInt64() const {int64 Val; return IsInt64(false, 0, 0, Val);}
594  int64 GetInt64() const {
595  int64 Val; IAssert(IsInt64(false, 0, 0, Val)); return Val;}
596  int64 GetInt64(const int64& DfVal) const {
597  int64 Val; if (IsInt64(false, 0, 0, Val)){return Val;} else {return DfVal;}}
598 
599  bool IsUInt64(
600  const bool& Check, const uint64& MnVal, const uint64& MxVal, uint64& Val) const;
601  bool IsUInt64(uint64& Val) const {return IsUInt64(false, 0, 0, Val);}
602  bool IsUInt64() const {uint64 Val; return IsUInt64(false, 0, 0, Val);}
603  uint64 GetUInt64() const {
604  uint64 Val; IAssert(IsUInt64(false, 0, 0, Val)); return Val;}
605  uint64 GetUInt64(const uint64& DfVal) const {
606  uint64 Val; if (IsUInt64(false, 0, 0, Val)){return Val;} else {return DfVal;}}
607 
608  bool IsHexInt(const bool& Check, const int& MnVal, const int& MxVal, int& Val) const;
609  bool IsHexInt(int& Val) const {return IsHexInt(false, 0, 0, Val);}
610  bool IsHexInt() const {int Val; return IsHexInt(false, 0, 0, Val);}
611  int GetHexInt() const {
612  int Val; IAssert(IsHexInt(false, 0, 0, Val)); return Val;}
613  int GetHexInt(const int& DfVal) const {
614  int Val; if (IsHexInt(false, 0, 0, Val)){return Val;} else {return DfVal;}}
615 
616  bool IsHexInt64(const bool& Check, const int64& MnVal, const int64& MxVal, int64& Val) const;
617  bool IsHexInt64(int64& Val) const {return IsHexInt64(false, 0, 0, Val);}
618  bool IsHexInt64() const {int64 Val; return IsHexInt64(false, 0, 0, Val);}
619  int64 GetHexInt64() const {
620  int64 Val; IAssert(IsHexInt64(false, 0, 0, Val)); return Val;}
621  int64 GetHexInt64(const int64& DfVal) const {
622  int64 Val; if (IsHexInt64(false, 0, 0, Val)){return Val;} else {return DfVal;}}
623 
624  bool IsFlt(const bool& Check, const double& MnVal, const double& MxVal,
625  double& Val, const char& DecDelimCh='.') const;
626  bool IsFlt(double& Val) const {return IsFlt(false, 0, 0, Val);}
627  bool IsFlt() const {double Val; return IsFlt(false, 0, 0, Val);}
628  double GetFlt() const {
629  double Val; IAssert(IsFlt(false, 0, 0, Val)); return Val;}
630  double GetFlt(const double& DfVal) const {
631  double Val; if (IsFlt(false, 0, 0, Val)){return Val;} else {return DfVal;}}
632 
633  bool IsWord(const bool& WsPrefixP=true, const bool& FirstUcAllowedP=true) const;
634  bool IsWs() const;
635 
636  bool IsWcMatch(
637  const int& StrBChN, const TStr& WcStr, const int& WcStrBChN, TStrV& StarStrV,
638  const char& StarCh='*', const char& QuestCh='?') const;
639  bool IsWcMatch(
640  const TStr& WcStr, TStrV& StarStrV,
641  const char& StarCh='*', const char& QuestCh='?') const;
642  bool IsWcMatch(const TStr& WcStr, const char& StarCh, const char& QuestCh) const;
643  bool IsWcMatch(const TStr& WcStr, const int& StarStrN, TStr& StarStr) const;
644  bool IsWcMatch(const TStr& WcStr) const;
645  TStr GetWcMatch(const TStr& WcStr, const int& StarStrN=0) const;
646 
647  TStr GetFPath() const;
648  TStr GetFBase() const;
649  TStr GetFMid() const;
650  TStr GetFExt() const;
651  static TStr GetNrFPath(const TStr& FPath);
652  static TStr GetNrFMid(const TStr& FMid);
653  static TStr GetNrFExt(const TStr& FExt);
654  static TStr GetNrNumFExt(const int& FExtN);
655  static TStr GetNrFNm(const TStr& FNm);
656  static TStr GetNrAbsFPath(const TStr& FPath, const TStr& BaseFPath=TStr());
657  static bool IsAbsFPath(const TStr& FPath);
658  static TStr PutFExt(const TStr& FNm, const TStr& FExt);
659  static TStr PutFExtIfEmpty(const TStr& FNm, const TStr& FExt);
660  static TStr PutFBase(const TStr& FNm, const TStr& FBase);
661  static TStr PutFBaseIfEmpty(const TStr& FNm, const TStr& FBase);
662  static TStr AddToFMid(const TStr& FNm, const TStr& ExtFMid);
663  static TStr GetNumFNm(const TStr& FNm, const int& Num);
664  static TStr GetFNmStr(const TStr& Str, const bool& AlNumOnlyP=true);
665 
666  static TStr LoadTxt(const PSIn& SIn){
667  return TStr(SIn);}
668  static TStr LoadTxt(const TStr& FNm){
669  PSIn SIn=TFIn::New(FNm); return LoadTxt(SIn);}
670  void SaveTxt(const PSOut& SOut) const {
671  SOut->SaveBf(CStr(), Len());}
672  void SaveTxt(const TStr& FNm) const {
673  PSOut SOut=TFOut::New(FNm); SaveTxt(SOut);}
674 
675  static TStr& GetChStr(const char& Ch);
676  static TStr& GetDChStr(const char& Ch1, const char& Ch2);
677 
678  TStr GetStr() const {return *this;}
679  static TStr GetStr(const TStr& Str, const char* FmtStr);
680  static TStr GetStr(const TStr& Str, const TStr& FmtStr){
681  return GetStr(Str, FmtStr.CStr());}
682  static TStr GetStr(const TStrV& StrV, const TStr& DelimiterStr);
683  static TStr Fmt(const char *FmtStr, ...);
684  static TStr GetSpaceStr(const int& Spaces);
685  char* GetCStr() const {
686  char* Bf=new char[Len()+1]; strcpy(Bf, CStr()); return Bf;}
687 
688  static TStr MkClone(const TStr& Str){return TStr(Str.CStr());}
689  static TStr GetNullStr();
690 
691  friend TStr operator+(const TStr& LStr, const TStr& RStr);
692  friend TStr operator+(const TStr& LStr, const char* RCStr);
693 };
694 
696 // Input-String
697 class TStrIn: public TSIn{
698 private:
700  char* Bf;
701  int BfC, BfL;
702 private:
703  TStrIn();
704  TStrIn(const TStrIn&);
705  TStrIn& operator = (const TStrIn&);
706 public:
707  TStrIn(const TStr& _Str);
708  static PSIn New(const TStr& Str){return PSIn(new TStrIn(Str));}
710 
711  bool Eof(){return BfC==BfL;}
712  int Len() const {return BfL-BfC;}
713  char GetCh(){Assert(BfC<BfL); return Bf[BfC++];}
714  char PeekCh(){Assert(BfC<BfL); return Bf[BfC];}
715  int GetBf(const void* LBf, const TSize& LBfL);
716  void Reset(){Cs=TCs(); BfC=0;}
717  bool GetNextLnBf(TChA& LnChA);
718 };
719 
721 // Double-String
722 class TDbStr{
723 public:
726 public:
727  TDbStr(): Str1(), Str2(){}
728  TDbStr(const TDbStr& DbStr): Str1(DbStr.Str1), Str2(DbStr.Str2){}
729  TDbStr(const TStr& _Str1): Str1(_Str1), Str2(){}
730  TDbStr(const TStr& _Str1, const TStr& _Str2): Str1(_Str1), Str2(_Str2){}
731  explicit TDbStr(TSIn& SIn): Str1(SIn), Str2(SIn){}
732  void Save(TSOut& SOut) const {Str1.Save(SOut); Str2.Save(SOut);}
733 
734  TDbStr& operator=(const TDbStr& DbStr){
735  if (this!=&DbStr){Str1=DbStr.Str1; Str2=DbStr.Str2;} return *this;}
736  bool operator==(const TDbStr& DbStr) const {
737  return (Str1==DbStr.Str1)&&(Str2==DbStr.Str2);}
738  bool operator<(const TDbStr& DbStr) const {
739  return (Str1<DbStr.Str1)||((Str1==DbStr.Str1)&&(Str2<DbStr.Str2));}
740 
741  TStr GetStr(const TStr& MidStr=TStr()) const {
742  if (Filled()){return Str1+MidStr+Str2;} else {return Str1+Str2;}}
743  int GetPrimHashCd() const {
744  return Str1.GetPrimHashCd()+Str2.GetPrimHashCd();}
745  int GetSecHashCd() const {
746  return Str1.GetSecHashCd()+Str2.GetSecHashCd();}
747 
748  bool Empty() const {return (Str1.Empty())&&(Str2.Empty());}
749  bool Filled() const {return (!Str2.Empty())&&(!Str1.Empty());}
750 };
751 
753 // Simple-String-Pool
754 //ClassTP(TSStrPool, PSStrPool)//{
755 //private:
756 // TMem Bf;
757 //public:
758 // TSStrPool(const int& MxLen=0): Bf(MxLen){}
759 // TSStrPool(TSStrPool& StrPool): Bf(StrPool.Bf){}
760 // TSStrPool(TSIn& SIn): Bf(SIn){}
761 // void Save(TSOut& SOut) const {Bf.Save(SOut);}
762 //
763 // TSStrPool& operator=(const TSStrPool& StrPool){
764 // Bf=StrPool.Bf; return *this;}
765 //
766 // int Len() const {return Bf.Len();}
767 // void Clr(){Bf.Clr();}
768 // int AddStr(const TStr& Str){
769 // if (Str.Empty()){return -1;}
770 // else {int StrId=Bf.Len(); Bf+=Str; Bf+=char(0); return StrId;}}
771 // TStr GetStr(const int& StrId) const {
772 // if (StrId==-1){return "";}
773 // else {return TStr(Bf()+StrId);}}
774 //};
775 
777 // String-Pool
779 private:
780  uint MxBfL, BfL, GrowBy;
781  char *Bf;
782 private:
783  void Resize(const uint& _MxBfL);
784 public:
785  TStrPool(const uint& MxBfLen = 0, const uint& _GrowBy = 16*1024*1024);
786  TStrPool(TSIn& SIn, bool LoadCompact = true);
787  TStrPool(const TStrPool& Pool) : MxBfL(Pool.MxBfL), BfL(Pool.BfL), GrowBy(Pool.GrowBy) {
788  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); }
789  ~TStrPool() { if (Bf) free(Bf); else IAssertR(MxBfL == 0, TStr::Fmt("size: %u, expected size: 0", MxBfL).CStr()); Bf = 0; MxBfL = 0; BfL = 0; }
790 
791  static PStrPool New(const uint& _MxBfLen = 0, const uint& _GrowBy = 16*1024*1024) { return PStrPool(new TStrPool(_MxBfLen, _GrowBy)); }
792  static PStrPool New(TSIn& SIn) { return new TStrPool(SIn); }
793  static PStrPool New(const TStr& fileName) { PSIn SIn = TFIn::New(fileName); return new TStrPool(*SIn); }
794  static PStrPool Load(TSIn& SIn, bool LoadCompacted = true) { return PStrPool(new TStrPool(SIn, LoadCompacted)); }
795  void Save(TSOut& SOut) const;
796  void Save(const TStr& FNm){PSOut SOut=TFOut::New(FNm); Save(*SOut);}
797 
798  uint Len() const { return BfL; }
799  uint Size() const { return MxBfL; }
800  bool Empty() const { return ! Len(); }
801  char* operator () () const { return Bf; }
802  TStrPool& operator = (const TStrPool& Pool);
803  ::TSize GetMemUsed(){ return 4 * sizeof(int) + MxBfL;}
804 
805  uint AddStr(const char *Str, const uint& Len);
806  uint AddStr(const char *Str) { return AddStr(Str, uint(strlen(Str)) + 1); }
807  uint AddStr(const TStr& Str) { return AddStr(Str.CStr(), Str.Len() + 1); }
808 
809  TStr GetStr(const uint& Offset) const { Assert(Offset < BfL);
810  if (Offset == 0) return TStr::GetNullStr(); else return TStr(Bf + Offset); }
811  const char *GetCStr(const uint& Offset) const { Assert(Offset < BfL);
812  if (Offset == 0) return TStr::GetNullStr().CStr(); else return Bf + Offset; }
813 
814  // Clr() removes the empty string at the start.
815  // Call AddStr("") after Clr(), if you want to use the pool again.
816  void Clr(bool DoDel = false) { BfL = 0; if (DoDel && Bf) { free(Bf); Bf = 0; MxBfL = 0; } }
817  int Cmp(const uint& Offset, const char *Str) const { Assert(Offset < BfL);
818  if (Offset != 0) return strcmp(Bf + Offset, Str); else return strcmp("", Str); }
819 
820  static int GetPrimHashCd(const char *CStr);
821  static int GetSecHashCd(const char *CStr);
822  int GetPrimHashCd(const uint& Offset) { Assert(Offset < BfL);
823  if (Offset != 0) return GetPrimHashCd(Bf + Offset); else return GetPrimHashCd(""); }
824  int GetSecHashCd(const uint& Offset) { Assert(Offset < BfL);
825  if (Offset != 0) return GetSecHashCd(Bf + Offset); else return GetSecHashCd(""); }
826  static PStrPool LoadShM(TSIn& SIn){ return new TStrPool(SIn); }
827 };
828 
830 // String-Pool-64bit
832 private:
833  ::TSize MxBfL, BfL, GrowBy;
834  char *Bf;
835 private:
836  void Resize(const ::TSize& _MxBfL);
837 public:
838  TStrPool64(::TSize _MxBfL = 0, ::TSize _GrowBy = 16*1024*1024);
839  TStrPool64(const TStrPool64& StrPool);
840  TStrPool64(TSIn& SIn, bool LoadCompact = true);
841  ~TStrPool64() { Clr(true); }
842  void Save(TSOut& SOut) const;
843 
844  static PStrPool64 New(::TSize MxBfL = 0, ::TSize GrowBy = 16*1024*1024) {
845  return PStrPool64(new TStrPool64(MxBfL, GrowBy)); }
846  static PStrPool64 Load(TSIn& SIn, bool LoadCompact = true) {
847  return PStrPool64(new TStrPool64(SIn, LoadCompact)); }
848 
849  TStrPool64& operator=(const TStrPool64& StrPool);
850 
851  uint64 GetMemUsed() const { return 3*sizeof(::TSize) + uint64(MxBfL); }
852 
853  bool Empty() const { return (BfL == 0); }
854  uint64 Len() const {return BfL;}
855  uint64 Reserved() const { return MxBfL; }
856  void Clr(bool DoDel = false);
857  int Cmp(uint64 Offset, const char *Str) const { Assert(Offset < BfL);
858  if (Offset != 0) return strcmp(Bf + Offset, Str); else return strcmp("", Str); }
859 
860  uint64 AddStr(const TStr& Str);
861  TStr GetStr(const uint64& StrId) const;
862 };
863 
865 // Number Base Template
866 template <class Base> class TNum{
867 public:
868  Base Val;
869  TNum() : Val(0){}
870  TNum(const Base& _Val) : Val(_Val){}
871  operator Base() const { return Val; }
872  explicit TNum(TSIn& SIn){ SIn.Load(Val); }
873  void Load(TSIn& SIn){ SIn.Load(Val); }
874  void Save(TSOut& SOut) const { SOut.Save(Val); }
875 
876  TNum& operator=(const TNum& Other){ Val = Other.Val; return *this; }
877  TNum& operator=(const Base& _Val){ Val = _Val; return *this; }
878  TNum& operator++(){ ++Val; return *this; } // prefix
879  TNum& operator--(){ --Val; return *this; } // prefix
880  TNum operator++(Base){ TNum oldVal = Val; Val++; return oldVal; } // postfix
881  TNum operator--(Base){ TNum oldVal = Val; Val--; return oldVal; } // postfix
882  Base& operator()() { return Val; }
883 
884  int GetMemUsed() const { return sizeof(TNum); }
885 };
886 
888 // Signed-Integer-64Bit
890 template<>
891 class TNum<int64>{
892 public:
894 public:
895  static const int64 Mn;
896  static const int64 Mx;
897 
898  TNum() : Val(0){}
899  TNum(const TNum& Int) : Val(Int.Val){}
900  TNum(const int64& Int) : Val(Int){}
901  operator int64() const { return Val; }
902  explicit TNum(TSIn& SIn){ SIn.Load(Val); }
903  void Load(TSIn& SIn){ SIn.Load(Val); }
904  void Save(TSOut& SOut) const { SOut.Save(Val); }
905  TNum& operator=(const TNum& Int){ Val = Int.Val; return *this; }
906  TNum& operator+=(const TNum& Int){ Val += Int.Val; return *this; }
907  TNum& operator-=(const TNum& Int){ Val -= Int.Val; return *this; }
908  TNum& operator++(){ ++Val; return *this; } // prefix
909  TNum& operator--(){ --Val; return *this; } // prefix
910  TNum operator++(int){ TNum oldVal = Val; Val++; return oldVal; } // postfix
911  TNum operator--(int){ TNum oldVal = Val; Val--; return oldVal; } // postfix
912  int GetMemUsed() const { return sizeof(TNum); }
913 
914 #ifdef GLib_WIN
915  TStr GetStr() const { return TStr::Fmt("%I64", Val); }
916  static TStr GetStr(const TNum& Int){ return TStr::Fmt("%I64", Int.Val); }
917  static TStr GetHexStr(const TNum& Int){ return TStr::Fmt("%I64X", Int.Val); }
918 #else
919  TStr GetStr() const { return TStr::Fmt("%ll", Val); }
920  static TStr GetStr(const TNum& Int){ return TStr::Fmt("%ll", Int.Val); }
921  static TStr GetHexStr(const TNum& Int){ return TStr::Fmt("%ll", Int.Val); }
922 #endif
923 
924  static TStr GetKiloStr(const int64& Val){
925  if (Val>100 * 1000){ return GetStr(Val / 1000) + "K"; }
926  else if (Val>1000){ return GetStr(Val / 1000) + "." + GetStr((Val % 1000) / 100) + "K"; }
927  else { return GetStr(Val); }
928  }
929  static TStr GetMegaStr(const int64& Val){
930  if (Val>100 * 1000000){ return GetStr(Val / 1000000) + "M"; }
931  else if (Val>1000000){
932  return GetStr(Val / 1000000) + "." + GetStr((Val % 1000000) / 100000) + "M";
933  }
934  else { return GetKiloStr(Val); }
935  }
936  /*static TStr GetGigaStr(const int64& Val){
937  * if (Val>100*1000000000){return GetStr(Val/1000000000)+"G";}
938  * else if (Val>1000000000){
939  * return GetStr(Val/1000000000)+"."+GetStr((Val%1000000000)/100000000)+"G";}
940  * else {return GetMegaStr(Val);}}*/
941 
942  static int64 GetFromBufSafe(const char * Bf) {
943 #ifdef ARM
944  int64 Val;
945  memcpy(&Val, Bf, sizeof(int64)); //we cannot use a cast on ARM (needs 8byte memory aligned doubles)
946  return Val;
947 #else
948  return *((int64*)Bf);
949 #endif
950  }
951 };
952 
954 // Void
955 class TVoid{
956 public:
957  TVoid(){}
959  void Save(TSOut&) const {}
960  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
961  void SaveXml(TSOut& SOut, const TStr& Nm) const;
962 
963  TVoid& operator=(const TVoid&){return *this;}
964  bool operator==(const TVoid&) const {return true;}
965  bool operator<(const TVoid&) const {Fail; return false;}
966  int GetMemUsed() const {return sizeof(TVoid);}
967 };
968 
970 // Boolean
971 class TBool{
972 public:
973  bool Val;
974 public:
975  static const bool Mn;
976  static const bool Mx;
977  static const int Vals;
978  static TRnd Rnd;
979 
980  static const TStr FalseStr;
981  static const TStr TrueStr;
982  static const TStr NStr;
983  static const TStr YStr;
984  static const TStr NoStr;
985  static const TStr YesStr;
986 
987  TBool(): Val(false){}
988  TBool(const bool& _Val): Val(_Val){}
989  operator bool() const {return Val;}
990  explicit TBool(TSIn& SIn){SIn.Load(Val);}
991  void Load(TSIn& SIn){SIn.Load(Val);}
992  void Save(TSOut& SOut) const {SOut.Save(Val);}
993  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
994  void SaveXml(TSOut& SOut, const TStr& Nm) const;
995 
996  TBool& operator=(const TBool& Bool){Val=Bool.Val; return *this;}
997  bool operator==(const TBool& Bool) const {return Val==Bool.Val;}
998  bool operator<(const TBool& Bool) const {//return Val<Bool.Val;
999  return (Val==false)&&(Bool.Val==true);}
1000  bool operator()() const {return Val;}
1001  int GetMemUsed() const {return sizeof(TBool);}
1002 
1003  int GetPrimHashCd() const {return Val;}
1004  int GetSecHashCd() const {return Val;}
1005 
1006  static bool GetRnd(){return Rnd.GetUniDevInt(2)==1;}
1007 
1008  static TStr GetStr(const bool& Val){
1009  if (Val){return TrueStr;} else {return FalseStr;}}
1010  static TStr GetStr(const TBool& Bool){
1011  return GetStr(Bool.Val);}
1012  static TStr GetYNStr(const bool& Val){
1013  if (Val){return YStr;} else {return NStr;}}
1014  static TStr GetYesNoStr(const bool& Val){
1015  if (Val){return YesStr;} else {return NoStr;}}
1016  static TStr Get01Str(const bool& Val){
1017  if (Val){return "1";} else {return "0";}}
1018  static bool IsValStr(const TStr& Str);
1019  static bool GetValFromStr(const TStr& Str);
1020  static bool GetValFromStr(const TStr& Str, const bool& DfVal);
1021 };
1022 
1024 // Char
1025 class TCh{
1026 public:
1027  char Val;
1028 public:
1029  static const char Mn;
1030  static const char Mx;
1031  static const int Vals;
1032 
1033  static const char NullCh;
1034  static const char TabCh;
1035  static const char LfCh;
1036  static const char CrCh;
1037  static const char EofCh;
1038  static const char HashCh;
1039 
1041  TCh(const char& _Val): Val(_Val){}
1042  operator char() const {return Val;}
1043  explicit TCh(TSIn& SIn){SIn.Load(Val);}
1044  void Load(TSIn& SIn) {SIn.Load(Val);}
1045  void Save(TSOut& SOut) const {SOut.Save(Val);}
1046  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1047  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1048 
1049  TCh& operator=(const TCh& Ch){Val=Ch.Val; return *this;}
1050  bool operator==(const TCh& Ch) const {return Val==Ch.Val;}
1051  bool operator<(const TCh& Ch) const {return Val<Ch.Val;}
1052  char operator()() const {return Val;}
1053  int GetMemUsed() const {return sizeof(TCh);}
1054 
1055  int GetPrimHashCd() const {return Val;}
1056  int GetSecHashCd() const {return Val;}
1057 
1058  static bool IsHashCh(const char& Ch){
1059  return (Ch==HashCh);}
1060  static bool IsWs(const char& Ch){
1061  return (Ch==' ')||(Ch==TabCh)||(Ch==CrCh)||(Ch==LfCh);}
1062  static bool IsAlpha(const char& Ch){
1063  return (('A'<=Ch)&&(Ch<='Z'))||(('a'<=Ch)&&(Ch<='z'));}
1064  static bool IsNum(const char& Ch){return ('0'<=Ch)&&(Ch<='9');}
1065  static bool IsAlNum(const char& Ch){return IsAlpha(Ch)||IsNum(Ch);}
1066  static int GetNum(const char& Ch){Assert(IsNum(Ch)); return Ch-'0';}
1067  static bool IsHex(const char& Ch){return
1068  (('0'<=Ch)&&(Ch<='9'))||(('A'<=Ch)&&(Ch<='F'))||(('a'<=Ch)&&(Ch<='f'));}
1069  static int GetHex(const char& Ch){
1070  if (('0'<=Ch)&&(Ch<='9')){return Ch-'0';}
1071  else if (('A'<=Ch)&&(Ch<='F')){return Ch-'A'+10;}
1072  else if (('a'<=Ch)&&(Ch<='f')){return Ch-'a'+10;}
1073  else Fail; return 0;}
1074  static char GetHexCh(const int& Val){
1075  if ((0<=Val)&&(Val<=9)){return char('0'+char(Val));}
1076  else if ((10<=Val)&&(Val<=15)){return char('A'+char(Val-10));}
1077  else Fail; return 0;}
1078  static char IsUc(const char& Ch){
1079  return ('A'<=Ch)&&(Ch<='Z');}
1080  static char GetUc(const char& Ch){
1081  if (('a'<=Ch)&&(Ch<='z')){return Ch-'a'+'A';} else {return Ch;}}
1082  static char GetUsFromYuAscii(const char& Ch);
1083 
1084  static TStr GetStr(const TCh& Ch){
1085  return TStr(Ch.Val);}
1086 };
1087 
1089 // Unsigned-Char
1090 class TUCh{
1091 public:
1093 public:
1094  static const uchar Mn;
1095  static const uchar Mx;
1096  static const int Vals;
1097 
1098  TUCh(): Val(TCh::NullCh){}
1099  TUCh(const uchar& _Val): Val(_Val){}
1100  operator uchar() const {return Val;}
1101  explicit TUCh(TSIn& SIn){SIn.Load(Val);}
1102  void Save(TSOut& SOut) const {SOut.Save(Val);}
1103  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1104  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1105 
1106  TUCh& operator=(const TUCh& UCh){Val=UCh.Val; return *this;}
1107  bool operator==(const TUCh& UCh) const {return Val==UCh.Val;}
1108  bool operator<(const TUCh& UCh) const {return Val<UCh.Val;}
1109  uchar operator()() const {return Val;}
1110  int GetMemUsed() const {return sizeof(TUCh);}
1111 
1112  int GetPrimHashCd() const {return Val;}
1113  int GetSecHashCd() const {return Val;}
1114 };
1115 
1117 // Short-Integer
1118 class TSInt{
1119 public:
1121 public:
1122  TSInt(): Val(0){}
1123  TSInt(const int16& _Val): Val(_Val){}
1124  operator int16() const {return Val;}
1125  explicit TSInt(TSIn& SIn){SIn.Load(Val);}
1126  void Load(TSIn& SIn){SIn.Load(Val);}
1127  void Save(TSOut& SOut) const {SOut.Save(Val);}
1128  int GetPrimHashCd() const {return Val;}
1129  int GetSecHashCd() const {return Val/0x10;}
1130 };
1131 
1133 // Integer
1134 class TInt{
1135 public:
1136  int Val;
1137 public:
1138  static const int Mn;
1139  static const int Mx;
1140  static const int Kilo;
1141  static const int Mega;
1142  static const int Giga;
1143  static TRnd Rnd;
1144 
1145  TInt(): Val(0){}
1146  TInt(const int& _Val): Val(_Val){}
1147  operator int() const {return Val;}
1148  explicit TInt(TSIn& SIn){SIn.Load(Val);}
1149  void Load(TSIn& SIn){SIn.Load(Val);}
1150  void Save(TSOut& SOut) const {SOut.Save(Val);}
1151  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1152  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1153 
1154  TInt& operator=(const TInt& Int){Val=Int.Val; return *this;}
1155  TInt& operator=(const int& Int){Val=Int; return *this;}
1156  bool operator==(const TInt& Int) const {return Val==Int.Val;}
1157  bool operator==(const int& Int) const {return Val==Int;}
1158  bool operator!=(const int& Int) const {return Val!=Int;}
1159  bool operator<(const TInt& Int) const {return Val<Int.Val;}
1160  bool operator<(const int& Int) const {return Val<Int;}
1161  int operator()() const {return Val;}
1162  TInt& operator+=(const int& Int){Val+=Int; return *this;}
1163  TInt& operator-=(const int& Int){Val-=Int; return *this;}
1164  TInt operator++(int){Val++; return *this;}
1165  TInt operator--(int){Val--; return *this;}
1166  int GetMemUsed() const {return sizeof(TInt);}
1167 
1168  int GetPrimHashCd() const {return Val;}
1169  int GetSecHashCd() const {return Val/0x10;}
1170 
1171  static int Abs(const int& Int){return Int<0?-Int:Int;}
1172  static int Sign(const int& Int){return Int<0?-1:(Int>0?1:0);}
1173  static void Swap(int& Int1, int& Int2){
1174  int SwapInt1=Int1; Int1=Int2; Int2=SwapInt1;}
1175  static int GetRnd(const int& Range=0){return Rnd.GetUniDevInt(Range);}
1176 
1177  static bool IsOdd(const int& Int){return ((Int%2)==1);}
1178  static bool IsEven(const int& Int){return ((Int%2)==0);}
1179 
1180  static int GetMn(const int& Int1, const int& Int2){
1181  return Int1<Int2?Int1:Int2;}
1182  static int GetMx(const int& Int1, const int& Int2){
1183  return Int1>Int2?Int1:Int2;}
1184  static int GetMn(const int& Int1, const int& Int2, const int& Int3){
1185  return GetMn(Int1, GetMn(Int2, Int3));}
1186  static int GetMn(const int& Int1, const int& Int2,
1187  const int& Int3, const int& Int4){
1188  return GetMn(GetMn(Int1, Int2), GetMn(Int3, Int4));}
1189  static int GetMx(const int& Int1, const int& Int2, const int& Int3){
1190  return GetMx(Int1, GetMx(Int2, Int3));}
1191  static int GetMx(const int& Int1, const int& Int2,
1192  const int& Int3, const int& Int4){
1193  return GetMx(GetMx(Int1, Int2), GetMx(Int3, Int4));}
1194  static int GetInRng(const int& Val, const int& Mn, const int& Mx){
1195  IAssert(Mn<=Mx); return Val<Mn?Mn:(Val>Mx?Mx:Val);}
1196 
1197  TStr GetStr() const {return TInt::GetStr(Val);}
1198 
1199  static TStr GetStr(const int& Val){ return TStr::Fmt("%d", Val); }
1200  static TStr GetStr(const TInt& Int){ return GetStr(Int.Val);}
1201  static TStr GetStr(const int& Val, const char* FmtStr);
1202  static TStr GetStr(const int& Val, const TStr& FmtStr){ return GetStr(Val, FmtStr.CStr());}
1203 
1204  //J: So that TInt can convert any kind of integer to a string
1205  static TStr GetStr(const uint& Val){ return TStr::Fmt("%u", Val); }
1206  #ifdef GLib_WIN
1207  static TStr GetStr(const int64& Val) {return TStr::Fmt("%I64d", Val);}
1208  static TStr GetStr(const uint64& Val) {return TStr::Fmt("%I64u", Val);}
1209  #else
1210  static TStr GetStr(const int64& Val) {return TStr::Fmt("%lld", Val);}
1211  static TStr GetStr(const uint64& Val) {return TStr::Fmt("%llu", Val);}
1212  #endif
1213 
1214  static TStr GetHexStr(const int& Val){
1215  char Bf[255]; sprintf(Bf, "%X", Val); return TStr(Bf);}
1216  static TStr GetHexStr(const TInt& Int){
1217  return GetHexStr(Int.Val);}
1218 
1219  static TStr GetKiloStr(const int& Val){
1220  if (Val>=100*1000){return GetStr(Val/1000)+"K";}
1221  else if (Val>=1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";}
1222  else {return GetStr(Val);}}
1223  static TStr GetMegaStr(const int& Val){
1224  if (Val>=100*1000000){return GetStr(Val/1000000)+"M";}
1225  else if (Val>=1000000){
1226  return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";}
1227  else {return GetKiloStr(Val);}}
1228 
1229  // frugal
1230  static char* SaveFrugalInt(char *pDest, int i);
1231  static char* LoadFrugalInt(char *pSrc, int& i);
1232  static void TestFrugalInt();
1233  static void SaveFrugalIntV(TSOut& SOut, const TVec<TInt, int>& IntV);
1234  static void LoadFrugalIntV(TSIn& SIn, TVec<TInt, int>& IntV, bool ClrP=true);
1235 };
1236 
1238 // Unsigned-Integer
1239 class TUInt{
1240 public:
1242 public:
1243  static const uint Mn;
1244  static const uint Mx;
1245  static TRnd Rnd;
1246 
1247  TUInt(): Val(0){}
1248  TUInt(const uint& _Val): Val(_Val){}
1249  operator uint() const {return Val;}
1250  explicit TUInt(TSIn& SIn){SIn.Load(Val);}
1251  void Load(TSIn& SIn){SIn.Load(Val);}
1252  void Save(TSOut& SOut) const {SOut.Save(Val);}
1253  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1254  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1255 
1256  TUInt& operator=(const TUInt& UInt){Val=UInt.Val; return *this;}
1257  TUInt& operator=(const uint& _Val){Val=_Val; return *this;}
1258  TUInt operator++(int){Val++; return *this;}
1259  TUInt operator--(int){Val--; return *this;}
1260  //bool operator==(const TUInt& UInt) const {return Val==UInt.Val;}
1261  //bool operator==(const uint& UInt) const {return Val==UInt;}
1262  //bool operator!=(const uint& UInt) const {return Val!=UInt;}
1263  //bool operator<(const TUInt& UInt) const {return Val<UInt.Val;}
1264  uint operator()() const {return Val;}
1265  uint& operator()() {return Val;}
1266  TUInt& operator~(){Val=~Val; return *this;}
1267  TUInt& operator&=(const TUInt& UInt){Val&=UInt.Val; return *this;}
1268  TUInt& operator|=(const TUInt& UInt){Val|=UInt.Val; return *this;}
1269  TUInt& operator^=(const TUInt& UInt){Val^=UInt.Val; return *this;}
1270  TUInt& operator>>=(const int& ShiftBits){Val>>=ShiftBits; return *this;}
1271  TUInt& operator<<=(const int& ShiftBits){Val<<=ShiftBits; return *this;}
1272  int GetMemUsed() const {return sizeof(TUInt);}
1273 
1274  int GetPrimHashCd() const {return int(Val);}
1275  int GetSecHashCd() const {return Val/0x10;}
1276 
1277  static uint GetRnd(const uint& Range=0){return Rnd.GetUniDevUInt(Range);}
1278 
1279  TStr GetStr() const {return TUInt::GetStr(Val);}
1280  static TStr GetStr(const uint& Val){
1281  char Bf[255]; sprintf(Bf, "%u", Val); return TStr(Bf);}
1282  static TStr GetStr(const TUInt& UInt){
1283  return GetStr(UInt.Val);}
1284  static TStr GetStr(const uint& Val, const char* FmtStr);
1285  static TStr GetStr(const uint& Val, const TStr& FmtStr){
1286  return GetStr(Val, FmtStr.CStr());}
1287 
1288  static TStr GetKiloStr(const uint& Val){
1289  if (Val>100*1000){return GetStr(Val/1000)+"K";}
1290  else if (Val>1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";}
1291  else {return GetStr(Val);}}
1292  static TStr GetMegaStr(const uint& Val){
1293  if (Val>100*1000000){return GetStr(Val/1000000)+"M";}
1294  else if (Val>1000000){
1295  return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";}
1296  else {return GetKiloStr(Val);}}
1297 
1298  static uint JavaUIntToCppUInt(const uint& JavaUInt){
1299  uint B1=(JavaUInt & 0xFF000000) >> 24;
1300  uint B2=(JavaUInt & 0x00FF0000) >> 16;
1301  uint B3=(JavaUInt & 0x0000FF00) >> 8;
1302  uint B4=(JavaUInt & 0x000000FF) >> 0;
1303  uint CppUInt=(B4<<24)+(B3<<16)+(B2<<8)+(B1<<0);
1304  return CppUInt;}
1305 
1306  static bool IsIpStr(const TStr& IpStr, uint& Ip, const char& SplitCh = '.');
1307  static bool IsIpStr(const TStr& IpStr, const char& SplitCh = '.') { uint Ip; return IsIpStr(IpStr, Ip, SplitCh); }
1308  static uint GetUIntFromIpStr(const TStr& IpStr, const char& SplitCh = '.');
1309  static TStr GetStrFromIpUInt(const uint& Ip);
1310  static bool IsIpv6Str(const TStr& IpStr, const char& SplitCh = ':');
1311 };
1312 
1314 // Unsigned-Integer-64Bit
1315 class TUInt64{
1316 public:
1318 public:
1319  static const TUInt64 Mn;
1320  static const TUInt64 Mx;
1321 
1322  TUInt64(): Val(0){}
1323  TUInt64(const TUInt64& Int): Val(Int.Val){}
1324  TUInt64(const uint64& Int): Val(Int){}
1325  TUInt64(const uint& MsVal, const uint& LsVal): Val(0){
1326  Val=(((uint64)MsVal) << 32) | ((uint64)LsVal);}
1327  explicit TUInt64(void* Pt): Val(0){
1328  TConv_Pt64Ints32 Conv(Pt); Val=Conv.GetUInt64();}
1329  operator uint64() const {return Val;}
1330  explicit TUInt64(TSIn& SIn){SIn.Load(Val);}
1331  void Load(TSIn& SIn){SIn.Load(Val);}
1332  void Save(TSOut& SOut) const {SOut.Save(Val);}
1333  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1334  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1335 
1336  TUInt64& operator=(const TUInt64& Int){Val=Int.Val; return *this;}
1337  TUInt64& operator+=(const TUInt64& Int){Val+=Int.Val; return *this;}
1338  TUInt64& operator-=(const TUInt64& Int){Val-=Int.Val; return *this;}
1339  TUInt64& operator*=(const TUInt64& Int){Val*=Int.Val; return *this;}
1340  TUInt64 operator++(int){Val++; return *this;}
1341  TUInt64 operator--(int){Val--; return *this;}
1342  int GetMemUsed() const {return sizeof(TUInt64);}
1343 
1344  int GetPrimHashCd() const { return (int)GetMsVal() + (int)GetLsVal(); } //TODO: to check
1345  int GetSecHashCd() const { return ((int)GetMsVal() + (int)GetLsVal()) / 0x10; } //TODO: to check
1346 
1347  uint GetMsVal() const {
1348  return (uint)(Val >> 32);}
1349  uint GetLsVal() const {
1350  return (uint)(Val & 0xffffffff);}
1351 
1352  //TStr GetStr() const {return TStr::Fmt("%Lu", Val);}
1353  //static TStr GetStr(const TUInt64& Int){return TStr::Fmt("%Lu", Int.Val);}
1354  //static TStr GetHexStr(const TUInt64& Int){return TStr::Fmt("%LX", Int.Val);}
1355  #ifdef GLib_WIN
1356  TStr GetStr() const {return TStr::Fmt("%I64u", Val);}
1357  static TStr GetStr(const TUInt64& Int){return TStr::Fmt("%I64u", Int.Val);}
1358  static TStr GetHexStr(const TUInt64& Int){return TStr::Fmt("%I64X", Int.Val);}
1359  #else
1360  TStr GetStr() const {return TStr::Fmt("%llu", Val);}
1361  static TStr GetStr(const TUInt64& Int){return TStr::Fmt("%llu", Int.Val);}
1362  static TStr GetHexStr(const TUInt64& Int){return TStr::Fmt("%llX", Int.Val);}
1363  #endif
1364 
1365  static TStr GetKiloStr(const uint64& Val){
1366  if (Val>100*1000){return GetStr(Val/1000)+"K";}
1367  else if (Val>1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";}
1368  else {return GetStr(Val);}}
1369  static TStr GetMegaStr(const uint64& Val){
1370  if (Val>100*1000000){return GetStr(Val/1000000)+"M";}
1371  else if (Val>1000000){
1372  return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";}
1373  else {return GetKiloStr(Val);}}
1374  /*static TStr GetGigaStr(const uint64& Val){
1375  if (Val>100*1000000000){return GetStr(Val/1000000000)+"G";}
1376  else if (Val>1000000000){
1377  return GetStr(Val/1000000000)+"."+GetStr((Val%1000000000)/100000000)+"G";}
1378  else {return GetMegaStr(Val);}}*/
1379 };
1380 
1382 // Float
1383 class TFlt{
1384 public:
1385  double Val;
1386 public:
1387  static const double Mn;
1388  static const double Mx;
1389  static const double NInf;
1390  static const double PInf;
1391  static const double Eps;
1392  static const double EpsHalf;
1393  static TRnd Rnd;
1394 
1395  TFlt(): Val(0){}
1396  TFlt(const double& _Val): Val(_Val){}
1397  operator double() const {return Val;}
1398  explicit TFlt(TSIn& SIn){SIn.Load(Val);}
1399  void Save(TSOut& SOut) const {SOut.Save(Val);}
1400  explicit TFlt(TSIn& SIn, const bool& IsTxt){
1401  if (IsTxt){TStr Str(SIn, true); Val=Str.GetFlt(0);} else {SIn.Load(Val);}}
1402  void Load(TSIn& SIn){SIn.Load(Val);}
1403  void Save(TSOut& SOut, const bool& IsTxt) const {
1404  if (IsTxt){GetStr(Val).Save(SOut, true);} else {SOut.Save(Val);}}
1405  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1406  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1407 
1408  TFlt& operator=(const TFlt& Flt){Val=Flt.Val; return *this;}
1409  TFlt& operator=(const double& Flt){Val=Flt; return *this;}
1410  bool operator==(const TFlt& Flt) const _CMPWARN {return Val==Flt.Val;}
1411  bool operator==(const double& Flt) const _CMPWARN {return Val==Flt;}
1412  bool operator!=(const double& Flt) const _CMPWARN {return Val!=Flt;}
1413  double operator()() const {return Val;}
1414  TFlt& operator+=(const double& Flt){Val+=Flt; return *this;}
1415  TFlt& operator-=(const double& Flt){Val-=Flt; return *this;}
1416  TFlt& operator*=(const double& Flt){Val*=Flt; return *this;}
1417  TFlt& operator/=(const double& Flt){Val/=Flt; return *this;}
1418  TFlt operator++(int){Val++; return *this;}
1419  TFlt operator--(int){Val--; return *this;}
1420  int GetMemUsed() const {return sizeof(TFlt);}
1421 
1422  int GetPrimHashCd() const {
1423  int Expn; return int((frexp(Val, &Expn)-0.5)*double(TInt::Mx));}
1424  int GetSecHashCd() const {
1425  int Expn; frexp(Val, &Expn); return Expn;}
1426 
1427  static double Abs(const double& Flt){return Flt<0?-Flt:Flt;}
1428  static int Sign(const double& Flt){return Flt<0?-1:(Flt>0?1:0);}
1429  static int Round(const double& Flt){return int(floor(Flt+0.5));}
1430  static double GetRnd(){return Rnd.GetUniDev();}
1431  static bool Eq6(const double& LFlt, const double& RFlt){
1432  return fabs(LFlt-RFlt)<0.000001;}
1433 
1434  static double GetMn(const double& Flt1, const double& Flt2){
1435  return Flt1<Flt2?Flt1:Flt2;}
1436  static double GetMn(const double& Flt1, const double& Flt2, const double& Flt3){
1437  return GetMn(GetMn(Flt1, Flt2), Flt3); }
1438  static double GetMn(const double& Flt1, const double& Flt2, const double& Flt3, const double& Flt4){
1439  return GetMn(GetMn(Flt1, Flt2), GetMn(Flt3, Flt4)); }
1440 
1441  static double GetMx(const double& Flt1, const double& Flt2){
1442  return Flt1>Flt2?Flt1:Flt2;}
1443  static double GetMx(const double& Flt1, const double& Flt2, const double Flt3){
1444  return GetMx(GetMx(Flt1, Flt2), Flt3); }
1445  static double GetMx(const double& Flt1, const double& Flt2, const double Flt3, const double& Flt4){
1446  return GetMx(GetMx(Flt1, Flt2), GetMx(Flt3, Flt4)); }
1447 
1448  static double GetInRng(const double& Val, const double& Mn, const double& Mx){
1449  IAssert(Mn<=Mx); return Val<Mn?Mn:(Val>Mx?Mx:Val);}
1450 
1451  static bool IsNum(const double& Val){
1452  return (Mn<=Val)&&(Val<=Mx);}
1453  static bool IsNan(const double& Val){
1454  return (Val!=Val);}
1455 
1456  bool IsNum() const { return IsNum(Val); }
1457  bool IsNan() const { return IsNan(Val); }
1458 
1459  TStr GetStr() const {return TFlt::GetStr(Val);}
1460  static TStr GetStr(const double& Val, const int& Width=-1, const int& Prec=-1);
1461  static TStr GetStr(const TFlt& Flt, const int& Width=-1, const int& Prec=-1){
1462  return GetStr(Flt.Val, Width, Prec);}
1463  static TStr GetStr(const double& Val, const char* FmtStr);
1464  static TStr GetStr(const double& Val, const TStr& FmtStr){
1465  return GetStr(Val, FmtStr.CStr());}
1466  static TStr GetPrcStr(const double& RelVal, const double& FullVal){
1467  return GetStr(100*RelVal/FullVal, "%3.0f%%");}
1468 
1469  static TStr GetKiloStr(const double& Val){
1470  if (fabs(Val)>100*1000){return TStr::Fmt("%.0fK", Val/1000);}
1471  else if (fabs(Val)>1000){return TStr::Fmt("%.1fK", Val/1000);}
1472  else {return TStr::Fmt("%.0f", Val);}}
1473  static TStr GetMegaStr(const double& Val){
1474  if (fabs(Val)>100*1000000){return TStr::Fmt("%.0fM", Val/1000000);}
1475  else if (fabs(Val)>1000000){return TStr::Fmt("%.1fM", Val/1000000);}
1476  else {return GetKiloStr(Val);}}
1477  static TStr GetGigaStr(const double& Val){
1478  if (fabs(Val)>100*1000000000.0){return TStr::Fmt("%.0fG", Val/1000000000.0);}
1479  else if (fabs(Val)>1000000000.0){return TStr::Fmt("%.1fG", Val/1000000000.0);}
1480  else {return GetMegaStr(Val);}}
1481 };
1482 
1484 // Ascii-Float
1485 class TAscFlt: public TFlt{
1486 public:
1487  TAscFlt(): TFlt(){}
1488  TAscFlt(const double& Val): TFlt(Val){}
1489  explicit TAscFlt(TSIn& SIn): TFlt(SIn, true){}
1490  void Save(TSOut& SOut) const {TFlt::Save(SOut, true);}
1491 };
1492 
1494 // Short-Float
1495 class TSFlt{
1496 public:
1498 public:
1499  static const sdouble Mn;
1500  static const sdouble Mx;
1501 
1502  TSFlt(): Val(0){}
1503  TSFlt(const sdouble& _Val): Val(sdouble(_Val)){}
1504  //TSFlt(const double& _Val): Val(sdouble(_Val)){}
1505  operator sdouble() const {return Val;}
1506  //operator double() const {return Val;}
1507  explicit TSFlt(TSIn& SIn){SIn.Load(Val);}
1508  void Save(TSOut& SOut) const {SOut.Save(Val);}
1509  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1510  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1511 
1512  TSFlt& operator=(const TSFlt& SFlt){Val=SFlt.Val; return *this;}
1513  bool operator==(const TSFlt& SFlt) const _CMPWARN {return Val==SFlt.Val;}
1514  bool operator==(const double& Flt) const _CMPWARN {return Val==Flt;}
1515  bool operator!=(const double& Flt) const _CMPWARN {return Val!=Flt;}
1516  bool operator<(const TSFlt& SFlt) const {return Val<SFlt.Val;}
1517  sdouble operator()() const {return Val;}
1518  TSFlt& operator+=(const double& SFlt){Val+=sdouble(SFlt); return *this;}
1519  TSFlt& operator-=(const double& SFlt){Val-=sdouble(SFlt); return *this;}
1520  TSFlt& operator*=(const double& SFlt){Val*=sdouble(SFlt); return *this;}
1521  TSFlt& operator/=(const double& SFlt){Val/=sdouble(SFlt); return *this;}
1522  TSFlt operator++(int){Val++; return *this;}
1523  TSFlt operator--(int){Val--; return *this;}
1524  int GetMemUsed() const {return sizeof(TSFlt);}
1525 
1526  int GetPrimHashCd() const {
1527  int Expn; return int((frexp(Val, &Expn)-0.5)*double(TInt::Mx));}
1528  int GetSecHashCd() const {
1529  int Expn; frexp(Val, &Expn); return Expn;}
1530 };
1531 
1533 // Long-Float
1534 class TLFlt{
1535 public:
1537 public:
1538  static const ldouble Mn;
1539  static const ldouble Mx;
1540 
1541  TLFlt(): Val(0){}
1542  TLFlt(const ldouble& _Val): Val(_Val){}
1543  operator ldouble() const {return Val;}
1544  explicit TLFlt(TSIn& SIn){SIn.Load(Val);}
1545  void Save(TSOut& SOut) const {SOut.Save(Val);}
1546  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1547  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1548 
1549  TLFlt& operator=(const TLFlt& LFlt){Val=LFlt.Val; return *this;}
1550  bool operator==(const TLFlt& LFlt) const _CMPWARN {return Val==LFlt.Val;}
1551  bool operator==(const ldouble& LFlt) const _CMPWARN {return Val==LFlt;}
1552  bool operator!=(const ldouble& LFlt) const _CMPWARN {return Val!=LFlt;}
1553  bool operator<(const TLFlt& LFlt) const {return Val<LFlt.Val;}
1554  ldouble operator()() const {return Val;}
1555  TLFlt& operator+=(const ldouble& LFlt){Val+=LFlt; return *this;}
1556  TLFlt& operator-=(const ldouble& LFlt){Val-=LFlt; return *this;}
1557  int GetMemUsed() const {return sizeof(TLFlt);}
1558 
1559  int GetPrimHashCd() const {Fail; return 0;}
1560  int GetSecHashCd() const {Fail; return 0;}
1561 
1562  static TStr GetStr(const ldouble& Val, const int& Width=-1, const int& Prec=-1);
1563  static TStr GetStr(const TLFlt& LFlt, const int& Width=-1, const int& Prec=-1){
1564  return GetStr(LFlt.Val, Width, Prec);}
1565  static TStr GetStr(const ldouble& Val, const char* FmtStr);
1566  static TStr GetStr(const ldouble& Val, const TStr& FmtStr){
1567  return GetStr(Val, FmtStr.CStr());}
1568 };
1569 
1571 // Float-Rectangle
1572 class TFltRect{
1573 public:
1575 public:
1577  MnX(), MnY(), MxX(), MxY(){}
1578  TFltRect(const TFltRect& FltRect):
1579  MnX(FltRect.MnX), MnY(FltRect.MnY), MxX(FltRect.MxX), MxY(FltRect.MxY){}
1581  const double& _MnX, const double& _MnY,
1582  const double& _MxX, const double& _MxY):
1583  MnX(_MnX), MnY(_MnY), MxX(_MxX), MxY(_MxY){}
1585  MnX(SIn), MnY(SIn), MxX(SIn), MxY(SIn){}
1586  void Save(TSOut& SOut) const {
1587  MnX.Save(SOut); MnY.Save(SOut); MxX.Save(SOut); MxY.Save(SOut);}
1588  void LoadXml(const PXmlTok& XmlTok, const TStr& Nm);
1589  void SaveXml(TSOut& SOut, const TStr& Nm) const;
1590 
1591  TFltRect& operator=(const TFltRect& FltRect){
1592  MnX=FltRect.MnX; MnY=FltRect.MnY; MxX=FltRect.MxX; MxY=FltRect.MxY;
1593  return *this;}
1594 
1595  // get coordinates
1596  double GetMnX() const {return MnX;}
1597  double GetMnY() const {return MnY;}
1598  double GetMxX() const {return MxX;}
1599  double GetMxY() const {return MxY;}
1600 
1601  // get lengths
1602  double GetXLen() const {return MxX-MnX;}
1603  double GetYLen() const {return MxY-MnY;}
1604 
1605  // get centers
1606  double GetXCenter() const {return MnX+(MxX-MnX)/2;}
1607  double GetYCenter() const {return MnY+(MxY-MnY)/2;}
1608 
1609  // tests
1610  bool IsXYIn(const double& X, const double& Y) const {
1611  return (MnX<=X)&&(X<=MxX)&&(MnY<=Y)&&(Y<=MxY);}
1612  static bool Intersection(const TFltRect& Rect1, const TFltRect& Rect2);
1613 
1614  // string
1615  TStr GetStr() const;
1616 };
1617 
TSFlt & operator/=(const double &SFlt)
Definition: dt.h:1521
#define IAssert(Cond)
Definition: bd.h:262
TChAIn & operator=(const TChAIn &)
int GetPrimHashCd() const
Definition: dt.h:1168
static int CmpI(const char *CStr1, const char *CStr2)
Definition: dt.cpp:699
bool operator==(const double &Flt) const _CMPWARN
Definition: dt.h:1411
static bool IsHex(const char &Ch)
Definition: dt.h:1067
int GetInt() const
Definition: dt.h:578
Definition: bd.h:514
char * GetCStr() const
Definition: dt.h:685
bool IsUInt() const
Definition: dt.h:585
bool operator==(const TDbStr &DbStr) const
Definition: dt.h:736
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:1258
TStr(const char &Ch, bool)
Definition: dt.h:416
TFlt & operator*=(const double &Flt)
Definition: dt.h:1416
void Save(TSOut &SOut) const
Definition: dt.h:1490
int SearchCh(const char &Ch, const int &BChN=0) const
Definition: dt.cpp:1043
static TStr GetHexStr(const int &Val)
Definition: dt.h:1214
TStr GetFromHex() const
Definition: dt.h:514
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:1389
ldouble operator()() const
Definition: dt.h:1554
TMemOut(const PMem &_Mem)
Definition: dt.cpp:334
TUInt()
Definition: dt.h:1247
static TStr GetPrcStr(const double &RelVal, const double &FullVal)
Definition: dt.h:1466
void Randomize()
Definition: dt.h:60
TStr GetSubStr(const int &BChN) const
Definition: dt.h:517
char GetCh()
Definition: dt.h:173
TLFlt & operator=(const TLFlt &LFlt)
Definition: dt.h:1549
TUInt64 operator--(int)
Definition: dt.h:1341
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:1445
static PMem New(const PMem &Mem)
Definition: dt.h:96
static const uint Mn
Definition: dt.h:1243
TStr GetStr() const
Definition: dt.h:1197
#define IAssertR(Cond, Reason)
Definition: bd.h:265
static const int Kilo
Definition: dt.h:1140
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:1056
bool IsInt64() const
Definition: dt.h:593
TLFlt(const ldouble &_Val)
Definition: dt.h:1542
TStr(const TChA &ChA)
Definition: dt.h:425
TSFlt(TSIn &SIn)
Definition: dt.h:1507
TNum operator--(Base)
Definition: dt.h:881
uint GetLsVal() const
Definition: dt.h:1349
static PSOut New(const TStr &FNm, const bool &Append=false)
Definition: fl.cpp:442
static uint JavaUIntToCppUInt(const uint &JavaUInt)
Definition: dt.h:1298
int Len() const
Definition: dt.h:487
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
bool Eof()
Definition: dt.h:335
int GetMemUsed() const
Definition: dt.h:884
void Resize(const int &_MxBfL)
Definition: dt.cpp:348
void Reset()
Definition: dt.h:176
static TStr GetHexStr(const TUInt64 &Int)
Definition: dt.h:1362
void Save(TSOut &SOut) const
Definition: dt.h:732
int GetPrimHashCd() const
Definition: dt.h:1055
TStr Right(const int &BChN) const
Definition: dt.h:545
TNum & operator=(const TNum &Int)
Definition: dt.h:905
TRStr()
Definition: dt.h:351
bool operator!=(const char *_CStr) const
Definition: dt.h:236
TUCh(TSIn &SIn)
Definition: dt.h:1101
static TStr GetMegaStr(const int &Val)
Definition: dt.h:1223
void Save(TSOut &SOut) const
Definition: dt.h:1586
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:617
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:1597
static TStr GetStr(const uint64 &Val)
Definition: dt.h:1211
static int GetInRng(const int &Val, const int &Mn, const int &Mx)
Definition: dt.h:1194
int GetNextSeed()
Definition: dt.h:17
static TStr GetKiloStr(const uint64 &Val)
Definition: dt.h:1365
static bool IsNum(const char &Ch)
Definition: dt.h:1064
int BfC
Definition: dt.h:701
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:1572
TSInt(TSIn &SIn)
Definition: dt.h:1125
static const sdouble Mn
Definition: dt.h:1499
static PStrPool Load(TSIn &SIn, bool LoadCompacted=true)
Definition: dt.h:794
bool IsFlt() const
Definition: dt.h:627
static TStr GetStr(const int &Val, const TStr &FmtStr)
Definition: dt.h:1202
TSFlt & operator-=(const double &SFlt)
Definition: dt.h:1519
static const TStr NoStr
Definition: dt.h:984
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:1186
TStr GetFPath() const
Definition: dt.cpp:1389
TFltRect & operator=(const TFltRect &FltRect)
Definition: dt.h:1591
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:618
int Val
Definition: dt.h:1136
sdouble Val
Definition: dt.h:1497
static const uint Mx
Definition: dt.h:1244
static TRnd Rnd
Definition: dt.h:978
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:1417
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:1833
void Save(TSOut &SOut) const
Definition: dt.h:1150
bool IsFlt(double &Val) const
Definition: dt.h:626
static double GetMx(const double &Flt1, const double &Flt2)
Definition: dt.h:1441
bool operator!=(const char *CStr) const
Definition: dt.h:467
TDbStr(const TStr &_Str1, const TStr &_Str2)
Definition: dt.h:730
void FlushBf()
bool IsLc() const
Definition: dt.h:497
int Len() const
Definition: dt.h:134
TUCh(const uchar &_Val)
Definition: dt.h:1099
unsigned int uint
Definition: bd.h:11
TNum< int64 > TInt64
Definition: dt.h:889
bool IsXYIn(const double &X, const double &Y) const
Definition: dt.h:1610
TMem & operator=(const TMem &Mem)
Definition: dt.h:108
bool IsHexInt() const
Definition: dt.h:610
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:1464
static TStr GetStr(const TUInt64 &Int)
Definition: dt.h:1361
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1182
TUInt64(const TUInt64 &Int)
Definition: dt.h:1323
Base & operator()()
Definition: dt.h:882
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:1139
TRnd(TSIn &SIn)
Definition: dt.h:22
#define Fail
Definition: bd.h:238
bool operator!=(const double &Flt) const _CMPWARN
Definition: dt.h:1515
bool EqI(const TStr &Str) const
Definition: dt.h:495
TStr(const TStr &Str)
Definition: dt.h:424
bool operator!=(const ldouble &LFlt) const _CMPWARN
Definition: dt.h:1552
void ToCap()
Definition: dt.cpp:685
const char * GetCStr(const uint &Offset) const
Definition: dt.h:811
TPt< TStrPool64 > PStrPool64
Definition: dt.h:831
int BfL
Definition: dt.h:325
TStr GetUc() const
Definition: dt.h:493
static const char NullCh
Definition: dt.h:1033
static bool IsHashCh(const char &Ch)
Definition: dt.h:1058
static char * SaveFrugalInt(char *pDest, int i)
Definition: dt.cpp:1954
TSFlt & operator*=(const double &SFlt)
Definition: dt.h:1520
void PutCh(const int &ChN, const char &Ch)
Definition: dt.h:278
static char GetHexCh(const int &Val)
Definition: dt.h:1074
TFlt(TSIn &SIn)
Definition: dt.h:1398
TStr Str2
Definition: dt.h:725
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:991
void Save(TSOut &SOut) const
Definition: dt.h:1102
double Val
Definition: dt.h:1385
TStr GetStr() const
Definition: dt.h:919
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:963
static const double EpsHalf
Definition: dt.h:1392
TUInt64 operator++(int)
Definition: dt.h:1340
TCh(const char &_Val)
Definition: dt.h:1041
bool IsPrefix(const TStr &Str) const
Definition: dt.h:556
int GetPrimHashCd() const
Definition: dt.h:1559
TFlt & operator=(const double &Flt)
Definition: dt.h:1409
static PStrPool New(const uint &_MxBfLen=0, const uint &_GrowBy=16 *1024 *1024)
Definition: dt.h:791
bool IsChIn(const char &Ch) const
Definition: dt.h:300
static bool IsNum(const double &Val)
Definition: dt.h:1451
static void SaveFrugalIntV(TSOut &SOut, const TVec< TInt, int > &IntV)
Definition: dt.cpp:2018
static TStr GetMegaStr(const double &Val)
Definition: dt.h:1473
TInt & operator-=(const int &Int)
Definition: dt.h:1163
uint Size() const
Definition: dt.h:799
int GetPrimHashCd() const
Definition: dt.h:569
TRStr(const char *CStr, const int &MxLen)
Definition: dt.h:356
static TStr GetYesNoStr(const bool &Val)
Definition: dt.h:1014
TUCh & operator=(const TUCh &UCh)
Definition: dt.h:1106
uint64 GetUniDevUInt64(const uint64 &Range=0)
Definition: dt.cpp:57
int GetMemUsed() const
Definition: dt.h:912
bool Empty() const
Definition: dt.h:748
TInt operator--(int)
Definition: dt.h:1165
void Save(TSOut &SOut) const
Definition: dt.h:1127
static const bool Mx
Definition: dt.h:976
TSFlt()
Definition: dt.h:1502
int CmpI(const TStr &Str) const
Definition: dt.h:494
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:1324
virtual int GetBf(const void *Bf, const TSize &BfL)=0
static int GetHex(const char &Ch)
Definition: dt.h:1069
double GetMxY() const
Definition: dt.h:1599
Base Val
Definition: dt.h:868
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:1414
TDbStr & operator=(const TDbStr &DbStr)
Definition: dt.h:734
static bool GetRnd()
Definition: dt.h:1006
static TStr GetNrFNm(const TStr &FNm)
Definition: dt.cpp:1467
TStr & ToHex()
Definition: dt.cpp:785
void Save(TSOut &SOut) const
Definition: dt.h:992
TUInt & operator|=(const TUInt &UInt)
Definition: dt.h:1268
int Cmp(uint64 Offset, const char *Str) const
Definition: dt.h:857
int GetSecHashCd() const
Definition: dt.h:570
int GetMemUsed() const
Definition: dt.h:1053
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:1517
static double GetMn(const double &Flt1, const double &Flt2, const double &Flt3)
Definition: dt.h:1436
bool operator==(const char &Ch) const
Definition: dt.h:234
bool operator==(const TSFlt &SFlt) const _CMPWARN
Definition: dt.h:1513
TStr & operator=(const char &Ch)
Definition: dt.h:451
bool operator==(const TInt &Int) const
Definition: dt.h:1156
int64 GetHexInt64() const
Definition: dt.h:619
TStr GetFExt() const
Definition: dt.cpp:1421
bool IsInt64(int64 &Val) const
Definition: dt.h:592
int GetSecHashCd() const
Definition: dt.h:1113
static TStr GetKiloStr(const uint &Val)
Definition: dt.h:1288
TPt< TStrPool > PStrPool
Definition: dt.h:778
TNum operator++(Base)
Definition: dt.h:880
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
TStr Str
Definition: dt.h:699
void Load(TSIn &SIn)
Definition: dt.h:1331
TNum(TSIn &SIn)
Definition: dt.h:902
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:486
TFlt MnX
Definition: dt.h:1574
uint & operator()()
Definition: dt.h:1265
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:1285
TNum & operator++()
Definition: dt.h:878
bool operator==(const TRnd &) const
Definition: dt.h:28
TNum operator--(int)
Definition: dt.h:911
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:2077
static TRnd Rnd
Definition: dt.h:1143
TStr & ToCap()
Definition: dt.cpp:764
bool operator!=(const int &Int) const
Definition: dt.h:1158
TLFlt & operator+=(const ldouble &LFlt)
Definition: dt.h:1555
TLFlt & operator-=(const ldouble &LFlt)
Definition: dt.h:1556
static TStr GetStr(const uint &Val)
Definition: dt.h:1280
static const double Mx
Definition: dt.h:1388
int ChangeChAll(const char &SrcCh, const char &DstCh)
Definition: dt.cpp:1113
double GetXCenter() const
Definition: dt.h:1606
TDbStr(const TDbStr &DbStr)
Definition: dt.h:728
int MxBfL
Definition: dt.h:203
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:2263
void Reset()
Definition: dt.h:716
Definition: dt.h:831
bool IsHexInt(int &Val) const
Definition: dt.h:609
TBool & operator=(const TBool &Bool)
Definition: dt.h:996
static PSIn New(const PMem &Mem)
Definition: dt.h:167
TAscFlt()
Definition: dt.h:1487
TCh(TSIn &SIn)
Definition: dt.h:1043
static const TStr YStr
Definition: dt.h:983
Definition: dt.h:1534
int GetSecHashCd() const
Definition: dt.h:745
static double GetMx(const double &Flt1, const double &Flt2, const double Flt3)
Definition: dt.h:1443
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:1383
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:603
static const ldouble Mn
Definition: dt.h:1538
bool operator==(const TCh &Ch) const
Definition: dt.h:1050
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:874
int GetMemUsed() const
Definition: dt.h:1342
Definition: fl.h:58
TInt & operator=(const TInt &Int)
Definition: dt.h:1154
int GetPrimHashCd() const
Definition: dt.h:1422
static const int Giga
Definition: dt.h:1142
TUInt64(TSIn &SIn)
Definition: dt.h:1330
char GetCh()
Definition: dt.h:337
Definition: dt.h:182
int GetSecHashCd() const
Definition: dt.h:1528
double GetFlt() const
Definition: dt.h:628
double GetGammaDev(const int &Order)
Definition: dt.cpp:95
char * operator()()
Definition: dt.h:253
static TStr GetStr(const TUInt &UInt)
Definition: dt.h:1282
static TStr GetMegaStr(const uint &Val)
Definition: dt.h:1292
Definition: dt.h:77
TStr GetWcMatch(const TStr &WcStr, const int &StarStrN=0) const
Definition: dt.cpp:1379
Definition: dt.h:866
TFltRect(const TFltRect &FltRect)
Definition: dt.h:1578
void SplitOnCh(TStr &LStr, const char &SplitCh, TStr &RStr) const
Definition: dt.cpp:901
TInt(TSIn &SIn)
Definition: dt.h:1148
void Optimize()
Definition: dt.cpp:729
void Save(TSOut &SOut, const bool &IsTxt) const
Definition: dt.h:1403
static const TStr FalseStr
Definition: dt.h:980
int GetPrimHashCd() const
Definition: dt.h:1112
char LastLastCh() const
Definition: dt.h:282
static const char EofCh
Definition: dt.h:1037
#define ClassTP(TNm, PNm)
Definition: bd.h:126
static const int Mega
Definition: dt.h:1141
static const char Mx
Definition: dt.h:1030
int64 GetInt64() const
Definition: dt.h:594
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:2232
static int Sign(const int &Int)
Definition: dt.h:1172
void DelLastCh()
Definition: dt.h:263
TSFlt & operator+=(const double &SFlt)
Definition: dt.h:1518
void Reverse()
Definition: dt.cpp:440
static TStr GetMegaStr(const uint64 &Val)
Definition: dt.h:1369
bool Empty() const
Definition: dt.h:800
char * Bf
Definition: dt.h:348
bool IsUInt64(uint64 &Val) const
Definition: dt.h:601
int GetSecHashCd() const
Definition: dt.h:1004
void Clr(bool DoDel=false)
Definition: dt.h:816
void Save(TSOut &SOut) const
Definition: dt.h:1252
uint GetUInt() const
Definition: dt.h:586
bool IsInt(int &Val) const
Definition: dt.h:576
TAscFlt(const double &Val)
Definition: dt.h:1488
int GetSecHashCd() const
Definition: dt.h:1560
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:778
bool Empty() const
Definition: dt.h:383
static PSIn New(const TStr &FNm)
Definition: fl.cpp:290
TDbStr(TSIn &SIn)
Definition: dt.h:731
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:713
void Load(TSIn &SIn)
Definition: dt.h:1044
static double GetMn(const double &Flt1, const double &Flt2, const double &Flt3, const double &Flt4)
Definition: dt.h:1438
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:1811
static const int Mn
Definition: dt.h:1138
TNum & operator=(const TNum &Other)
Definition: dt.h:876
uint64 GetUInt64(const uint64 &DfVal) const
Definition: dt.h:605
void Push(const char &Ch)
Definition: dt.h:138
static TStr GetKiloStr(const double &Val)
Definition: dt.h:1469
int BfL
Definition: dt.h:79
TUInt & operator<<=(const int &ShiftBits)
Definition: dt.h:1271
int SearchChBack(const char &Ch, int BChN=-1) const
Definition: dt.cpp:477
static bool IsWs(const char &Ch)
Definition: dt.h:1060
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:1003
int ChangeStrAll(const TStr &SrcStr, const TStr &DstStr, const bool &FromStartP=false)
Definition: dt.cpp:1141
int GetPrimHashCd() const
Definition: dt.h:743
int GetPrimHashCd() const
Definition: dt.h:1344
TStr GetStr(const TStr &MidStr=TStr()) const
Definition: dt.h:741
TRStr(const char *CStr)
Definition: dt.h:354
void Load(TSIn &SIn)
Definition: dt.h:903
static PStrPool LoadShM(TSIn &SIn)
Definition: dt.h:826
int GetPrimHashCd() const
Definition: dt.h:1128
int GetMemUsed() const
Definition: dt.h:1420
TUInt(const uint &_Val)
Definition: dt.h:1248
TStr(const TSStr &SStr)
Definition: dt.h:426
static const int a
Definition: dt.h:15
TStr GetUsFromYuAscii() const
Definition: dt.h:509
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:1180
Definition: dt.h:697
void Save(TSOut &SOut) const
Definition: dt.h:1508
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:1256
TMem(const void *_Bf, const int &_BfL)
Definition: dt.h:88
TInt()
Definition: dt.h:1145
int GetSecHashCd() const
Definition: dt.h:1169
void Save(TSOut &SOut, const bool &IsSmall=false) const
Definition: dt.h:440
TFlt MnY
Definition: dt.h:1574
void Flush()
Definition: dt.h:196
Definition: dt.h:1025
Definition: dt.h:955
unsigned long long uint64
Definition: bd.h:38
bool IsInt() const
Definition: dt.h:577
static const char TabCh
Definition: dt.h:1034
static const char Mn
Definition: dt.h:1029
TFlt(const double &_Val)
Definition: dt.h:1396
void Save(TSOut &SOut) const
Definition: dt.h:904
~TMem()
Definition: dt.h:99
TSFlt & operator=(const TSFlt &SFlt)
Definition: dt.h:1512
TNum & operator--()
Definition: dt.h:909
static TStr Get01Str(const bool &Val)
Definition: dt.h:1016
bool operator==(const TFlt &Flt) const _CMPWARN
Definition: dt.h:1410
void Load(bool &Bool)
Definition: fl.h:84
TSFlt(const sdouble &_Val)
Definition: dt.h:1503
int64 GetHexInt64(const int64 &DfVal) const
Definition: dt.h:621
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:809
void Load(TSIn &SIn)
Definition: dt.h:1126
void SaveTxt(const PSOut &SOut) const
Definition: dt.cpp:622
TNum operator++(int)
Definition: dt.h:910
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:708
void MkRef()
Definition: dt.h:378
TNum()
Definition: dt.h:869
TUInt & operator~()
Definition: dt.h:1266
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:1216
TFlt MxY
Definition: dt.h:1574
TMemIn(const TMem &_Mem, const int &_BfC=0)
Definition: dt.cpp:315
static bool IsIpStr(const TStr &IpStr, const char &SplitCh= '.')
Definition: dt.h:1307
static int GetNum(const char &Ch)
Definition: dt.h:1066
static TStr GetStr(const TLFlt &LFlt, const int &Width=-1, const int &Prec=-1)
Definition: dt.h:1563
TStr GetStr() const
Definition: dt.h:1279
uint GetUniDevUInt(const uint &Range=0)
Definition: dt.cpp:45
TUInt64 & operator=(const TUInt64 &Int)
Definition: dt.h:1336
TStr Str1
Definition: dt.h:724
char PeekCh()
Definition: dt.h:174
int GetSecHashCd(const uint &Offset)
Definition: dt.h:824
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:740
void Load(TSIn &SIn)
Definition: dt.h:1149
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:539
static TRStr * GetNullRStr()
Definition: dt.h:402
static PStrPool New(TSIn &SIn)
Definition: dt.h:792
~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:471
char & operator[](const int &ChN)
Definition: dt.h:249
static bool IsOdd(const int &Int)
Definition: dt.h:1177
Definition: lx.h:251
void Save(TSOut &SOut) const
Definition: dt.h:1545
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:1332
Definition: dt.h:1495
TStr & ConvUsFromYuAscii()
Definition: dt.cpp:779
int GetSecHashCd() const
Definition: dt.cpp:611
int GetMemUsed() const
Definition: dt.h:1557
TMem(const TMem &Mem)
Definition: dt.h:92
const char * CStr() const
Definition: dt.h:477
bool Eof()
Definition: dt.h:171
char LastCh() const
Definition: dt.h:484
TVoid(TSIn &)
Definition: dt.h:958
bool operator==(const char *CStr) const
Definition: dt.h:463
TFlt operator--(int)
Definition: dt.h:1419
TChA GetSubStr(const int &BChN, const int &EChN) const
Definition: dt.cpp:448
static const char HashCh
Definition: dt.h:1038
TRStr(const char *CStr1, const char *CStr2)
Definition: dt.h:358
uchar operator()() const
Definition: dt.h:1109
TFlt(TSIn &SIn, const bool &IsTxt)
Definition: dt.h:1400
TCh()
Definition: dt.h:1040
TUInt & operator&=(const TUInt &UInt)
Definition: dt.h:1267
bool operator==(const TVoid &) const
Definition: dt.h:964
void Load(TSIn &SIn)
Definition: dt.h:1251
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:499
bool Val
Definition: dt.h:973
TNum & operator++()
Definition: dt.h:908
static TStr LoadTxt(const TStr &FNm)
Definition: dt.h:668
static const int Vals
Definition: dt.h:1096
bool operator<(const int &Int) const
Definition: dt.h:1160
TStr & operator=(const TStr &Str)
Definition: dt.h:445
double GetYLen() const
Definition: dt.h:1603
void Trunc(const int &_BfL)
Definition: dt.h:136
TInt(const int &_Val)
Definition: dt.h:1146
bool operator<(const TCh &Ch) const
Definition: dt.h:1051
bool operator!=(const double &Flt) const _CMPWARN
Definition: dt.h:1412
bool operator<(const TUCh &UCh) const
Definition: dt.h:1108
uint GetUInt(const uint &DfVal) const
Definition: dt.h:587
TNum & operator-=(const TNum &Int)
Definition: dt.h:907
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:1928
int GetPrimHashCd(const uint &Offset)
Definition: dt.h:822
static PStrPool64 Load(TSIn &SIn, bool LoadCompact=true)
Definition: dt.h:846
int Len() const
Definition: dt.h:712
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:672
static TStr GetNrFExt(const TStr &FExt)
Definition: dt.cpp:1455
void Save(TSOut &) const
Definition: dt.h:959
::TSize GetMemUsed()
Definition: dt.h:803
static TStr GetNullStr()
Definition: dt.cpp:1626
TStr & ToLc()
Definition: dt.cpp:758
static const sdouble Mx
Definition: dt.h:1500
bool operator<(const TChA &ChA) const
Definition: dt.h:238
TDbStr()
Definition: dt.h:727
static TStr GetStr(const int &Val)
Definition: dt.h:1199
int GetMemUsed() const
Definition: dt.h:1524
TUInt64 & operator-=(const TUInt64 &Int)
Definition: dt.h:1338
void Load(TSIn &SIn)
Definition: dt.h:222
char * operator()()
Definition: dt.h:474
int Len() const
Definition: dt.h:384
bool IsNum() const
Definition: dt.h:1456
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:1477
TCh & operator=(const TCh &Ch)
Definition: dt.h:1049
TLFlt()
Definition: dt.h:1541
unsigned char uchar
Definition: bd.h:10
TChA(TSIn &SIn)
Definition: dt.h:220
double GetMxX() const
Definition: dt.h:1598
void SaveBf(const void *Bf, const TSize &BfL)
Definition: fl.h:172
char GetCh(const int &ChN) const
Definition: dt.h:483
uint64 Len() const
Definition: dt.h:854
TChA & operator+=(const TMem &Mem)
Definition: dt.cpp:387
TUInt64(const uint &MsVal, const uint &LsVal)
Definition: dt.h:1325
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:1550
int GetMemUsed() const
Definition: dt.h:1272
void Trunc()
Definition: dt.cpp:420
bool operator<(const TVoid &) const
Definition: dt.h:965
TFlt()
Definition: dt.h:1395
Definition: fl.h:128
TBool(TSIn &SIn)
Definition: dt.h:990
char & operator[](const int &ChN) const
Definition: dt.h:119
int BfC
Definition: dt.h:162
int GetMemUsed() const
Definition: dt.h:1110
void SaveXml(TSOut &SOut, const TStr &Nm) const
Definition: dt.cpp:1838
TStr(TSIn &SIn, const bool &IsSmall=false)
Definition: dt.h:436
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:1118
static const char LfCh
Definition: dt.h:1035
int64 GetInt64(const int64 &DfVal) const
Definition: dt.h:596
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:678
void Save(const bool &Bool)
Definition: fl.h:173
static uint GetRnd(const uint &Range=0)
Definition: dt.h:1277
TDbStr(const TStr &_Str1)
Definition: dt.h:729
int GetSecHashCd() const
Definition: dt.h:1129
TNum & operator=(const Base &_Val)
Definition: dt.h:877
TRnd(const int &_Seed=1, const int &Steps=0)
Definition: dt.h:20
static double Abs(const double &Flt)
Definition: dt.h:1427
static double GetUniDevStep(const int &Seed, const int &Steps)
Definition: dt.h:64
static int Round(const double &Flt)
Definition: dt.h:1429
TFlt operator++(int)
Definition: dt.h:1418
Definition: dt.h:1134
bool GetNextLnBf(TChA &LnChA)
Definition: dt.cpp:326
TStr Left(const int &EChN) const
Definition: dt.h:544
static TStr PutFBase(const TStr &FNm, const TStr &FBase)
Definition: dt.cpp:1511
TSFlt operator--(int)
Definition: dt.h:1523
char PeekCh()
Definition: dt.h:714
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:906
void Move(const int &Steps)
Definition: dt.cpp:29
Definition: fl.h:495
static PStrPool New(const TStr &fileName)
Definition: dt.h:793
void SaveTxt(TOLx &Lx) const
Definition: dt.cpp:219
TUInt & operator=(const uint &_Val)
Definition: dt.h:1257
static const TStr YesStr
Definition: dt.h:985
Definition: dt.h:201
TUInt operator--(int)
Definition: dt.h:1259
static TStr GetNumFNm(const TStr &FNm, const int &Num)
Definition: dt.cpp:1527
uchar Val
Definition: dt.h:1092
void Save(TSOut &SOut) const
Definition: dt.h:1045
static int Abs(const int &Int)
Definition: dt.h:1171
TUInt64()
Definition: dt.h:1322
static const bool Mn
Definition: dt.h:975
void Save(const TStr &FNm)
Definition: dt.h:796
uint64 Reserved() const
Definition: dt.h:855
bool operator<(const TLFlt &LFlt) const
Definition: dt.h:1553
Definition: dt.h:1239
TFltRect()
Definition: dt.h:1576
bool IsNan() const
Definition: dt.h:1457
static const TStr NStr
Definition: dt.h:982
double GetNrmDev()
Definition: dt.cpp:63
TStr GetTrunc() const
Definition: dt.h:506
int Seed
Definition: dt.h:16
static int GetRnd(const int &Range=0)
Definition: dt.h:1175
Definition: dt.h:722
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:1065
static int GetMx(const int &Int1, const int &Int2, const int &Int3, const int &Int4)
Definition: dt.h:1191
void Save(TSOut &SOut, const bool &IsSmall) const
Definition: dt.h:371
float sdouble
Definition: bd.h:15
TFlt MxX
Definition: dt.h:1574
TStr LeftOf(const char &SplitCh) const
Definition: dt.cpp:873
TInt & operator=(const int &Int)
Definition: dt.h:1155
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:1607
TInt operator++(int)
Definition: dt.h:1164
static char * LoadFrugalInt(char *pSrc, int &i)
Definition: dt.cpp:1975
uint AddStr(const char *Str)
Definition: dt.h:806
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:879
static double GetMn(const double &Flt1, const double &Flt2)
Definition: dt.h:1434
TStr GetStr() const
Definition: dt.h:1360
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:1250
TStr & operator+=(const TStr &Str)
Definition: dt.h:453
TFltRect(TSIn &SIn)
Definition: dt.h:1584
TBool()
Definition: dt.h:987
static const ldouble Mx
Definition: dt.h:1539
long long int64
Definition: bd.h:27
TStr(const char *CStr)
Definition: dt.h:427
TStr Mid(const int &BChN) const
Definition: dt.h:540
TSFlt operator++(int)
Definition: dt.h:1522
~TStrPool()
Definition: dt.h:789
TMem(TSIn &SIn)
Definition: dt.h:100
static TStr GetYNStr(const bool &Val)
Definition: dt.h:1012
static bool IsAlpha(const char &Ch)
Definition: dt.h:1062
int64 Val
Definition: dt.h:893
Definition: dt.h:412
TSInt()
Definition: dt.h:1122
TChA & operator=(const TChA &ChA)
Definition: dt.cpp:366
TNum(const TNum &Int)
Definition: dt.h:899
int GetMemUsed() const
Definition: dt.h:1166
TRnd & operator=(const TRnd &Rnd)
Definition: dt.h:27
bool Empty() const
Definition: dt.h:488
static PMem New(const int &MxBfL=0)
Definition: dt.h:87
~TStr()
Definition: dt.h:435
uint64 Val
Definition: dt.h:1317
bool IsChIn(const char &Ch) const
Definition: dt.h:553
static TStr GetMegaStr(const int64 &Val)
Definition: dt.h:929
TStr & ToTrunc()
Definition: dt.cpp:770
TStr GetCap() const
Definition: dt.h:502
static double GetRnd()
Definition: dt.h:1430
TStr LeftOfLast(const char &SplitCh) const
Definition: dt.cpp:880
static TStr GetStr(const TNum &Int)
Definition: dt.h:920
bool operator<(const TInt &Int) const
Definition: dt.h:1159
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:688
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:2151
static bool IsNan(const double &Val)
Definition: dt.h:1453
double operator()() const
Definition: dt.h:1413
void Swap(const int &ChN1, const int &ChN2)
Definition: dt.cpp:595
int GetHexInt(const int &DfVal) const
Definition: dt.h:613
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:1245
int BfC
Definition: dt.h:325
TStr GetStr() const
Definition: dt.cpp:2325
bool Eof()
Definition: dt.h:711
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:1489
void ToUc()
Definition: dt.cpp:667
TStr & operator=(const TChA &ChA)
Definition: dt.h:447
static TStr LoadTxt(const PSIn &SIn)
Definition: dt.h:666
int MxBfL
Definition: dt.h:79
static int64 GetFromBufSafe(const char *Bf)
Definition: dt.h:942
const char * operator()() const
Definition: dt.h:475
double GetFlt(const double &DfVal) const
Definition: dt.h:630
bool IsSuffix(const char *CStr) const
Definition: dt.cpp:518
void Load(TSIn &SIn)
Definition: dt.h:1402
bool IsUInt(uint &Val) const
Definition: dt.h:584
TSInt(const int16 &_Val)
Definition: dt.h:1123
TNum(const int64 &Int)
Definition: dt.h:900
TStr & operator=(const char *CStr)
Definition: dt.h:449
TStr GetHex() const
Definition: dt.h:512
static const char CrCh
Definition: dt.h:1036
TUInt64 & operator*=(const TUInt64 &Int)
Definition: dt.h:1339
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:817
static PStrPool64 New(::TSize MxBfL=0,::TSize GrowBy=16 *1024 *1024)
Definition: dt.h:844
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:680
void GenZeros(const int &_BfL)
Definition: dt.h:125
bool operator<(const TStr &Str) const
Definition: dt.h:469
TRStr(TSIn &SIn, const bool &IsSmall)
Definition: dt.h:368
static TStr GetStr(const bool &Val)
Definition: dt.h:1008
uint Len() const
Definition: dt.h:798
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:966
static int Sign(const double &Flt)
Definition: dt.h:1428
int GetSecHashCd() const
Definition: dt.h:1275
bool operator<(const TBool &Bool) const
Definition: dt.h:998
Definition: bd.h:196
static const double PInf
Definition: dt.h:1390
static TStr GetStr(const int64 &Val)
Definition: dt.h:1210
static TStr GetStr(const TCh &Ch)
Definition: dt.h:1084
static double GetInRng(const double &Val, const double &Mn, const double &Mx)
Definition: dt.h:1448
static TStr GetKiloStr(const int64 &Val)
Definition: dt.h:924
uint Val
Definition: dt.h:1241
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:1157
TNum(const Base &_Val)
Definition: dt.h:870
bool operator==(const TBool &Bool) const
Definition: dt.h:997
TStr GetStr() const
Definition: dt.h:1459
TUInt & operator^=(const TUInt &UInt)
Definition: dt.h:1269
bool Filled() const
Definition: dt.h:749
void CompressWs()
Definition: dt.cpp:581
TStr Reverse() const
Definition: dt.h:566
TPt< TSIn > PSIn
Definition: fl.h:119
bool operator==(const TStr &Str) const
Definition: dt.h:461
short int16
Definition: bd.h:20
ldouble Val
Definition: dt.h:1536
TMem(const int &_MxBfL=0)
Definition: dt.h:84
TUInt & operator>>=(const int &ShiftBits)
Definition: dt.h:1270
int Len() const
Definition: dt.h:172
bool operator==(const double &Flt) const _CMPWARN
Definition: dt.h:1514
static const uchar Mx
Definition: dt.h:1095
char * GetBf() const
Definition: dt.h:144
static const TUInt64 Mn
Definition: dt.h:1319
bool Empty() const
Definition: dt.h:853
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:1031
TInt & operator+=(const int &Int)
Definition: dt.h:1162
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:479
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:1551
TUInt64 & operator+=(const TUInt64 &Int)
Definition: dt.h:1337
static char IsUc(const char &Ch)
Definition: dt.h:1078
TChA & ToTrunc()
Definition: dt.cpp:568
bool operator!=(const TChA &ChA) const
Definition: dt.h:235
TFlt & operator=(const TFlt &Flt)
Definition: dt.h:1408
static bool Eq6(const double &LFlt, const double &RFlt)
Definition: dt.h:1431
static const int Vals
Definition: dt.h:977
char * Bf
Definition: dt.h:700
static const int m
Definition: dt.h:15
char * CStr()
Definition: dt.h:476
char Pop()
Definition: dt.h:265
int GetPrimHashCd() const
Definition: dt.h:1274
int BfL
Definition: dt.h:162
TFltRect(const double &_MnX, const double &_MnY, const double &_MxX, const double &_MxY)
Definition: dt.h:1580
TLFlt(TSIn &SIn)
Definition: dt.h:1544
int GetHexInt() const
Definition: dt.h:611
int Refs
Definition: dt.h:349
~TChA()
Definition: dt.h:219
TStr()
Definition: dt.h:423
virtual int Len() const =0
char operator()() const
Definition: dt.h:1052
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:1347
void SplitOnLastCh(TStr &LStr, const char &SplitCh, TStr &RStr) const
Definition: dt.cpp:912
double GetMnX() const
Definition: dt.h:1596
TChA(const char *CStr, const int &StrLen)
Definition: dt.h:211
static TStr GetStr(const uint &Val)
Definition: dt.h:1205
PMem Mem
Definition: dt.h:160
static TStr GetStr(const ldouble &Val, const TStr &FmtStr)
Definition: dt.h:1566
Definition: dt.h:971
char * operator()() const
Definition: dt.h:114
static char GetUc(const char &Ch)
Definition: dt.h:1080
TRStr(const char &Ch1, const char &Ch2)
Definition: dt.h:363
TStr Slice(int BChN, int EChNP1) const
Definition: dt.h:546
bool IsStrIn(const TStr &Str) const
Definition: dt.h:554
TVoid()
Definition: dt.h:957
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:1173
static TStr GetHexStr(const TNum &Int)
Definition: dt.h:921
static TStr GetStr(const TBool &Bool)
Definition: dt.h:1010
uint64 GetMemUsed() const
Definition: dt.h:851
int GetPrimHashCd() const
Definition: dt.cpp:607
bool IsSuffix(const TStr &Str) const
Definition: dt.h:559
TStr operator()(const int &BChN, const int &EChNP1) const
Definition: dt.h:547
void SplitOnAllAnyCh(const TStr &SplitChStr, TStrV &StrV, const bool &SkipEmpty=true) const
Definition: dt.cpp:944
TBool(const bool &_Val)
Definition: dt.h:988
uint AddStr(const TStr &Str)
Definition: dt.h:807
int GetSecHashCd() const
Definition: dt.h:1345
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:1461
int16 Val
Definition: dt.h:1120
int BfL
Definition: dt.h:701
int CountCh(const char &Ch, const int &BChN=0) const
Definition: dt.cpp:1033
static const TStr TrueStr
Definition: dt.h:981
TUInt64(void *Pt)
Definition: dt.h:1327
void LoadXml(const PXmlTok &XmlTok, const TStr &Nm)
Definition: dt.cpp:2258
TNum(TSIn &SIn)
Definition: dt.h:872
int GetMemUsed() const
Definition: dt.h:472
int GetPrimHashCd() const
Definition: dt.h:1526
static const int64 Mn
Definition: dt.h:895
bool IsUc() const
Definition: dt.h:491
static int GetMn(const int &Int1, const int &Int2, const int &Int3)
Definition: dt.h:1184
bool operator!=(const char &Ch) const
Definition: dt.h:237
uint operator()() const
Definition: dt.h:1264
bool GetNextLnBf(TChA &LnChA)
Definition: dt.cpp:652
static TStr GetStr(const TInt &Int)
Definition: dt.h:1200
Definition: dt.h:1485
TChA(const char *CStr)
Definition: dt.h:209
bool operator<(const TSFlt &SFlt) const
Definition: dt.h:1516
bool operator==(const TUCh &UCh) const
Definition: dt.h:1107
TStr RightOfLast(const char &SplitCh) const
Definition: dt.cpp:894
TCs Cs
Definition: fl.h:44
static const TUInt64 Mx
Definition: dt.h:1320
int GetSeed() const
Definition: dt.h:59
int GetSecHashCd() const
Definition: dt.h:1424
static const uchar Mn
Definition: dt.h:1094
int GetMemUsed() const
Definition: dt.h:1001
void Save(TSOut &SOut) const
Definition: dt.h:1399
TNum()
Definition: dt.h:898
bool operator<(const TDbStr &DbStr) const
Definition: dt.h:738
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:896
TFlt & operator-=(const double &Flt)
Definition: dt.h:1415
TUCh()
Definition: dt.h:1098
static bool IsEven(const int &Int)
Definition: dt.h:1178
double GetPowerDev(const double &AlphaSlope)
Definition: dt.h:47
Definition: dt.h:1315
bool operator()() const
Definition: dt.h:1000
static const double Eps
Definition: dt.h:1391
bool IsUInt64() const
Definition: dt.h:602
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:1393
static const double Mn
Definition: dt.h:1387
int operator()() const
Definition: dt.h:1161
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:709
char Val
Definition: dt.h:1027
Definition: dt.h:1090
double GetXLen() const
Definition: dt.h:1602
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:1219
void Load(TSIn &SIn)
Definition: dt.h:873
void SaveTxt(const PSOut &SOut) const
Definition: dt.h:670
static TStr GetFNmStr(const TStr &Str, const bool &AlNumOnlyP=true)
Definition: dt.cpp:1531
int GetInt(const int &DfVal) const
Definition: dt.h:579
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:1189