16 #ifndef TIANCHI_TCCOMMON_H
17 #define TIANCHI_TCCOMMON_H
19 #include <tianchi/tcglobal.h>
25 #include <QMessageBox>
54 QTextCodec* initQS(
const QByteArray& name=
"GBK");
78 inline QString QS(
const char* s)
80 return QTextCodec::codecForLocale()->toUnicode(s);
84 #define max(a,b) (((a) > (b)) ? (a) : (b))
86 #define min(a,b) (((a) < (b)) ? (a) : (b))
88 inline int iif(
bool logic,
int v1,
int v2=0) {
return logic ? v1 : v2; }
90 inline QString iif(
bool logic,
const QString& v1,
const QString& v2=
"") {
return logic ? v1 : v2; }
96 inline void MsgBox(
const QString& s)
98 QMessageBox::information(NULL,
"", s);
101 #define TC_FREE(x) {delete x; x=NULL;}
102 #if defined(QT_DEBUG)
107 inline void debug_out(
const char* file,
int line,
const QString& text=
"")
109 cout<<QDateTime::currentDateTime().toString(
"yyyy/MM/dd HH:mm:ss->").toLocal8Bit().data()<<file<<
"("<<line<<
"): "<<text.toLocal8Bit().data()<<endl;
115 inline void debug_out(
const char* file,
int line,
int value)
117 debug_out(file, line, QString::number(value));
121 #define DEBUG_STEP debug_out(__FILE__, __LINE__);
123 #define DEBUG_OUT(x) debug_out(__FILE__, __LINE__, x);
132 QString YYYY_MM_DD_HH_MM_SS_ZZZ();
134 QString YYYY_MM_DD_HH_MM_SS();
136 #endif // TIANCHI_COMMON_H