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
c833b22b
Commit
c833b22b
authored
Jan 07, 2017
by
Théo DELRIEU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move type_name outside of basic_json, make it a friend
parent
d359684f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
40 deletions
+46
-40
json.hpp
src/json.hpp
+23
-20
json.hpp.re2c
src/json.hpp.re2c
+23
-20
No files found.
src/json.hpp
View file @
c833b22b
...
...
@@ -181,6 +181,27 @@ using is_unscoped_enum =
namespace
detail
{
template
<
typename
Json
>
std
::
string
type_name
(
Json
const
&
j
)
{
switch
(
j
.
m_type
)
{
case
value_t
:
:
null
:
return
"null"
;
case
value_t
:
:
object
:
return
"object"
;
case
value_t
:
:
array
:
return
"array"
;
case
value_t
:
:
string
:
return
"string"
;
case
value_t
:
:
boolean
:
return
"boolean"
;
case
value_t
:
:
discarded
:
return
"discarded"
;
default
:
return
"number"
;
}
}
// very useful construct against boilerplate (more boilerplate needed than in
// C++17: http://en.cppreference.com/w/cpp/types/void_t)
template
<
typename
...
>
struct
make_void
...
...
@@ -585,6 +606,7 @@ template <
class
basic_json
{
private
:
template
<
typename
Json
>
friend
std
::
string
detail
::
type_name
(
Json
const
&
);
/// workaround type for MSVC
using
basic_json_t
=
basic_json
<
ObjectType
,
ArrayType
,
StringType
,
BooleanType
,
NumberIntegerType
,
NumberUnsignedType
,
NumberFloatType
,
...
...
@@ -8129,26 +8151,7 @@ class basic_json
@since version 1.0.0
*/
std
::
string
type_name
()
const
{
switch
(
m_type
)
{
case
value_t
:
:
null
:
return
"null"
;
case
value_t
:
:
object
:
return
"object"
;
case
value_t
:
:
array
:
return
"array"
;
case
value_t
:
:
string
:
return
"string"
;
case
value_t
:
:
boolean
:
return
"boolean"
;
case
value_t
:
:
discarded
:
return
"discarded"
;
default
:
return
"number"
;
}
}
std
::
string
type_name
()
const
{
return
detail
::
type_name
(
*
this
);
}
private
:
/*!
...
...
src/json.hpp.re2c
View file @
c833b22b
...
...
@@ -181,6 +181,27 @@ using is_unscoped_enum =
namespace detail
{
template <typename Json> std::string type_name(Json const &j)
{
switch (j.m_type)
{
case value_t::null:
return "null";
case value_t::object:
return "object";
case value_t::array:
return "array";
case value_t::string:
return "string";
case value_t::boolean:
return "boolean";
case value_t::discarded:
return "discarded";
default:
return "number";
}
}
// very useful construct against boilerplate (more boilerplate needed than in
// C++17: http://en.cppreference.com/w/cpp/types/void_t)
template <typename...> struct make_void
...
...
@@ -586,6 +607,7 @@ template <
class basic_json
{
private:
template <typename Json> friend std::string detail::type_name(Json const &);
/// workaround type for MSVC
using basic_json_t = basic_json<ObjectType, ArrayType, StringType,
BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType,
...
...
@@ -8127,26 +8149,7 @@ class basic_json
@since version 1.0.0
*/
std::string type_name() const
{
switch (m_type)
{
case value_t::null:
return "null";
case value_t::object:
return "object";
case value_t::array:
return "array";
case value_t::string:
return "string";
case value_t::boolean:
return "boolean";
case value_t::discarded:
return "discarded";
default:
return "number";
}
}
std::string type_name() const { return detail::type_name(*this); }
private:
/*!
...
...
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