Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
540c5896
Commit
540c5896
authored
Jun 29, 2015
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
closed #91
parent
48c4f4d0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
157 additions
and
36 deletions
+157
-36
src/json.hpp
src/json.hpp
+81
-20
src/json.hpp.re2c
src/json.hpp.re2c
+76
-16
No files found.
src/json.hpp
View file @
540c5896
...
...
@@ -1860,37 +1860,73 @@ class basic_json
}
/// get a pointer to the value (object)
const
object_t
*
get_impl_ptr
(
object_t
*
)
const
noexcept
object_t
*
get_impl_ptr
(
object_t
*
)
noexcept
{
return
is_object
()
?
m_value
.
object
:
nullptr
;
}
/// get a pointer to the value (object)
const
object_t
*
get_impl_ptr
(
const
object_t
*
)
const
noexcept
{
return
is_object
()
?
m_value
.
object
:
nullptr
;
}
/// get a pointer to the value (array)
const
array_t
*
get_impl_ptr
(
array_t
*
)
const
noexcept
array_t
*
get_impl_ptr
(
array_t
*
)
noexcept
{
return
is_array
()
?
m_value
.
array
:
nullptr
;
}
/// get a pointer to the value (array)
const
array_t
*
get_impl_ptr
(
const
array_t
*
)
const
noexcept
{
return
is_array
()
?
m_value
.
array
:
nullptr
;
}
/// get a pointer to the value (string)
string_t
*
get_impl_ptr
(
string_t
*
)
noexcept
{
return
is_string
()
?
m_value
.
string
:
nullptr
;
}
/// get a pointer to the value (string)
const
string_t
*
get_impl_ptr
(
string_t
*
)
const
noexcept
const
string_t
*
get_impl_ptr
(
const
string_t
*
)
const
noexcept
{
return
is_string
()
?
m_value
.
string
:
nullptr
;
}
/// get a pointer to the value (boolean)
const
boolean_t
*
get_impl_ptr
(
boolean_t
*
)
const
noexcept
boolean_t
*
get_impl_ptr
(
boolean_t
*
)
noexcept
{
return
is_boolean
()
?
&
m_value
.
boolean
:
nullptr
;
}
/// get a pointer to the value (boolean)
const
boolean_t
*
get_impl_ptr
(
const
boolean_t
*
)
const
noexcept
{
return
is_boolean
()
?
&
m_value
.
boolean
:
nullptr
;
}
/// get a pointer to the value (integer number)
const
number_integer_t
*
get_impl_ptr
(
number_integer_t
*
)
const
noexcept
number_integer_t
*
get_impl_ptr
(
number_integer_t
*
)
noexcept
{
return
is_number_integer
()
?
&
m_value
.
number_integer
:
nullptr
;
}
/// get a pointer to the value (integer number)
const
number_integer_t
*
get_impl_ptr
(
const
number_integer_t
*
)
const
noexcept
{
return
is_number_integer
()
?
&
m_value
.
number_integer
:
nullptr
;
}
/// get a pointer to the value (floating-point number)
number_float_t
*
get_impl_ptr
(
number_float_t
*
)
noexcept
{
return
is_number_float
()
?
&
m_value
.
number_float
:
nullptr
;
}
/// get a pointer to the value (floating-point number)
const
number_float_t
*
get_impl_ptr
(
number_float_t
*
)
const
noexcept
const
number_float_t
*
get_impl_ptr
(
const
number_float_t
*
)
const
noexcept
{
return
is_number_float
()
?
&
m_value
.
number_float
:
nullptr
;
}
...
...
@@ -1969,7 +2005,21 @@ class basic_json
std
::
enable_if
<
std
::
is_pointer
<
PointerType
>
::
value
,
int
>::
type
=
0
>
PointerType
get
()
const
noexcept
PointerType
get
()
noexcept
{
// delegate the call to get_ptr
return
get_ptr
<
PointerType
>
();
}
/*!
@brief get a pointer value (explicit)
@copydoc get()
*/
template
<
typename
PointerType
,
typename
std
::
enable_if
<
std
::
is_pointer
<
PointerType
>
::
value
,
int
>::
type
=
0
>
const
PointerType
get
()
const
noexcept
{
// delegate the call to get_ptr
return
get_ptr
<
PointerType
>
();
...
...
@@ -2002,15 +2052,25 @@ class basic_json
std
::
enable_if
<
std
::
is_pointer
<
PointerType
>
::
value
,
int
>::
type
=
0
>
PointerType
get_ptr
()
const
noexcept
PointerType
get_ptr
()
noexcept
{
// delegate the call to get_impl_ptr<>()
return
get_impl_ptr
(
static_cast
<
PointerType
>
(
nullptr
));
}
/*!
@brief get a pointer value (implicit)
@copydoc get_ptr()
*/
template
<
typename
PointerType
,
typename
std
::
enable_if
<
std
::
is_pointer
<
PointerType
>
::
value
and
std
::
is_const
<
PointerType
>::
value
,
int
>::
type
=
0
>
const
PointerType
get_ptr
()
const
noexcept
{
// get_impl_ptr will only work with non-const and non-volatile pointer
// types. Therefore, we case away all cv properties to be able to
// select the correct function. The cv properties will then be added
// again by the const const cast to PointerType.
return
const_cast
<
PointerType
>
(
get_impl_ptr
(
static_cast
<
typename
std
::
add_pointer
<
typename
std
::
remove_cv
<
typename
std
::
remove_pointer
<
PointerType
>::
type
>::
type
>::
type
>
(
nullptr
)));
// delegate the call to get_impl_ptr<>() const
return
get_impl_ptr
(
static_cast
<
const
PointerType
>
(
nullptr
));
}
/*!
...
...
@@ -6326,15 +6386,16 @@ basic_json_parser_59:
{
public:
/// constructor for strings
parser
(
const
string_t
&
s
,
parser_callback_t
cb
=
nullptr
)
:
callback
(
cb
),
m_lexer
(
s
)
parser
(
const
string_t
&
s
,
parser_callback_t
cb
=
nullptr
)
:
callback
(
cb
),
m_lexer
(
s
)
{
// read first token
get_token
();
}
/// a parser reading from an input stream
parser
(
std
::
istream
&
_is
,
parser_callback_t
cb
=
nullptr
)
:
callback
(
cb
),
m_lexer
(
&
_is
)
parser
(
std
::
istream
&
_is
,
parser_callback_t
cb
=
nullptr
)
:
callback
(
cb
),
m_lexer
(
&
_is
)
{
// read first token
get_token
();
...
...
@@ -6601,7 +6662,7 @@ basic_json_parser_59:
}
private:
///
levels
of recursion
///
current level
of recursion
int
depth
=
0
;
/// callback function
parser_callback_t
callback
;
...
...
src/json.hpp.re2c
View file @
540c5896
...
...
@@ -1860,37 +1860,73 @@ class basic_json
}
/// get a pointer to the value (object)
const object_t* get_impl_ptr(object_t*) const
noexcept
object_t* get_impl_ptr(object_t*)
noexcept
{
return is_object() ? m_value.object : nullptr;
}
/// get a pointer to the value (object)
const object_t* get_impl_ptr(const object_t*) const noexcept
{
return is_object() ? m_value.object : nullptr;
}
/// get a pointer to the value (array)
array_t* get_impl_ptr(array_t*) noexcept
{
return is_array() ? m_value.array : nullptr;
}
/// get a pointer to the value (array)
const array_t* get_impl_ptr(array_t*) const noexcept
const array_t* get_impl_ptr(
const
array_t*) const noexcept
{
return is_array() ? m_value.array : nullptr;
}
/// get a pointer to the value (string)
const string_t* get_impl_ptr(string_t*) const noexcept
string_t* get_impl_ptr(string_t*) noexcept
{
return is_string() ? m_value.string : nullptr;
}
/// get a pointer to the value (string)
const string_t* get_impl_ptr(const string_t*) const noexcept
{
return is_string() ? m_value.string : nullptr;
}
/// get a pointer to the value (boolean)
const boolean_t* get_impl_ptr(boolean_t*) const noexcept
boolean_t* get_impl_ptr(boolean_t*) noexcept
{
return is_boolean() ? &m_value.boolean : nullptr;
}
/// get a pointer to the value (boolean)
const boolean_t* get_impl_ptr(const boolean_t*) const noexcept
{
return is_boolean() ? &m_value.boolean : nullptr;
}
/// get a pointer to the value (integer number)
const number_integer_t* get_impl_ptr(number_integer_t*) const noexcept
number_integer_t* get_impl_ptr(number_integer_t*) noexcept
{
return is_number_integer() ? &m_value.number_integer : nullptr;
}
/// get a pointer to the value (integer number)
const number_integer_t* get_impl_ptr(const number_integer_t*) const noexcept
{
return is_number_integer() ? &m_value.number_integer : nullptr;
}
/// get a pointer to the value (floating-point number)
const number_float_t* get_impl_ptr(number_float_t*) const noexcept
number_float_t* get_impl_ptr(number_float_t*) noexcept
{
return is_number_float() ? &m_value.number_float : nullptr;
}
/// get a pointer to the value (floating-point number)
const number_float_t* get_impl_ptr(const number_float_t*) const noexcept
{
return is_number_float() ? &m_value.number_float : nullptr;
}
...
...
@@ -1969,7 +2005,21 @@ class basic_json
std::enable_if<
std::is_pointer<PointerType>::value
, int>::type = 0>
PointerType get() const noexcept
PointerType get() noexcept
{
// delegate the call to get_ptr
return get_ptr<PointerType>();
}
/*!
@brief get a pointer value (explicit)
@copydoc get()
*/
template<typename PointerType, typename
std::enable_if<
std::is_pointer<PointerType>::value
, int>::type = 0>
const PointerType get() const noexcept
{
// delegate the call to get_ptr
return get_ptr<PointerType>();
...
...
@@ -2002,15 +2052,25 @@ class basic_json
std::enable_if<
std::is_pointer<PointerType>::value
, int>::type = 0>
PointerType get_ptr() const noexcept
{
// get_impl_ptr will only work with non-const and non-volatile pointer
// types. Therefore, we case away all cv properties to be able to
// select the correct function. The cv properties will then be added
// again by the const const cast to PointerType.
return const_cast<PointerType>(get_impl_ptr(
static_cast<typename std::add_pointer<typename std::remove_cv<typename std::remove_pointer<PointerType>::type>::type>::type>
(nullptr)));
PointerType get_ptr() noexcept
{
// delegate the call to get_impl_ptr<>()
return get_impl_ptr(static_cast<PointerType>(nullptr));
}
/*!
@brief get a pointer value (implicit)
@copydoc get_ptr()
*/
template<typename PointerType, typename
std::enable_if<
std::is_pointer<PointerType>::value
and std::is_const<PointerType>::value
, int>::type = 0>
const PointerType get_ptr() const noexcept
{
// delegate the call to get_impl_ptr<>() const
return get_impl_ptr(static_cast<const PointerType>(nullptr));
}
/*!
...
...
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