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
5b1f69ce
Commit
5b1f69ce
authored
Dec 28, 2014
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+ overworked comments
parent
45b101d2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
249 deletions
+0
-249
JSON.cc
src/JSON.cc
+0
-249
No files found.
src/JSON.cc
View file @
5b1f69ce
...
@@ -38,8 +38,6 @@ Construct an empty JSON given the type.
...
@@ -38,8 +38,6 @@ Construct an empty JSON given the type.
@param t the type from the @ref JSON::type enumeration.
@param t the type from the @ref JSON::type enumeration.
@post Memory for array, object, and string are allocated.
@post Memory for array, object, and string are allocated.
@test Tested in block "Basics" for every type.
*/
*/
JSON
::
JSON
(
const
value_type
t
)
noexcept
JSON
::
JSON
(
const
value_type
t
)
noexcept
:
_type
(
t
)
:
_type
(
t
)
...
@@ -85,8 +83,6 @@ JSON::JSON(const value_type t) noexcept
...
@@ -85,8 +83,6 @@ JSON::JSON(const value_type t) noexcept
/*!
/*!
Construct a null JSON object.
Construct a null JSON object.
@test Tested in block "Create from value" for "null".
*/
*/
JSON
::
JSON
(
std
::
nullptr_t
)
noexcept
:
JSON
()
JSON
::
JSON
(
std
::
nullptr_t
)
noexcept
:
JSON
()
{}
{}
...
@@ -95,72 +91,43 @@ JSON::JSON(std::nullptr_t) noexcept : JSON()
...
@@ -95,72 +91,43 @@ JSON::JSON(std::nullptr_t) noexcept : JSON()
Construct a string JSON object.
Construct a string JSON object.
@param s a string to initialize the JSON object with
@param s a string to initialize the JSON object with
@test Tested in block "Create from value" for "string".
*/
*/
JSON
::
JSON
(
const
std
::
string
&
s
)
noexcept
JSON
::
JSON
(
const
std
::
string
&
s
)
noexcept
:
_type
(
value_type
::
string
),
_value
(
new
string_t
(
s
))
:
_type
(
value_type
::
string
),
_value
(
new
string_t
(
s
))
{}
{}
/*!
@test Tested in block "Create from value" for "string".
*/
JSON
::
JSON
(
std
::
string
&&
s
)
noexcept
JSON
::
JSON
(
std
::
string
&&
s
)
noexcept
:
_type
(
value_type
::
string
),
_value
(
new
string_t
(
std
::
move
(
s
)))
:
_type
(
value_type
::
string
),
_value
(
new
string_t
(
std
::
move
(
s
)))
{}
{}
/*!
@test Tested in block "Create from value" for "string".
*/
JSON
::
JSON
(
const
char
*
s
)
noexcept
JSON
::
JSON
(
const
char
*
s
)
noexcept
:
_type
(
value_type
::
string
),
_value
(
new
string_t
(
s
))
:
_type
(
value_type
::
string
),
_value
(
new
string_t
(
s
))
{}
{}
/*!
@test Tested in block "Create from value" for "boolean".
*/
JSON
::
JSON
(
const
bool
b
)
noexcept
JSON
::
JSON
(
const
bool
b
)
noexcept
:
_type
(
value_type
::
boolean
),
_value
(
b
)
:
_type
(
value_type
::
boolean
),
_value
(
b
)
{}
{}
/*!
@test Tested in block "Create from value" for "number (int)".
*/
JSON
::
JSON
(
const
int
i
)
noexcept
JSON
::
JSON
(
const
int
i
)
noexcept
:
_type
(
value_type
::
number
),
_value
(
i
)
:
_type
(
value_type
::
number
),
_value
(
i
)
{}
{}
/*!
@test Tested in block "Create from value" for "number (float)".
*/
JSON
::
JSON
(
const
double
f
)
noexcept
JSON
::
JSON
(
const
double
f
)
noexcept
:
_type
(
value_type
::
number_float
),
_value
(
f
)
:
_type
(
value_type
::
number_float
),
_value
(
f
)
{}
{}
/*!
@test Tested in block "Create from value" for "array".
*/
JSON
::
JSON
(
const
array_t
&
a
)
noexcept
JSON
::
JSON
(
const
array_t
&
a
)
noexcept
:
_type
(
value_type
::
array
),
_value
(
new
array_t
(
a
))
:
_type
(
value_type
::
array
),
_value
(
new
array_t
(
a
))
{}
{}
/*!
@test Tested in block "Create from value" for "array".
*/
JSON
::
JSON
(
array_t
&&
a
)
noexcept
JSON
::
JSON
(
array_t
&&
a
)
noexcept
:
_type
(
value_type
::
array
),
_value
(
new
array_t
(
std
::
move
(
a
)))
:
_type
(
value_type
::
array
),
_value
(
new
array_t
(
std
::
move
(
a
)))
{}
{}
/*!
@test Tested in block "Create from value" for "array".
*/
JSON
::
JSON
(
const
object_t
&
o
)
noexcept
JSON
::
JSON
(
const
object_t
&
o
)
noexcept
:
_type
(
value_type
::
object
),
_value
(
new
object_t
(
o
))
:
_type
(
value_type
::
object
),
_value
(
new
object_t
(
o
))
{}
{}
/*!
@test Tested in block "Create from value" for "array".
*/
JSON
::
JSON
(
object_t
&&
o
)
noexcept
JSON
::
JSON
(
object_t
&&
o
)
noexcept
:
_type
(
value_type
::
object
),
_value
(
new
object_t
(
std
::
move
(
o
)))
:
_type
(
value_type
::
object
),
_value
(
new
object_t
(
std
::
move
(
o
)))
{}
{}
...
@@ -181,9 +148,6 @@ as is to create an array.
...
@@ -181,9 +148,6 @@ as is to create an array.
first element is again an arrays as array.
first element is again an arrays as array.
@todo Create test case for described bug.
@todo Create test case for described bug.
@test Tested in block "Create from value" for "array".
@test Tested in block "Create from value" for "object".
*/
*/
JSON
::
JSON
(
list_init_t
a
)
noexcept
JSON
::
JSON
(
list_init_t
a
)
noexcept
{
{
...
@@ -217,8 +181,6 @@ JSON::JSON(list_init_t a) noexcept
...
@@ -217,8 +181,6 @@ JSON::JSON(list_init_t a) noexcept
A copy constructor for the JSON class.
A copy constructor for the JSON class.
@param o the JSON object to copy
@param o the JSON object to copy
@test Tested in block "Basics" for every type.
*/
*/
JSON
::
JSON
(
const
JSON
&
o
)
noexcept
JSON
::
JSON
(
const
JSON
&
o
)
noexcept
:
_type
(
o
.
_type
)
:
_type
(
o
.
_type
)
...
@@ -268,8 +230,6 @@ A move constructor for the JSON class.
...
@@ -268,8 +230,6 @@ A move constructor for the JSON class.
@param o the JSON object to move
@param o the JSON object to move
@post The JSON object \p o is invalidated.
@post The JSON object \p o is invalidated.
@test Tested in block "Basics" for every type.
*/
*/
JSON
::
JSON
(
JSON
&&
o
)
noexcept
JSON
::
JSON
(
JSON
&&
o
)
noexcept
:
_type
(
std
::
move
(
o
.
_type
)),
_value
(
std
::
move
(
o
.
_value
))
:
_type
(
std
::
move
(
o
.
_type
)),
_value
(
std
::
move
(
o
.
_value
))
...
@@ -283,8 +243,6 @@ A copy assignment operator for the JSON class, following the copy-and-swap
...
@@ -283,8 +243,6 @@ A copy assignment operator for the JSON class, following the copy-and-swap
idiom.
idiom.
@param o A JSON object to assign to this object.
@param o A JSON object to assign to this object.
@test Tested in block "Basics" for every type.
*/
*/
JSON
&
JSON
::
operator
=
(
JSON
o
)
noexcept
JSON
&
JSON
::
operator
=
(
JSON
o
)
noexcept
{
{
...
@@ -293,9 +251,6 @@ JSON& JSON::operator=(JSON o) noexcept
...
@@ -293,9 +251,6 @@ JSON& JSON::operator=(JSON o) noexcept
return
*
this
;
return
*
this
;
}
}
/*!
@test Tested in block "Basics" for every type.
*/
JSON
::~
JSON
()
noexcept
JSON
::~
JSON
()
noexcept
{
{
switch
(
_type
)
switch
(
_type
)
...
@@ -340,8 +295,6 @@ JSON JSON::parse(std::string& s)
...
@@ -340,8 +295,6 @@ JSON JSON::parse(std::string& s)
/*!
/*!
@param s a string representation of a JSON object
@param s a string representation of a JSON object
@return a JSON object
@return a JSON object
@test Teste in block "Parser" for every type.
*/
*/
JSON
JSON
::
parse
(
const
char
*
s
)
JSON
JSON
::
parse
(
const
char
*
s
)
{
{
...
@@ -351,9 +304,6 @@ JSON JSON::parse(const char* s)
...
@@ -351,9 +304,6 @@ JSON JSON::parse(const char* s)
}
}
/*!
@test Tested in block "Basics" for every type.
*/
const
std
::
string
JSON
::
_typename
()
const
noexcept
const
std
::
string
JSON
::
_typename
()
const
noexcept
{
{
switch
(
_type
)
switch
(
_type
)
...
@@ -397,8 +347,6 @@ const std::string JSON::_typename() const noexcept
...
@@ -397,8 +347,6 @@ const std::string JSON::_typename() const noexcept
/*!
/*!
@exception std::logic_error if the function is called for JSON objects whose
@exception std::logic_error if the function is called for JSON objects whose
type is not string
type is not string
@test Tested in block "Basics" for every type (including exceptions).
*/
*/
template
<>
template
<>
std
::
string
JSON
::
get
()
const
std
::
string
JSON
::
get
()
const
...
@@ -415,8 +363,6 @@ std::string JSON::get() const
...
@@ -415,8 +363,6 @@ std::string JSON::get() const
/*!
/*!
@exception std::logic_error if the function is called for JSON objects whose
@exception std::logic_error if the function is called for JSON objects whose
type is not number (int or float)
type is not number (int or float)
@test Tested in block "Basics" for every type (including exceptions).
*/
*/
template
<>
template
<>
int
JSON
::
get
()
const
int
JSON
::
get
()
const
...
@@ -435,8 +381,6 @@ int JSON::get() const
...
@@ -435,8 +381,6 @@ int JSON::get() const
/*!
/*!
@exception std::logic_error if the function is called for JSON objects whose
@exception std::logic_error if the function is called for JSON objects whose
type is not number (int or float)
type is not number (int or float)
@test Tested in block "Basics" for every type (including exceptions).
*/
*/
template
<>
template
<>
double
JSON
::
get
()
const
double
JSON
::
get
()
const
...
@@ -455,8 +399,6 @@ double JSON::get() const
...
@@ -455,8 +399,6 @@ double JSON::get() const
/*!
/*!
@exception std::logic_error if the function is called for JSON objects whose
@exception std::logic_error if the function is called for JSON objects whose
type is not boolean
type is not boolean
@test Tested in block "Basics" for every type (including exceptions).
*/
*/
template
<>
template
<>
bool
JSON
::
get
()
const
bool
JSON
::
get
()
const
...
@@ -473,8 +415,6 @@ bool JSON::get() const
...
@@ -473,8 +415,6 @@ bool JSON::get() const
/*!
/*!
@exception std::logic_error if the function is called for JSON objects whose
@exception std::logic_error if the function is called for JSON objects whose
type is an object
type is an object
@test Tested in block "Basics" for every type (including exceptions).
*/
*/
template
<>
template
<>
JSON
::
array_t
JSON
::
get
()
const
JSON
::
array_t
JSON
::
get
()
const
...
@@ -496,8 +436,6 @@ JSON::array_t JSON::get() const
...
@@ -496,8 +436,6 @@ JSON::array_t JSON::get() const
/*!
/*!
@exception std::logic_error if the function is called for JSON objects whose
@exception std::logic_error if the function is called for JSON objects whose
type is not object
type is not object
@test Tested in block "Basics" for every type (including exceptions).
*/
*/
template
<>
template
<>
JSON
::
object_t
JSON
::
get
()
const
JSON
::
object_t
JSON
::
get
()
const
...
@@ -512,60 +450,36 @@ JSON::object_t JSON::get() const
...
@@ -512,60 +450,36 @@ JSON::object_t JSON::get() const
}
}
}
}
/*!
@test Tested in block "Basics" for every type.
*/
JSON
::
operator
const
std
::
string
()
const
JSON
::
operator
const
std
::
string
()
const
{
{
return
get
<
std
::
string
>
();
return
get
<
std
::
string
>
();
}
}
/*!
@test Tested in block "Basics" for every type.
@test Tested in block "Create from value" for "number (int)".
*/
JSON
::
operator
int
()
const
JSON
::
operator
int
()
const
{
{
return
get
<
int
>
();
return
get
<
int
>
();
}
}
/*!
@test Tested in block "Basics" for every type.
@test Tested in block "Create from value" for "number (float)".
*/
JSON
::
operator
double
()
const
JSON
::
operator
double
()
const
{
{
return
get
<
double
>
();
return
get
<
double
>
();
}
}
/*!
@test Tested in block "Basics" for every type.
@test Tested in block "Create from value" for "boolean".
*/
JSON
::
operator
bool
()
const
JSON
::
operator
bool
()
const
{
{
return
get
<
bool
>
();
return
get
<
bool
>
();
}
}
/*!
@test Tested in block "Basics" for every type.
*/
JSON
::
operator
array_t
()
const
JSON
::
operator
array_t
()
const
{
{
return
get
<
array_t
>
();
return
get
<
array_t
>
();
}
}
/*!
@test Tested in block "Basics" for every type.
*/
JSON
::
operator
object_t
()
const
JSON
::
operator
object_t
()
const
{
{
return
get
<
object_t
>
();
return
get
<
object_t
>
();
}
}
/*!
@test Tested in block "Basics" for every type.
*/
const
std
::
string
JSON
::
toString
()
const
noexcept
const
std
::
string
JSON
::
toString
()
const
noexcept
{
{
switch
(
_type
)
switch
(
_type
)
...
@@ -634,45 +548,30 @@ const std::string JSON::toString() const noexcept
...
@@ -634,45 +548,30 @@ const std::string JSON::toString() const noexcept
// ADDING ELEMENTS TO OBJECTS AND ARRAYS //
// ADDING ELEMENTS TO OBJECTS AND ARRAYS //
///////////////////////////////////////////
///////////////////////////////////////////
/*!
@test Tested in block "Array operators" for "array".
*/
JSON
&
JSON
::
operator
+=
(
const
JSON
&
o
)
JSON
&
JSON
::
operator
+=
(
const
JSON
&
o
)
{
{
push_back
(
o
);
push_back
(
o
);
return
*
this
;
return
*
this
;
}
}
/*!
@test Tested in block "Array operators" for "array".
*/
JSON
&
JSON
::
operator
+=
(
const
std
::
string
&
s
)
JSON
&
JSON
::
operator
+=
(
const
std
::
string
&
s
)
{
{
push_back
(
JSON
(
s
));
push_back
(
JSON
(
s
));
return
*
this
;
return
*
this
;
}
}
/*!
@test Tested in block "Array operators" for "array".
*/
JSON
&
JSON
::
operator
+=
(
const
char
*
s
)
JSON
&
JSON
::
operator
+=
(
const
char
*
s
)
{
{
push_back
(
JSON
(
s
));
push_back
(
JSON
(
s
));
return
*
this
;
return
*
this
;
}
}
/*!
@test Tested in block "Array operators" for "array".
*/
JSON
&
JSON
::
operator
+=
(
std
::
nullptr_t
)
JSON
&
JSON
::
operator
+=
(
std
::
nullptr_t
)
{
{
push_back
(
JSON
());
push_back
(
JSON
());
return
*
this
;
return
*
this
;
}
}
/*!
@test Tested in block "Array operators" for "array".
*/
JSON
&
JSON
::
operator
+=
(
bool
b
)
JSON
&
JSON
::
operator
+=
(
bool
b
)
{
{
push_back
(
JSON
(
b
));
push_back
(
JSON
(
b
));
...
@@ -684,8 +583,6 @@ Adds a number (int) to the current object. This is done by wrapping the number
...
@@ -684,8 +583,6 @@ Adds a number (int) to the current object. This is done by wrapping the number
into a JSON and call push_back for this.
into a JSON and call push_back for this.
@param i A number (int) to add to the array.
@param i A number (int) to add to the array.
@test Tested in block "Array operators" for "array".
*/
*/
JSON
&
JSON
::
operator
+=
(
int
i
)
JSON
&
JSON
::
operator
+=
(
int
i
)
{
{
...
@@ -698,8 +595,6 @@ Adds a number (float) to the current object. This is done by wrapping the
...
@@ -698,8 +595,6 @@ Adds a number (float) to the current object. This is done by wrapping the
number into a JSON and call push_back for this.
number into a JSON and call push_back for this.
@param f A number (float) to add to the array.
@param f A number (float) to add to the array.
@test Tested in block "Array operators" for "array".
*/
*/
JSON
&
JSON
::
operator
+=
(
double
f
)
JSON
&
JSON
::
operator
+=
(
double
f
)
{
{
...
@@ -737,8 +632,6 @@ an array, the passed element is added to the array.
...
@@ -737,8 +632,6 @@ an array, the passed element is added to the array.
does not support addition to an array (e.g., int or string).
does not support addition to an array (e.g., int or string).
@note Null objects are silently transformed into an array before the addition.
@note Null objects are silently transformed into an array before the addition.
@test Tested in block "Array operators" for "array".
*/
*/
void
JSON
::
push_back
(
const
JSON
&
o
)
void
JSON
::
push_back
(
const
JSON
&
o
)
{
{
...
@@ -776,8 +669,6 @@ an array, the passed element is added to the array using move semantics.
...
@@ -776,8 +669,6 @@ an array, the passed element is added to the array using move semantics.
@note Null objects are silently transformed into an array before the addition.
@note Null objects are silently transformed into an array before the addition.
@note This function applies move semantics for the given element.
@note This function applies move semantics for the given element.
@test Tested in block "Array operators" for "array".
*/
*/
void
JSON
::
push_back
(
JSON
&&
o
)
void
JSON
::
push_back
(
JSON
&&
o
)
{
{
...
@@ -800,33 +691,21 @@ void JSON::push_back(JSON&& o)
...
@@ -800,33 +691,21 @@ void JSON::push_back(JSON&& o)
_value
.
array
->
emplace_back
(
std
::
move
(
o
));
_value
.
array
->
emplace_back
(
std
::
move
(
o
));
}
}
/*!
@test Tested in block "Array operators" for "array".
*/
void
JSON
::
push_back
(
const
std
::
string
&
s
)
void
JSON
::
push_back
(
const
std
::
string
&
s
)
{
{
push_back
(
JSON
(
s
));
push_back
(
JSON
(
s
));
}
}
/*!
@test Tested in block "Array operators" for "array".
*/
void
JSON
::
push_back
(
const
char
*
s
)
void
JSON
::
push_back
(
const
char
*
s
)
{
{
push_back
(
JSON
(
s
));
push_back
(
JSON
(
s
));
}
}
/*!
@test Tested in block "Array operators" for "array".
*/
void
JSON
::
push_back
(
std
::
nullptr_t
)
void
JSON
::
push_back
(
std
::
nullptr_t
)
{
{
push_back
(
JSON
());
push_back
(
JSON
());
}
}
/*!
@test Tested in block "Array operators" for "array".
*/
void
JSON
::
push_back
(
bool
b
)
void
JSON
::
push_back
(
bool
b
)
{
{
push_back
(
JSON
(
b
));
push_back
(
JSON
(
b
));
...
@@ -837,8 +716,6 @@ Adds a number (int) to the current object. This is done by wrapping the number
...
@@ -837,8 +716,6 @@ Adds a number (int) to the current object. This is done by wrapping the number
into a JSON and call push_back for this.
into a JSON and call push_back for this.
@param i A number (int) to add to the array.
@param i A number (int) to add to the array.
@test Tested in block "Array operators" for "array".
*/
*/
void
JSON
::
push_back
(
int
i
)
void
JSON
::
push_back
(
int
i
)
{
{
...
@@ -850,8 +727,6 @@ Adds a number (float) to the current object. This is done by wrapping the
...
@@ -850,8 +727,6 @@ Adds a number (float) to the current object. This is done by wrapping the
number into a JSON and call push_back for this.
number into a JSON and call push_back for this.
@param f A number (float) to add to the array.
@param f A number (float) to add to the array.
@test Tested in block "Array operators" for "array".
*/
*/
void
JSON
::
push_back
(
double
f
)
void
JSON
::
push_back
(
double
f
)
{
{
...
@@ -919,8 +794,6 @@ index. Bounds will not be checked.
...
@@ -919,8 +794,6 @@ index. Bounds will not be checked.
@pre Object is an array.
@pre Object is an array.
@exception std::domain_error if object is not an array
@exception std::domain_error if object is not an array
@test Tested in block "Array operators" for "array" (including exceptions).
*/
*/
JSON
&
JSON
::
operator
[](
const
int
index
)
JSON
&
JSON
::
operator
[](
const
int
index
)
{
{
...
@@ -952,8 +825,6 @@ index. Bounds will not be checked.
...
@@ -952,8 +825,6 @@ index. Bounds will not be checked.
@pre Object is an array.
@pre Object is an array.
@exception std::domain_error if object is not an array
@exception std::domain_error if object is not an array
@test Tested in block "Array operators" for "array" (including exceptions).
*/
*/
const
JSON
&
JSON
::
operator
[](
const
int
index
)
const
const
JSON
&
JSON
::
operator
[](
const
int
index
)
const
{
{
...
@@ -984,8 +855,6 @@ index. Bounds will be checked.
...
@@ -984,8 +855,6 @@ index. Bounds will be checked.
@pre Object is an array.
@pre Object is an array.
@exception std::domain_error if object is not an array
@exception std::domain_error if object is not an array
@exception std::out_of_range if index is out of range (via std::vector::at)
@exception std::out_of_range if index is out of range (via std::vector::at)
@test Tested in block "Array operators" for "array" (including exceptions).
*/
*/
JSON
&
JSON
::
at
(
const
int
index
)
JSON
&
JSON
::
at
(
const
int
index
)
{
{
...
@@ -1018,8 +887,6 @@ index. Bounds will be checked.
...
@@ -1018,8 +887,6 @@ index. Bounds will be checked.
@pre Object is an array.
@pre Object is an array.
@exception std::domain_error if object is not an array
@exception std::domain_error if object is not an array
@exception std::out_of_range if index is out of range (via std::vector::at)
@exception std::out_of_range if index is out of range (via std::vector::at)
@test Tested in block "Array operators" for "array" (including exceptions).
*/
*/
const
JSON
&
JSON
::
at
(
const
int
index
)
const
const
JSON
&
JSON
::
at
(
const
int
index
)
const
{
{
...
@@ -1193,8 +1060,6 @@ Returns the size of the JSON object.
...
@@ -1193,8 +1060,6 @@ Returns the size of the JSON object.
string), and 0 for null.
string), and 0 for null.
@invariant The size is reported as 0 if and only if empty() would return true.
@invariant The size is reported as 0 if and only if empty() would return true.
@test Tested in block "Basics" for every type.
*/
*/
size_t
JSON
::
size
()
const
noexcept
size_t
JSON
::
size
()
const
noexcept
{
{
...
@@ -1230,8 +1095,6 @@ Returns whether a JSON object is empty.
...
@@ -1230,8 +1095,6 @@ Returns whether a JSON object is empty.
(array and object).
(array and object).
@invariant Empty would report true if and only if size() would return 0.
@invariant Empty would report true if and only if size() would return 0.
@test Tested in block "Basics" for every type.
*/
*/
bool
JSON
::
empty
()
const
noexcept
bool
JSON
::
empty
()
const
noexcept
{
{
...
@@ -1309,33 +1172,21 @@ void JSON::clear() noexcept
...
@@ -1309,33 +1172,21 @@ void JSON::clear() noexcept
}
}
}
}
/*!
@test Tested in block "Basics" for every type.
*/
JSON
::
value_type
JSON
::
type
()
const
noexcept
JSON
::
value_type
JSON
::
type
()
const
noexcept
{
{
return
_type
;
return
_type
;
}
}
/*!
@test Tested in block "Object operators" for "object".
*/
JSON
::
iterator
JSON
::
find
(
const
std
::
string
&
key
)
JSON
::
iterator
JSON
::
find
(
const
std
::
string
&
key
)
{
{
return
find
(
key
.
c_str
());
return
find
(
key
.
c_str
());
}
}
/*!
@test Tested in block "Object operators" for "object".
*/
JSON
::
const_iterator
JSON
::
find
(
const
std
::
string
&
key
)
const
JSON
::
const_iterator
JSON
::
find
(
const
std
::
string
&
key
)
const
{
{
return
find
(
key
.
c_str
());
return
find
(
key
.
c_str
());
}
}
/*!
@test Tested in block "Object operators" for "object".
*/
JSON
::
iterator
JSON
::
find
(
const
char
*
key
)
JSON
::
iterator
JSON
::
find
(
const
char
*
key
)
{
{
if
(
_type
!=
value_type
::
object
)
if
(
_type
!=
value_type
::
object
)
...
@@ -1358,9 +1209,6 @@ JSON::iterator JSON::find(const char* key)
...
@@ -1358,9 +1209,6 @@ JSON::iterator JSON::find(const char* key)
}
}
}
}
/*!
@test Tested in block "Object operators" for "object".
*/
JSON
::
const_iterator
JSON
::
find
(
const
char
*
key
)
const
JSON
::
const_iterator
JSON
::
find
(
const
char
*
key
)
const
{
{
if
(
_type
!=
value_type
::
object
)
if
(
_type
!=
value_type
::
object
)
...
@@ -1385,25 +1233,17 @@ JSON::const_iterator JSON::find(const char* key) const
...
@@ -1385,25 +1233,17 @@ JSON::const_iterator JSON::find(const char* key) const
/*!
/*!
@return the payload of the JSON object.
@return the payload of the JSON object.
@test Tested in block "Basics" for every type.
*/
*/
JSON
::
value
JSON
::
data
()
noexcept
JSON
::
value
JSON
::
data
()
noexcept
{
{
return
_value
;
return
_value
;
}
}
/*!
@test Tested in block "Basics" for every type.
*/
const
JSON
::
value
JSON
::
data
()
const
noexcept
const
JSON
::
value
JSON
::
data
()
const
noexcept
{
{
return
_value
;
return
_value
;
}
}
/*!
@test Tested in block "Basics" for every type.
*/
bool
JSON
::
operator
==
(
const
JSON
&
o
)
const
noexcept
bool
JSON
::
operator
==
(
const
JSON
&
o
)
const
noexcept
{
{
switch
(
_type
)
switch
(
_type
)
...
@@ -1483,55 +1323,31 @@ bool JSON::operator!=(const JSON& o) const noexcept
...
@@ -1483,55 +1323,31 @@ bool JSON::operator!=(const JSON& o) const noexcept
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
JSON
::
iterator
JSON
::
begin
()
noexcept
JSON
::
iterator
JSON
::
begin
()
noexcept
{
{
return
JSON
::
iterator
(
this
);
return
JSON
::
iterator
(
this
);
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
JSON
::
iterator
JSON
::
end
()
noexcept
JSON
::
iterator
JSON
::
end
()
noexcept
{
{
return
JSON
::
iterator
();
return
JSON
::
iterator
();
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
JSON
::
const_iterator
JSON
::
begin
()
const
noexcept
JSON
::
const_iterator
JSON
::
begin
()
const
noexcept
{
{
return
JSON
::
const_iterator
(
this
);
return
JSON
::
const_iterator
(
this
);
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
JSON
::
const_iterator
JSON
::
end
()
const
noexcept
JSON
::
const_iterator
JSON
::
end
()
const
noexcept
{
{
return
JSON
::
const_iterator
();
return
JSON
::
const_iterator
();
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
JSON
::
const_iterator
JSON
::
cbegin
()
const
noexcept
JSON
::
const_iterator
JSON
::
cbegin
()
const
noexcept
{
{
return
JSON
::
const_iterator
(
this
);
return
JSON
::
const_iterator
(
this
);
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
JSON
::
const_iterator
JSON
::
cend
()
const
noexcept
JSON
::
const_iterator
JSON
::
cend
()
const
noexcept
{
{
return
JSON
::
const_iterator
();
return
JSON
::
const_iterator
();
...
@@ -1596,10 +1412,6 @@ JSON::iterator::~iterator()
...
@@ -1596,10 +1412,6 @@ JSON::iterator::~iterator()
delete
_oi
;
delete
_oi
;
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
JSON
::
iterator
&
JSON
::
iterator
::
operator
=
(
JSON
::
iterator
o
)
JSON
::
iterator
&
JSON
::
iterator
::
operator
=
(
JSON
::
iterator
o
)
{
{
std
::
swap
(
_object
,
o
.
_object
);
std
::
swap
(
_object
,
o
.
_object
);
...
@@ -1608,10 +1420,6 @@ JSON::iterator& JSON::iterator::operator=(JSON::iterator o)
...
@@ -1608,10 +1420,6 @@ JSON::iterator& JSON::iterator::operator=(JSON::iterator o)
return
*
this
;
return
*
this
;
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Object operators" for "object".
*/
bool
JSON
::
iterator
::
operator
==
(
const
JSON
::
iterator
&
o
)
const
bool
JSON
::
iterator
::
operator
==
(
const
JSON
::
iterator
&
o
)
const
{
{
if
(
_object
!=
o
.
_object
)
if
(
_object
!=
o
.
_object
)
...
@@ -1651,20 +1459,11 @@ bool JSON::iterator::operator==(const JSON::iterator& o) const
...
@@ -1651,20 +1459,11 @@ bool JSON::iterator::operator==(const JSON::iterator& o) const
return
true
;
return
true
;
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Object operators" for "object".
@test Tested in block "Iterators" for "object".
*/
bool
JSON
::
iterator
::
operator
!=
(
const
JSON
::
iterator
&
o
)
const
bool
JSON
::
iterator
::
operator
!=
(
const
JSON
::
iterator
&
o
)
const
{
{
return
not
operator
==
(
o
);
return
not
operator
==
(
o
);
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
JSON
::
iterator
&
JSON
::
iterator
::
operator
++
()
JSON
::
iterator
&
JSON
::
iterator
::
operator
++
()
{
{
// iterator cannot be incremented
// iterator cannot be incremented
...
@@ -1703,10 +1502,6 @@ JSON::iterator& JSON::iterator::operator++()
...
@@ -1703,10 +1502,6 @@ JSON::iterator& JSON::iterator::operator++()
return
*
this
;
return
*
this
;
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
JSON
&
JSON
::
iterator
::
operator
*
()
const
JSON
&
JSON
::
iterator
::
operator
*
()
const
{
{
if
(
_object
==
nullptr
)
if
(
_object
==
nullptr
)
...
@@ -1735,10 +1530,6 @@ JSON& JSON::iterator::operator*() const
...
@@ -1735,10 +1530,6 @@ JSON& JSON::iterator::operator*() const
}
}
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
JSON
*
JSON
::
iterator
::
operator
->
()
const
JSON
*
JSON
::
iterator
::
operator
->
()
const
{
{
if
(
_object
==
nullptr
)
if
(
_object
==
nullptr
)
...
@@ -1767,10 +1558,6 @@ JSON* JSON::iterator::operator->() const
...
@@ -1767,10 +1558,6 @@ JSON* JSON::iterator::operator->() const
}
}
}
}
/*!
@test Tested in block "Object operators" for "object".
@test Tested in block "Iterators" for "object".
*/
std
::
string
JSON
::
iterator
::
key
()
const
std
::
string
JSON
::
iterator
::
key
()
const
{
{
if
(
_object
!=
nullptr
and
_object
->
_type
==
value_type
::
object
)
if
(
_object
!=
nullptr
and
_object
->
_type
==
value_type
::
object
)
...
@@ -1783,10 +1570,6 @@ std::string JSON::iterator::key() const
...
@@ -1783,10 +1570,6 @@ std::string JSON::iterator::key() const
}
}
}
}
/*!
@test Tested in block "Object operators" for "object".
@test Tested in block "Iterators" for "object".
*/
JSON
&
JSON
::
iterator
::
value
()
const
JSON
&
JSON
::
iterator
::
value
()
const
{
{
if
(
_object
==
nullptr
)
if
(
_object
==
nullptr
)
...
@@ -1900,10 +1683,6 @@ JSON::const_iterator::~const_iterator()
...
@@ -1900,10 +1683,6 @@ JSON::const_iterator::~const_iterator()
delete
_oi
;
delete
_oi
;
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
JSON
::
const_iterator
&
JSON
::
const_iterator
::
operator
=
(
JSON
::
const_iterator
o
)
JSON
::
const_iterator
&
JSON
::
const_iterator
::
operator
=
(
JSON
::
const_iterator
o
)
{
{
std
::
swap
(
_object
,
o
.
_object
);
std
::
swap
(
_object
,
o
.
_object
);
...
@@ -1912,10 +1691,6 @@ JSON::const_iterator& JSON::const_iterator::operator=(JSON::const_iterator o)
...
@@ -1912,10 +1691,6 @@ JSON::const_iterator& JSON::const_iterator::operator=(JSON::const_iterator o)
return
*
this
;
return
*
this
;
}
}
/*!
@test Tested in block "Object operators" for "object".
@test Tested in block "Iterators" for "object".
*/
bool
JSON
::
const_iterator
::
operator
==
(
const
JSON
::
const_iterator
&
o
)
const
bool
JSON
::
const_iterator
::
operator
==
(
const
JSON
::
const_iterator
&
o
)
const
{
{
if
(
_object
!=
o
.
_object
)
if
(
_object
!=
o
.
_object
)
...
@@ -1955,19 +1730,11 @@ bool JSON::const_iterator::operator==(const JSON::const_iterator& o) const
...
@@ -1955,19 +1730,11 @@ bool JSON::const_iterator::operator==(const JSON::const_iterator& o) const
return
true
;
return
true
;
}
}
/*!
@test Tested in block "Object operators" for "object".
@test Tested in block "Iterators" for "object".
*/
bool
JSON
::
const_iterator
::
operator
!=
(
const
JSON
::
const_iterator
&
o
)
const
bool
JSON
::
const_iterator
::
operator
!=
(
const
JSON
::
const_iterator
&
o
)
const
{
{
return
not
operator
==
(
o
);
return
not
operator
==
(
o
);
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
JSON
::
const_iterator
&
JSON
::
const_iterator
::
operator
++
()
JSON
::
const_iterator
&
JSON
::
const_iterator
::
operator
++
()
{
{
// iterator cannot be incremented
// iterator cannot be incremented
...
@@ -2006,10 +1773,6 @@ JSON::const_iterator& JSON::const_iterator::operator++()
...
@@ -2006,10 +1773,6 @@ JSON::const_iterator& JSON::const_iterator::operator++()
return
*
this
;
return
*
this
;
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
const
JSON
&
JSON
::
const_iterator
::
operator
*
()
const
const
JSON
&
JSON
::
const_iterator
::
operator
*
()
const
{
{
if
(
_object
==
nullptr
)
if
(
_object
==
nullptr
)
...
@@ -2038,10 +1801,6 @@ const JSON& JSON::const_iterator::operator*() const
...
@@ -2038,10 +1801,6 @@ const JSON& JSON::const_iterator::operator*() const
}
}
}
}
/*!
@test Tested in block "Iterators" for "array".
@test Tested in block "Iterators" for "object".
*/
const
JSON
*
JSON
::
const_iterator
::
operator
->
()
const
const
JSON
*
JSON
::
const_iterator
::
operator
->
()
const
{
{
if
(
_object
==
nullptr
)
if
(
_object
==
nullptr
)
...
@@ -2070,10 +1829,6 @@ const JSON* JSON::const_iterator::operator->() const
...
@@ -2070,10 +1829,6 @@ const JSON* JSON::const_iterator::operator->() const
}
}
}
}
/*!
@test Tested in block "Object operators" for "object".
@test Tested in block "Iterators" for "object".
*/
std
::
string
JSON
::
const_iterator
::
key
()
const
std
::
string
JSON
::
const_iterator
::
key
()
const
{
{
if
(
_object
!=
nullptr
and
_object
->
_type
==
value_type
::
object
)
if
(
_object
!=
nullptr
and
_object
->
_type
==
value_type
::
object
)
...
@@ -2086,10 +1841,6 @@ std::string JSON::const_iterator::key() const
...
@@ -2086,10 +1841,6 @@ std::string JSON::const_iterator::key() const
}
}
}
}
/*!
@test Tested in block "Object operators" for "object".
@test Tested in block "Iterators" for "object".
*/
const
JSON
&
JSON
::
const_iterator
::
value
()
const
const
JSON
&
JSON
::
const_iterator
::
value
()
const
{
{
if
(
_object
==
nullptr
)
if
(
_object
==
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