summaryrefslogtreecommitdiff
path: root/libs/libjson/src/JSONNode.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-06-29 16:06:12 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-06-29 16:06:12 +0000
commit2dad84e37b1ba2d2a0eb5b437031ee594ca43148 (patch)
tree4d71e13d6a2544c33e0a3b9fc237f5b6475cb254 /libs/libjson/src/JSONNode.cpp
parentff585c0bb2301f13bc6e8263077b0aaac209f80b (diff)
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@17046 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'libs/libjson/src/JSONNode.cpp')
-rw-r--r--libs/libjson/src/JSONNode.cpp40
1 files changed, 9 insertions, 31 deletions
diff --git a/libs/libjson/src/JSONNode.cpp b/libs/libjson/src/JSONNode.cpp
index 37e5d4ffe0..9bdc70e7e6 100644
--- a/libs/libjson/src/JSONNode.cpp
+++ b/libs/libjson/src/JSONNode.cpp
@@ -255,46 +255,24 @@ const JSONNode & JSONNode::at(const json_char *name_t) const {
}
#endif
-#ifndef JSON_LIBRARY
- struct auto_delete {
- public:
- auto_delete(JSONNode *node) : mynode(node){};
- ~auto_delete(void){ JSONNode::deleteJSONNode(mynode); };
- JSONNode * mynode;
- private:
- auto_delete(const auto_delete &);
- auto_delete & operator = (const auto_delete &);
- };
-#endif
-
-JSONNode JSON_PTR_LIB JSONNode::pop_back(json_index_t pos){
+JSONNode* JSON_PTR_LIB JSONNode::pop_back(json_index_t pos){
JSON_CHECK_INTERNAL();
if (pos >= internal -> size()) {
JSON_FAIL(JSON_TEXT("pop_back out of bounds"));
- return nullNode;
+ return &nullNode;
}
makeUniqueInternal();
- #ifdef JSON_LIBRARY
- return internal -> pop_back(pos);
- #else
- auto_delete temp(internal -> pop_back(pos));
- return *temp.mynode;
- #endif
+ return internal -> pop_back(pos);
}
-JSONNode JSON_PTR_LIB JSONNode::pop_back(const json_string & name_t){
+JSONNode* JSON_PTR_LIB JSONNode::pop_back(const json_string & name_t){
JSON_CHECK_INTERNAL();
JSON_ASSERT(type() == JSON_NODE, JSON_TEXT("popping a non-iteratable node"));
- #ifdef JSON_LIBRARY
- return internal -> pop_back(name_t);
- #else
- if (JSONNode * res = internal -> pop_back(name_t)) {
- auto_delete temp(res);
- return *(temp.mynode);
- }
- JSON_FAIL(json_string(JSON_TEXT("pop_back const could not find child by name: ")) + name_t);
- return nullNode;
- #endif
+ if (JSONNode *res = internal -> pop_back(name_t))
+ return res;
+
+ JSON_FAIL(json_string(JSON_TEXT("pop_back const could not find child by name: ")) + name_t);
+ return &nullNode;
}
#ifdef JSON_CASE_INSENSITIVE_FUNCTIONS