summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-25 21:27:35 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-25 21:27:35 +0000
commit80aa9c41fe75efdfdb7ef5a54e51fa6e580ad044 (patch)
treed0f0c44c4f99f01690d1aaed285d2c66363d5f35
parent99bea7a69e782c02d371f94a2988d49d0825fd7e (diff)
JSONNode::isnull() - correct way of checking for missing / erroneous nodes
also can be written as !node git-svn-id: http://svn.miranda-ng.org/main/trunk@13833 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--bin10/lib/mir_core.libbin378898 -> 386636 bytes
-rw-r--r--bin10/lib/mir_core64.libbin389328 -> 389806 bytes
-rw-r--r--bin10/mir_dev.sln13
-rw-r--r--bin12/lib/mir_core.libbin386158 -> 386636 bytes
-rw-r--r--bin12/lib/mir_core64.libbin389318 -> 389806 bytes
-rw-r--r--src/mir_core/src/json/JSONNode.h20
-rw-r--r--src/mir_core/src/json/JSONWorker.cpp4
-rw-r--r--src/mir_core/src/json/libJSON.cpp2
-rw-r--r--src/mir_core/src/mir_core.def2
-rw-r--r--src/mir_core/src/mir_core64.def2
10 files changed, 25 insertions, 18 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib
index 925f7588e0..da334b7bba 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 c08a06e32a..43df2494da 100644
--- a/bin10/lib/mir_core64.lib
+++ b/bin10/lib/mir_core64.lib
Binary files differ
diff --git a/bin10/mir_dev.sln b/bin10/mir_dev.sln
index 73b22dc0ce..61ab220a6a 100644
--- a/bin10/mir_dev.sln
+++ b/bin10/mir_dev.sln
@@ -197,11 +197,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StdFile", "..\src\core\stdf
{D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60} = {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StdUrl", "..\src\core\stdurl\stdurl_10.vcxproj", "{769FAC86-C761-11E1-A66F-0BE76188709B}"
- ProjectSection(ProjectDependencies) = postProject
- {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60} = {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}
- EndProjectSection
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StdAutoAway", "..\src\core\stdautoaway\stdautoaway_10.vcxproj", "{A8F23706-E590-4A87-96CC-5F8E5082503F}"
ProjectSection(ProjectDependencies) = postProject
{D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60} = {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}
@@ -1165,14 +1160,6 @@ Global
{6022990D-3FD5-46A9-8AB5-E444C51646F3}.Release|Win32.Build.0 = Release|Win32
{6022990D-3FD5-46A9-8AB5-E444C51646F3}.Release|x64.ActiveCfg = Release|x64
{6022990D-3FD5-46A9-8AB5-E444C51646F3}.Release|x64.Build.0 = Release|x64
- {769FAC86-C761-11E1-A66F-0BE76188709B}.Debug|Win32.ActiveCfg = Debug|Win32
- {769FAC86-C761-11E1-A66F-0BE76188709B}.Debug|Win32.Build.0 = Debug|Win32
- {769FAC86-C761-11E1-A66F-0BE76188709B}.Debug|x64.ActiveCfg = Debug|x64
- {769FAC86-C761-11E1-A66F-0BE76188709B}.Debug|x64.Build.0 = Debug|x64
- {769FAC86-C761-11E1-A66F-0BE76188709B}.Release|Win32.ActiveCfg = Release|Win32
- {769FAC86-C761-11E1-A66F-0BE76188709B}.Release|Win32.Build.0 = Release|Win32
- {769FAC86-C761-11E1-A66F-0BE76188709B}.Release|x64.ActiveCfg = Release|x64
- {769FAC86-C761-11E1-A66F-0BE76188709B}.Release|x64.Build.0 = Release|x64
{A8F23706-E590-4A87-96CC-5F8E5082503F}.Debug|Win32.ActiveCfg = Debug|Win32
{A8F23706-E590-4A87-96CC-5F8E5082503F}.Debug|Win32.Build.0 = Debug|Win32
{A8F23706-E590-4A87-96CC-5F8E5082503F}.Debug|x64.ActiveCfg = Debug|x64
diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib
index 9ca759ab11..da334b7bba 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 0b502487bb..43df2494da 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 8e415adfe3..01c6ffb405 100644
--- a/src/mir_core/src/json/JSONNode.h
+++ b/src/mir_core/src/json/JSONNode.h
@@ -93,6 +93,7 @@ public:
json_index_t size(void) const;
bool empty(void) const;
+ bool isnull(void) const;
void clear(void);
unsigned char type(void) const;
@@ -135,6 +136,7 @@ public:
JSONNode & at_nocase(const json_string & name_t);
const JSONNode & at_nocase(const json_string & name_t) const;
#endif
+ bool operator!() const;
JSONNode & operator[](const json_char *name_t);
const JSONNode & operator[](const json_char *name_t) const;
#ifdef JSON_LIBRARY
@@ -504,11 +506,23 @@ inline void JSONNode::clear(void){
internal -> Children.clear();
}
}
-inline unsigned char JSONNode::type(void) const {
+inline unsigned char JSONNode::type(void) const
+{
+ JSON_CHECK_INTERNAL();
+ return internal->type();
+}
+inline bool JSONNode::isnull(void) const
+{
JSON_CHECK_INTERNAL();
- return internal -> type();
+ return internal->type() == JSON_NULL;
}
-inline const json_char* JSONNode::name(void) const {
+inline bool JSONNode::operator!() const
+{
+ JSON_CHECK_INTERNAL();
+ return internal->type() == JSON_NULL;
+}
+inline const json_char* JSONNode::name(void) const
+{
JSON_CHECK_INTERNAL();
return internal -> name();
}
diff --git a/src/mir_core/src/json/JSONWorker.cpp b/src/mir_core/src/json/JSONWorker.cpp
index 832a9fee47..516f9095f1 100644
--- a/src/mir_core/src/json/JSONWorker.cpp
+++ b/src/mir_core/src/json/JSONWorker.cpp
@@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JSONWorker.h"
+extern JSONNode nullNode;
+
#ifdef JSON_VALIDATE
JSONNode JSONWorker::validate(const json_string & json){
JSONNode res = parse(json);
@@ -91,7 +93,7 @@ JSONNode JSONWorker::parse(const json_string & json){
}
JSON_FAIL(JSON_TEXT("Not JSON!"));
- throw std::invalid_argument(EMPTY_STRING2);
+ return nullNode;
}
#define QUOTECASE()\
diff --git a/src/mir_core/src/json/libJSON.cpp b/src/mir_core/src/json/libJSON.cpp
index 2a735ec3b4..9b977c259f 100644
--- a/src/mir_core/src/json/libJSON.cpp
+++ b/src/mir_core/src/json/libJSON.cpp
@@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JSONNode.h"
#include "JSONWorker.h"
-#include <stdexcept> //some methods throw exceptions
+
#ifdef JSON_MEMORY_MANAGE
auto_expand StringHandler;
auto_expand_node NodeHandler;
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index ded290235f..8c3473fcc0 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1239,3 +1239,5 @@ Proto_RegisterModule @1074 NONAME
?type@JSONNode@@QBEEXZ @1242 NONAME
?write@JSONNode@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @1243 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
+??7JSONNode@@QBE_NXZ @1246 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index 84b561fc13..70dc985da7 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1239,3 +1239,5 @@ Proto_RegisterModule @1074 NONAME
?type@JSONNode@@QEBAEXZ @1242 NONAME
?write@JSONNode@@QEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @1243 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
+??7JSONNode@@QEBA_NXZ @1246 NONAME