Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
d0e60de4
Commit
d0e60de4
authored
Jul 19, 2018
by
Hyeon Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new JSON_INTERNAL_CATCH macro function
parent
7bfc406d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
4 deletions
+20
-4
macro_scope.hpp
include/nlohmann/detail/macro_scope.hpp
+7
-0
macro_unscope.hpp
include/nlohmann/detail/macro_unscope.hpp
+1
-0
json.hpp
include/nlohmann/json.hpp
+2
-2
json.hpp
single_include/nlohmann/json.hpp
+10
-2
No files found.
include/nlohmann/detail/macro_scope.hpp
View file @
d0e60de4
...
@@ -42,10 +42,12 @@
...
@@ -42,10 +42,12 @@
#define JSON_THROW(exception) throw exception
#define JSON_THROW(exception) throw exception
#define JSON_TRY try
#define JSON_TRY try
#define JSON_CATCH(exception) catch(exception)
#define JSON_CATCH(exception) catch(exception)
#define JSON_INTERNAL_CATCH(exception) catch(exception)
#else
#else
#define JSON_THROW(exception) std::abort()
#define JSON_THROW(exception) std::abort()
#define JSON_TRY if(true)
#define JSON_TRY if(true)
#define JSON_CATCH(exception) if(false)
#define JSON_CATCH(exception) if(false)
#define JSON_INTERNAL_CATCH(exception) if(false)
#endif
#endif
// override exception macros
// override exception macros
...
@@ -60,6 +62,11 @@
...
@@ -60,6 +62,11 @@
#if defined(JSON_CATCH_USER)
#if defined(JSON_CATCH_USER)
#undef JSON_CATCH
#undef JSON_CATCH
#define JSON_CATCH JSON_CATCH_USER
#define JSON_CATCH JSON_CATCH_USER
#define JSON_INTERNAL_CATCH JSON_CATCH_USER
#endif
#if defined(JSON_INTERNAL_CATCH_USER)
#undef JSON_INTERNAL_CATCH
#define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
#endif
#endif
// manual branch prediction
// manual branch prediction
...
...
include/nlohmann/detail/macro_unscope.hpp
View file @
d0e60de4
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
#endif
#endif
// clean up
// clean up
#undef JSON_INTERNAL_CATCH
#undef JSON_CATCH
#undef JSON_CATCH
#undef JSON_THROW
#undef JSON_THROW
#undef JSON_TRY
#undef JSON_TRY
...
...
include/nlohmann/json.hpp
View file @
d0e60de4
...
@@ -3437,7 +3437,7 @@ class basic_json
...
@@ -3437,7 +3437,7 @@ class basic_json
{
{
return
ptr
.
get_checked
(
this
);
return
ptr
.
get_checked
(
this
);
}
}
JSON_CATCH
(
out_of_range
&
)
JSON_
INTERNAL_
CATCH
(
out_of_range
&
)
{
{
return
default_value
;
return
default_value
;
}
}
...
@@ -7359,7 +7359,7 @@ class basic_json
...
@@ -7359,7 +7359,7 @@ class basic_json
// the "path" location must exist - use at()
// the "path" location must exist - use at()
success
=
(
result
.
at
(
ptr
)
==
get_value
(
"test"
,
"value"
,
false
));
success
=
(
result
.
at
(
ptr
)
==
get_value
(
"test"
,
"value"
,
false
));
}
}
JSON_CATCH
(
out_of_range
&
)
JSON_
INTERNAL_
CATCH
(
out_of_range
&
)
{
{
// ignore out of range errors: success remains false
// ignore out of range errors: success remains false
}
}
...
...
single_include/nlohmann/json.hpp
View file @
d0e60de4
...
@@ -157,10 +157,12 @@ using json = basic_json<>;
...
@@ -157,10 +157,12 @@ using json = basic_json<>;
#define JSON_THROW(exception) throw exception
#define JSON_THROW(exception) throw exception
#define JSON_TRY try
#define JSON_TRY try
#define JSON_CATCH(exception) catch(exception)
#define JSON_CATCH(exception) catch(exception)
#define JSON_INTERNAL_CATCH(exception) catch(exception)
#else
#else
#define JSON_THROW(exception) std::abort()
#define JSON_THROW(exception) std::abort()
#define JSON_TRY if(true)
#define JSON_TRY if(true)
#define JSON_CATCH(exception) if(false)
#define JSON_CATCH(exception) if(false)
#define JSON_INTERNAL_CATCH(exception) if(false)
#endif
#endif
// override exception macros
// override exception macros
...
@@ -175,6 +177,11 @@ using json = basic_json<>;
...
@@ -175,6 +177,11 @@ using json = basic_json<>;
#if defined(JSON_CATCH_USER)
#if defined(JSON_CATCH_USER)
#undef JSON_CATCH
#undef JSON_CATCH
#define JSON_CATCH JSON_CATCH_USER
#define JSON_CATCH JSON_CATCH_USER
#define JSON_INTERNAL_CATCH JSON_CATCH_USER
#endif
#if defined(JSON_INTERNAL_CATCH_USER)
#undef JSON_INTERNAL_CATCH
#define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
#endif
#endif
// manual branch prediction
// manual branch prediction
...
@@ -14272,7 +14279,7 @@ class basic_json
...
@@ -14272,7 +14279,7 @@ class basic_json
{
{
return
ptr
.
get_checked
(
this
);
return
ptr
.
get_checked
(
this
);
}
}
JSON_CATCH
(
out_of_range
&
)
JSON_
INTERNAL_
CATCH
(
out_of_range
&
)
{
{
return
default_value
;
return
default_value
;
}
}
...
@@ -18194,7 +18201,7 @@ class basic_json
...
@@ -18194,7 +18201,7 @@ class basic_json
// the "path" location must exist - use at()
// the "path" location must exist - use at()
success
=
(
result
.
at
(
ptr
)
==
get_value
(
"test"
,
"value"
,
false
));
success
=
(
result
.
at
(
ptr
)
==
get_value
(
"test"
,
"value"
,
false
));
}
}
JSON_CATCH
(
out_of_range
&
)
JSON_
INTERNAL_
CATCH
(
out_of_range
&
)
{
{
// ignore out of range errors: success remains false
// ignore out of range errors: success remains false
}
}
...
@@ -18565,6 +18572,7 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std
...
@@ -18565,6 +18572,7 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std
#endif
#endif
// clean up
// clean up
#undef JSON_INTERNAL_CATCH
#undef JSON_CATCH
#undef JSON_CATCH
#undef JSON_THROW
#undef JSON_THROW
#undef JSON_TRY
#undef JSON_TRY
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment