summaryrefslogtreecommitdiff
path: root/include/m_netlib.h
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2025-03-30 11:35:03 +0300
committerGeorge Hazan <george.hazan@gmail.com>2025-03-30 11:35:03 +0300
commit7d95e67308ee0abcce5c7bd66265146d3dfefd74 (patch)
tree9c377087518bb53a429151edb6a947fc47e89242 /include/m_netlib.h
parent66821b916cc298111f9e5ddd2684d15ff7909f02 (diff)
useful helper JsonReply moved to the core
Diffstat (limited to 'include/m_netlib.h')
-rw-r--r--include/m_netlib.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/m_netlib.h b/include/m_netlib.h
index 421ca5b05c..71e2696c4f 100644
--- a/include/m_netlib.h
+++ b/include/m_netlib.h
@@ -503,6 +503,20 @@ public:
}
};
+class MIR_APP_EXPORT JsonReply : public MNonCopyable
+{
+ class JSONNode *m_root = nullptr;
+ int m_errorCode = 0;
+
+public:
+ explicit JsonReply(MHttpResponse *response);
+ ~JsonReply();
+
+ __forceinline JSONNode &data() const { return *m_root; }
+ __forceinline int error() const { return m_errorCode; }
+ __forceinline operator bool() const { return m_errorCode == 200; }
+};
+
/////////////////////////////////////////////////////////////////////////////////////////
// Free the memory used by a MHttpRequest structure
//