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
433da313
Unverified
Commit
433da313
authored
Dec 29, 2020
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
⚗
try to use GCC 10
parent
7b98df51
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
73 additions
and
21 deletions
+73
-21
.github/workflows/ubuntu.yml
.github/workflows/ubuntu.yml
+8
-0
.travis.yml
.travis.yml
+0
-10
include/nlohmann/detail/iterators/iter_impl.hpp
include/nlohmann/detail/iterators/iter_impl.hpp
+24
-1
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+24
-1
test/src/unit-class_parser.cpp
test/src/unit-class_parser.cpp
+1
-1
test/src/unit-items.cpp
test/src/unit-items.cpp
+8
-0
test/src/unit-regression1.cpp
test/src/unit-regression1.cpp
+1
-1
test/src/unit-udt.cpp
test/src/unit-udt.cpp
+7
-7
No files found.
.github/workflows/ubuntu.yml
View file @
433da313
...
@@ -8,8 +8,16 @@ jobs:
...
@@ -8,8 +8,16 @@ jobs:
steps
:
steps
:
-
uses
:
actions/checkout@v1
-
uses
:
actions/checkout@v1
-
name
:
install_gcc
run
:
|
sudo apt update
sudo apt install gcc-10 g++-10
shell
:
bash
-
name
:
cmake
-
name
:
cmake
run
:
cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
run
:
cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
env
:
CC
:
gcc-10
CXX
:
g++-10
-
name
:
build
-
name
:
build
run
:
cmake --build build --parallel
10
run
:
cmake --build build --parallel
10
-
name
:
test
-
name
:
test
...
...
.travis.yml
View file @
433da313
...
@@ -300,16 +300,6 @@ matrix:
...
@@ -300,16 +300,6 @@ matrix:
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
llvm-toolchain-trusty-7'
]
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
llvm-toolchain-trusty-7'
]
packages
:
[
'
g++-7'
,
'
clang-7'
,
'
ninja-build'
]
packages
:
[
'
g++-7'
,
'
clang-7'
,
'
ninja-build'
]
-
os
:
linux
compiler
:
clang
env
:
-
COMPILER=clang++-7
-
CXX_STANDARD=20
addons
:
apt
:
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
llvm-toolchain-trusty-7'
]
packages
:
[
'
g++-7'
,
'
clang-7'
,
'
ninja-build'
]
################
################
# build script #
# build script #
################
################
...
...
include/nlohmann/detail/iterators/iter_impl.hpp
View file @
433da313
...
@@ -393,7 +393,30 @@ class iter_impl
...
@@ -393,7 +393,30 @@ class iter_impl
@brief comparison: equal
@brief comparison: equal
@pre The iterator is initialized; i.e. `m_object != nullptr`.
@pre The iterator is initialized; i.e. `m_object != nullptr`.
*/
*/
bool
operator
==
(
const
iter_impl
&
other
)
const
bool
operator
==
(
const
iter_impl
<
const
BasicJsonType
>&
other
)
const
{
// if objects are not the same, the comparison is undefined
if
(
JSON_HEDLEY_UNLIKELY
(
m_object
!=
other
.
m_object
))
{
JSON_THROW
(
invalid_iterator
::
create
(
212
,
"cannot compare iterators of different containers"
));
}
JSON_ASSERT
(
m_object
!=
nullptr
);
switch
(
m_object
->
m_type
)
{
case
value_t
:
:
object
:
return
(
m_it
.
object_iterator
==
other
.
m_it
.
object_iterator
);
case
value_t
:
:
array
:
return
(
m_it
.
array_iterator
==
other
.
m_it
.
array_iterator
);
default:
return
(
m_it
.
primitive_iterator
==
other
.
m_it
.
primitive_iterator
);
}
}
bool
operator
==
(
const
iter_impl
<
typename
std
::
remove_const
<
BasicJsonType
>::
type
>&
other
)
const
{
{
// if objects are not the same, the comparison is undefined
// if objects are not the same, the comparison is undefined
if
(
JSON_HEDLEY_UNLIKELY
(
m_object
!=
other
.
m_object
))
if
(
JSON_HEDLEY_UNLIKELY
(
m_object
!=
other
.
m_object
))
...
...
single_include/nlohmann/json.hpp
View file @
433da313
...
@@ -11279,7 +11279,30 @@ class iter_impl
...
@@ -11279,7 +11279,30 @@ class iter_impl
@brief comparison: equal
@brief comparison: equal
@pre The iterator is initialized; i.e. `m_object != nullptr`.
@pre The iterator is initialized; i.e. `m_object != nullptr`.
*/
*/
bool
operator
==
(
const
iter_impl
&
other
)
const
bool
operator
==
(
const
iter_impl
<
const
BasicJsonType
>&
other
)
const
{
// if objects are not the same, the comparison is undefined
if
(
JSON_HEDLEY_UNLIKELY
(
m_object
!=
other
.
m_object
))
{
JSON_THROW
(
invalid_iterator
::
create
(
212
,
"cannot compare iterators of different containers"
));
}
JSON_ASSERT
(
m_object
!=
nullptr
);
switch
(
m_object
->
m_type
)
{
case
value_t
:
:
object
:
return
(
m_it
.
object_iterator
==
other
.
m_it
.
object_iterator
);
case
value_t
:
:
array
:
return
(
m_it
.
array_iterator
==
other
.
m_it
.
array_iterator
);
default:
return
(
m_it
.
primitive_iterator
==
other
.
m_it
.
primitive_iterator
);
}
}
bool
operator
==
(
const
iter_impl
<
typename
std
::
remove_const
<
BasicJsonType
>::
type
>&
other
)
const
{
{
// if objects are not the same, the comparison is undefined
// if objects are not the same, the comparison is undefined
if
(
JSON_HEDLEY_UNLIKELY
(
m_object
!=
other
.
m_object
))
if
(
JSON_HEDLEY_UNLIKELY
(
m_object
!=
other
.
m_object
))
...
...
test/src/unit-class_parser.cpp
View file @
433da313
...
@@ -509,7 +509,7 @@ TEST_CASE("parser class")
...
@@ -509,7 +509,7 @@ TEST_CASE("parser class")
CHECK
(
parser_helper
(
"
\"
€
\"
"
).
get
<
json
::
string_t
>
()
==
"€"
);
CHECK
(
parser_helper
(
"
\"
€
\"
"
).
get
<
json
::
string_t
>
()
==
"€"
);
CHECK
(
parser_helper
(
"
\"
🎈
\"
"
).
get
<
json
::
string_t
>
()
==
"🎈"
);
CHECK
(
parser_helper
(
"
\"
🎈
\"
"
).
get
<
json
::
string_t
>
()
==
"🎈"
);
CHECK
(
parser_helper
(
"
\"\\
ud80c
\\
udc60
\"
"
).
get
<
json
::
string_t
>
()
==
u8
"\U00013060"
);
CHECK
(
parser_helper
(
"
\"\\
ud80c
\\
udc60
\"
"
).
get
<
json
::
string_t
>
()
==
"\U00013060"
);
CHECK
(
parser_helper
(
"
\"\\
ud83c
\\
udf1e
\"
"
).
get
<
json
::
string_t
>
()
==
"🌞"
);
CHECK
(
parser_helper
(
"
\"\\
ud83c
\\
udf1e
\"
"
).
get
<
json
::
string_t
>
()
==
"🌞"
);
}
}
}
}
...
...
test/src/unit-items.cpp
View file @
433da313
...
@@ -1448,3 +1448,11 @@ TEST_CASE("items()")
...
@@ -1448,3 +1448,11 @@ TEST_CASE("items()")
}
}
}
}
}
}
#ifdef JSON_HAS_CPP_17
#undef JSON_HAS_CPP_17
#endif
#ifdef JSON_HAS_CPP_14
#undef JSON_HAS_CPP_14
#endif
test/src/unit-regression1.cpp
View file @
433da313
...
@@ -400,7 +400,7 @@ TEST_CASE("regression tests 1")
...
@@ -400,7 +400,7 @@ TEST_CASE("regression tests 1")
SECTION
(
"issue #146 - character following a surrogate pair is skipped"
)
SECTION
(
"issue #146 - character following a surrogate pair is skipped"
)
{
{
CHECK
(
json
::
parse
(
"
\"\\
ud80c
\\
udc60abc
\"
"
).
get
<
json
::
string_t
>
()
==
u8
"\U00013060abc"
);
CHECK
(
json
::
parse
(
"
\"\\
ud80c
\\
udc60abc
\"
"
).
get
<
json
::
string_t
>
()
==
"\U00013060abc"
);
}
}
SECTION
(
"issue #171 - Cannot index by key of type static constexpr const char*"
)
SECTION
(
"issue #171 - Cannot index by key of type static constexpr const char*"
)
...
...
test/src/unit-udt.cpp
View file @
433da313
...
@@ -112,13 +112,13 @@ static void to_json(BasicJsonType& j, country c)
...
@@ -112,13 +112,13 @@ static void to_json(BasicJsonType& j, country c)
switch
(
c
)
switch
(
c
)
{
{
case
country
:
:
china
:
case
country
:
:
china
:
j
=
u8
"中华人民共和国"
;
j
=
"中华人民共和国"
;
return
;
return
;
case
country
:
:
france
:
case
country
:
:
france
:
j
=
"France"
;
j
=
"France"
;
return
;
return
;
case
country
:
:
russia
:
case
country
:
:
russia
:
j
=
u8
"Российская Федерация"
;
j
=
"Российская Федерация"
;
return
;
return
;
default:
default:
break
;
break
;
...
@@ -201,9 +201,9 @@ static void from_json(const BasicJsonType& j, country& c)
...
@@ -201,9 +201,9 @@ static void from_json(const BasicJsonType& j, country& c)
const
auto
str
=
j
.
template
get
<
std
::
string
>();
const
auto
str
=
j
.
template
get
<
std
::
string
>();
static
const
std
::
map
<
std
::
string
,
country
>
m
=
static
const
std
::
map
<
std
::
string
,
country
>
m
=
{
{
{
u8
"中华人民共和国"
,
country
::
china
},
{
"中华人民共和国"
,
country
::
china
},
{
"France"
,
country
::
france
},
{
"France"
,
country
::
france
},
{
u8
"Российская Федерация"
,
country
::
russia
}
{
"Российская Федерация"
,
country
::
russia
}
};
};
const
auto
it
=
m
.
find
(
str
);
const
auto
it
=
m
.
find
(
str
);
...
@@ -248,7 +248,7 @@ TEST_CASE("basic usage" * doctest::test_suite("udt"))
...
@@ -248,7 +248,7 @@ TEST_CASE("basic usage" * doctest::test_suite("udt"))
const
udt
::
name
n
{
"theo"
};
const
udt
::
name
n
{
"theo"
};
const
udt
::
country
c
{
udt
::
country
::
france
};
const
udt
::
country
c
{
udt
::
country
::
france
};
const
udt
::
person
sfinae_addict
{
a
,
n
,
c
};
const
udt
::
person
sfinae_addict
{
a
,
n
,
c
};
const
udt
::
person
senior_programmer
{{
42
},
{
u8
"王芳"
},
udt
::
country
::
china
};
const
udt
::
person
senior_programmer
{{
42
},
{
"王芳"
},
udt
::
country
::
china
};
const
udt
::
address
addr
{
"Paris"
};
const
udt
::
address
addr
{
"Paris"
};
const
udt
::
contact
cpp_programmer
{
sfinae_addict
,
addr
};
const
udt
::
contact
cpp_programmer
{
sfinae_addict
,
addr
};
const
udt
::
contact_book
book
{{
"C++"
},
{
cpp_programmer
,
{
senior_programmer
,
addr
}}};
const
udt
::
contact_book
book
{{
"C++"
},
{
cpp_programmer
,
{
senior_programmer
,
addr
}}};
...
@@ -265,14 +265,14 @@ TEST_CASE("basic usage" * doctest::test_suite("udt"))
...
@@ -265,14 +265,14 @@ TEST_CASE("basic usage" * doctest::test_suite("udt"))
CHECK
(
CHECK
(
json
(
book
)
==
json
(
book
)
==
u8
R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"
_json
);
R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"
_json
);
}
}
SECTION
(
"conversion from json via free-functions"
)
SECTION
(
"conversion from json via free-functions"
)
{
{
const
auto
big_json
=
const
auto
big_json
=
u8
R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"
_json
;
R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"
_json
;
SECTION
(
"via explicit calls to get"
)
SECTION
(
"via explicit calls to get"
)
{
{
const
auto
parsed_book
=
big_json
.
get
<
udt
::
contact_book
>
();
const
auto
parsed_book
=
big_json
.
get
<
udt
::
contact_book
>
();
...
...
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