summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-26 11:22:59 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-26 11:22:59 +0000
commit06ad3075a2f5743dcd8be2305dfa6a459f54c5e3 (patch)
treea265720ac87f6dbb73f7ef3cb2fdf0d5d20020a8
parent0abc2a0018c17277a27e64ef7d76566441d8071d (diff)
JSONNode::as_mstring() -> a safe way to read strings in Unicode directly from json
git-svn-id: http://svn.miranda-ng.org/main/trunk@13845 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--bin10/lib/mir_core.libbin386636 -> 387088 bytes
-rw-r--r--bin10/lib/mir_core64.libbin389806 -> 390262 bytes
-rw-r--r--bin12/lib/mir_core.libbin386636 -> 387088 bytes
-rw-r--r--bin12/lib/mir_core64.libbin389806 -> 390262 bytes
-rw-r--r--src/mir_core/src/json/JSONNode.h36
-rw-r--r--src/mir_core/src/json/internalJSONNode.h6
-rw-r--r--src/mir_core/src/mir_core.def1
-rw-r--r--src/mir_core/src/mir_core64.def1
8 files changed, 34 insertions, 10 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib
index 152201b2e1..300d38d115 100644
--- a/bin10/lib/mir_core.lib
+++ b/bin10/lib/mir_core.lib
Binary files differ
diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib
index c9532340ca..fa853c7ade 100644
--- a/bin10/lib/mir_core64.lib
+++ b/bin10/lib/mir_core64.lib
Binary files differ
diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib
index 152201b2e1..300d38d115 100644
--- a/bin12/lib/mir_core.lib
+++ b/bin12/lib/mir_core.lib
Binary files differ
diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib
index c9532340ca..fa853c7ade 100644
--- a/bin12/lib/mir_core64.lib
+++ b/bin12/lib/mir_core64.lib
Binary files differ
diff --git a/src/mir_core/src/json/JSONNode.h b/src/mir_core/src/json/JSONNode.h
index 0812a70b71..93ca2dd2cd 100644
--- a/src/mir_core/src/json/JSONNode.h
+++ b/src/mir_core/src/json/JSONNode.h
@@ -114,6 +114,7 @@ public:
#endif
json_string as_string(void) const;
+ CMString as_mstring(void) const;
long as_int(void) const;
double as_float(void) const;
bool as_bool(void) const;
@@ -479,19 +480,23 @@ inline JSONNode::JSONNode(char mytype) : internal(internalJSONNode::newInternal(
(mytype == JSON_NODE), JSON_TEXT("Not a proper JSON type"));
incAllocCount();
}
-inline JSONNode::JSONNode(const JSONNode & orig): internal(orig.internal -> incRef()) {
+inline JSONNode::JSONNode(const JSONNode & orig): internal(orig.internal -> incRef())
+{
incAllocCount();
}
//this allows a temp node to simply transfer its contents, even with ref counting off
-inline JSONNode::JSONNode(bool, JSONNode & orig): internal(orig.internal){
+inline JSONNode::JSONNode(bool, JSONNode & orig): internal(orig.internal)
+{
orig.internal = 0;
incAllocCount();
}
-inline JSONNode::~JSONNode(void){
+inline JSONNode::~JSONNode(void)
+{
if (internal) decRef();
decAllocCount();
}
-inline json_index_t JSONNode::size(void) const {
+inline json_index_t JSONNode::size(void) const
+{
JSON_CHECK_INTERNAL();
return internal -> size();
}
@@ -526,13 +531,15 @@ inline const json_char* JSONNode::name(void) const
JSON_CHECK_INTERNAL();
return internal -> name();
}
-inline void JSONNode::set_name(const json_string & newname){
+inline void JSONNode::set_name(const json_string & newname)
+{
JSON_CHECK_INTERNAL();
makeUniqueInternal();
internal -> setname(newname);
}
#ifdef JSON_COMMENTS
- inline void JSONNode::set_comment(const json_string & newname){
+ inline void JSONNode::set_comment(const json_string & newname)
+ {
JSON_CHECK_INTERNAL();
makeUniqueInternal();
internal -> setcomment(newname);
@@ -542,11 +549,18 @@ inline void JSONNode::set_name(const json_string & newname){
return internal -> getcomment();
}
#endif
-inline json_string JSONNode::as_string(void) const {
+inline json_string JSONNode::as_string(void) const
+{
JSON_CHECK_INTERNAL();
return internal -> as_string();
}
-inline long JSONNode::as_int(void) const {
+inline CMString JSONNode::as_mstring(void) const
+{
+ JSON_CHECK_INTERNAL();
+ return internal->as_mstring();
+}
+inline long JSONNode::as_int(void) const
+{
JSON_CHECK_INTERNAL();
return internal -> as_int();
}
@@ -569,10 +583,12 @@ inline bool JSONNode::as_bool(void) const {
return JSONBase64::json_decode64(as_string());
}
#endif
-inline JSONNode & JSONNode::operator[](const json_char *name_t) {
+inline JSONNode & JSONNode::operator[](const json_char *name_t)
+{
return at(name_t);
}
-inline const JSONNode & JSONNode::operator[](const json_char *name_t) const {
+inline const JSONNode & JSONNode::operator[](const json_char *name_t) const
+{
return at(name_t);
}
#ifdef JSON_LIBRARY
diff --git a/src/mir_core/src/json/internalJSONNode.h b/src/mir_core/src/json/internalJSONNode.h
index cf626ceae0..6d857d3cd1 100644
--- a/src/mir_core/src/json/internalJSONNode.h
+++ b/src/mir_core/src/json/internalJSONNode.h
@@ -88,6 +88,7 @@ public:
json_string getcomment(void) const;
#endif
json_string as_string(void) const;
+ CMString as_mstring(void) const;
long as_int(void) const;
json_number as_float(void) const;
bool as_bool(void) const;
@@ -288,6 +289,11 @@ inline json_string internalJSONNode::as_string(void) const {
return _string;
}
+inline CMString internalJSONNode::as_mstring(void) const {
+ Fetch();
+ return CMString(ptrT(mir_utf8decodeT(_string.c_str())));
+}
+
inline long internalJSONNode::as_int(void) const {
Fetch();
switch(type()) {
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 58bbb59e16..ef180d7bdd 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1241,3 +1241,4 @@ Proto_RegisterModule @1074 NONAME
?write_formatted@JSONNode@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @1244 NONAME
?isnull@JSONNode@@QBE_NXZ @1245 NONAME
??BJSONNode@@QBE_NXZ @1246 NONAME
+?as_mstring@JSONNode@@QBE?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@XZ @1247 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index 699e984893..c75553762f 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1241,3 +1241,4 @@ Proto_RegisterModule @1074 NONAME
?write_formatted@JSONNode@@QEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @1244 NONAME
?isnull@JSONNode@@QEBA_NXZ @1245 NONAME
??BJSONNode@@QEBA_NXZ @1246 NONAME
+?as_mstring@JSONNode@@QEBA?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@XZ @1247 NONAME