From 322fece4cdb97f834c3c13b7bb3157ba6e4fa449 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 11 Dec 2017 12:04:28 +0300 Subject: parameters unification between JSON & HTTP --- include/m_json.h | 8 +++++++- include/m_system_cpp.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/m_json.h b/include/m_json.h index d63c6184e4..dfbc293022 100644 --- a/include/m_json.h +++ b/include/m_json.h @@ -126,6 +126,8 @@ LIBJSON_DLL(JSONNode*) json_pop_back(JSONNode *node, const char *name); //comparison LIBJSON_DLL(int) json_equal(JSONNode *node, JSONNode *node2); +} + #ifdef __cplusplus class JSONROOT @@ -142,7 +144,11 @@ public: __forceinline JSONNode* Parse(LPCSTR text) { return (m_node = json_parse(text)); } }; -} +LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const INT_PARAM ¶m); +LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const INT64_PARAM ¶m); +LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const BOOL_PARAM ¶m); +LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const CHAR_PARAM ¶m); +LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const WCHAR_PARAM ¶m); #endif // __cplusplus diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index be7c6ff84f..e26ef5a3de 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -319,6 +319,56 @@ public: void remove(size_t sz); }; +/////////////////////////////////////////////////////////////////////////////// +// parameter classes for XML, JSON & HTTP requests + +struct PARAM +{ + const char *szName; + __forceinline PARAM(const char *_name) : szName(_name) + {} +}; + +struct BOOL_PARAM : public PARAM +{ + bool bValue; + __forceinline BOOL_PARAM(const char *_name, bool _value) : + PARAM(_name), bValue(_value) + {} +}; + +struct INT_PARAM : public PARAM +{ + int32_t iValue; + __forceinline INT_PARAM(const char *_name, int32_t _value) : + PARAM(_name), iValue(_value) + {} +}; + +struct INT64_PARAM : public PARAM +{ + int64_t iValue; + __forceinline INT64_PARAM(const char *_name, int64_t _value) : + PARAM(_name), iValue(_value) + {} +}; + +struct CHAR_PARAM : public PARAM +{ + const char *szValue; + __forceinline CHAR_PARAM(const char *_name, const char *_value) : + PARAM(_name), szValue(_value) + {} +}; + +struct WCHAR_PARAM : public PARAM +{ + const wchar_t *wszValue; + __forceinline WCHAR_PARAM(const char *_name, const wchar_t *_value) : + PARAM(_name), wszValue(_value) + {} +}; + #endif #endif // M_SYSTEM_CPP_H -- cgit v1.2.3