11 #define T_DEFINE_CONTROLLER(TYPE) T_DEFINE_TYPE(TYPE)
12 #define T_DEFINE_VIEW(TYPE) T_DEFINE_TYPE(TYPE)
13 #define T_DEFINE_TYPE(TYPE) \
14 class Static##TYPE##Definition { \
16 Static##TYPE##Definition() noexcept \
18 Tf::objectFactories()->insert(QByteArray(#TYPE).toLower(), []() { return new TYPE(); }); \
21 static Static##TYPE##Definition _static##TYPE##Definition;
23 #if QT_VERSION < 0x060000
24 #define T_REGISTER_STREAM_OPERATORS(TYPE) \
25 class Static##TYPE##Instance { \
27 Static##TYPE##Instance() noexcept \
29 qRegisterMetaTypeStreamOperators<TYPE>(#TYPE); \
32 static Static##TYPE##Instance _static##TYPE##Instance;
35 #define T_REGISTER_STREAM_OPERATORS(TYPE)
38 #define T_DEFINE_PROPERTY(TYPE, PROPERTY) \
39 inline void set##PROPERTY(const TYPE &v__) noexcept { PROPERTY = v__; } \
40 inline TYPE get##PROPERTY() const noexcept { return PROPERTY; }
43 #if defined(Q_CC_GNU) && !defined(__INSURE__)
44 #if defined(Q_CC_MINGW) && !defined(Q_CC_CLANG)
45 #define T_ATTRIBUTE_FORMAT(A, B) __attribute__((format(gnu_printf, (A), (B))))
47 #define T_ATTRIBUTE_FORMAT(A, B) __attribute__((format(printf, (A), (B))))
50 #define T_ATTRIBUTE_FORMAT(A, B)
54 #define T_EXPORT(VAR) \
56 QVariant ___##VAR##_; \
57 ___##VAR##_.setValue(VAR); \
58 Tf::currentController()->exportVariant(QLatin1String(#VAR), (___##VAR##_), true); \
60 #define texport(VAR) T_EXPORT(VAR)
62 #define T_EXPORT_UNLESS(VAR) \
64 QVariant ___##VAR##_; \
65 ___##VAR##_.setValue(VAR); \
66 Tf::currentController()->exportVariant(QLatin1String(#VAR), (___##VAR##_), false); \
68 #define texportUnless(VAR) T_EXPORT_UNLESS(VAR)
70 #define T_FETCH(TYPE, VAR) TYPE VAR = variant(QLatin1String(#VAR)).value<TYPE>()
71 #define tfetch(TYPE, VAR) T_FETCH(TYPE, VAR)
73 #define T_FETCH_V(TYPE, VAR, DEFAULT) TYPE VAR = (hasVariant(QLatin1String(#VAR))) ? (variant(QLatin1String(#VAR)).value<TYPE>()) : (DEFAULT)
74 #define tfetchv(TYPE, VAR, DEFAULT) T_FETCH_V(TYPE, VAR, DEFAULT)
76 #if QT_VERSION < 0x060000
79 auto ___##VAR##_ = variant(QLatin1String(#VAR)); \
80 int ___##VAR##_type = (___##VAR##_).type(); \
81 switch (___##VAR##_type) { \
82 case QMetaType::QJsonValue: \
83 eh((___##VAR##_).toJsonValue()); \
85 case QMetaType::QJsonObject: \
86 eh((___##VAR##_).toJsonObject()); \
88 case QMetaType::QJsonArray: \
89 eh((___##VAR##_).toJsonArray()); \
91 case QMetaType::QJsonDocument: \
92 eh((___##VAR##_).toJsonDocument()); \
94 case QMetaType::QVariantMap: \
95 eh((___##VAR##_).toMap()); \
103 #define T_EHEX(VAR) \
105 auto ___##VAR##_ = variant(QLatin1String(#VAR)); \
106 int ___##VAR##_type = (___##VAR##_).typeId(); \
107 switch (___##VAR##_type) { \
108 case QMetaType::QJsonValue: \
109 eh((___##VAR##_).toJsonValue()); \
111 case QMetaType::QJsonObject: \
112 eh((___##VAR##_).toJsonObject()); \
114 case QMetaType::QJsonArray: \
115 eh((___##VAR##_).toJsonArray()); \
117 case QMetaType::QJsonDocument: \
118 eh((___##VAR##_).toJsonDocument()); \
120 case QMetaType::QVariantMap: \
121 eh((___##VAR##_).toMap()); \
130 #define tehex(VAR) T_EHEX(VAR)
132 #define T_EHEX_V(VAR, DEFAULT) \
134 auto ___##VAR##_ = variant(QLatin1String(#VAR)); \
135 if ((___##VAR##_).isNull()) { \
142 #define tehexv(VAR, DEFAULT) T_EHEX_V(VAR, DEFAULT)
145 #define T_EHEX2(VAR, DEFAULT) T_EHEX_V(VAR, DEFAULT)
146 #define tehex2(VAR, DEFAULT) T_EHEX2(VAR, DEFAULT)
148 #if QT_VERSION < 0x060000
149 #define T_ECHOEX(VAR) \
151 auto ___##VAR##_ = variant(QLatin1String(#VAR)); \
152 int ___##VAR##_type = (___##VAR##_).type(); \
153 switch (___##VAR##_type) { \
154 case QMetaType::QJsonValue: \
155 echo((___##VAR##_).toJsonValue()); \
157 case QMetaType::QJsonObject: \
158 echo((___##VAR##_).toJsonObject()); \
160 case QMetaType::QJsonArray: \
161 echo((___##VAR##_).toJsonArray()); \
163 case QMetaType::QJsonDocument: \
164 echo((___##VAR##_).toJsonDocument()); \
166 case QMetaType::QVariantMap: \
167 echo((___##VAR##_).toMap()); \
175 #define T_ECHOEX(VAR) \
177 auto ___##VAR##_ = variant(QLatin1String(#VAR)); \
178 int ___##VAR##_type = (___##VAR##_).typeId(); \
179 switch (___##VAR##_type) { \
180 case QMetaType::QJsonValue: \
181 echo((___##VAR##_).toJsonValue()); \
183 case QMetaType::QJsonObject: \
184 echo((___##VAR##_).toJsonObject()); \
186 case QMetaType::QJsonArray: \
187 echo((___##VAR##_).toJsonArray()); \
189 case QMetaType::QJsonDocument: \
190 echo((___##VAR##_).toJsonDocument()); \
192 case QMetaType::QVariantMap: \
193 echo((___##VAR##_).toMap()); \
203 #define techoex(VAR) T_ECHOEX(VAR)
205 #define T_ECHOEX_V(VAR, DEFAULT) \
207 auto ___##VAR##_ = variant(QLatin1String(#VAR)); \
208 if ((___##VAR##_).isNull()) { \
215 #define techoexv(VAR, DEFAULT) T_ECHOEX_V(VAR, DEFAULT)
218 #define T_ECHOEX2(VAR, DEFAULT) T_ECHOEX_V(VAR, DEFAULT)
219 #define techoex2(VAR, DEFAULT) T_ECHOEX2(VAR, DEFAULT)
221 #define T_FLASH(VAR) \
223 QVariant ___##VAR##_; \
224 ___##VAR##_.setValue(VAR); \
225 Tf::currentController()->setFlash(QLatin1String(#VAR), (___##VAR##_)); \
228 #define tflash(VAR) T_FLASH(VAR)
230 #define T_VARIANT(VAR) (variant(QLatin1String(#VAR)).toString())
233 #define tFatal TDebug(Tf::FatalLevel).fatal
234 #define tError TDebug(Tf::ErrorLevel).error
235 #define tWarn TDebug(Tf::WarnLevel).warn
236 #define tInfo TDebug(Tf::InfoLevel).info
237 #define tDebug TDebug(Tf::DebugLevel).debug
238 #define tTrace TDebug(Tf::TraceLevel).trace
241 #if QT_VERSION < 0x060000
256 #include <functional>
260 class TActionContext;
262 class TAbstractActionContext;
294 inline
bool strcmp(const QByteArray &str1, const QByteArray &str2)
296 return str1.length() == str2.length() && !std::strncmp(str1.data(), str2.data(), str1.length());
299 constexpr
auto CR =
"\x0d";
300 constexpr
auto LF =
"\x0a";
301 constexpr
auto CRLF =
"\x0d\x0a";
The TAbstractController class is the abstract base class of controllers, providing functionality comm...
Definition: tabstractcontroller.h:13
The TCache class stores items so that can be served faster.
Definition: tcache.h:7
The TDatabaseContext class is the base class of contexts for database access.
Definition: tdatabasecontext.h:11
The TWebApplication class provides an event loop for TreeFrog applications.
Definition: twebapplication.h:23
The Tf namespace contains miscellaneous identifiers used throughout the library of TreeFrog Framework...
Definition: tdebug.h:10
constexpr auto CRLF
Definition: tglobal.h:301
T_CORE_EXPORT QByteArray lz4Compress(const char *data, int nbytes, int compressionLevel=1) noexcept
Definition: tglobal.cpp:190
constexpr auto CRLFCRLF
Definition: tglobal.h:302
T_CORE_EXPORT const QVariantMap & conf(const QString &configName) noexcept
Returns the map associated with config file configName in 'conf' directory.
Definition: tglobal.cpp:57
constexpr auto WriteOnly
Definition: tglobal.h:246
T_CORE_EXPORT uint64_t random(uint64_t min, uint64_t max) noexcept
Random number generator in the range from min to max.
Definition: tglobal.cpp:98
T_CORE_EXPORT TWebApplication * app() noexcept
Returns a global pointer referring to the unique application object.
Definition: tglobal.cpp:40
bool strcmp(const QByteArray &str1, const QByteArray &str2)
Definition: tglobal.h:294
T_CORE_EXPORT TDatabaseContext * currentDatabaseContext()
Definition: tglobal.cpp:143
constexpr auto CR
Definition: tglobal.h:299
T_CORE_EXPORT QByteArray lz4Uncompress(const char *data, int nbytes) noexcept
Definition: tglobal.cpp:246
T_CORE_EXPORT QMap< QByteArray, std::function< QObject *()> > * objectFactories() noexcept
Definition: tglobal.cpp:183
T_CORE_EXPORT uint32_t rand32_r() noexcept
Definition: tglobal.cpp:78
T_CORE_EXPORT int64_t getMSecsSinceEpoch()
Definition: tglobal.cpp:295
T_CORE_EXPORT void msleep(int64_t msecs) noexcept
Causes the current thread to sleep for msecs milliseconds.
Definition: tglobal.cpp:65
constexpr auto LF
Definition: tglobal.h:300
T_CORE_EXPORT QSqlDatabase & currentSqlDatabase(int id) noexcept
Definition: tglobal.cpp:177
T_CORE_EXPORT TAbstractController * currentController()
Definition: tglobal.cpp:122
T_CORE_EXPORT TAppSettings * appSettings() noexcept
Returns a global pointer referring to the unique application settings object.
Definition: tglobal.cpp:48
constexpr auto ReadOnly
Definition: tglobal.h:245
T_CORE_EXPORT uint64_t rand64_r() noexcept
Definition: tglobal.cpp:87
T_CORE_EXPORT TCache * cache() noexcept
Definition: tglobal.cpp:116
const TAbstractController * constCurrentController()
Definition: tglobal.h:283
#define T_CORE_EXPORT
Definition: tdeclexport.h:28
constexpr auto TF_SRC_REVISION
Definition: tglobal.h:4
constexpr auto TF_VERSION_NUMBER
Definition: tglobal.h:3
constexpr auto TF_VERSION_STR
Definition: tglobal.h:2