6 #define forever for(;;)
23 typedef __int64
int64;
24 #elif defined(GLib_GLIBC)
25 typedef int64_t
int64;
34 typedef unsigned __int64
uint64;
35 #elif defined(GLib_GLIBC)
41 #if (!defined(__ssize_t_defined) && !defined(GLib_MACOSX))
45 #if defined(GLib_UNIX)
46 #define _isnan(x) isnan(x)
47 #if defined(GLib_MACOSX)
48 #define _finite(x) isfinite(x)
50 #define _finite(x) finite(x)
54 #if defined(GLib_WIN32)
55 #define _vsnprintf vsnprintf
59 #define TSizeMx SIZE_MAX
67 void WrNotify(
const char* CaptionCStr,
const char* NotifyCStr);
71 WrNotify(
"Information", NotifyCStr);}
81 #if defined (GLib_WIN)
82 #define snprintf _snprintf
83 #define vsnprintf _vsnprintf
85 #pragma warning(disable: 4786)
92 #pragma warning(disable: 4996)
95 #if defined (GLib_GCC)
101 #if defined(_CONSOLE)||defined(__CONSOLE__)
106 #if defined(GLib_Console) && (! (defined(__CONSOLE__)||defined(_CONSOLE)))
107 #define GLib_CreateConsole
112 #define ClassT(TNm) \
115 #define ClassTV(TNm, TNmV) \
117 typedef TVec<TNm> TNmV; \
120 #define ClassTVQ(TNm, TNmV, TNmQ) \
122 typedef TVec<TNm> TNmV; \
123 typedef TQQueue<TNm> TNmQ; \
126 #define ClassTP(TNm, PNm) \
128 typedef TPt<TNm> PNm; \
133 friend class TPt<TNm>;
135 #define ClassHdTP(TNm, PNm) \
137 typedef TPt<TNm> PNm;
139 #define ClassTPE(TNm, PNm, ENm) \
141 typedef TPt<TNm> PNm; \
142 class TNm: public ENm{ \
146 friend class TPt<TNm>;
148 #define ClassTPEE(TNm, PNm, ENm1, ENm2) \
150 typedef TPt<TNm> PNm; \
151 class TNm: public ENm1, public ENm2{ \
155 friend class TPt<TNm>;
157 #define ClassTE(TNm, ENm) \
159 class TNm: public ENm{ \
162 #define ClassTPV(TNm, PNm, TNmV) \
164 typedef TPt<TNm> PNm; \
165 typedef TVec<PNm> TNmV; \
170 friend class TPt<TNm>;
172 #define ClassHdTPV(TNm, PNm, TNmV) \
174 typedef TPt<TNm> PNm; \
175 typedef TVec<PNm> TNmV;
177 #define ClassTPVL(TNm, PNm, TNmV, TNmL, TNmLN) \
179 typedef TPt<TNm> PNm; \
180 typedef TVec<PNm> TNmV; \
181 typedef TLst<PNm> TNmL; \
182 typedef TLstNd<PNm>* TNmLN; \
187 friend class TPt<TNm>;
196 template <
class TRec>
class TPt;
203 #define UndefDefaultCopyAssign(TNm) \
207 TNm& operator=(const TNm&)
209 #define UndefCopyAssign(TNm) \
212 TNm& operator=(const TNm&)
214 #define UndefCopy(TNm) \
218 #define UndefAssign(TNm) \
220 TNm& operator=(const TNm&)
235 const char* MsgStr,
const char* ReasonStr,
236 const char* CondStr,
const char* FNm,
const int& LnN);
238 #define Fail ExeStop(NULL, NULL, "Fail", __FILE__, __LINE__)
240 #define FailR(Reason) ExeStop((Reason), NULL, "Fail", __FILE__, __LINE__)
241 #define FailRA(Reason, ArgStr) \
242 ExeStop((TStr(Reason)+" ("+ArgStr+")").CStr(), NULL, "Fail", __FILE__, __LINE__)
244 #define EFail TExcept::ThrowFull("", TStr("[")+ TStr(__FILE__) + " line " + TInt::GetStr(__LINE__) + "]")
246 #define EFailR(Reason) TExcept::ThrowFull(Reason, TStr("[")+TStr(__FILE__)+" line "+TInt::GetStr(__LINE__)+"]")
251 #define Assert(Cond) \
252 ((Cond) ? static_cast<void>(0) : ExeStop(NULL, NULL, #Cond, __FILE__, __LINE__))
256 #define AssertR(Cond, Reason)
258 #define AssertR(Cond, Reason) ((Cond) ? static_cast<void>(0) : \
259 ExeStop(NULL, TStr(Reason).CStr(), #Cond, __FILE__, __LINE__))
262 #define IAssert(Cond) \
263 ((Cond) ? static_cast<void>(0) : ExeStop(NULL, NULL, #Cond, __FILE__, __LINE__))
265 #define IAssertR(Cond, Reason) \
266 ((Cond) ? static_cast<void>(0) : ExeStop(NULL, TStr(Reason).CStr(), #Cond, __FILE__, __LINE__))
268 #define WAssert(Cond, MsgCStr) \
269 ((Cond) ? static_cast<void>(0) : WarnNotify(MsgCStr))
271 #define SAssert(Cond) \
272 ((Cond) ? static_cast<void>(0) : ExeStop(TSysStr::GetLastMsgCStr(), NULL, #Cond, __FILE__, __LINE__))
274 #define FAssert(Cond, MsgCStr) \
275 ((Cond) ? static_cast<void>(0) : ExeStop(TStr(MsgCStr).CStr(), NULL, NULL, __FILE__, __LINE__))
277 #define FSAssert(Cond) \
278 ((Cond) ? static_cast<void>(0) : ExeStop(TSysStr::GetLastMsgCStr(), NULL, NULL, __FILE__, __LINE__))
280 #define EAssert(Cond) \
281 ((Cond) ? static_cast<void>(0) : TExcept::ThrowFull(#Cond, TStr(__FILE__) + " line " + TInt::GetStr(__LINE__) +": "+ TStr(#Cond)))
283 #define EAssertR(Cond, MsgStr) \
284 ((Cond) ? static_cast<void>(0) : TExcept::ThrowFull(MsgStr, TStr(__FILE__)+" line "+TInt::GetStr(__LINE__)+": "+TStr(#Cond)))
286 #define EAssertRA(Cond, MsgStr, ArgStr) \
287 ((Cond) ? static_cast<void>(0) : TExcept::Throw(MsgStr, ArgStr))
289 #define EAssertRAA(Cond, MsgStr, ArgStr1, ArgStr2) \
290 ((Cond) ? static_cast<void>(0) : TExcept::Throw(MsgStr, ArgStr1, ArgStr2))
292 #define ESAssert(Cond) \
293 ((Cond) ? static_cast<void>(0) : TExcept::Throw(TSysStr::GetLastMsgCStr(), \
294 TStr(__FILE__) + " line " + TInt::GetStr(__LINE__) +": "+ TStr(#Cond)))
302 #define CAssert(Cond) \
307 template <
class TRec>
309 template <
class TRec>
312 #define XLoadHd(Nm) \
313 {TStr TypeNm=TXmlObjSer::GetTagNm(TStr(typeid(*this).name())); \
314 TXmlObjSer::AssertXmlHd(XmlTok, Nm, TypeNm);}
316 Nm.LoadXml(XmlTok->GetTagTok(#Nm), #Nm);
318 #define XSaveHd(Nm) \
319 TStr _TypeNm=TXmlObjSer::GetTagNm(TStr(typeid(*this).name())); \
320 TXmlObjSerTagNm XmlObjSerTagNm(SOut, false, Nm, _TypeNm);
321 #define XSaveHdArg(Nm, ArgNm, ArgVal) \
322 TStr _TypeNm=TXmlObjSer::GetTagNm(TStr(typeid(*this).name())); \
323 TXmlObjSerTagNm XmlObjSerTagNm(SOut, false, Nm, _TypeNm, ArgNm, ArgVal);
324 #define XSaveBETag(Nm) \
325 TStr _TypeNm=TXmlObjSer::GetTagNm(TStr(typeid(*this).name())); \
326 TXmlObjSerTagNm XmlObjSerTagNm(SOut, true, Nm, _TypeNm);
327 #define XSaveBETagArg(Nm, ArgNm, ArgVal) \
328 TStr _TypeNm=TXmlObjSer::GetTagNm(TStr(typeid(*this).name())); \
329 TXmlObjSerTagNm XmlObjSerTagNm(SOut, true, Nm, _TypeNm, ArgNm, ArgVal);
330 #define XSaveBETagArg4(Nm, ArgNm1, ArgVal1, ArgNm2, ArgVal2, ArgNm3, ArgVal3, ArgNm4, ArgVal4) \
331 TStr _TypeNm=TXmlObjSer::GetTagNm(TStr(typeid(*this).name())); \
332 TXmlObjSerTagNm XmlObjSerTagNm(SOut, true, Nm, _TypeNm, ArgNm1, ArgVal1, ArgNm2, ArgVal2, ArgNm3, ArgVal3, ArgNm4, ArgVal4);
334 Nm.SaveXml(SOut, #Nm)
335 #define XSaveToFile(Nm, FNm) \
336 {TFOut SOut(FNm); Nm.SaveXml(SOut, #Nm);}
346 #define min(a,b) ((a)<(b)?(a):(b))
350 #define max(a,b) ((a)>(b)?(a):(b))
371 int Cmp(
const T& d1,
const T& d2)
const {
372 if (d1<d2){
return -1;}
373 else if (d2<d1){
return 1;}
387 bool operator() (
const T& x,
const T& y)
const {
return x>y; }
388 int Cmp(
const T& d1,
const T& d2)
const {
389 if (d1<d2){
return 1;}
390 else if (d2<d1){
return -1;}
405 if (x < y){
return -1;}
406 else if (x > y){
return 1;}
413 template <
class TRec>
414 bool operator!=(
const TRec& Rec1,
const TRec& Rec2){
return !(Rec1==Rec2);}
416 template <
class TRec>
417 bool operator>(
const TRec& Rec1,
const TRec& Rec2){
return Rec2<Rec1;}
419 template <
class TRec>
420 bool operator<=(
const TRec& Rec1,
const TRec& Rec2){
return !(Rec2<Rec1);}
422 template <
class TRec>
423 bool operator>=(
const TRec& Rec1,
const TRec& Rec2){
return !(Rec1<Rec2);}
425 template <
class TRec>
426 bool Cmp(
const int& RelOp,
const TRec& Rec1,
const TRec& Rec2){
428 case roLs:
return Rec1<Rec2;
429 case roLEq:
return Rec1<=Rec2;
430 case roEq:
return Rec1==Rec2;
431 case roNEq:
return Rec1!=Rec2;
432 case roGEq:
return Rec1>=Rec2;
433 case roGt:
return Rec1>Rec2;
434 default:
Fail;
return false;
458 template <
class TRec>
472 if (
Addr->CRef.NoRef()){
delete Addr;}
482 explicit TPt(
TSIn& SIn,
void* ThisPt);
504 if (
Addr==NULL){
return -1;}
else {
return Addr->CRef.GetRefs();}}
519 Bf=
new char[0+1];
Bf[0]=0;}
521 Bf=
new char[strlen(SStr.
Bf)+1]; strcpy(
Bf, SStr.
Bf);}
523 Bf=
new char[strlen(_Bf)+1]; strcpy(
Bf, _Bf);}
528 delete[]
Bf;
Bf=
new char[strlen(SStr.
Bf)+1]; strcpy(
Bf, SStr.
Bf);}
534 int Len()
const {
return int(strlen(
Bf));}
549 Val.Pt=0;
Val.UInt32.Ms=0;
Val.UInt32.Ls=0;}
567 template <
class TRec>
568 void Swap(TRec& Rec1, TRec& Rec2){
569 TRec Rec=Rec1; Rec1=Rec2; Rec2=Rec;
579 static inline int GetHashCd(
const int hc1,
const int hc2) {
580 unsigned long long sum = ((
unsigned long long) hc1) + ((
unsigned long long) hc2);
581 unsigned long long c = ((sum * (sum + 1)) >> 1) + hc1;
582 return (
int) (c % 0x7fffffffULL); }
590 static inline int GetHashCd(
const int hc1,
const int hc2) {
591 unsigned long long sum = ((
unsigned long long) hc1) + ((
unsigned long long) hc2);
592 unsigned long long c = ((sum * (sum + 1)) >> 1) + hc1;
593 unsigned int R = (
unsigned int) (c >> 31), Q = (
unsigned int) (c & 0x7fffffffULL);
594 if ((R & 0x80000000U) != 0) R -= 0x7fffffffU;
595 unsigned int RQ = R + Q;
596 if (RQ < 0x7fffffffU)
return (
int) RQ;
598 return (RQ == 0x7fffffffU) ? 0 : (int) RQ; }
602 #if (defined(GLib_64Bit)) && ! (defined(DEBUG) || defined(_DEBUG))
void PutLsUInt32(const uint &Ls)
UndefCopyAssign(TConv_Pt64Ints32)
void XLoadFromFile(const TStr &FNm, const TStr &Nm, TRec &Rec)
const char * CStr() const
TPairHashImpl2 TPairHashImpl
static int GetHashCd(const int hc1, const int hc2)
bool operator!=(const TPt &Pt) const
#define ClassHdTP(TNm, PNm)
TPt & operator=(const TPt &Pt)
static void PutOnExeStopF(TOnExeStopF _OnExeStopF)
void ExeStop(const char *MsgStr, const char *ReasonStr, const char *CondStr, const char *FNm, const int &LnN)
void SaveXml(TSOut &SOut, const TStr &Nm) const
TRec * operator->() const
bool operator()(const T &x, const T &y) const
bool operator()(const T &x, const T &y) const
int Cmp(const T &d1, const T &d2) const
bool IsXLoadFromFileOk(const TStr &FNm, const TStr &Nm, TRec &Rec, TStr &MsgStr)
void ErrNotify(const char *NotifyCStr)
bool operator!=(const TRec &Rec1, const TRec &Rec2)
PPp MkClone(const PPp &Pp)
void SaveToErrLog(const char *MsgCStr)
void WarnNotify(const char *NotifyCStr)
TConv_Pt64Ints32(const uint &Ms, const uint &Ls)
struct TConv_Pt64Ints32::@1::@2 UInt32
unsigned long long uint64
TSStr & operator=(const TSStr &SStr)
void PutMsUInt32(const uint &Ms)
TRec & operator[](const int &RecN) const
bool operator>=(const TRec &Rec1, const TRec &Rec2)
TRec * operator()() const
static int GetHashCd(const int hc1, const int hc2)
bool operator==(const TPt &Pt) const
static TOnExeStopF OnExeStopF
bool operator<=(const TRec &Rec1, const TRec &Rec2)
void InfoNotify(const char *NotifyCStr)
static bool IsOnExeStopF()
bool operator()(const T &x, const T &y) const
TCRef & operator=(const TCRef &)
Computes a hash code from a pair of hash codes.
void Save(TSOut &SOut) const
TConv_Pt64Ints32(void *Pt)
void StatNotify(const char *NotifyCStr)
bool Cmp(const int &RelOp, const TRec &Rec1, const TRec &Rec2)
bool operator<(const TPt &Pt) const
bool(* TOnExeStopF)(char *MsgCStr)
void WrNotify(const char *CaptionCStr, const char *NotifyCStr)
bool operator()(const T &x, const T &y) const
int operator()(const T &x, const T &y) const
bool operator()(const T &x, const T &y) const
void PutUInt64(const uint64 &_UInt64)
Computes a hash code from a pair of hash codes.
void LoadXml(const TPt< TXmlTok > &XmlTok, const TStr &Nm)
static TOnExeStopF GetOnExeStopF()
int GetPrimHashCd() const
union TConv_Pt64Ints32::@1 Val
bool operator()(const T &x, const T &y) const
void Swap(TRec &Rec1, TRec &Rec2)
int Cmp(const T &d1, const T &d2) const
bool operator>(const TRec &Rec1, const TRec &Rec2)