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
afe45713
Unverified
Commit
afe45713
authored
7 years ago
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup + some noexcept
parent
b182308e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
35 deletions
+28
-35
develop/detail/iterators/iteration_proxy.hpp
develop/detail/iterators/iteration_proxy.hpp
+1
-1
develop/detail/iterators/primitive_iterator.hpp
develop/detail/iterators/primitive_iterator.hpp
+15
-23
develop/detail/macro_scope.hpp
develop/detail/macro_scope.hpp
+1
-3
develop/json.hpp
develop/json.hpp
+11
-8
No files found.
develop/detail/iterators/iteration_proxy.hpp
View file @
afe45713
...
@@ -79,7 +79,7 @@ template<typename IteratorType> class iteration_proxy
...
@@ -79,7 +79,7 @@ template<typename IteratorType> class iteration_proxy
public:
public:
/// construct iteration proxy from a container
/// construct iteration proxy from a container
explicit
iteration_proxy
(
typename
IteratorType
::
reference
cont
)
explicit
iteration_proxy
(
typename
IteratorType
::
reference
cont
)
noexcept
:
container
(
cont
)
{}
:
container
(
cont
)
{}
/// return iterator begin (needed for range-based for)
/// return iterator begin (needed for range-based for)
...
...
This diff is collapsed.
Click to expand it.
develop/detail/iterators/primitive_iterator.hpp
View file @
afe45713
#pragma once
#pragma once
#include <ciso646> // not
#include <cstddef> // ptrdiff_t
#include <cstddef> // ptrdiff_t
#include <limits> // numeric_limits
#include <limits> // numeric_limits
#include <ostream> // ostream
namespace
nlohmann
namespace
nlohmann
{
{
...
@@ -20,9 +18,15 @@ end_value (`1`) models past the end.
...
@@ -20,9 +18,15 @@ end_value (`1`) models past the end.
*/
*/
class
primitive_iterator_t
class
primitive_iterator_t
{
{
p
ublic
:
p
rivate
:
using
difference_type
=
std
::
ptrdiff_t
;
using
difference_type
=
std
::
ptrdiff_t
;
static
constexpr
difference_type
begin_value
=
0
;
static
constexpr
difference_type
end_value
=
begin_value
+
1
;
/// iterator as signed integer type
difference_type
m_it
=
(
std
::
numeric_limits
<
std
::
ptrdiff_t
>::
min
)();
public:
constexpr
difference_type
get_value
()
const
noexcept
constexpr
difference_type
get_value
()
const
noexcept
{
{
return
m_it
;
return
m_it
;
...
@@ -62,10 +66,10 @@ class primitive_iterator_t
...
@@ -62,10 +66,10 @@ class primitive_iterator_t
return
lhs
.
m_it
<
rhs
.
m_it
;
return
lhs
.
m_it
<
rhs
.
m_it
;
}
}
primitive_iterator_t
operator
+
(
difference_type
i
)
primitive_iterator_t
operator
+
(
difference_type
n
)
noexcept
{
{
auto
result
=
*
this
;
auto
result
=
*
this
;
result
+=
i
;
result
+=
n
;
return
result
;
return
result
;
}
}
...
@@ -74,55 +78,43 @@ class primitive_iterator_t
...
@@ -74,55 +78,43 @@ class primitive_iterator_t
return
lhs
.
m_it
-
rhs
.
m_it
;
return
lhs
.
m_it
-
rhs
.
m_it
;
}
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
primitive_iterator_t
it
)
primitive_iterator_t
&
operator
++
()
noexcept
{
return
os
<<
it
.
m_it
;
}
primitive_iterator_t
&
operator
++
()
{
{
++
m_it
;
++
m_it
;
return
*
this
;
return
*
this
;
}
}
primitive_iterator_t
const
operator
++
(
int
)
primitive_iterator_t
const
operator
++
(
int
)
noexcept
{
{
auto
result
=
*
this
;
auto
result
=
*
this
;
m_it
++
;
m_it
++
;
return
result
;
return
result
;
}
}
primitive_iterator_t
&
operator
--
()
primitive_iterator_t
&
operator
--
()
noexcept
{
{
--
m_it
;
--
m_it
;
return
*
this
;
return
*
this
;
}
}
primitive_iterator_t
const
operator
--
(
int
)
primitive_iterator_t
const
operator
--
(
int
)
noexcept
{
{
auto
result
=
*
this
;
auto
result
=
*
this
;
m_it
--
;
m_it
--
;
return
result
;
return
result
;
}
}
primitive_iterator_t
&
operator
+=
(
difference_type
n
)
primitive_iterator_t
&
operator
+=
(
difference_type
n
)
noexcept
{
{
m_it
+=
n
;
m_it
+=
n
;
return
*
this
;
return
*
this
;
}
}
primitive_iterator_t
&
operator
-=
(
difference_type
n
)
primitive_iterator_t
&
operator
-=
(
difference_type
n
)
noexcept
{
{
m_it
-=
n
;
m_it
-=
n
;
return
*
this
;
return
*
this
;
}
}
private:
static
constexpr
difference_type
begin_value
=
0
;
static
constexpr
difference_type
end_value
=
begin_value
+
1
;
/// iterator as signed integer type
difference_type
m_it
=
(
std
::
numeric_limits
<
std
::
ptrdiff_t
>::
min
)();
};
};
}
}
}
}
This diff is collapsed.
Click to expand it.
develop/detail/macro_scope.hpp
View file @
afe45713
#pragma once
#pragma once
#include <ciso646> // not
// This file contains all internal macro definitions
// This file contains all internal macro definitions
// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them
// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them
...
@@ -38,7 +36,7 @@
...
@@ -38,7 +36,7 @@
#endif
#endif
// allow to disable exceptions
// allow to disable exceptions
#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) &&
not
defined(JSON_NOEXCEPTION)
#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) &&
!
defined(JSON_NOEXCEPTION)
#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)
...
...
This diff is collapsed.
Click to expand it.
develop/json.hpp
View file @
afe45713
...
@@ -1301,7 +1301,7 @@ class basic_json
...
@@ -1301,7 +1301,7 @@ class basic_json
array
=
create
<
array_t
>
(
std
::
move
(
value
));
array
=
create
<
array_t
>
(
std
::
move
(
value
));
}
}
void
destroy
(
value_t
t
)
void
destroy
(
value_t
t
)
noexcept
{
{
switch
(
t
)
switch
(
t
)
{
{
...
@@ -1346,7 +1346,7 @@ class basic_json
...
@@ -1346,7 +1346,7 @@ class basic_json
value is changed, because the invariant expresses a relationship between
value is changed, because the invariant expresses a relationship between
@a m_type and @a m_value.
@a m_type and @a m_value.
*/
*/
void
assert_invariant
()
const
void
assert_invariant
()
const
noexcept
{
{
assert
(
m_type
!=
value_t
::
object
or
m_value
.
object
!=
nullptr
);
assert
(
m_type
!=
value_t
::
object
or
m_value
.
object
!=
nullptr
);
assert
(
m_type
!=
value_t
::
array
or
m_value
.
array
!=
nullptr
);
assert
(
m_type
!=
value_t
::
array
or
m_value
.
array
!=
nullptr
);
...
@@ -2140,7 +2140,7 @@ class basic_json
...
@@ -2140,7 +2140,7 @@ class basic_json
@since version 1.0.0
@since version 1.0.0
*/
*/
~
basic_json
()
~
basic_json
()
noexcept
{
{
assert_invariant
();
assert_invariant
();
m_value
.
destroy
(
m_type
);
m_value
.
destroy
(
m_type
);
...
@@ -4481,7 +4481,7 @@ class basic_json
...
@@ -4481,7 +4481,7 @@ class basic_json
@note The name of this function is not yet final and may change in the
@note The name of this function is not yet final and may change in the
future.
future.
*/
*/
static
iteration_proxy
<
iterator
>
iterator_wrapper
(
reference
ref
)
static
iteration_proxy
<
iterator
>
iterator_wrapper
(
reference
ref
)
noexcept
{
{
return
iteration_proxy
<
iterator
>
(
ref
);
return
iteration_proxy
<
iterator
>
(
ref
);
}
}
...
@@ -4489,7 +4489,7 @@ class basic_json
...
@@ -4489,7 +4489,7 @@ class basic_json
/*!
/*!
@copydoc iterator_wrapper(reference)
@copydoc iterator_wrapper(reference)
*/
*/
static
iteration_proxy
<
const_iterator
>
iterator_wrapper
(
const_reference
ref
)
static
iteration_proxy
<
const_iterator
>
iterator_wrapper
(
const_reference
ref
)
noexcept
{
{
return
iteration_proxy
<
const_iterator
>
(
ref
);
return
iteration_proxy
<
const_iterator
>
(
ref
);
}
}
...
@@ -4531,7 +4531,8 @@ class basic_json
...
@@ -4531,7 +4531,8 @@ class basic_json
@endcode
@endcode
@note When iterating over an array, `key()` will return the index of the
@note When iterating over an array, `key()` will return the index of the
element as string (see example).
element as string (see example). For primitive types (e.g., numbers),
`key()` returns an empty string.
@return iteration proxy object wrapping @a ref with an interface to use in
@return iteration proxy object wrapping @a ref with an interface to use in
range-based for loops
range-based for loops
...
@@ -4542,8 +4543,10 @@ class basic_json
...
@@ -4542,8 +4543,10 @@ class basic_json
changes in the JSON value.
changes in the JSON value.
@complexity Constant.
@complexity Constant.
@since version 3.x.x.
*/
*/
iteration_proxy
<
iterator
>
items
()
iteration_proxy
<
iterator
>
items
()
noexcept
{
{
return
iteration_proxy
<
iterator
>
(
*
this
);
return
iteration_proxy
<
iterator
>
(
*
this
);
}
}
...
@@ -4551,7 +4554,7 @@ class basic_json
...
@@ -4551,7 +4554,7 @@ class basic_json
/*!
/*!
@copydoc items()
@copydoc items()
*/
*/
iteration_proxy
<
const_iterator
>
items
()
const
iteration_proxy
<
const_iterator
>
items
()
const
noexcept
{
{
return
iteration_proxy
<
const_iterator
>
(
*
this
);
return
iteration_proxy
<
const_iterator
>
(
*
this
);
}
}
...
...
This diff is collapsed.
Click to expand it.
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