[add] Add SAFE_TYPEDEF

Former-commit-id: 06c78091b4
This commit is contained in:
Leroy.H.Y 2019-11-27 20:35:37 +08:00
parent 268c56a6eb
commit 834dca8bf8
2 changed files with 20 additions and 3 deletions

View File

@ -1 +1 @@
934
936

View File

@ -71,13 +71,30 @@
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
#define SAFE_TYPEDEF(Base, name) \
class name : public Base { \
public: \
template <class... Args> \
explicit name (Args... args) : Base(args...) {} \
const Base& raw() const { return *this; } \
};
namespace Qv2ray
{
// To prevent anonying QJsonObject misuse
SAFE_TYPEDEF(QJsonObject, INBOUND)
SAFE_TYPEDEF(QJsonObject, OUTBOUND)
SAFE_TYPEDEF(QJsonObject, ROOT)
SAFE_TYPEDEF(QJsonArray, OUTBOUNDS)
SAFE_TYPEDEF(QJsonArray, INBOUNDS)
SAFE_TYPEDEF(QJsonArray, ROUTING)
SAFE_TYPEDEF(QJsonObject, ROUTERULE)
//
// Extra header for QvConfigUpgrade.cpp
QJsonObject UpgradeConfig(int fromVersion, int toVersion, QJsonObject root);
struct QvBarLine {
string Family;
string Family;
bool Bold;
bool Italic;
int ColorA;
@ -86,7 +103,7 @@ namespace Qv2ray
int ColorB;
int ContentType;
double Size;
string Message;
string Message;
QvBarLine()
: Family("Consolas")
, Bold(true)