Compare commits

..

2718 Commits

Author SHA1 Message Date
Niels Lohmann
d34771cafc Merge branch 'release/3.9.0' into develop 2020-07-27 15:54:39 +02:00
Niels Lohmann
e110667d21 🔖 set version to 3.9.0 2020-07-27 15:48:09 +02:00
Niels Lohmann
c006fc9bec 📝 add more documentation 2020-07-27 14:07:13 +02:00
Niels Lohmann
84c0c76849 🚧 add Clang-Tidy configuration 2020-07-27 09:15:57 +02:00
Niels Lohmann
2f05f5175c 🚧 add Clang-Tidy configuration 2020-07-26 22:38:14 +02:00
Niels Lohmann
1b06184f22 👥 update list of contributors 2020-07-26 20:50:04 +02:00
Niels Lohmann
84a899f511 👥 update list of contributors 2020-07-26 14:54:51 +02:00
Niels Lohmann
7a4841a42a 📝 add binary() function to SAX documentation 2020-07-26 14:40:46 +02:00
Niels Lohmann
bbcdf18ba5 🚚 move test utils header file 2020-07-26 14:07:34 +02:00
Niels Lohmann
e22cbacc41 🚨 fix warning 2020-07-26 12:12:17 +02:00
Niels Lohmann
67ed63b196 Merge pull request #2312 from nlohmann/docs
Update documentation
2020-07-26 10:06:01 +02:00
Niels Lohmann
a34070d36a fix test for meta() function 2020-07-25 22:28:14 +02:00
Niels Lohmann
9c75c7eace 🔧 clean generated XML files 2020-07-25 22:04:42 +02:00
Niels Lohmann
7bd6242f04 📝 add more documentation 2020-07-25 22:00:28 +02:00
Niels Lohmann
808aca41aa Merge pull request #2305 from AODQ/develop
fixes unused variable 'ex' for #2304
2020-07-25 21:51:54 +02:00
Niels Lohmann
63e7c40e35 Merge pull request #2297 from nlohmann/issue2286
Add support for high-precision numbers in UBJSON encoding
2020-07-25 21:50:53 +02:00
Niels Lohmann
1816aae862 Merge branch 'develop' of https://github.com/nlohmann/json into docs 2020-07-25 21:48:51 +02:00
Niels Lohmann
980f8c6f61 🔀 merge develop branch 2020-07-25 21:45:47 +02:00
Niels Lohmann
42f8708940 Merge branch 'develop' of https://github.com/nlohmann/json into issue2286
 Conflicts:
	single_include/nlohmann/json.hpp
2020-07-25 21:44:58 +02:00
Niels Lohmann
40b78d3847 Merge pull request #2308 from nlohmann/cbor_tags
Fix bug in CBOR tag handling
2020-07-25 19:43:11 +02:00
Niels Lohmann
fad14aabe7 📝 update output of meta function 2020-07-25 14:41:06 +02:00
Niels Lohmann
6e5be17b62 📝 add more documentation 2020-07-25 14:40:50 +02:00
Niels Lohmann
62f98b7537 Merge branch 'develop' of https://github.com/nlohmann/json into docs 2020-07-25 11:20:13 +02:00
Niels Lohmann
a1dbfcd736 Merge pull request #2306 from jwittbrodt/develop
added inline to NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE macro
2020-07-25 10:52:56 +02:00
Niels Lohmann
c00c3162b2 Merge branch 'develop' into develop 2020-07-25 10:52:42 +02:00
Niels Lohmann
448ceb2e12 Merge pull request #2303 from nlohmann/cleanup
Cleanup
2020-07-25 05:41:51 +02:00
aodq
15ec0fe150 change c-style cast to static_cast for #2304 2020-07-24 16:21:30 -04:00
Niels Lohmann
58167173a2 📝 add more documentation 2020-07-24 15:25:53 +02:00
Niels Lohmann
d8d499ce9b 📝 add more documentation 2020-07-24 14:35:52 +02:00
Niels Lohmann
480ad529e3 🐛 fix bug in CBOR tag handling 2020-07-24 14:18:39 +02:00
Niels Lohmann
a84370c61f 📝 add more documentation 2020-07-24 14:04:58 +02:00
Niels Lohmann
33662417c1 improve coverage 2020-07-24 09:32:03 +02:00
Jonas Wittbrodt
0f22ed0b5b added inline to DEFINE_TYPE macro 2020-07-23 19:24:21 +02:00
aodq
12885446d8 fixes unused variable 'ex' for #2304 2020-07-23 13:21:38 -04:00
Niels Lohmann
3c7dc635e7 🙈 extend ignore list 2020-07-23 14:19:57 +02:00
Niels Lohmann
27232455c8 📝 update documentation 2020-07-23 14:17:02 +02:00
Niels Lohmann
59cb7674be 📝 update documentation 2020-07-23 14:15:20 +02:00
Niels Lohmann
0cd120f7e1 🚨 fix UBSAN warning 2020-07-23 14:06:09 +02:00
Niels Lohmann
bba57cc4af 🚨 fix UBSAN warning 2020-07-23 14:02:49 +02:00
Niels Lohmann
e571c67c0d 🚨 fix implicit conversion warning when opening binary file 2020-07-23 14:02:12 +02:00
Niels Lohmann
43e07bb92d Merge pull request #2301 from nlohmann/regression2281
Add test with multiple translation units
2020-07-23 13:14:24 +02:00
Niels Lohmann
fb22233f34 🔊 add message if implicit conversions are switched off 2020-07-23 13:11:48 +02:00
Niels Lohmann
f9b71afebf 🚚 unify cmake build dir names 2020-07-23 13:02:53 +02:00
Niels Lohmann
8159091d8f 🔀 rename variable to avoid shadowing 2020-07-23 12:58:09 +02:00
Niels Lohmann
230dcfb7a3 🚨 add prefix to avoid shadowing 2020-07-23 12:57:52 +02:00
Niels Lohmann
b315fe484a 🔀 merge develop branch 2020-07-23 12:30:26 +02:00
Niels Lohmann
a33c3fdf25 Merge branch 'develop' of https://github.com/nlohmann/json into issue2286
 Conflicts:
	single_include/nlohmann/json.hpp
2020-07-23 12:30:07 +02:00
Niels Lohmann
88122467bd ♻️ pull code into function 2020-07-23 12:16:18 +02:00
Niels Lohmann
a048b72fe1 Merge pull request #1559 from theodelrieu/feat/explicit_conversion_operator
Feat/explicit conversion operator
2020-07-23 08:52:51 +02:00
Niels Lohmann
484029b51c Merge pull request #2299 from nlohmann/fix_warnings
Fix unused parameter
2020-07-22 18:43:33 +02:00
Niels Lohmann
a6d112ffbf add regression test for #2281 2020-07-22 13:39:40 +02:00
Niels Lohmann
2301bd1177 add regression test for #2281 2020-07-22 13:24:07 +02:00
Niels Lohmann
c4356c68e0 add regression test for #2281 2020-07-22 12:38:39 +02:00
Niels Lohmann
4d63252c6c add regression test for #2281 2020-07-22 12:23:58 +02:00
Niels Lohmann
a7c4c84d68 add regression test for #2281 2020-07-22 12:03:37 +02:00
Théo DELRIEU
797329315a add a CI job for explicit conversions on every os 2020-07-22 10:49:01 +02:00
Théo DELRIEU
74b446f5fd add a switch to enable implicit conversions (defaults to true)
wrap implicit conversions tests around the JSON_USE_IMPLICIT_CONVERSIONS
macro
2020-07-22 10:49:01 +02:00
Niels Lohmann
2cd10a7405 Merge pull request #2300 from nlohmann/gihub_actions
Merge Gitlab actions
2020-07-22 09:45:55 +02:00
Niels Lohmann
6bd38a2cb9 👷 merge Gitlab actions 2020-07-22 09:02:55 +02:00
Niels Lohmann
8b14c9b305 🚨 fix warnings 2020-07-21 23:00:56 +02:00
Niels Lohmann
3bb43ecd51 🔀 merge develop branch 2020-07-21 22:02:14 +02:00
Niels Lohmann
3249a4d821 Merge branch 'develop' of https://github.com/nlohmann/json into issue2286
 Conflicts:
	single_include/nlohmann/json.hpp
2020-07-21 22:01:32 +02:00
Niels Lohmann
96e9f66025 🔇 remove debug output 2020-07-21 22:01:15 +02:00
Niels Lohmann
8046754c15 🔊 add debug output to tests 2020-07-21 12:44:38 +02:00
Niels Lohmann
b1903fff1f 💚 fix build 2020-07-21 09:09:30 +02:00
Niels Lohmann
1339d6b683 🐛 add missing EOF check 2020-07-20 22:40:28 +02:00
Niels Lohmann
a9117828e1 🚨 fix warnings 2020-07-20 22:38:00 +02:00
Niels Lohmann
8344857764 Merge pull request #2287 from pfeatherstone/develop
Serialisation macros: increase upper bound on number of member variables
2020-07-20 21:35:55 +02:00
Niels Lohmann
4a5277d09d 📝 update documentation 2020-07-20 14:11:43 +02:00
Niels Lohmann
8aa6da61dc 🚧 support for UBJSON high-precision numbers #2286 2020-07-20 13:57:19 +02:00
Niels Lohmann
7360e09830 🚧 support for UBJSON high-precision numbers #2286 2020-07-20 13:12:20 +02:00
pf
35b899e988 [JSON] initialise all member variables. Maybe this will shut valgrind up. std::tie probably wasn't the problem initially 2020-07-20 10:51:43 +01:00
Niels Lohmann
7cf2fe149c 🚧 support for UBJSON high-precision numbers #2286 2020-07-20 09:42:37 +02:00
pf
7660ea12f6 [JSON] drop use of std::tie and std::tupe for operator== overload. valgrind and clang < 4 complain 2020-07-20 08:31:56 +01:00
Niels Lohmann
893eda8353 Merge pull request #2294 from jprochazk/develop
fix eof for get_binary and get_string
2020-07-20 08:02:03 +02:00
pf
678d310b85 [JSON] don't know why CHECK doesn't like "CHECK(obj1 == obj2)". So using a temporary bool. 2020-07-19 21:29:39 +01:00
pf
e83ddb185d [JSON] use CHECK from doctest 2020-07-19 21:25:27 +01:00
pf
254f0e3cee [JSON] CHECK in doctest only accepts std::string ? Use assert statement instead. Does the job 2020-07-19 18:22:16 +01:00
pf
578217eaa3 [JSON] doctest: need another section ? 2020-07-19 18:17:03 +01:00
pf
6d9b2040ab [JSON] as per Nlohmann's suggestion, added unit tests for the (de)serialisation macros 2020-07-19 18:12:13 +01:00
pf
75a6888d55 [JSON] since we no longer use a netbeans project for the (de)serialisation macro building code, can revert the changes made to the .gitignore file 2020-07-19 18:11:37 +01:00
pf
8f14aaa13f [JSON] as per Nlohmann's suggestion, moved the macro builder code to third_party directory 2020-07-19 18:10:08 +01:00
jprochazk
851315c878 add regression test 2020-07-19 18:35:58 +02:00
pf
f7374c9a8d Merge branch 'develop' of https://github.com/pfeatherstone/json into develop 2020-07-19 17:32:35 +01:00
pf
0a158ee830 [JSON] rough and ready code for generating (de)serialisation macros. Current upper bound on number of member variables is set to 64 2020-07-19 17:32:16 +01:00
pf
21bd6e971b [JSON] - dirty code for building intrusive and non-intrusive serialisation/deserialisation macros for custom types
- updated .gitignore file to ignore private netbeans project configurations
2020-07-19 17:26:56 +01:00
pf
0b744e1ed0 [JSON] - dirty code for building intrusive and non-intrusive serialisation/deserialisation macros for custom types
- used code to increase the upper bound on number of member variables to 64
2020-07-19 17:26:56 +01:00
pf
8a045713ed [JSON] - dirty code for building intrusive and non-intrusive serialisation/deserialisation macros for custom types
- used code to increase the upper bound on number of member variables to 64
2020-07-19 17:26:56 +01:00
pf
a575008c48 [JSON] - dirty code for building intrusive and non-intrusive serialisation/deserialisation macros for custom types
- updated .gitignore file to ignore "dist" and "build" directories in netbeans project
2020-07-19 17:26:56 +01:00
pf
5eb739a585 [JSON] - dirty code for building intrusive and non-intrusive serialisation/deserialisation macros for custom types
- netbeans project configurations
2020-07-19 17:26:56 +01:00
pf
68122fe0ed [JSON] dirty code for building intrusive and non-intrusive serialisation/deserialisation macros for custom types 2020-07-19 17:26:56 +01:00
Niels Lohmann
b1da58b76b Merge pull request #2282 from nlohmann/missing_sax_check
Add static assertion for missing binary function in SAX interface
2020-07-19 18:09:08 +02:00
Niels Lohmann
1fd6c5882a Merge pull request #2285 from T0b1-iOS/develop
add inline specifier for detail::combine
2020-07-19 17:55:51 +02:00
jprochazk
d371a5283c run amalgamate 2020-07-19 10:57:17 +02:00
jprochazk
ab25de05f7 fix: return -> result.push_back 2020-07-19 10:51:13 +02:00
jprochazk
a3a9d5665e add break to binary_reader::get_binary and get_string 2020-07-19 09:35:49 +02:00
pf
0d2d088b97 [JSON] - dirty code for building intrusive and non-intrusive serialisation/deserialisation macros for custom types
- updated .gitignore file to ignore private netbeans project configurations
2020-07-18 16:13:56 +01:00
pf
c122d8a94f [JSON] - dirty code for building intrusive and non-intrusive serialisation/deserialisation macros for custom types
- used code to increase the upper bound on number of member variables to 64
2020-07-18 16:12:49 +01:00
pf
4706d6e976 [JSON] - dirty code for building intrusive and non-intrusive serialisation/deserialisation macros for custom types
- used code to increase the upper bound on number of member variables to 64
2020-07-18 16:12:27 +01:00
pf
9afe757648 [JSON] - dirty code for building intrusive and non-intrusive serialisation/deserialisation macros for custom types
- updated .gitignore file to ignore "dist" and "build" directories in netbeans project
2020-07-18 16:11:34 +01:00
pf
8730af0788 [JSON] - dirty code for building intrusive and non-intrusive serialisation/deserialisation macros for custom types
- netbeans project configurations
2020-07-18 16:10:32 +01:00
pf
beb1fb48f0 [JSON] dirty code for building intrusive and non-intrusive serialisation/deserialisation macros for custom types 2020-07-18 16:08:29 +01:00
T0b1-iOS
88243b3f8c run amalgamate 2020-07-18 07:09:56 +02:00
T0b1-iOS
281349d0d6 add inline specifier for detail::combine 2020-07-18 06:28:11 +02:00
Niels Lohmann
43ab8a2357 Merge pull request #2279 from nlohmann/issue1818
Add test for target_include_directories
2020-07-18 06:12:57 +02:00
Niels Lohmann
7fc4b2901a 🚸 add static assertion for missing binary function in SAX interface 2020-07-17 20:41:11 +02:00
Niels Lohmann
2fd57d3ed1 add test for target_include_directories #1818 2020-07-17 14:26:22 +02:00
Niels Lohmann
a10d486e36 Merge pull request #2244 from matthewbauer/tag-cbor
Tag binary values in cbor if set
2020-07-17 14:05:48 +02:00
Niels Lohmann
e65cc9dccb Merge pull request #2274 from nlohmann/analyzers
Clean up maintainer Makefiles and fix some linter warnings
2020-07-17 14:01:19 +02:00
Niels Lohmann
548e7e54c9 Merge pull request #2273 from nlohmann/issue1968
Add option to ignore CBOR tags
2020-07-17 13:59:55 +02:00
Niels Lohmann
6023a7ccd9 Merge branch 'develop' into analyzers 2020-07-17 13:59:32 +02:00
Niels Lohmann
270f1ae482 Merge pull request #2269 from nlohmann/hash
Hash function without allocation
2020-07-17 13:57:47 +02:00
Niels Lohmann
d047b3d495 🚨 remove linter warning 2020-07-16 14:45:39 +02:00
Niels Lohmann
26196f25f6 🔥 remove test Makefile targets (all handled by CMake) 2020-07-16 13:38:25 +02:00
Niels Lohmann
3d60befde3 🔧 adjust analysis targets 2020-07-16 12:14:06 +02:00
Niels Lohmann
7f6ea47bdb 🔧 adjust analysis targets 2020-07-16 09:44:07 +02:00
Niels Lohmann
4c59d6aaef 🔥 remove leftover 2020-07-16 09:43:35 +02:00
Niels Lohmann
23c97f4aa5 Merge pull request #2268 from t-b/feature/add-clang-cl
Add ClangCL for MSVC
2020-07-16 07:40:58 +02:00
Niels Lohmann
93cdf05928 add tests 2020-07-15 14:23:22 +02:00
Niels Lohmann
01e196f6b6 Merge branch 'develop' of https://github.com/nlohmann/json into issue1968 2020-07-15 13:50:00 +02:00
Niels Lohmann
b821ed074f 💡 add documentation 2020-07-15 13:45:16 +02:00
Niels Lohmann
496ddd127c 💚 make test deterministic 2020-07-15 12:14:30 +02:00
Niels Lohmann
9449dfcc6a 💚 add test cases for hash 2020-07-15 09:27:01 +02:00
Thomas Braun
25a59b59f2 Github Actions: Add ClangCL on Windows
MS Visual Studio 2019 has builtin support for other compiler toolsets [1].

This commit adds support for compiling using LLVM/Clang 10 using Visual
Studio.

ClangCL pretends to be MSVC so the usual MSVC flags apply, see also [2].
For detecting if ClangCL is used, newer cmake verisons (>= 3.15) have
builtin support using CMAKE_CXX_COMPILER_FRONTEND_VARIANT [3], for older
ones a workaround is available using CMAKE_CXX_SIMULATE_ID [4].

[1]: https://devblogs.microsoft.com/cppblog/clang-llvm-support-in-visual-studio/
[2]: https://clang.llvm.org/docs/UsersManual.html#clang-cl
[3]: https://stackoverflow.com/a/10055571
[4]: 4fe34b2d29
2020-07-14 16:02:44 +02:00
Thomas Braun
6d7f8b3793 README.md: Remove trailing whitespace 2020-07-14 15:36:42 +02:00
Niels Lohmann
33b0bed7fe 💚 fix compilation 2020-07-14 14:34:55 +02:00
Niels Lohmann
5b229f4cce hash function without allocation 2020-07-14 14:31:19 +02:00
Niels Lohmann
1a521cbd36 Merge pull request #2264 from t-b/feature/use-proper-SED-in-makefile
Makefile: Always use SED variable
2020-07-14 14:07:33 +02:00
Niels Lohmann
8921e5e5db Merge pull request #2262 from nlohmann/more_ci
Add Xcode 12 CI
2020-07-13 21:04:57 +02:00
Thomas Braun
88adffdaba Makefile: Always use SED variable
We need to have a proper sed, even on MacOSX. So let's use the variable
introduced in 191aa0fd (🔧 overworked maintaner targets,
2019-03-28) in more places.
2020-07-13 14:44:40 +02:00
Niels Lohmann
938b867450 📝 add Xcode 12 to CI list 2020-07-12 21:45:00 +02:00
Niels Lohmann
3952739189 add CBOR tag handler #1968 2020-07-12 16:51:43 +02:00
Niels Lohmann
a244531627 ♻️ overwork Travis YAML 2020-07-12 15:33:16 +02:00
Niels Lohmann
cf741313b3 📝 add Clang on Windows to CI list 2020-07-12 15:31:17 +02:00
Niels Lohmann
e316f5c5b6 Merge pull request #2258 from nlohmann/issue2179
Add ordered_json specialization with ordered object keys
2020-07-12 13:11:23 +02:00
Niels Lohmann
486812904f Merge pull request #2259 from nlohmann/clang_windows
Make library work with Clang on Windows
2020-07-12 13:09:35 +02:00
Niels Lohmann
4d28694756 ♻️ replace further alternative operators 2020-07-11 19:28:58 +02:00
Niels Lohmann
738c83d6af 💚 add test for ordered_map 2020-07-11 19:24:32 +02:00
Niels Lohmann
8d295235a5 🔥 remove unused boolean_operators.hpp header 2020-07-11 19:20:44 +02:00
Niels Lohmann
6477b9b20a ♻️ replace further alternative operators 2020-07-11 14:09:06 +02:00
Niels Lohmann
7f923424b3 🔀 merge develop branch and resolve conflicts 2020-07-11 14:05:02 +02:00
Niels Lohmann
dc06f100be Merge branch 'develop' of https://github.com/nlohmann/json into clang_windows
 Conflicts:
	include/nlohmann/detail/input/binary_reader.hpp
	include/nlohmann/detail/input/json_sax.hpp
	include/nlohmann/detail/input/lexer.hpp
	include/nlohmann/detail/input/parser.hpp
	include/nlohmann/detail/json_pointer.hpp
	include/nlohmann/detail/output/serializer.hpp
	include/nlohmann/json.hpp
	single_include/nlohmann/json.hpp
2020-07-11 14:04:40 +02:00
Niels Lohmann
889f269a6c ♻️ replace further alternative operators 2020-07-11 13:51:25 +02:00
Niels Lohmann
b2240f7508 🏁 remove failing code for Clang/Windows 2020-07-11 13:46:04 +02:00
Niels Lohmann
609a0046c4 ♻️ replace further alternative operators 2020-07-11 13:39:14 +02:00
Niels Lohmann
3a80823ff8 🔀 merge develop branch and resolve conflicts 2020-07-11 13:21:13 +02:00
Niels Lohmann
9c21285133 Merge branch 'develop' of https://github.com/nlohmann/json into issue2179
 Conflicts:
	single_include/nlohmann/json.hpp
2020-07-11 13:20:16 +02:00
Niels Lohmann
5f146cb853 Merge pull request #2206 from gatopeich/issue2179
Simple ordered_json that works on all supported compilers
2020-07-11 13:15:40 +02:00
gatopeich
47d154dd49 Remove redundant comment 2020-07-11 00:34:12 +01:00
gatopeich
f9a1fec272 Remove redundant comment 2020-07-11 00:34:02 +01:00
Niels Lohmann
cbafed3494 ⬇️ require CMake 3.1 2020-07-10 12:53:48 +02:00
gatopeich
f62b4626be Removing comment about AllocatorType per review request 2020-07-09 21:12:14 +01:00
gatopeich
0eb7b0a991 Update README.md per review comments
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
2020-07-09 20:47:19 +01:00
Niels Lohmann
75d5d05993 Merge pull request #2253 from ericonr/pkgconf
Add pkg-config file
2020-07-09 20:42:42 +02:00
Niels Lohmann
4c7bd014d9 Merge pull request #2242 from nlohmann/issue2239
Make assert configurable via JSON_ASSERT
2020-07-09 15:13:12 +02:00
Niels Lohmann
d740622f96 📝 add documentation for macros 2020-07-09 13:23:33 +02:00
Érico Rolim
251fce819c README: add explanation on how to use pkg-config. 2020-07-09 03:59:53 -03:00
Palmer Dabbelt
c7d18c1625 cmake: Generate and install a pkg-config file.
The meson builds install a pkg-config file, but the cmake builds don't.
This adds a pkg-config file to the cmake builds that is functionally
equivalent to the one generated from meson.
2020-07-09 03:59:53 -03:00
Niels Lohmann
0306525cdb Merge pull request #2251 from nlohmann/fix_2181
Fix regression from #2181
2020-07-09 07:33:03 +02:00
Niels Lohmann
f774a32d2b fix test 2020-07-08 14:47:22 +02:00
Niels Lohmann
e3e9ccfc02 🚑 fix regression from #2181 2020-07-08 14:02:28 +02:00
Niels Lohmann
1b04092c5c fix test 2020-07-08 12:38:46 +02:00
Niels Lohmann
d019ddfcdb 👷 add code scanning 2020-07-08 12:25:53 +02:00
Matthew Bauer
dd08f7705f Add simple test for cbor byte 2020-07-06 18:06:10 -04:00
Niels Lohmann
28ef87370b 🚨 fix warning 2020-07-06 13:19:06 +02:00
Niels Lohmann
99fc6b16ab Merge branch 'develop' of https://github.com/nlohmann/json into issue2239 2020-07-06 12:52:59 +02:00
Niels Lohmann
ba8174041e add test case for JSON_ASSERT 2020-07-06 12:52:48 +02:00
Niels Lohmann
efcc826ecb 🚨 fix warning 2020-07-06 12:37:39 +02:00
Niels Lohmann
98b1c6d302 🚩 use JSON_ASSERT(x) instead of assert(x) 2020-07-06 12:22:31 +02:00
Niels Lohmann
b04dc055b2 Merge pull request #2233 from nlohmann/issue2175
Add specialization of get_to
2020-07-06 07:58:52 +02:00
Niels Lohmann
197c3d4fb0 Merge pull request #2232 from nlohmann/ignore_documentation
Refine documentation of error_handler parameter
2020-07-06 07:58:28 +02:00
Agustín F. Pozuelo
803c16e5af Clean-up unintended changes to whitespace 2020-07-03 10:26:05 +01:00
Agustín F. Pozuelo
25f5d75e6e Fix compilation for xcode 9.x 2020-07-03 01:44:18 +01:00
Agustín F. Pozuelo
93770467a1 Precisely 4 template arguments for the sake of clang 3.6 (?) 2020-07-03 01:28:54 +01:00
Agustín F. Pozuelo
0fc261f0f2 Make ordered_map compatible with GCC 5.5 2020-07-03 00:33:31 +01:00
Matthew Bauer
e54f03f73b Tag binary values in cbor if set
CBOR has tags, which work similarly to "subtype"s:

https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml

Unsure if this makes sense. Note that the subtype must just be one
byte wide.
2020-07-02 17:40:02 -04:00
Niels Lohmann
f59f4a2b61 💚 fix build 2020-06-30 19:55:40 +02:00
Niels Lohmann
c7e079cc98 🚑 add specialization of get_to #2175 2020-06-30 14:26:52 +02:00
Niels Lohmann
ad6eadeb70 📝 refine documentation of error_handler parameter 2020-06-30 13:59:43 +02:00
gatopeich
49f26a0250 Have 4 template parameters for ordered_map 2020-06-29 17:32:55 +01:00
Niels Lohmann
eb7376bb13 Merge pull request #2225 from nlohmann/issue2175
Simplify conversion from/to custom types
2020-06-29 14:41:09 +02:00
Niels Lohmann
470f7c0c68 📝 add documentation 2020-06-29 13:43:06 +02:00
Niels Lohmann
1b4ea8f89b Merge pull request #2224 from nlohmann/issue2221
Remove unused typedefs
2020-06-28 15:08:18 +02:00
Niels Lohmann
d7a2956b24 🔀 merge from develop 2020-06-27 13:16:20 +02:00
Niels Lohmann
ac3922c7aa Merge branch 'develop' of https://github.com/nlohmann/json into clang_windows
 Conflicts:
	include/nlohmann/detail/input/binary_reader.hpp
	include/nlohmann/detail/input/input_adapters.hpp
	include/nlohmann/detail/input/lexer.hpp
	include/nlohmann/detail/output/binary_writer.hpp
	include/nlohmann/json.hpp
	single_include/nlohmann/json.hpp
2020-06-27 13:14:48 +02:00
Niels Lohmann
fa9f4040df 🔥 remove unused typedefs #2221 2020-06-27 13:07:02 +02:00
Niels Lohmann
5ba0f65c34 🔧 remove feature request template 2020-06-27 12:55:41 +02:00
Niels Lohmann
aefa0b3e86 🔧 use Github discussions for questions 2020-06-27 12:54:42 +02:00
Niels Lohmann
3948b5b091 Merge pull request #2212 from nlohmann/comments
Add option to ignore comments in parse/accept functions
2020-06-27 12:44:51 +02:00
Niels Lohmann
1af4f5f360 Merge pull request #2222 from alexreinking/patch-1
Enable CMake policy CMP0077
2020-06-27 12:43:52 +02:00
Niels Lohmann
c5ee222982 Merge pull request #2211 from nlohmann/fix_warnings
Fix Clang-Tidy warnings
2020-06-27 12:34:18 +02:00
Alex Reinking
ec43371e07 Enable CMake policy CMP0077
Projects that import json via [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) or `add_subdirectory` pointed at a git submodule may want to set `JSON_BuildTests` to "NO". However, this doesn't work without creating an identical `option()` in the importing project. Enabling CMP0077 in supported versions of CMake changes the behavior of `option()` to allow importing projects to set default values for the variables without touching the cache.

See the documentation for CMP0077 here: https://cmake.org/cmake/help/latest/policy/CMP0077.html
2020-06-26 11:47:36 -07:00
Niels Lohmann
635b9a0ae4 Merge pull request #2193 from dota17/issue#2059
Fix consistency in function `int_to_string()`
2020-06-24 11:46:48 +02:00
gatopeich
cf18ba2394 Test initialization with dup keys 2020-06-23 17:50:51 +01:00
gatopeich
08963d6826 Revert types.md 2020-06-23 15:48:02 +01:00
gatopeich
d08fca2bb9 Use const Key in ordered map
(forgotten in previous commit!)
2020-06-23 15:44:46 +01:00
gatopeich
5e7bdf1cab Roll-back to hard-coded object_t::value_type 2020-06-23 15:39:00 +01:00
gatopeich
fb8c11f25c Re-implement ordered_map::erase,
so that it can handle pair<const Key,...>
2020-06-23 15:01:20 +01:00
gatopeich
acd748e16f Use std::map default allocator as a placeholder
to extract the actual ObjectType::value_type
Still fails on older compilers (GCC <= 5.5)
2020-06-23 12:03:21 +01:00
gatopeich
49623a75ee Revert "Using ordered_json instead of fifo_map in test-regression"
This reverts commit 5fe3d3929a.
2020-06-23 11:30:52 +01:00
Niels Lohmann
8575fdf9ad Merge pull request #2181 from dota17/issue#1275
Fix issue#1275
2020-06-23 09:23:03 +02:00
Niels Lohmann
4bfe4add20 Merge pull request #2203 from t-b/use-unsigned-indizies-for-array-index-in-json-pointer
Use unsigned indizies for array index in json pointer
2020-06-23 09:16:01 +02:00
chenguoping
0ecf297457 drop std::enable_if part 2020-06-23 09:14:55 +08:00
Niels Lohmann
a9809f3381 🏁 revert change that breaks with MSVC 2020-06-22 23:02:28 +02:00
Niels Lohmann
8b3d2399a4 🚨 remove warnings 2020-06-22 22:32:21 +02:00
gatopeich
5fe3d3929a Using ordered_json instead of fifo_map in test-regression
This is more comprehensive and the "my_workaround_fifo_map" wrapper does not allow to infer value type as required in this branch.

This reverts commit 064a9c9212.
2020-06-22 19:10:35 +01:00
gatopeich
064a9c9212 Fix regression test 2020-06-22 18:59:19 +01:00
gatopeich
ddf0a45abb Use AllocatorType<ObjectType::value_type>,
instead of hard-coding it for std::map's value_type
2020-06-22 18:35:46 +01:00
chenguoping
aeef50709e to allow for ADL in int_to_string() function 2020-06-22 20:17:56 +08:00
Thomas Braun
ecbb2756fd json_pointer::array_index: Use unsigned values for the array index when parsing
The current code uses std::stoi to convert the input string to an int
array_index. This limits the maximum addressable array size to ~2GB on
most platforms.

But all callers immediately convert the result of array_index to
BasicJsonType::size_type.

So let's parse it as unsigned long long, which allows us to have as
big arrays as available memory. And also makes the call sites nicer to
read.

One complication arises on platforms where size_type is smaller than
unsigned long long. We need to bail out on these if the parsed array
index does not fit into size_type.
2020-06-22 13:42:55 +02:00
Niels Lohmann
65e8ee985a 🔨 clean up 2020-06-22 08:59:03 +02:00
gatopeich
15337b2cc3 Ignore allocator hardcoded to match std::map 2020-06-22 00:03:48 +01:00
gatopeich
27aaf6f845 Clean-up ordered_map declarations 2020-06-21 22:28:03 +01:00
Niels Lohmann
29ad2178c6 Merge pull request #2176 from gracicot/cpp20-support-no-std-fct-templ-specialization
C++20 support by removing swap specialization
2020-06-21 20:39:58 +02:00
Niels Lohmann
e22ce45065 🚸 improve diagnostics 2020-06-21 13:28:00 +02:00
Niels Lohmann
139a0258cc Merge branch 'develop' of https://github.com/nlohmann/json into comments 2020-06-21 12:40:21 +02:00
Niels Lohmann
8dade80499 Merge pull request #2202 from nlohmann/issue2189
Add option to not rely on Internet connectivity during test stage
2020-06-21 08:41:48 +02:00
Thomas Braun
f0e73163f2 json_pointer.hpp: Mention more exception in documentation
Forgotten in dcd3a6c6 (move the catch of std::invalid_argument into
array_index(), 2020-03-23).
2020-06-20 15:27:22 +02:00
Niels Lohmann
0fe9f23254 add macros from #2175 2020-06-20 14:11:37 +02:00
Niels Lohmann
6ee9e5f402 ⚗️ remove const from value type 2020-06-20 13:23:44 +02:00
Niels Lohmann
24992003d9 📝 add notes from #2189 2020-06-20 09:55:11 +02:00
Niels Lohmann
e4675887a6 Merge branch 'develop' of https://github.com/nlohmann/json into issue2189 2020-06-20 09:47:12 +02:00
Niels Lohmann
74c6e4295f Merge pull request #2201 from nlohmann/issue2196
Serialize floating-point numbers with 32 bit when possible (MessagePack)
2020-06-20 09:31:02 +02:00
Niels Lohmann
4fd0d02b6f 🚧 toward an ordered_json type 2020-06-19 15:27:05 +02:00
Niels Lohmann
b64002bbca ♻️ extract common code to function 2020-06-19 13:24:08 +02:00
Niels Lohmann
0585ecc56b add tests for comment skipping 2020-06-19 13:10:35 +02:00
Niels Lohmann
cd115cbc33 update test suite 2020-06-18 12:50:32 +02:00
Niels Lohmann
74520d8bb0 🚧 extend API 2020-06-17 22:03:14 +02:00
Niels Lohmann
88a37010d6 🐛 serialize 32-bit floating-point numbers as float 32 in MessagePack (0xCA) #2196 2020-06-17 21:14:23 +02:00
Niels Lohmann
e9bfcf7255 improve comment parsing 2020-06-17 14:59:47 +02:00
chenguoping
4a6c68c7eb drop new blank line 2020-06-17 20:44:31 +08:00
chenguoping
da8fa3535a drop testcase 2020-06-17 20:41:31 +08:00
Niels Lohmann
e86b3fae98 🔧 add label to tests that require a git checkout 2020-06-17 12:35:59 +02:00
chenguoping
f466919ec2 change test cases 2020-06-17 15:07:25 +08:00
chenguoping
8aaa4013a3 remove overload function, change default_value to rvalue 2020-06-17 15:05:28 +08:00
Niels Lohmann
4d96f4cf6a 🔧 overwork CMake files 2020-06-16 20:23:01 +02:00
Niels Lohmann
f4c4bab600 add option JSON_TestDataDirectory to set path with test data #2189 2020-06-16 12:55:36 +02:00
Niels Lohmann
b53c6e2f81 ignore comments 2020-06-16 12:28:59 +02:00
chenguoping
691fb0c57a fix issue#2059 2020-06-16 15:35:26 +08:00
Niels Lohmann
e7452d8778 Merge branch 'release/3.8.0' into develop 2020-06-14 17:44:18 +02:00
Niels Lohmann
5f862710fe 🔖 set version to 3.8.0 2020-06-14 17:16:45 +02:00
Niels Lohmann
1ecb7884d1 👥 update contributor list 2020-06-14 15:22:08 +02:00
Niels Lohmann
c05bd90467 Merge pull request #2182 from tanuj208/develop
Improve parse_ubjson_fuzzer
2020-06-12 09:37:44 +02:00
Tanuj Garg
c3c5c03ea3 added fuzzing with different values to default argument in to_ubjson method 2020-06-10 20:50:25 +05:30
chenguoping
a3df26b771 add some test cases 2020-06-10 19:27:57 +08:00
chenguoping
71830be06d fix issue#1275 2020-06-10 19:27:28 +08:00
Niels Lohmann
27f5a6e827 🙈 ignore __pycache__ directory 2020-06-09 16:59:03 +02:00
Niels Lohmann
262d9cc67d 🚨 fix a maybe-uninitialized warning 2020-06-09 16:57:06 +02:00
Niels Lohmann
14881cf901 Merge pull request #2178 from nlohmann/input_adapter_tests
Add input adapter tests
2020-06-09 08:46:32 +02:00
Niels Lohmann
ae04426c85 🏁 fix for MSVC (see https://github.com/nlohmann/json/pull/2178#issuecomment-640622532) 2020-06-08 20:07:15 +02:00
Niels Lohmann
2cf16625ac add test for character types 2020-06-07 22:49:39 +02:00
Niels Lohmann
d4bc0c39af add test for character types 2020-06-07 22:47:54 +02:00
Niels Lohmann
6d73126ea9 🚨 fix warnings 2020-06-07 22:47:25 +02:00
Niels Lohmann
28048d8207 Merge branches 'develop' and 'mkdocs' of https://github.com/nlohmann/json into develop
 Conflicts:
	doc/examples/swap__binary_t.link
2020-06-07 21:02:08 +02:00
Niels Lohmann
eca5490b94 📝 add example link for swap function 2020-06-07 21:01:13 +02:00
Niels Lohmann
8c1d26e186 📝 add documentation and example for accept function 2020-06-07 20:59:43 +02:00
Niels Lohmann
543dcee3a7 Merge pull request #2174 from nlohmann/fix_warnings
Fix warnings
2020-06-07 20:35:05 +02:00
Niels Lohmann
907803189b 🏁 fix MSVC 2015 compilation 2020-06-07 12:51:33 +02:00
Niels Lohmann
e6a7e7a16a 🚑 hotfix for #2177 2020-06-07 12:41:36 +02:00
Guillaume Racicot
82fbbeeac5 Adapted unit tests to use ADL calls for swap like the new swappable concept 2020-06-06 12:28:52 -04:00
Guillaume Racicot
225c8f150a Disable std::swap specialization in C++20 and added a friend swap function 2020-06-06 11:36:39 -04:00
Niels Lohmann
bf2e714e96 🚨 fix warnings 2020-06-06 14:30:17 +02:00
Niels Lohmann
7444c7fa25 Merge pull request #2145 from FrancoisChabot/1813-user-input
Fix Issue#1813: user defined input adapters
2020-06-05 14:30:39 +02:00
Niels Lohmann
dd7e25927f 🚨 fix warning 2020-06-05 08:27:15 +02:00
Niels Lohmann
5fe6b83c26 Merge pull request #2158 from dota17/output_adapter
Fix PR#1006
2020-06-05 08:25:19 +02:00
chenguoping
ad2b4ff23b recover original blank line 2020-06-05 14:23:00 +08:00
chenguoping
0f67c5849f undo: remove comment 2020-06-05 10:09:15 +08:00
Niels Lohmann
2df5f107a9 📝 add page on parsing and exceptions 2020-06-04 14:01:57 +02:00
Niels Lohmann
32bda1a7af Merge branches 'develop' and 'mkdocs' of https://github.com/nlohmann/json into mkdocs 2020-06-04 13:07:20 +02:00
Niels Lohmann
24e8562664 👷 remove Clang 8 2020-06-04 12:48:03 +02:00
Niels Lohmann
a53e3a5443 👷 try Clang 8 2020-06-04 12:34:56 +02:00
Niels Lohmann
dc323314d5 👷 try Clang 10 2020-06-04 12:29:53 +02:00
Niels Lohmann
402c34c526 👷 try Clang 10 2020-06-04 12:27:37 +02:00
Niels Lohmann
65c4b07451 🎨 replace alternative operators (and, not, or) 2020-06-03 21:22:07 +02:00
Niels Lohmann
0498202a03 🎨 replace alternative operators (and, not, or) 2020-06-03 14:20:36 +02:00
Niels Lohmann
4f04ea1bef Merge branches 'clang_windows' and 'develop' of https://github.com/nlohmann/json into clang_windows 2020-06-03 14:01:18 +02:00
Niels Lohmann
9212590764 👥 update contributor list 2020-06-03 13:56:01 +02:00
Niels Lohmann
9708b1e9c3 🔥 remove Code Inspector 2020-06-03 13:49:46 +02:00
Niels Lohmann
68fd772fdf 👷 add Code Inspector via GitHub Action 2020-06-03 13:44:33 +02:00
Niels Lohmann
9bc2a7fa25 👷 add Code Inspector via GitHub Action 2020-06-03 13:39:56 +02:00
Niels Lohmann
c24218afe8 Merge remote-tracking branch 'origin/develop' into develop 2020-06-03 13:38:15 +02:00
Niels Lohmann
2c4be7d65c Merge pull request #2152 from TotalCaesar659/patch-1
Update URLs to HTTPS
2020-06-03 12:31:33 +02:00
Niels Lohmann
2ad847f21b 🔨 fix doxygen link 2020-06-03 12:30:42 +02:00
Niels Lohmann
fdf5a63dfd 🔨 fix Doxygen link 2020-06-03 12:30:10 +02:00
Niels Lohmann
309acb445a Merge pull request #2153 from dota17/issue#1972
Fix issue#1972
2020-06-03 12:26:17 +02:00
chenguoping
eca4b8785c fix test case in PR#1006 2020-06-02 15:44:26 +08:00
chenguoping
fff1499963 add comment about PR#1006 2020-06-02 15:43:57 +08:00
chenguoping
8cd39578e3 add test case 2020-06-01 11:34:03 +08:00
Niels Lohmann
5ea205f570 👷 install clang 2020-05-30 18:17:54 +02:00
Niels Lohmann
5f10d5d156 👷 install clang 2020-05-30 18:15:13 +02:00
Niels Lohmann
7c0c522b96 👷 install clang 2020-05-30 18:11:54 +02:00
Niels Lohmann
522ec5d7bd 👷 install clang 2020-05-30 18:06:52 +02:00
Niels Lohmann
7e5c2a480a 👷 install clang 2020-05-30 18:04:07 +02:00
Niels Lohmann
9c971c2d2f 👷 install clang 2020-05-30 17:40:27 +02:00
Niels Lohmann
4ba8c95794 👷 install clang 2020-05-30 13:41:18 +02:00
Niels Lohmann
fbd3e8f677 👷 install clang 2020-05-30 13:35:19 +02:00
Niels Lohmann
0309025b45 👷 set full path 2020-05-30 13:28:44 +02:00
Niels Lohmann
9191926fff 👷 use Makefiles 2020-05-30 13:23:13 +02:00
Niels Lohmann
42ef2a5adb 👷 use Clang compiler 2020-05-30 13:15:56 +02:00
Niels Lohmann
2182935397 👷 add Clang/Windows step 2020-05-30 13:07:23 +02:00
chenguoping
4350c5ed97 fix bug in issue#1972 2020-05-30 17:15:56 +08:00
TotalCaesar659
0aa13599f0 Update URLs to HTTPS 2020-05-30 06:02:25 +03:00
Francois Chabot
0da131d717 minor readme correction 2020-05-28 17:12:26 -04:00
Francois Chabot
b715a70673 changed macro order to satisfy clang 2020-05-28 12:26:29 -04:00
Francois Chabot
7646253940 fix inconsistent fwd declaration 2020-05-28 12:20:02 -04:00
Francois Chabot
ce3143a038 use correct deprecation macro 2020-05-28 12:16:10 -04:00
Francois Chabot
d575534471 brought back the from_*(ptr, len) syntax with a deprecation warning 2020-05-28 12:13:43 -04:00
Francois Chabot
248f310215 cleaned up custom iterator example 2020-05-28 10:14:55 -04:00
Francois Chabot
897061c434 amalgamate 2020-05-28 10:11:19 -04:00
Francois Chabot
7ceb06baac Merge branch '1813-user-input' of https://github.com/FrancoisChabot/json into 1813-user-input 2020-05-28 09:30:07 -04:00
Francois Chabot
dcf6175978 use the correct convention for boolean operators 2020-05-28 09:29:38 -04:00
Niels Lohmann
23c8ab95da 👥 update contributor list 2020-05-28 14:24:08 +02:00
Niels Lohmann
53ef076715 🔧 add more warning flags from GCC 10 2020-05-28 13:46:56 +02:00
Niels Lohmann
2edb5cb999 👷 fix -DJSON_BuildTests=On parameter placement 2020-05-28 13:46:47 +02:00
Niels Lohmann
61832afe15 Merge pull request #2144 from XyFreak/gcc10_type_limits
Fix issue#1939: Cast character to unsigned for comparison
2020-05-28 12:59:57 +02:00
Niels Lohmann
5ff4d7b7ff Merge branch 'develop' of https://github.com/nlohmann/json into develop 2020-05-28 12:54:13 +02:00
Niels Lohmann
fcda998ee2 🔧 add more warning flags from GCC 10 2020-05-28 12:53:22 +02:00
Francois Chabot
d3caf93ab0 Merge branch 'develop' into 1813-user-input 2020-05-28 03:40:34 -04:00
Francois Chabot
bfcd32c099 removed clang-format 2020-05-28 03:16:24 -04:00
Francois Chabot
3a91a05db6 added custom input to readme 2020-05-28 03:13:39 -04:00
Francois Chabot
a4f1cf4d00 better parse documentation 2020-05-28 02:50:58 -04:00
Francois Chabot
76b49f9ee6 misc formatting fixes 2020-05-28 02:29:53 -04:00
Niels Lohmann
9ec0e4c25b Merge pull request #2140 from nlohmann/issue1715
Respect allow_exceptions=false for binary formats
2020-05-28 07:52:26 +02:00
Niels Lohmann
a01759af0f Merge pull request #2143 from quentin-dev/develop
Fix issue#2142: readme: fix typo in CMake FetchContent example
2020-05-28 07:50:27 +02:00
Francois Chabot
377995f495 forcefully exclude arrays from being interpreted as pointers 2020-05-27 18:21:38 -04:00
Francois Chabot
b9416a26aa correct ADL lookup of arrays on Mac and Windows 2020-05-27 13:21:23 -04:00
Francois Chabot
f1969e60a3 reamalgamate 2020-05-27 12:56:26 -04:00
Francois Chabot
5684d9a498 unified input API 2020-05-27 12:40:04 -04:00
Quentin Barbarat
e44418ea26 readme: fix typo in CMake FetchContent example 2020-05-27 13:51:13 +02:00
Niels Lohmann
bb9619ef8b 📝 request more details in question template 2020-05-27 13:22:34 +02:00
Niels Lohmann
325e8ab8ab 🔧 explicitly switch on tests in CI 2020-05-27 13:22:14 +02:00
Tobias Kux
23051df2c7 Cast character to unsigned for comparison 2020-05-27 13:15:31 +02:00
Niels Lohmann
ed5c28d00c 👥 update contributor list 2020-05-27 13:07:24 +02:00
Niels Lohmann
d70d06ae41 Merge pull request #2137 from dota17/MSC_VER
Fix issue 2112
2020-05-27 08:49:19 +02:00
Niels Lohmann
e3d9b3d755 📝 add documentation of parser callbacks 2020-05-26 14:16:13 +02:00
Niels Lohmann
ace594da6a Merge branches 'develop' and 'mkdocs' of https://github.com/nlohmann/json into mkdocs 2020-05-26 13:17:55 +02:00
Niels Lohmann
3c60a66c4c Merge pull request #2104 from dota17/issue#2086
Fix issue#2086: disallow json::value_t type parameter in value()
2020-05-26 13:15:06 +02:00
Niels Lohmann
27fe50dc92 📝 add example for contains #2133
Closes #2133.
2020-05-26 12:46:04 +02:00
Niels Lohmann
25aab7ee41 Merge pull request #2136 from aokellermann/CircleCI_GCC_BleedingEdge
Add bleeding edge GCC to CI
2020-05-26 12:39:42 +02:00
chenguoping
eb50fbf926 fix issue 2112 2020-05-26 16:43:16 +08:00
Antony Kellermann
49000cd77d Update documentation to reflect addition of Arch Linux CI testing. 2020-05-25 20:46:39 -04:00
Antony Kellermann
5a72cfa0c3 Add base and base-devel to list of arch linux programs to install. 2020-05-25 20:43:15 -04:00
Antony Kellermann
1d57ddd2d4 Add -y flag to pacman to sync repos. 2020-05-25 20:24:54 -04:00
Antony Kellermann
41a84b1202 Add workflows for CircleCI so that build_stable and build_bleeding_edge jobs can run concurrently. 2020-05-25 20:17:02 -04:00
Antony Kellermann
eff2f51071 Add build_bleeding_edge job to CircleCI, mimicking the original job except using the latest Arch Linux docker image. 2020-05-25 20:14:49 -04:00
Antony Kellermann
bf4a090075 Rename build job to build_stable to be more descriptive. 2020-05-25 20:12:54 -04:00
Niels Lohmann
413df0fd88 📝 add more content to iterator page 2020-05-25 14:03:11 +02:00
Niels Lohmann
95a3c76643 📝 make examples collapsible 2020-05-24 22:45:38 +02:00
Niels Lohmann
ddf92606ab 📝 add PlantUML 2020-05-24 21:05:35 +02:00
Niels Lohmann
3400af21cd 📝 add release page 2020-05-24 13:40:43 +02:00
Niels Lohmann
a8f0cd15df 📝 add mkdocs 2020-05-24 13:03:04 +02:00
Niels Lohmann
c92a696852 📝 update documentation 2020-05-22 18:21:37 +02:00
Niels Lohmann
88292d9499 🚨 remove redundant assertions 2020-05-22 14:19:07 +02:00
Niels Lohmann
225fa58f16 🚧 add fix from #1715 2020-05-20 22:20:40 +02:00
Niels Lohmann
a82c80e9af Merge pull request #2125 from nlohmann/binary_type
Clean up implementation of binary type
2020-05-20 18:58:29 +02:00
Niels Lohmann
ae29456b3f 🚸 overwork report templates 2020-05-20 18:57:21 +02:00
Niels Lohmann
a861bdb81f Merge pull request #2121 from gistrec/fix_compilation_error_msvc
Fixed a compilation error in MSVC
2020-05-19 13:55:37 +02:00
Niels Lohmann
4d39644bd0 💚 fix build 2020-05-19 13:45:52 +02:00
Niels Lohmann
21b1680ea1 🚚 rename binary_array() to binary() 2020-05-19 13:30:22 +02:00
Niels Lohmann
86b053e916 Merge branches 'binary_type' and 'develop' of https://github.com/nlohmann/json into binary_type 2020-05-19 13:10:35 +02:00
Niels Lohmann
952a87a4f4 🚚 move byte container outside detail namespace 2020-05-19 13:08:18 +02:00
Niels Lohmann
79347b484b improve test coverage 2020-05-19 12:40:32 +02:00
Niels Lohmann
5cfa8a586e 👷 run workflows on pull requests 2020-05-18 14:01:54 +02:00
Niels Lohmann
b7ff40029a 💥 change serialization of binary values 2020-05-18 13:53:20 +02:00
Niels Lohmann
9eb19bcc27 add more tests for binary type 2020-05-18 12:33:26 +02:00
gistrec
9e765f5aed Fixed std::numeric_limit::max() call 2020-05-18 10:25:55 +00:00
gistrec
3f0cf26f7a changes to the single header were applied 2020-05-18 10:17:45 +00:00
gistrec
454480f581 fixed a compilation error in MSVC 2020-05-18 14:57:04 +07:00
Niels Lohmann
5dec7166ea Merge branches 'binary_type' and 'develop' of https://github.com/nlohmann/json into binary_type 2020-05-18 09:13:22 +02:00
Niels Lohmann
16d78a82e0 👷 add link to GitHub workflows 2020-05-18 09:12:18 +02:00
Niels Lohmann
c237aa3a68 Merge pull request #2119 from nlohmann/release_cleanup
Overwork CI
2020-05-18 09:07:36 +02:00
Niels Lohmann
904642f261 ♻️ rename internal_binary_t with binary_t 2020-05-17 22:50:27 +02:00
Niels Lohmann
1ce8a5be87 Merge branch 'develop' of https://github.com/nlohmann/json into release_cleanup 2020-05-17 14:11:49 +02:00
Niels Lohmann
dead99eb0e 🔨 overwork binary subtypes 2020-05-17 13:51:59 +02:00
Niels Lohmann
ab6e76dd05 Merge branches 'binary_type' and 'develop' of https://github.com/nlohmann/json into binary_type 2020-05-17 12:27:58 +02:00
Niels Lohmann
3799b3f8dd Merge pull request #2116 from nlohmann/issue2113
Fix warnings from Clang 10 and GCC 9
2020-05-17 12:19:06 +02:00
Niels Lohmann
6154d50a9f Merge pull request #2115 from nlohmann/issue2089
Do not include <ciso646> when using C++17
2020-05-17 12:17:17 +02:00
Niels Lohmann
28e20bd9e4 🚨 fix warnings #2113 2020-05-16 14:26:17 +02:00
Niels Lohmann
ad32f576bd Merge branch 'develop' of https://github.com/nlohmann/json into release_cleanup 2020-05-16 13:22:23 +02:00
Niels Lohmann
c0cf67ead3 Merge branch 'develop' of https://github.com/nlohmann/json into binary_type 2020-05-16 12:58:13 +02:00
Niels Lohmann
f40a9f876a Merge pull request #2044 from dota17/issue#1719
Fix issue#1719
2020-05-16 12:57:00 +02:00
Niels Lohmann
3ed059f6ff revert faulty changes 2020-05-16 12:56:18 +02:00
Niels Lohmann
bc1886fb60 ♻️ refine interface of wrapped_binary_t 2020-05-15 23:21:49 +02:00
Niels Lohmann
a452e8a0a1 💚 fix GCC 4.9 compilation 2020-05-15 22:38:18 +02:00
chenguoping
ed9c205b5d add somes test cases 2020-05-15 21:48:29 +08:00
chenguoping
5dd27f1a9f compare against max float and min float before converting 2020-05-15 21:47:59 +08:00
Niels Lohmann
daf2d296dd ♻️ move wrapped binary type to separate file 2020-05-15 14:12:32 +02:00
chenguoping
779a0ec7df update 2020-05-15 17:35:43 +08:00
Niels Lohmann
bcf4f3ce9a 📝 add warning for items() on temporary objects #2040 2020-05-14 19:06:48 +02:00
Niels Lohmann
fc267af909 📝 update CI list 2020-05-14 17:53:00 +02:00
chenguoping
e175150f5b fix UBSAN 2020-05-14 20:54:47 +08:00
Niels Lohmann
f4cc729054 🔊 add compiler version output 2020-05-14 13:37:59 +02:00
Niels Lohmann
e91236e6d3 🔊 add compiler version output 2020-05-14 13:33:10 +02:00
chenguoping
8f5b5c7469 use json_test_data version 2.0.0 2020-05-14 15:11:38 +08:00
chenguoping
47c6570470 Add some test cases about to_cbor() 2020-05-14 15:11:38 +08:00
chenguoping
44fe284f9d Enhace to_cbor() to support +/-Infinity, NaN, and single-precision float 2020-05-14 15:10:44 +08:00
Niels Lohmann
c4c23f34c5 Merge branch 'develop' of https://github.com/nlohmann/json into release_cleanup 2020-05-14 07:55:09 +02:00
Niels Lohmann
33ae93beed 📝 update CI list 2020-05-14 07:55:01 +02:00
Niels Lohmann
0857140839 Merge pull request #1950 from FrancoisChabot/issues/1457
templated input adapters
2020-05-14 07:52:02 +02:00
chenguoping
cdf5327ace Fix issue#2086 2020-05-14 12:44:30 +08:00
Niels Lohmann
d7b032f565 add tests to improve coverage 2020-05-13 21:28:43 +02:00
Niels Lohmann
ec68bb3387 📝 update CI list 2020-05-13 20:18:56 +02:00
Niels Lohmann
f6f350a5c7 🔊 add operating system output 2020-05-13 14:25:51 +02:00
Niels Lohmann
a4266bbb7d Merge branch 'develop' into issues/1457 2020-05-13 12:48:46 +02:00
Niels Lohmann
855d25a76c Merge branches 'develop' and 'release_cleanup' of https://github.com/nlohmann/json into release_cleanup 2020-05-13 12:41:22 +02:00
Niels Lohmann
a414e35971 🚨 add newline to end of file 2020-05-13 12:35:11 +02:00
Niels Lohmann
def8aeb141 Merge branches 'develop' and 'release_cleanup' of https://github.com/nlohmann/json into release_cleanup 2020-05-13 07:57:03 +02:00
Niels Lohmann
9265ca7a08 Merge pull request #2099 from nlohmann/issue2082
Add tests for binary values
2020-05-13 07:56:11 +02:00
Niels Lohmann
6778ad8b0a 📝 update year 2020-05-12 22:26:55 +02:00
Niels Lohmann
7dbe5cf904 📝 update badges 2020-05-12 21:43:33 +02:00
Niels Lohmann
94115a302e 🏁 exclude slow Unicode test 2020-05-12 21:22:47 +02:00
Niels Lohmann
8c44c7b6de 🏁 set Windows CI to Release mode 2020-05-12 21:18:08 +02:00
Niels Lohmann
44a2158b18 👷 make debug build 2020-05-12 20:51:45 +02:00
Niels Lohmann
77e0ba8750 👷 parallelize builds 2020-05-12 20:45:18 +02:00
Niels Lohmann
6e59c8301a 👷 simplify CMake invocations 2020-05-12 20:37:50 +02:00
Niels Lohmann
ab02b08296 👷 rename workflows 2020-05-12 20:30:11 +02:00
Niels Lohmann
cd76f59af6 👷 add more GitHub actions workflows 2020-05-12 20:26:17 +02:00
Niels Lohmann
b1c1eb145e 🔧 fix maintainer target 2020-05-12 19:36:33 +02:00
Niels Lohmann
abeb80411b 📝 fix example 2020-05-12 16:28:26 +02:00
Niels Lohmann
52f5f3d29f 📝 fix example 2020-05-12 16:27:55 +02:00
Niels Lohmann
e9a845f08a 📝 fix example output 2020-05-12 16:13:33 +02:00
Niels Lohmann
8e0ae9b46f ⬆️ update Doxyfile 2020-05-12 14:37:35 +02:00
Niels Lohmann
afc30a14a7 🔧 set Wandbox script to use HTTPS 2020-05-12 14:37:22 +02:00
Niels Lohmann
6014419818 Merge branches 'develop' and 'issue2082' of https://github.com/nlohmann/json into issue2082 2020-05-12 12:28:34 +02:00
Niels Lohmann
1de30bc611 Merge pull request #2100 from nlohmann/fix_coveralls
Fix Coveralls integration
2020-05-12 12:26:22 +02:00
Niels Lohmann
76c01501f7 🔧 fix pedantic maintainer targets 2020-05-11 20:03:13 +02:00
Niels Lohmann
66dfa22de2 ⚗️ try to fix SSL issue 2020-05-11 14:24:38 +02:00
Niels Lohmann
0ad595709d ⚗️ try to fix SSL issue 2020-05-11 13:40:43 +02:00
Niels Lohmann
cbb2d4e4d8 ⚗️ try to fix SSL issue 2020-05-11 13:29:40 +02:00
Niels Lohmann
8389c1961b ⚗️ try to fix SSL issue 2020-05-11 13:19:22 +02:00
Niels Lohmann
19b21e61e5 ⚗️ try to fix SSL issue 2020-05-11 13:05:53 +02:00
Niels Lohmann
697305819f ⚗️ try to fix SSL issue 2020-05-11 12:37:24 +02:00
Niels Lohmann
18cbcc4135 ⚗️ try to fix SSL issue 2020-05-11 12:25:41 +02:00
Niels Lohmann
a3a803a389 📝 add FOSSA status badge 2020-05-10 13:49:26 +02:00
Niels Lohmann
5c42847011 add tests for binary type 2020-05-10 13:23:18 +02:00
Niels Lohmann
fff46ea98c add tests for binary type 2020-05-09 23:18:12 +02:00
Niels Lohmann
34430994bf add tests for binary type 2020-05-09 14:16:57 +02:00
Niels Lohmann
b036ace235 🐛 fix bug in binary constructor 2020-05-09 14:16:49 +02:00
Niels Lohmann
3fa94f0755 add tests for binary type 2020-05-09 13:46:24 +02:00
Niels Lohmann
f0c6ab4d3b 🐛 fix bug in SAX callback parser 2020-05-08 14:21:11 +02:00
Niels Lohmann
5bfb27c865 🚨 fix some warnings 2020-05-08 12:32:28 +02:00
Niels Lohmann
8c2b26de4a ⚗️ do not include <ciso646> with C++20 #2089 2020-05-07 10:17:32 +02:00
Niels Lohmann
9adb1c0235 🏁 do not include <ciso646> unless old MSVC is used #2089 2020-05-07 09:43:41 +02:00
Niels Lohmann
cf4a6552f3 add tests for binary serialization 2020-05-06 22:24:48 +02:00
Niels Lohmann
3cd2a977ae add test for get_ptr<binary_t*> 2020-05-06 22:13:55 +02:00
Niels Lohmann
1d6f7b0d4e add tests for binary serialization 2020-05-06 22:13:31 +02:00
Niels Lohmann
c10bc7efdd 🔥 remove pretty-print code for binary values 2020-05-06 22:13:08 +02:00
Niels Lohmann
ddff459fa3 add test for BSON binary subtype 2020-05-06 21:24:00 +02:00
Niels Lohmann
421a084396 add convenience function to create binary value with given subtype 2020-05-06 21:23:45 +02:00
Niels Lohmann
2b39efd545 add tests for binary type 2020-05-05 12:59:57 +02:00
Niels Lohmann
6dee8866a8 🐛 fix binary comparison 2020-05-05 12:40:04 +02:00
Niels Lohmann
908941b87d fix test cases 2020-05-05 07:47:20 +02:00
Niels Lohmann
2a34f4cd63 add tests for binary type 2020-05-04 22:07:50 +02:00
Niels Lohmann
48aa441661 add swap function for binary type 2020-05-04 22:07:36 +02:00
Niels Lohmann
a50a14088c Merge pull request #2081 from nlohmann/external_test_data
Use external test data
2020-05-04 20:58:02 +02:00
Niels Lohmann
2304629a3f 📌 use JSON test data v1.0.0 2020-05-04 16:00:00 +02:00
Niels Lohmann
e7a88b2d7f 💚 fix AppVeyor and Travis builds 2020-05-03 19:33:01 +02:00
Niels Lohmann
634fa87e5a Merge pull request #2080 from nlohmann/remove_doozer
Remove Doozer CI
2020-05-03 13:58:29 +02:00
Niels Lohmann
24237af983 🎨 fix format 2020-05-03 13:40:23 +02:00
Niels Lohmann
2f0d37d7d2 🔥 remove fastcov 2020-05-02 23:48:11 +02:00
Niels Lohmann
9c0c58d948 🔥 remove Doozer CI 2020-05-02 23:41:28 +02:00
Niels Lohmann
929f5d398c 🔨 fix coverage tests 2020-05-02 23:24:21 +02:00
Niels Lohmann
752c62b4bd 🔨 remove double tests 2020-05-02 16:07:09 +02:00
Niels Lohmann
f0050c9ba0 Merge pull request #2019 from dota17/contains_v2
fix #1982:json_pointer.contains() exception is incorrectly raised
2020-05-02 11:04:57 +02:00
Niels Lohmann
bec554936c 🔨 fix paths 2020-05-02 10:56:01 +02:00
Niels Lohmann
08c9472184 🔨 simplify workflow 2020-05-01 21:06:41 +02:00
Niels Lohmann
3ae7237f5a 🔨 clean up 2020-05-01 21:01:47 +02:00
Niels Lohmann
cfb2f34ebb 🔨 fix benchmarks 2020-05-01 20:59:47 +02:00
Niels Lohmann
d0ef591ce2 Merge branches 'develop' and 'external_test_data' of https://github.com/nlohmann/json into external_test_data 2020-05-01 20:23:08 +02:00
Niels Lohmann
ec5cfdd307 🔨 properly find and use Git 2020-05-01 16:18:04 +02:00
Niels Lohmann
d144459f1e add git 2020-05-01 16:14:13 +02:00
Niels Lohmann
f58383b8ee 🔊 output on failure 2020-05-01 15:22:18 +02:00
Niels Lohmann
7ade3a0efb remove dependency to FetchContent 2020-05-01 15:14:37 +02:00
Niels Lohmann
dbf1a1f413 ♻️ download test data from external repository 2020-05-01 14:32:37 +02:00
Niels Lohmann
2251741b53 Merge pull request #2077 from ArthurSonzogni/develop-2
Fix README.md. Missing ```
2020-05-01 14:08:59 +02:00
ArthurSonzogni
f26689e006 Fix README.md
About pull request:
https://github.com/nlohmann/json/pull/2074

An error has been introduced by accepting the suggestions:
4be4a038cc

One was about removing ~~~, but it was meant to be replaced by ``` in
reality. This caused the README.md to be slightly broken.
2020-05-01 13:55:24 +02:00
Niels Lohmann
798dbb5c19 📝 add detail 2020-05-01 13:19:49 +02:00
Niels Lohmann
c9f404dc98 Merge pull request #2076 from rmisev/patch-1
Fix error message about invalid surrogate pairs
2020-05-01 12:47:39 +02:00
Niels Lohmann
b27d8a3253 Merge pull request #2074 from ArthurSonzogni/develop
Add CMake fetchcontent documentation and tests
2020-05-01 12:42:29 +02:00
Rimas Misevičius
6f1800889a Fix tests 2020-05-01 00:59:12 +03:00
Rimas Misevičius
4c053e3ec9 Fix tests 2020-05-01 00:48:24 +03:00
Rimas Misevičius
6815968a42 Fix error message about invalid surrogate pairs
I tested following strings with invalid surrogate pair and unpaired surrogate in files:

1. `"a\uD800\uD800x"`
2. `"a\uD800x"`

The error messge was: "... invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; ..."

I think it must be: "... invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; ..."
2020-05-01 00:23:04 +03:00
Arthur Sonzogni
4be4a038cc Apply suggestions from code review
Co-Authored-By: Niels Lohmann <niels.lohmann@gmail.com>
2020-04-29 21:08:39 +02:00
Niels Lohmann
db013c9428 Merge pull request #2071 from nlohmann/issue2067
Properly pass serialize_binary to dump function
2020-04-29 19:39:58 +02:00
ArthurSonzogni
c331706644 Add CMake fetchcontent documentation and tests
Github issue:
https://github.com/nlohmann/json/issues/2073

nlohmann::json documents 2 way of depending on it using CMake
1) Copy-paste the project/source into your own project.
2) Install nlohman::json and then use find_package.

(1) pollutes your git repository, (2) requires everyone to install the
dependencies themselves.

Since 2018, CMake provide some kind of 'package manager' features using
[FetchContent](https://cmake.org/cmake/help/v3.17/module/FetchContent.html)
It gives the following:
~~~cmake
include(FetchContent)

FetchContent_Declare(json
  GIT_REPOSITORY https://github.com/nlohmann/json
  GIT_TAG v3.7.3)

FetchContent_GetProperties(json)
if(NOT json_POPULATED)
  FetchContent_Populate(json)
  add_subdirectory( ${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
~~~

Then declares the dependency in the target using it:
~~~cmake
target_link_library(my_project PRIVATE nlohmann_json::nlohmann_json
~~~

This patch updates the documentation and provides tests.
2020-04-29 18:28:06 +02:00
Niels Lohmann
b1fe6ee0d1 Merge pull request #2069 from nlohmann/issue2064
Fix returning reference to local temporary object
2020-04-28 20:56:48 +02:00
Niels Lohmann
2e5727d778 🐛 properly pass serialize_binary to dump function #2067 2020-04-27 15:10:23 +02:00
Niels Lohmann
9e0180b698 🐛 fix returning reference to local temporary object #2064 2020-04-27 14:43:49 +02:00
Niels Lohmann
d9d1279a94 Merge pull request #2060 from alexandermyasnikov/develop
updated wandbox link
2020-04-24 09:18:23 +02:00
Alexander Myasnikov
b01bc05b2b updated wandbox link 2020-04-23 13:32:42 +03:00
Niels Lohmann
63afc8e3f8 Merge pull request #2043 from dota17/unit-constructor1
Add missing testcase about NaN in unit-constructor1.cpp
2020-04-21 07:35:44 +02:00
Niels Lohmann
a29e3b1318 Merge pull request #2054 from nlohmann/feature/issue1983
Fix bug in diff function
2020-04-20 19:44:35 +02:00
Niels Lohmann
c0a39b22a6 🚨 fix compiler warning 2020-04-20 19:42:58 +02:00
chenguoping
8bfc692602 update condition 2020-04-20 16:00:55 +08:00
Niels Lohmann
3607687a14 Merge pull request #2053 from nlohmann/gcc10warnings
Fix GCC compiler warnings
2020-04-20 08:05:42 +02:00
Niels Lohmann
721a1a0b5d Merge pull request #2051 from nlohmann/clang10warnings
Fix Clang compiler warnings
2020-04-20 08:04:23 +02:00
Niels Lohmann
f14a7d8af7 Merge pull request #2050 from nlohmann/doctest_update
Update doctest to 2.3.7
2020-04-20 08:02:58 +02:00
chenguoping
c379d02b3e Add missing testcase about NaN in unit-constructor1.cpp 2020-04-20 10:25:44 +08:00
Niels Lohmann
e8356928bd 🚨 fix compiler warnings #2052 2020-04-19 13:25:02 +02:00
Niels Lohmann
4fb0795ec1 🚨 fix compiler warnings #2049 2020-04-19 13:01:36 +02:00
Niels Lohmann
45d5b09425 ⬆️ doctest 2.3.7 #2048 2020-04-19 12:33:42 +02:00
Niels Lohmann
be137609df Merge pull request #1746 from uhoreg/cmake_arch_indep
make CMake's version config file architecture-independent
2020-04-19 10:09:28 +02:00
Hubert Chathi
2b0e4c7a94 add comments 2020-04-17 15:44:12 -04:00
Niels Lohmann
3bc9e053c9 Merge pull request #1969 from dota17/dota17-warning
fix warnings in serializer.hpp for VS2019
2020-04-17 10:10:38 +02:00
Niels Lohmann
69ac336042 Merge pull request #1967 from dota17/dota17-disable
Fix C26451 warnnings in to_chars.hpp
2020-04-17 10:08:21 +02:00
Niels Lohmann
f2b43a36b2 Merge pull request #1662 from OmnipotentEntity/develop
Add binary type support to all binary file formats, as well as an internally represented binary type
2020-04-16 11:14:32 +02:00
Michael Reilly
012c9665ac Add binary type support to all binary file formats, as well as an internally represented binary type 2020-04-14 10:22:45 -04:00
Niels Lohmann
dd04a32918 🐛 fix bug in diff function #1983 2020-04-13 14:35:36 +02:00
chenguoping
f5a487d1b4 fix issue1982: contains() exceptions are incorrectly raised 2020-04-13 19:41:13 +08:00
Niels Lohmann
b7be613b6e Merge pull request #1990 from dota17/json_pointer
catch exceptions for json_pointer : ..../+99
2020-04-13 13:29:33 +02:00
Niels Lohmann
84f19d6333 Merge pull request #2034 from ArtemSarmini/gh-1920-gcc-10-incomplete-types
Templatize basic_json constructor from json_ref
2020-04-13 13:19:28 +02:00
Niels Lohmann
b0a3883081 🎨 fix format 2020-04-13 13:11:26 +02:00
Niels Lohmann
3483d923d4 Merge pull request #2033 from nlohmann/feature/issue1913
Replace deprecated std::is_pod
2020-04-13 12:32:37 +02:00
Artöm Bakri Al-Sarmini
70be9751cd typo fix 2020-04-12 23:42:26 +03:00
Artöm Bakri Al-Sarmini
ec955f08b4 Templatize basic_json ctor from json_ref 2020-04-12 22:32:39 +03:00
Niels Lohmann
7fcc860329 🔥 remove WhiteSource 2020-04-12 16:35:41 +02:00
Niels Lohmann
4396a68d2d Merge pull request #1984 from dota17/document-fix
Modify the document about operator==
2020-04-11 18:55:18 +02:00
Niels Lohmann
062fd3842c Merge pull request #2004 from wsjcpp/develop
Added wsjcpp.yml
2020-04-11 11:48:04 +02:00
Niels Lohmann
9154e991b8 Merge branch 'develop' into feature/issue1913 2020-04-11 11:33:46 +02:00
Evgenii Sopov
d164a2bf09 Added wsjcpp.yml: C++ Source Package Manager 2020-04-11 16:30:04 +07:00
Niels Lohmann
6121fc52cf 🎨 fix indentation 2020-04-10 13:22:58 +02:00
Niels Lohmann
ea0a7c7b4f Merge pull request #2025 from ArtemSarmini/issue-1971-basic_json-push_back
Fixes #1971 (memory leak in basic_json::push_back)
2020-04-10 13:19:14 +02:00
Niels Lohmann
d01193a4e4 🎨 run "make amalgamate" 2020-04-10 13:18:12 +02:00
Niels Lohmann
299feb13e7 Merge pull request #1958 from t-b/add-zc-flag-for-msvc
appveyor.yml: Compile and test with latest version for __cplusplus ma…
2020-04-10 13:12:34 +02:00
Artöm Bakri Al-Sarmini
8db02bcc55 Fix for gcc 2020-04-08 15:53:14 +03:00
Artöm Bakri Al-Sarmini
fec0bdd93b still fixing 2020-04-08 00:42:03 +03:00
Artöm Bakri Al-Sarmini
4ce31695f1 Fixed formatting, trying to fix msvc build error in appveyor 2020-04-08 00:26:43 +03:00
Niels Lohmann
c6b298799a 👷 remove failing Travis workers 2020-04-07 09:09:44 +02:00
chenguoping
34cf7b7a48 just restart ci 2020-04-07 10:00:21 +08:00
Thomas Braun
5607dfb48a appveyor.yml: Compile and test with latest version for __cplusplus macro on MSVC
According to [1] the C++ macro __cplusplus has always the value 199711L
even if you enable later version of C++ support via /std.

Use one job with /Zc:__cplusplus defined so that we know that it
compiles.

[1]: https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=vs-2019
2020-04-06 11:56:33 +02:00
Niels Lohmann
6a53a95c32 ⬆️ Hedley 13 2020-04-06 11:56:33 +02:00
Niels Lohmann
3884d33c60 Merge pull request #1980 from linev/fix_warning
Rename argument array_index to array_indx in json_pointer methods
2020-04-05 22:00:41 +02:00
Niels Lohmann
554e8c7356 Merge pull request #2002 from alexandermyasnikov/develop
fix error 'setw' is not a member of 'std' in Wandbox example
2020-04-05 21:58:21 +02:00
Niels Lohmann
5c00308de7 Merge pull request #2010 from magamig/patch-1
Update LICENSE.MIT
2020-04-05 21:55:47 +02:00
Niels Lohmann
83e36f314f Merge pull request #2008 from garethsb-sony/implicit-cast-vs2019
PR for #2006 to test in AppVeyor.
2020-04-05 21:53:47 +02:00
Niels Lohmann
379ed1f67e 💰 add sponsor 2020-04-05 15:23:00 +02:00
Artöm Bakri Al-Sarmini
a74a031bba Fix build error 2020-04-02 15:47:08 +03:00
Artöm Bakri Al-Sarmini
e4d8dc02e8 Fixes #1971 (memory leak in basic_json::push_back) 2020-04-02 15:20:25 +03:00
Miguel Magalhães
3df622a417 Update LICENSE.MIT 2020-03-25 17:24:23 +00:00
chenguoping
e07686f0c7 update array_index() and add testcases 2020-03-25 15:57:20 +08:00
chenguoping
2e7d340dad docs:modify the document about operator== 2020-03-25 10:18:04 +08:00
garethsb-sony
7fe16f9400 PR for #2006 to test in AppVeyor. 2020-03-24 12:53:59 +00:00
chenguoping
dcd3a6c62b move the catch of std::invalid_argument into array_index() 2020-03-23 17:24:47 +08:00
chenguoping
59cb4c93be fix C26451 warnning in serializer.hpp for VS2019 2020-03-23 16:08:47 +08:00
chenguoping
0a8216890d fix C26451 warnnings in to_chars.hpp 2020-03-23 15:27:35 +08:00
Alexander Myasnikov
4df7dc04f6 fix error 'setw' is not a member of 'std' in Wandbox example 2020-03-21 18:34:40 +03:00
Sergey Linev
78e911b8c3 Use array_idx as methods args
Avoid mix-up with array_index member

Co-Authored-By: Niels Lohmann <niels.lohmann@gmail.com>
2020-03-19 11:52:40 +01:00
Niels Lohmann
19843b038c Merge pull request #1933 from dota17/dota17-FAQ
Update README.md : add a FAQ about memory release
2020-03-19 11:25:47 +01:00
Niels Lohmann
ebb5a4c09f 💰 add sponsor 2020-03-19 11:14:50 +01:00
chenguoping
bfc003cadf catch exceptions for json_point : /xx/+99 2020-03-17 20:49:28 +08:00
chenguoping
2ccdfebaa7 fix typo 2020-03-14 18:10:55 +08:00
Niels Lohmann
54656ef279 Merge pull request #1956 from dota17/dota17-fix-typo
Fix typo in examples
2020-03-13 17:26:24 +01:00
Niels Lohmann
d102da61ad Merge pull request #1979 from alex-weej/patch-2
README: Fix string representation of `dump`ed `json`
2020-03-13 16:49:13 +01:00
Sergey Linev
00049c20d0 Rename argument array_index to array_indx in json_pointer methods
Fixes gcc48 warning:

declaration of ‘array_index’ shadows a member of 'this' [-Wshadow]
2020-03-11 07:41:53 +01:00
Alexander “weej” Jones
5fdb1d08aa README: Fix string representation of dumped json
As is it's confusing and inconsistent with the indented form right below. The backslash escapes make it confusing.
2020-03-10 19:37:20 +00:00
Francois Chabot
41b0704ce1 removed move assignments from input adapters 2020-03-02 23:50:01 -05:00
Francois Chabot
7eadd6daef added back forward declaration to address warnings 2020-02-28 18:15:11 -05:00
dota17
699e0a923c fix typo in examples 2020-02-26 13:44:08 +08:00
Francois Chabot
c7282d5b1e simpler endian detection for older gcc versions 2020-02-20 10:19:29 -05:00
Francois Chabot
770ae6e9da accomodate older gcc 2020-02-19 16:54:09 -05:00
Francois Chabot
de35fad88e fixed missing return arg of operator=() 2020-02-19 15:23:49 -05:00
Francois Chabot
2e2cf02cfd duck-typed object input adapters 2020-02-19 14:59:31 -05:00
Francois Chabot
a0c4fc945a fixed bad friend class declaration 2020-02-19 11:23:02 -05:00
Francois Chabot
617b3cf42e templated input adapters 2020-02-19 10:32:49 -05:00
Chen
42566c6bef Update README.md 2020-02-17 15:40:52 +08:00
Niels Lohmann
61b46a56fb 🏗️ replace is_pod by is_trivial 2020-02-15 10:12:27 +01:00
Chen
88097a250f Update README.md : add a FAQ about memory release 2020-02-10 21:03:57 +08:00
Niels Lohmann
973c52dd4a Merge pull request #1923 from Coeur/typos
Some typos
2020-02-02 14:48:07 +01:00
Antoine Cœur
8d92ca865f Some typos 2020-02-02 17:29:37 +08:00
Niels Lohmann
6a6790ab68 Merge pull request #1917 from jothepro/update-links-to-hunter
Readme: Updated links to hunter repo & docs
2020-01-31 11:47:42 +01:00
Niels Lohmann
3eb6b0e7a2 Merge pull request #1918 from kastiglione/patch-1
Fix link to parse function in README
2020-01-31 11:46:53 +01:00
Dave Lee
f25a1287f9 Fix link to parse function in README 2020-01-29 14:19:00 -08:00
jothepro
0257533866 Updated links to hunter repo & docs
hunter was recently passed over to a new maintainer, this is why the github url & the link to the documentation have changed.
2020-01-29 22:33:59 +01:00
Niels Lohmann
6ca5338a0c Merge pull request #1909 from Klaim/patch-1
Adds instruction for using Build2's package manager
2020-01-28 19:00:45 +01:00
Joël Lamotte
ab538ba523 Formatting
(proper naming suggested by `build2`'s author)
2020-01-21 17:49:23 +01:00
Joël Lamotte
708e107d8e Adds instruction for using Build2's package manager
I created a `nlohmann-json` package for `build2` (https://build2.org) that have been published on the central public repository https://cppget.org : https://cppget.org/nlohmann-json (at the moment you can see that there is only one version: 3.7.3).

The repository of the package code is there: https://github.com/build2-packaging/nlohmann-json and is owned by the build2 community now. (with build2 you can use either a repository like cppget.org or a git repository so both are useful to users for different use cases).

This patch just add the basic information as to how to use this library with build2.
2020-01-20 14:50:15 +01:00
Niels Lohmann
ad383f66bc Merge pull request #1907 from pauljurczak/patch-1
Update README.md
2020-01-19 22:45:53 +01:00
Paul Jurczak
bc95563814 Update README.md 2020-01-18 14:25:03 -07:00
Niels Lohmann
7acf6218b6 📝 fix typo #1903 2020-01-15 17:40:03 +01:00
Niels Lohmann
0feea6168d 📝 fix scanner documentation 2020-01-12 10:22:11 +01:00
Niels Lohmann
bde5712418 Merge pull request #1871 from sonulohani/develop
Fix warning: ignoring return value
2019-12-16 15:06:47 +01:00
Sonu Lohani
4c1ebb4413 Fix warning: ignoring return value 2019-12-16 14:22:41 +05:30
Niels Lohmann
b568619c4a 💰 add sponsor section 2019-12-15 19:26:51 +01:00
Niels Lohmann
bccc8f0577 Merge pull request #1857 from gocarlos/develop
docs: add central repository as conan source to readme
2019-12-01 11:53:24 +01:00
Carlos Gomes Martinho
ac9df48453 style: format readme 2019-12-01 10:23:24 +01:00
Carlos Gomes Martinho
f44e8ac090 revert: adding conan badge 2019-12-01 10:22:48 +01:00
Carlos Gomes Martinho
134a5faa2b docs: add central repository as conan source to readme 2019-11-29 13:49:53 +01:00
Niels Lohmann
c3270ac734 Merge pull request #1853 from podsvirov/readme-msys2-package-rename
README: Package in MSYS2 renamed to nlohmann-json
2019-11-23 09:21:52 +01:00
Konstantin Podsvirov
f586bc014f README: Package in MSYS2 renamed to nlohmann-json
This is done to correctly match with the
corresponding package in Archlinux.
2019-11-23 05:02:20 +03:00
Niels Lohmann
c0f52edbc3 📝 add badges 2019-11-22 21:17:31 +01:00
Niels Lohmann
a4c01f3380 👥 add GitHub Sponsors 2019-11-22 20:58:44 +01:00
Niels Lohmann
3f044dad81 📝 add Xocde 11.2.1 to CI list 2019-11-22 08:00:41 +01:00
Niels Lohmann
28b1448508 👷 add Xcode 11.2.1
https://twitter.com/travisci/status/1197625080119021568
2019-11-21 22:22:06 +01:00
Niels Lohmann
7439cfe5c8 Merge pull request #1844 from Tridacnid/develop
Update tests that generate CMake projects to use main project's C++ compiler
2019-11-19 19:27:14 +01:00
Niels Lohmann
b2bec943d1 Merge pull request #1846 from Mike-Bal/fix_warnings
Fix msvc warnings
2019-11-19 19:24:36 +01:00
Michael Balszun
25e0175bc3 Remove unnecessary warning suppressions in test cmake file 2019-11-19 11:26:35 +01:00
Michael Balszun
5c045f7d0a Use correct accumulator type in binary_writer if size_t != ul
- Also fixes warning in msvc about possible loss of data in
  that size computation.
2019-11-19 11:06:45 +01:00
Joe Burzinski
fbb0bd7556 Update tests that generate CMake projects to use the CMAKE_CXX_COMPILER the main project was CMake'd with. Fixes #1747. 2019-11-18 21:46:34 -06:00
Niels Lohmann
e7b3b40b5a Merge branch 'release/3.7.3' into develop 2019-11-17 12:21:44 +01:00
Niels Lohmann
c5eafe74e8 🔖 set version to 3.7.3 2019-11-17 12:09:12 +01:00
Niels Lohmann
c6e1e26018 Merge pull request #1838 from nickaein/fix-quadratic-destruction
Fix quadratic destruction complexity
2019-11-15 07:02:12 +01:00
Isaac Nickaein
efa13c663d Reserve stack only for top-level items 2019-11-13 15:23:08 +03:30
Isaac Nickaein
948f98cf4a Cleanups
Make our intent more clear in destruction
2019-11-12 22:24:11 +03:30
Isaac Nickaein
0f3ec003bb Remove harmful vector::reserve during destruction (#1837) 2019-11-12 22:22:55 +03:30
Niels Lohmann
be61ad1470 🎨 fix inconsistent operator style 2019-11-11 21:37:32 +01:00
Niels Lohmann
411158d896 Merge branch 'release/3.7.2' into develop 2019-11-10 21:39:14 +01:00
Niels Lohmann
56109eacd7 🔖 set version to 3.7.2 2019-11-10 21:23:39 +01:00
Niels Lohmann
7b0c50b9a5 🔨 add path 2019-11-10 19:09:48 +01:00
Niels Lohmann
0a513a35cb Merge pull request #1436 from nickaein/iterate-on-destruction
Prevent stackoverflow caused by recursive deconstruction
2019-11-10 11:57:06 +01:00
Isaac Nickaein
7e2445a0f4 Move deep JSON test to a separate unit-test 2019-11-09 21:42:39 +03:30
Isaac Nickaein
68d0a7b246 Reduce depth in unit-test to avoid choking valgrind 2019-11-09 21:19:12 +03:30
Isaac Nickaein
eec1974218 Merge remote-tracking branch 'nlohmann/develop' into iterate-on-destruction 2019-11-09 14:50:48 +03:30
Niels Lohmann
67259d698f Merge pull request #1830 from nlohmann/whitesource/configure
Configure WhiteSource Bolt for GitHub
2019-11-08 14:04:27 +01:00
whitesource-bolt-for-github[bot]
760076abca Add .whitesource configuration file 2019-11-08 13:01:29 +00:00
Niels Lohmann
1a9de88117 🚨 fix a linter warning
Coverity detected two "Memory - illegal accesses  (OVERRUN)" issues. Resizing the buffer should silence this warning.
2019-11-07 08:00:21 +01:00
Niels Lohmann
d98bf0278d Merge branch 'release/3.7.1' into develop 2019-11-06 20:34:07 +01:00
Niels Lohmann
aacdc6bbe3 🔖 set version to 3.7.1 2019-11-06 18:37:26 +01:00
Niels Lohmann
0f6a58eeaf 👥 update contributors 2019-11-06 17:35:04 +01:00
Niels Lohmann
1e9f16dff0 🚨 fix linter errors 2019-11-05 20:25:53 +01:00
Niels Lohmann
c0ae88bf50 🚨 fix linter errors 2019-11-05 20:23:17 +01:00
Niels Lohmann
62dada05ca 🐛 fix conversion to std::valarray
closes #1824
2019-11-05 19:28:00 +01:00
Niels Lohmann
7bcaba0ca9 Merge pull request #1821 from AnthonyVH/develop
Fix for #1647
2019-11-05 19:15:54 +01:00
Niels Lohmann
1ca6f2901b Merge pull request #1826 from cbegue/develop
Add restriction for tuple specialization of to_json
2019-11-05 19:14:37 +01:00
Niels Lohmann
abccafa5c5 ⬆️ upgrade Doctest to 2.3.5 2019-11-05 19:11:54 +01:00
Anthony VH
c4923e3d05 Merge remote-tracking branch 'upstream/develop' into develop 2019-11-04 20:50:43 +01:00
Anthony VH
ec9647ae63 Moved test for #1647 regression to regressions file. 2019-11-04 20:45:24 +01:00
Camille Bégué
8b686b30eb Add restriction for tuple specialization of to_json
This commit fix the issue #1825

Signed-off-by: Camille Bégué <c.begue@samsung.com>
2019-11-04 09:57:16 +01:00
Niels Lohmann
3790bd9ae0 👷 add Xcode 10.2 2019-11-04 06:22:39 +01:00
Niels Lohmann
42e9ad32c6 🔨 remove full path 2019-11-03 21:49:22 +01:00
Niels Lohmann
e779714dd8 👷 add Xcode 10.2 2019-11-03 20:45:21 +01:00
Niels Lohmann
bf2afaeee6 🔊 add version output 2019-11-03 20:27:07 +01:00
Niels Lohmann
6a4cc29f01 📝 update examples 2019-11-03 19:40:38 +01:00
Niels Lohmann
dfe53c36da 🚨 fix UBSAN warnings 2019-11-03 13:48:25 +01:00
Niels Lohmann
0db1692f45 👥 update contributors 2019-11-02 10:24:06 +01:00
Niels Lohmann
1307862b1d Merge pull request #1694 from eli-schwartz/release-include-meson
release: add singleinclude and meson.build to include.zip
2019-11-02 09:28:51 +01:00
Niels Lohmann
4d1e4c6d93 Merge pull request #1780 from t-b/add-msvc-16-2019
appveyor.yml: Add MSVC 16 2019 support
2019-11-02 08:16:53 +01:00
Niels Lohmann
a1828bbf57 Merge pull request #1806 from cbegue/develop
Fix issue #1805
2019-11-01 19:46:19 +01:00
Camille Bégué
794a3d411a Fix issue #1805
* Add some restriction on pair partial specialization of to_json

Signed-off-by: Camille Bégué <camille.begue.pro@gmail.com>
2019-10-31 18:04:15 +01:00
Anthony Van Herrewege
ddda67a096 Don't capture json input by value (fixed #1822). 2019-10-30 16:16:34 +01:00
Anthony Van Herrewege
fb9a2643c8 Add test for #1647. 2019-10-30 15:46:31 +01:00
Anthony Van Herrewege
27d0dfc17a Fix #1647: non-member operator== breaks enum (de)serialization. 2019-10-30 14:54:52 +01:00
Niels Lohmann
f272ad533d 👥 add CODEOWNERS file 2019-10-23 21:41:12 +02:00
Niels Lohmann
f7e7a62358 📝 add comment on JSON_THROW_USER, JSON_TRY_USER, and JSON_CATCH_USER 2019-10-23 20:58:06 +02:00
Niels Lohmann
507d5676ad 🚨 fix warning 2019-10-23 20:57:10 +02:00
Niels Lohmann
00cb98a3d1 Merge pull request #1803 from flopp/spelling
Fix some spelling errors - mostly in comments & documentation.
2019-10-21 20:50:13 +02:00
Florian Pigorsch
b93d414a35 Fix some spelling errors - mostly in comments & documentation.
I did not touch the Changelog file and any third party stuff.

additonal -> additional (1)
apppend -> append (2)
constuctor -> constructor (2)
contect -> context (2)
dobulequote -> doublequote (1)
elemnts -> elements (1)
exakt -> exact (2)
exluded -> exclude (1)
explicitely -> explicitly (2)
narcissic -> narcissistic (1)
ocurred -> occurred (1)
occuring -> occurring (2)
preceeds -> preceded (1)
ot -> to (2)
wehther -> whether (2)
2019-10-19 11:59:51 +02:00
Eli Schwartz
f4332d4097 README: describe how to use json as a meson subproject
Also call out to the guidelines for using pkg-config dependencies first,
and reference it for other build systems as well.

Although the possibility of installing with a pkg-config file is
somewhat hidden away in the meson docs, it's been deemed less invasive
due to not distracting away from cmake. So it will have to do.
2019-10-17 15:38:06 -04:00
Eli Schwartz
84faa36ec5 release: add singleinclude and meson.build to include.zip
This serves as a minimal release-only way to embed json into a project.
Add meson support to this directly, to make it usable standalone as a
meson subproject.

Implements #1672
2019-10-17 15:26:51 -04:00
Niels Lohmann
0245ae5157 Merge pull request #1797 from t-b/fix-integer-truncation
iteration_proxy: Fix integer truncation from std::size_t to int
2019-10-17 21:02:48 +02:00
Niels Lohmann
4c06191836 Merge pull request #1799 from nemequ/develop
Update Hedley to v11.
2019-10-17 20:59:49 +02:00
Evan Nemerson
fbcbc76d10 Update Hedley to v11. 2019-10-16 13:39:40 -07:00
Thomas Braun
c6cbdf96a9 appveyor.yml: Add debug build on x64 and VS 2019 2019-10-16 22:34:33 +02:00
Thomas Braun
01e486bb55 appveyor.yml: Add MSVC 16 2019 support 2019-10-16 22:34:33 +02:00
Thomas Braun
35b47c2793 iteration_proxy: Fix integer truncation from std::size_t to int
Bug introduced in 0f073e26 (Allow items() to be used with custom string,
2019-09-26).
2019-10-16 20:00:05 +02:00
Thomas Braun
5541a2bd25 test/cmake_import: Pass the generator platform required by MSVC 2019 2019-10-16 17:10:19 +02:00
Thomas Braun
7a521150aa appveyor: Pass the generator platform explicitly
In a future commit we want to add support for MSVC 2019. For that
version cmake requires us to pass in the architecture not part of the
generator but explicitly.

So let's pass that in always like that. This also removes the doubling
of the platform/architecture.
2019-10-16 17:10:19 +02:00
Niels Lohmann
ed5541440a Merge pull request #1779 from t-b/avoid-using-glob-in-cmake
test/CMakeLists.txt: Use an explicit list instead of GLOB
2019-10-09 07:37:43 +02:00
Thomas Braun
eb6fe421ae test/CMakeLists.txt: Use an explicit list instead of GLOB
Using GLOB is slow and considered bad practice.

From https://cmake.org/cmake/help/latest/command/file.html:

> We do not recommend using GLOB to collect a list of source files from
> your source tree. If no CMakeLists.txt file changes when a source is
> added or removed then the generated build system cannot know when to ask
> CMake to regenerate. The CONFIGURE_DEPENDS flag may not work reliably on
> all generators, or if a new generator is added in the future that cannot
> support it, projects using it will be stuck. Even if CONFIGURE_DEPENDS
> works reliably, there is still a cost to perform the check on every
> rebuild.
2019-10-07 21:13:09 +02:00
Niels Lohmann
d187488e0d Merge pull request #1765 from crazyjul/fix/items-with-alt-string
Allow items() to be used with custom string
2019-10-05 22:11:14 +02:00
Niels Lohmann
dae0fe79af Merge pull request #1769 from chris0x44/json_pointer
Make json_pointer::back const (resolves #1764)
2019-10-03 10:35:34 +02:00
Niels Lohmann
d826282f53 Merge pull request #1767 from 0xflotus/patch-1
did you mean 'serialization'?
2019-10-01 11:32:05 +02:00
Julien Hamaide
4615f5a980 Provide default implementation for int_to_string, but allow for overloaded function 2019-10-01 10:34:21 +02:00
christian
7476f5ee0c Make json_pointer::back const (resolves #1764) 2019-10-01 00:57:27 +02:00
0xflotus
d7579b8cbf did you mean 'serialization'? 2019-09-30 18:11:44 +02:00
Julien Hamaide
0f073e26eb Allow items() to be used with custom string 2019-09-26 13:20:57 +02:00
Niels Lohmann
99d7518d21 📝 add OSS Fuzz status badge 2019-09-24 21:01:06 +02:00
Niels Lohmann
e2c531a1f7 Merge pull request #1760 from Xav83/cppcheckFixes
Cppcheck fixes
2019-09-24 20:42:38 +02:00
Xav83
87afee1c39 Runs make amalgamate on the project. 2019-09-20 11:45:38 +02:00
Xav83
13a7c60257 Correct a warning from cppcheck:
binary_writer.hpp:869: (style) Consider using std::accumulate algorithm instead of a raw loop.

910a7d2b87/checks (step):5:107

Signed-off-by: Xav83 <x.jouvenot@gmail.com>
2019-09-20 11:45:38 +02:00
Xav83
b9dfdbe6be Correct a warning from cppcheck:
binary_reader.hpp:650: (style) Unsigned expression 'mant' can't be negative so it is unnecessary to test it

910a7d2b87/checks (step):5:84

Signed-off-by: Xav83 <x.jouvenot@gmail.com>
2019-09-19 19:25:55 +02:00
Niels Lohmann
771d5dadc6 Merge pull request #1741 from tete17/Fix-SFINAE
Fix and add test's for SFINAE problem
2019-09-16 22:39:42 +02:00
Hubert Chathi
cade804c1a make CMake's version config file architecture-independent 2019-09-10 23:41:38 -04:00
Miguel Sacristan
e26a2904fc Fix and add test's for SFINAE problem 2019-09-10 21:36:23 +02:00
Niels Lohmann
06ccd43a2a Merge pull request #1722 from t-b/fix-int64-min-issue
Fix int64 min issue
2019-09-10 07:58:02 +02:00
Niels Lohmann
a6bd798bfa Merge pull request #1728 from t-b/fix-clang-sanitizer-invocation
Fix clang sanitizer invocation
2019-09-10 07:50:02 +02:00
Thomas Braun
8067c3ca5b Add serialization unit tests for extreme integer values 2019-09-03 13:55:19 +02:00
Thomas Braun
70aa8a31a2 Add regression test for dumping the minimum value of int64_t 2019-09-03 13:55:19 +02:00
Thomas Braun
6ce2f35ba8 Fix outputting extreme integer values in edge cases
For some gcc version (Ubuntu 5.5.0-12ubuntu1~16.04) the existing code
crashes when the minimum value of int64_t is outputted.

Resurrect the code from before 546e2cbf (🚨 fixed some warnings,
2019-03-13) but delegate the sign removal so that the compilers don't
complain about taking the negative value of an unsigned value.

In addition we also rewrite the expression so that we first increment
and then negate.

The definition of remove_sign(number_unsigned_t) is never called as
unsigned values are never negative.
2019-09-03 13:55:15 +02:00
Thomas Braun
6d701b29df .travis.yml: Increase the timeout to 45 minutes
The clang sanitizer tests, and there especially the unicode tests, can
hit the default timeout of 25 minutes (1500 seconds) quite easily, so
let's raise the timeout to 45 minutes (2700 seconds).
2019-09-03 13:32:25 +02:00
Thomas Braun
d5c0d52f37 external_constructor<std::valarray>: Handle empty array properly
Clang UBSAN complains with the following message when an empty std::valarray is passed in:

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/valarray:571:14 in

2/2 Test #68: test-regression_all ..............***Failed    4.68 sec
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/valarray:571:14: runtime error: reference binding to null pointer of type 'const do
uble'
    #0 0x6fbe57 in std::valarray<double>::operator[](unsigned long) const /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/valarray:
571:7
    #1 0x6fbe57 in double const* std::begin<double>(std::valarray<double> const&) /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/v
alarray:1207
    #2 0x6fbe57 in void nlohmann::detail::external_constructor<(nlohmann::detail::value_t)2>::construct<nlohmann::basic_json<std::map, std::vector, s
td::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_seri
alizer>, double, 0>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool
, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>&, std::valarray<double> const&) /home/firma/devel/json/include/nlohmann/deta
il/conversions/to_json.hpp:157
    #3 0x5e3fe3 in void nlohmann::detail::to_json<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>
, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>, double, 0>(nlohmann::basic_json<std::map, std
::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohman
n::adl_serializer>&, std::valarray<double> const&) /home/firma/devel/json/include/nlohmann/detail/conversions/to_json.hpp:270:5
    #4 0x5e3fe3 in decltype((to_json(fp, std::forward<std::valarray<double>&>(fp0))) , ((void)())) nlohmann::detail::to_json_fn::operator()<nlohmann:
:basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double
, std::allocator, nlohmann::adl_serializer>, std::valarray<double>&>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std
::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>&, std::valarray<double>&) c
onst /home/firma/devel/json/include/nlohmann/detail/conversions/to_json.hpp:334
    #5 0x5e3fe3 in decltype((nlohmann::(anonymous namespace)::to_json(fp, std::forward<std::valarray<double>&>(fp0))) , ((void)())) nlohmann::adl_ser
ializer<std::valarray<double>, void>::to_json<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, st
d::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>, std::valarray<double>&>(nlohmann::basic_json<std:
:map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator
, nlohmann::adl_serializer>&, std::valarray<double>&) /home/firma/devel/json/include/nlohmann/adl_serializer.hpp:45
    #6 0x5e3fe3 in nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool,
 long, unsigned long, double, std::allocator, nlohmann::adl_serializer>::basic_json<std::valarray<double>&, std::valarray<double>, 0>(std::valarray<d
ouble>&) /home/firma/devel/json/include/nlohmann/json.hpp:1257
    #7 0x5e3fe3 in _DOCTEST_ANON_FUNC_2() /home/firma/devel/json/test/src/unit-regression.cpp:1377
    #8 0x77313e in doctest::Context::run() /home/firma/devel/json/test/thirdparty/doctest/doctest.h:5938:21
    #9 0x777ae0 in main /home/firma/devel/json/test/thirdparty/doctest/doctest.h:6016:71
    #10 0x7fae220532e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #11 0x4a6479 in _start (/home/firma/devel/json/build/test/test-regression+0x4a6479)

The important thing to note here is that a std::valarray is *not* a STL
container, so the usual containter and iterator semantics don't apply.

Therefore we have to check if the container is non-empty before.
2019-09-03 13:22:03 +02:00
Thomas Braun
61fe5f1eee input_buffer_adapter: Fix handling of nullptr input
Clang UBSAN currently complains that the char * to input_buffer_adapter
is a nullptr.

Turns out it is actually required to accept nullptr, see for example
line 415 in input_adapters.hpp

  ...
  // the address of first cannot be used: use nullptr
  ia = std::make_shared<input_buffer_adapter>(nullptr, len);
  ....

Therefore we have to handle it gracefully here. We now also ignore the
length parameter l if b is a nullptr.
2019-09-03 13:22:03 +02:00
Thomas Braun
9ea3e19121 .travis/cmake: Rework clang sanitizer invocation
- Switch to clang-7
- Adapt PATH so that llvm-symbolizer can be found for useful stacktraces
- Adapt compile flags
  "-O0" ensures much faster compile times
  "-fno-sanitize-recover=all
  -fsanitize-recover=unsigned-integer-overflow" this fails the build on
  all issues except unsigned integer overflows. Not failing in this case
  is required in combination with the sanitizer suppression file as only
  recoverable errors can be suppressed.

The UBSAN suppression file ignores errors from stl_bvector.h (which
holds std::vector<bool>).

Clang reports that error as

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_bvector.h:158:20 in

      Start 34: test-deserialization_all
28/88 Test #71: test-testsuites_default .............***Failed    0.32 sec
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_bvector.h:158:20: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'
    #0 0x628f72 in std::_Bit_iterator_base::_M_bump_down() /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_bvector.h:158:20
    #1 0x628d16 in std::_Bit_iterator::operator--() /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_bvector.h:251:7
    #2 0x634aac in std::vector<bool, std::allocator<bool> >::pop_back() /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_bvector.h:1010:7
    #3 0x61eff0 in bool nlohmann::detail::parser<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::sax_parse_internal<nlohmann::detail::json_sax_dom_parser<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > >(nlohmann::detail::json_sax_dom_parser<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >*) /home/firma/devel/json/include/nlohmann/detail/input/parser.hpp:439:28
    #4 0x604864 in nlohmann::detail::parser<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::parse(bool, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>&) /home/firma/devel/json/include/nlohmann/detail/input/parser.hpp:116:13
    #5 0x5f8079 in nlohmann::operator>>(std::istream&, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>&) /home/firma/devel/json/include/nlohmann/json.hpp:6356:42
    #6 0x5e1d92 in _DOCTEST_ANON_FUNC_21() /home/firma/devel/json/test/src/unit-testsuites.cpp:343:9
    #7 0x7207fe in doctest::Context::run() /home/firma/devel/json/test/thirdparty/doctest/doctest.h:5938:21
    #8 0x72681a in main /home/firma/devel/json/test/thirdparty/doctest/doctest.h:6016:71
    #9 0x7f75d22362e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #10 0x4c28b9 in _start (/home/firma/devel/json/build/test/test-testsuites+0x4c28b9)

The pop_back() in parser.hpp

      assert(not states.empty());
  ->  states.pop_back();

triggers the UBSAN report. But the assertion above ensure that we only
call pop_back() on an non-empty vector, therefore this is a STL library
bug and thus must be ignored for us.
2019-09-03 13:22:03 +02:00
Thomas Braun
f0bff49ffd test/CMakeLists.txt: Remove trailing whitespace 2019-09-03 13:22:03 +02:00
Niels Lohmann
eab68e7750 👷 add test step 2019-09-02 22:15:11 +02:00
Niels Lohmann
90c1c24ccb 👷 try GitHub Actions 2019-09-02 21:35:53 +02:00
Niels Lohmann
bf4156056b ✏️ fix a typo 2019-08-27 20:18:04 +02:00
Niels Lohmann
b6ee34cc99 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2019-08-27 20:03:05 +02:00
Niels Lohmann
7dccfa5355 Merge pull request #1724 from t-b/enhance-travis
Add gcc 9 and compile with experimental C++20 support
2019-08-27 19:57:23 +02:00
Thomas Braun
a4eaaa56d1 .travis.yml: Add gcc 9 and compile with experimental C++20 support 2019-08-26 12:38:36 +02:00
Niels Lohmann
fe618ac246 👷 adjust maintainer scripts 2019-07-29 18:49:21 +02:00
Niels Lohmann
a015b78e81 🔒 add security policy 2019-07-28 21:46:32 +02:00
Niels Lohmann
6291803f59 👥 update contributors 2019-07-28 21:31:17 +02:00
Niels Lohmann
53c3eefa2c Merge branch 'release/3.7.0' into develop 2019-07-28 21:23:36 +02:00
Niels Lohmann
d275d05514 📝 update documentation 2019-07-28 20:54:02 +02:00
Niels Lohmann
ddb7f70a12 📝 update documentation 2019-07-28 20:53:18 +02:00
Niels Lohmann
48e1fe03b5 🔖 set version to 3.7.0 2019-07-28 20:20:41 +02:00
Niels Lohmann
66d63abe6d Update Makefile 2019-07-28 18:40:11 +02:00
Niels Lohmann
d4fd731f1f 🔨 fix release target 2019-07-28 17:55:01 +02:00
Niels Lohmann
d80f8b09f5 🔨 adjust version 2019-07-28 15:20:07 +02:00
Niels Lohmann
7bf8a86090 🔨 adjust paths 2019-07-28 14:30:17 +02:00
Niels Lohmann
65e4b973bd 🔥 remove leftover file 2019-07-21 14:10:37 +02:00
Niels Lohmann
323cf95d8c 🚨 fix linter warning 2019-07-21 14:04:49 +02:00
Niels Lohmann
ffe0e3d70f Merge pull request #1673 from remyabel/gnuinstalldirs
Use GNUInstallDirs instead of hard-coded path.
2019-07-17 06:28:38 +02:00
Tommy Nguyen
3184e9bd8b Use GNUInstallDirs instead of hard-coded path. 2019-07-16 11:44:32 -04:00
Niels Lohmann
cf8251eb54 🚑 fix compiler errors 2019-07-14 21:19:55 +02:00
Niels Lohmann
6c7cde181c Merge branch 'develop' of https://github.com/nlohmann/json into develop 2019-07-14 20:58:29 +02:00
Niels Lohmann
a501365ea2 Merge branch 'feature/hedley' into develop 2019-07-14 20:58:08 +02:00
Niels Lohmann
8d059b96a1 Merge pull request #1670 from podsvirov/readme-package-managers-msys2
Package Manager: MSYS2 (pacman)
2019-07-13 17:58:08 +02:00
Konstantin Podsvirov
6a3cdb281e Package Manager: MSYS2 (pacman)
Add a package installation instructions for MSYS2 software distro.
2019-07-12 22:27:17 +03:00
Niels Lohmann
b17440c12f 🚨 fix compiler warnings 2019-07-12 21:05:16 +02:00
Niels Lohmann
104c5c1996 Merge branch 'feature/json_pointer_contains' into develop 2019-07-09 08:08:56 +02:00
Niels Lohmann
7a23aa1c0d Merge branch 'feature/emplace_back' into develop 2019-07-09 08:06:27 +02:00
Niels Lohmann
24fa285edb 📝 remove HEDLEY annotation from documentation 2019-07-02 21:15:52 +02:00
Niels Lohmann
947656544d 🚨 fix warnings 2019-07-02 21:06:42 +02:00
Niels Lohmann
346e9813c5 🚧 add more annotations 2019-07-02 20:25:51 +02:00
Niels Lohmann
9289a23a76 Merge pull request #1643 from kevinlul/develop
Fix json.hpp compilation issue with other typedefs with same name (Issue #1642)
2019-07-01 22:57:04 +02:00
Niels Lohmann
90798caa62 🚚 rename Hedley macros 2019-07-01 22:37:30 +02:00
Niels Lohmann
025f4cea42 🚨 fix warning 2019-07-01 22:29:21 +02:00
Niels Lohmann
897362191d 🔨 add NLOHMANN_JSON prefix and undef macros 2019-07-01 22:24:39 +02:00
Niels Lohmann
1720bfedd1 ⚗️ add Hedley annotations 2019-06-30 22:14:02 +02:00
kevinlul
e616d095ab Remove boolean regression test for #1642 2019-06-30 11:57:57 -04:00
Niels Lohmann
1be63431f3 make emplace_back return a reference #1609 2019-06-30 12:19:41 +02:00
Niels Lohmann
258fa798f1 add contains function for JSON pointers 2019-06-30 10:03:08 +02:00
kevinlul
855156b5e8 Add regression tests for #1642 2019-06-29 19:26:38 -04:00
Niels Lohmann
9a775bcb14 Merge pull request #1570 from nickaein/msvc-regression-tests
Regression tests for MSVC
2019-06-25 07:05:53 +02:00
Isaac Nickaein
5b2e2305a0 CI: Skip test-unit_all on MSVC Debug builds 2019-06-24 21:21:58 +04:30
Isaac Nickaein
3db14cbfae 📝 Improve doc on const_inter constructor 2019-06-24 15:40:01 +04:30
Isaac Nickaein
0a137b78ac Appveyor: Set timeout of unit-tests in appveyor.yml instead of CMake 2019-06-22 22:14:40 +04:30
Isaac Nickaein
f559142008 Appveyor: Set build mode explicitly 2019-06-22 21:15:17 +04:30
Isaac Nickaein
eba8244ead Avoid collision of ::max with windows.h macro 2019-06-22 21:15:13 +04:30
Isaac Nickaein
798e83a038 Workaround msvc2015 bug with explicit copy-constructor for const_iterator 2019-06-22 21:15:11 +04:30
Isaac Nickaein
d28b4b900e Add a separate build with Windows.h included 2019-06-22 21:15:07 +04:30
Isaac Nickaein
4ac0fe2628 Increase timeout of test-unicode_all in Debug build 2019-06-22 21:15:03 +04:30
Isaac Nickaein
ec43d27f9f Add Debug builds for AppVeyor 2019-06-22 21:14:51 +04:30
Niels Lohmann
39011a1759 📝 mention json type in documentation start page #1616 2019-06-22 09:54:59 +02:00
Niels Lohmann
3b82a350ed 📝 mention 302 exception in value() documentation #1601 2019-06-22 09:44:12 +02:00
Niels Lohmann
13d4f8f5ad Merge pull request #1639 from taylorhoward92/develop
Add explicit conversion from json to std::string_view in conversion unit test
2019-06-22 09:25:02 +02:00
kevinlul
f4fca2d59a Fix #1642
While in our case, only the string case was affected, to be safe and allow the library to work with other unforeseen cases, all of the cases have been wrapped with parentheses.

Thank you @DyXel and @edo9300
2019-06-16 18:22:40 -04:00
Taylor Howard
2f389cdde7 Added explicit converstion to std::string_view. Fixes failing test with GCC 8.3 2019-06-16 14:49:01 +10:00
Niels Lohmann
4fc98e0b34 Merge pull request #1625 from nickaein/fix-docs
Minor fixes in docs
2019-06-05 20:25:48 +02:00
Isaac Nickaein
0c214949f5 ✏️ Fix links to create an issue page 2019-06-04 11:27:25 +04:30
Isaac Nickaein
b22c577e83 ✏️ Fix brew instructions in README 2019-06-04 11:25:44 +04:30
Isaac Nickaein
0d55ddc5bf ✏️ Fix a typo in README 2019-06-04 11:24:22 +04:30
Niels Lohmann
17c0849a63 Merge pull request #1585 from Macr0Nerd/iss916
Added to_string and added basic tests
2019-05-24 09:20:15 +02:00
Niels Lohmann
9f2179deb1 Merge pull request #1598 from nickaein/patch-2
Fix broken links to documentation
2019-05-24 09:16:38 +02:00
Isaac Nickaein
40c3d5024a Fix broken links to documentation
Fixes #1597 and some other links
2019-05-12 22:04:01 +04:30
Macr0Nerd
26952500b8 Merge branch 'iss916' of https://github.com/Macr0Nerd/json into iss916 2019-04-26 18:15:52 -05:00
Macr0Nerd
aa4c45ee4d Added to_string (with ugly macro) and tests 2019-04-26 18:10:45 -05:00
Macr0Nerd
293cd6b794 Added to_string and added basic tests 2019-04-25 22:12:15 -05:00
Niels Lohmann
ee4028b8e4 Merge branch 'feature/fastcov' into develop 2019-04-06 09:15:43 +02:00
Niels Lohmann
cf6b6692aa Merge branch 'develop' into feature/fastcov 2019-04-06 09:03:35 +02:00
Niels Lohmann
f0bc16d899 🔨 overworked coverage targets 2019-04-06 09:02:17 +02:00
Niels Lohmann
b4b06d89b5 ⬆️ updated fastcov 2019-04-06 00:24:19 +02:00
Niels Lohmann
e65cff2a8f 🔨 small cleanup 2019-04-05 23:31:04 +02:00
Niels Lohmann
63fe1cbbcf 📝 updated README 2019-04-05 18:29:57 +02:00
Niels Lohmann
0bdadb12c7 Merge branch 'feature/circleci' into develop 2019-04-05 17:50:48 +02:00
Niels Lohmann
0a1ddd6882 ⬆️ updated fastcov 2019-04-05 07:54:46 +02:00
Niels Lohmann
4676f759e8 ⬆️ updated fastcov 2019-04-04 09:50:27 +02:00
Niels Lohmann
da279234d5 Merge branch 'develop' into feature/fastcov 2019-04-04 09:03:11 +02:00
Niels Lohmann
f05614b240 🏗️ adding anonymous namespace 2019-04-04 08:56:36 +02:00
Niels Lohmann
0da99027b7 🚨 silenced a warning 2019-04-03 17:44:09 +02:00
Niels Lohmann
1f03395e2c Merge branch 'develop' of https://github.com/nlohmann/json into develop 2019-04-03 17:28:50 +02:00
Niels Lohmann
2f9095ddab 🔨 relaxed requirements to coverage 2019-04-03 17:28:47 +02:00
Niels Lohmann
ee8732c359 Merge pull request #1555 from theodelrieu/fix/1511
Fix/1511
2019-04-03 17:24:25 +02:00
Niels Lohmann
d1ef75316e Merge pull request #1439 from onqtam/doctest
moved from Catch to doctest for unit tests
2019-04-03 17:01:48 +02:00
Théo DELRIEU
d66abda4ee tests: fix coverage 2019-04-03 12:34:15 +02:00
Théo DELRIEU
e6e6805c6c add built-in array support in get_to 2019-04-01 17:47:45 +02:00
Théo DELRIEU
2806b201a8 make sure values are overwritten in from_json overloads
Caused unexpected behaviors when using get_to with values previously
set.

Fixes !1511
2019-04-01 17:47:42 +02:00
onqtam
da5b7833a0 fixing the remaining of the pedantic gcc/clang target warnings 2019-03-31 13:57:44 +03:00
Viktor Kirilov
64873fb5b8 Merge branch 'develop' into doctest 2019-03-30 23:23:33 +02:00
Niels Lohmann
80daa19331 👷 Ninja seems not to work 2019-03-30 17:39:50 +01:00
Niels Lohmann
0a57c51a69 👷 adding concurrency 2019-03-30 17:32:52 +01:00
Niels Lohmann
a5e00f2cf7 👷 fixed path 2019-03-30 17:19:27 +01:00
Niels Lohmann
5ebe722045 👷 full workflow 2019-03-30 17:14:50 +01:00
Niels Lohmann
ecf4d5e91d 👷 trying CircleCI 2019-03-30 17:05:43 +01:00
Niels Lohmann
53001414c7 🔨 using --exclude-gcov to exclude files 2019-03-30 17:00:30 +01:00
Niels Lohmann
b12287b362 ⚗️ trying fastcov 2019-03-30 09:12:32 +01:00
Niels Lohmann
b21c04c938 🔥 removed unsupported flag 2019-03-29 17:34:58 +01:00
Niels Lohmann
c7878173f9 🔨 minor changes to maintainer targets 2019-03-29 13:10:11 +01:00
Niels Lohmann
b52c3638f5 Merge pull request #1551 from heavywatal/fix-1535-nodiscard-clang
Remove C++17 extension warning from clang; #1535
2019-03-29 09:14:25 +01:00
Niels Lohmann
d21d298397 🎨 fixed indentation 2019-03-28 14:23:26 +01:00
Niels Lohmann
23635704c3 ⬆️ added script to update cpplint 2019-03-28 14:23:07 +01:00
Niels Lohmann
191aa0fd6f 🔧 overworked maintaner targets 2019-03-28 14:22:48 +01:00
Watal M. Iwasaki
5ccdaf643f Remove C++17 extension warning from clang; #1535
- Switch off `nodiscard` for clang unless C++17 is detected.
- Detect C++ standard before the switch.
2019-03-28 14:38:58 +09:00
onqtam
b4def6dcba tabs instead of spaces... 2019-03-27 01:13:10 +02:00
onqtam
a0000c3235 finished the last of the warnings 2019-03-27 01:09:47 +02:00
onqtam
5d511a6e96 fixed a bunch of warnings from the Makefile from the root of the repo 2019-03-27 00:58:53 +02:00
Viktor Kirilov
82af0ecdc1 Merge branch 'develop' into doctest 2019-03-26 23:32:32 +02:00
Niels Lohmann
d79c16801a Merge branch 'feature/doozer' into develop 2019-03-26 10:49:56 +01:00
Niels Lohmann
24d91cf36f 📝 added Doozer to README 2019-03-26 10:49:14 +01:00
Niels Lohmann
0991824584 👷 version output 2019-03-26 10:41:05 +01:00
onqtam
0caf986505 reverted the removal of this if/else branching - this is the easiest way to get -std=c++0x support 2019-03-25 22:04:37 +02:00
Niels Lohmann
9d2f0391e0 👷 fixed timeout 2019-03-25 12:30:45 +01:00
Niels Lohmann
af9da22b87 👷 adding xenial-armhf 2019-03-25 07:15:03 +01:00
Niels Lohmann
0a67b51fce 👷 forgot path to ctest 2019-03-25 07:03:41 +01:00
Niels Lohmann
e27b282033 👷 skip certificate check 2019-03-25 06:45:35 +01:00
Niels Lohmann
cde0b24389 👷 fixed required packages 2019-03-25 06:43:14 +01:00
Niels Lohmann
f091fe31bc 👷 increased timeout 2019-03-25 06:39:41 +01:00
Niels Lohmann
28dfbedda7 👷 fixed timeout 2019-03-24 18:14:59 +01:00
onqtam
ff51a32be1 updated doctest to version 2.3.1 released today 2019-03-24 17:28:52 +02:00
onqtam
2b346099df Merge branch 'develop' of https://github.com/nlohmann/json into doctest 2019-03-24 17:21:44 +02:00
Niels Lohmann
dcbc028b5b 👷 fixed syntax 2019-03-24 09:02:46 +01:00
Niels Lohmann
842d42b135 👷 unified paths 2019-03-24 09:02:06 +01:00
Niels Lohmann
1e86976cfe 👷 fixed paths 2019-03-24 08:53:30 +01:00
Niels Lohmann
30211477b7 👷 fixed package name 2019-03-24 08:36:01 +01:00
Niels Lohmann
5e1cae0a7d 👷 install g++ 2019-03-24 08:24:50 +01:00
Niels Lohmann
c871c9a01c 👷 install correct g++ 2019-03-24 06:51:10 +01:00
Niels Lohmann
63d619e21f 👷 need to install g++ 2019-03-24 00:48:59 +01:00
Niels Lohmann
c94b764a6e 👷 fixed installation 2019-03-24 00:43:01 +01:00
Niels Lohmann
65cdccfa8a 👷 fixed syntax error 2019-03-24 00:36:46 +01:00
Niels Lohmann
a72ac18514 👷 use recent cmake 2019-03-24 00:36:05 +01:00
Niels Lohmann
4327ae0bef 👷 need more recent cmake for CentOS 2019-03-24 00:15:57 +01:00
Niels Lohmann
fabf953305 👷 fixed a typo 2019-03-24 00:12:36 +01:00
Niels Lohmann
6e3e2ee2e4 👷 fixed buildenv values 2019-03-24 00:11:20 +01:00
Niels Lohmann
bc5089e803 👷 add test output to avoid timeout 2019-03-24 00:02:41 +01:00
Niels Lohmann
7dd3e6384b 👷 added Fedora and CentOS 2019-03-23 23:42:29 +01:00
Niels Lohmann
490c6e926e 👷 using raspbian 2019-03-23 23:27:39 +01:00
Niels Lohmann
2fcca259b0 👷 added cmake 2019-03-23 23:21:17 +01:00
Niels Lohmann
72dd6f349e 👷 trying doozer 2019-03-23 23:18:27 +01:00
Niels Lohmann
baaa2a4d0f 🏁 trying to use constructors from std::allocator #1536 2019-03-21 14:09:29 +01:00
Niels Lohmann
1126c9ca74 Merge branch 'release/3.6.1' into develop 2019-03-20 21:03:43 +01:00
Niels Lohmann
efa1b9a7bb 🔖 set version to 3.6.1 2019-03-20 20:50:05 +01:00
Niels Lohmann
b33093d610 🐛 fixed regression #1530 2019-03-20 14:40:23 +01:00
Niels Lohmann
9d6ab9014f 🏁 fixed a compilation error in MSVC #1531 2019-03-20 14:13:29 +01:00
Niels Lohmann
c790b9f8c0 🐛 fixed regression #1530 2019-03-20 12:41:08 +01:00
Niels Lohmann
483a086562 ⚗️ added funding link 2019-03-20 11:42:24 +01:00
Niels Lohmann
d2a08ddafd Merge branch 'develop' of https://github.com/nlohmann/json into develop 2019-03-20 11:06:55 +01:00
Niels Lohmann
7c55510f76 🚨 fixed some warnings #1527 2019-03-20 11:06:39 +01:00
Niels Lohmann
3ac5fa31c5 💬 update issue templates 2019-03-20 01:27:37 +01:00
Niels Lohmann
51e1564c9e Merge branch 'release/3.6.0' into develop 2019-03-20 00:38:29 +01:00
Niels Lohmann
0abf0f80c9 🔖 set version to 3.6.0 2019-03-20 00:22:12 +01:00
Niels Lohmann
b37392b7ac 🔖 set version to 3.6.0 2019-03-20 00:19:07 +01:00
Niels Lohmann
002addabd8 🚨 fixed a warning 2019-03-19 23:10:21 +01:00
Niels Lohmann
a6f9b4e36d 👥 added contributors 2019-03-19 17:18:33 +01:00
Niels Lohmann
18cc7ddd62 📝 completed documentation index page 2019-03-19 16:03:02 +01:00
Niels Lohmann
e07e8e7912 📝 updated documentation 2019-03-19 15:40:23 +01:00
Niels Lohmann
710f26f95c 📝 added documentation 2019-03-19 10:06:35 +01:00
Niels Lohmann
b224c52376 🎨 cleanup 2019-03-19 09:17:14 +01:00
Niels Lohmann
37a72dac48 💚 forgot two semicolons 2019-03-18 17:23:34 +01:00
Viktor Kirilov
155d196bfa Update CMakeLists.txt 2019-03-18 17:58:35 +02:00
Viktor Kirilov
365944b0bc Merge branch 'develop' into doctest 2019-03-18 16:59:36 +02:00
Niels Lohmann
8d3f4f21bc 🔨 clean up 2019-03-18 13:53:48 +01:00
Niels Lohmann
9fc093c9e0 👷 added targets for infer and oclint 2019-03-18 00:19:28 +01:00
Niels Lohmann
22c733e6fe 📝 added documentation 2019-03-17 22:25:18 +01:00
Niels Lohmann
56f6d1d68e 💚 fix CI and #1521 2019-03-17 15:20:22 +01:00
Niels Lohmann
df0f7f2b5d 👷 overworked clang-tidy target 2019-03-17 12:02:23 +01:00
Niels Lohmann
9f26dac9b3 ⬆️ updated Doxyfile 2019-03-17 12:02:05 +01:00
Niels Lohmann
b8451c236f 🚨 fixed warnings 2019-03-17 12:01:49 +01:00
Niels Lohmann
d6c4cd3b6d 🚨 adding targets for static analyzers 2019-03-17 00:30:08 +01:00
Niels Lohmann
baf8b4be7c adding cpplint 2019-03-17 00:28:14 +01:00
Niels Lohmann
34f8b4f711 🚨 fixed more warnings 2019-03-17 00:27:44 +01:00
Niels Lohmann
02b3494711 🔥 removing unstable macOS builds on Traivs 2019-03-16 08:28:44 +01:00
Niels Lohmann
b02ee16721 🚨 fixed warnings 2019-03-15 15:55:52 +01:00
Niels Lohmann
8d6c033f80 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2019-03-15 14:55:15 +01:00
Niels Lohmann
27011e3718 🚨 fixed warnings 2019-03-15 14:55:13 +01:00
Niels Lohmann
9dc3552931 Merge pull request #1514 from naszta/macrofix
Change macros to numeric_limits
2019-03-15 12:46:42 +01:00
Ferenc Nasztanovics
0067ea8f9e Change macros to numeric_limits #1483 2019-03-13 23:44:34 +01:00
Niels Lohmann
0c65ba960e Merge branch 'develop' of https://github.com/nlohmann/json into develop 2019-03-13 22:14:57 +01:00
Niels Lohmann
546e2cbf5e 🚨 fixed some warnings 2019-03-13 22:14:53 +01:00
Niels Lohmann
c6fc902184 Merge pull request #1489 from andreas-schwab/develop
Do proper endian conversions
2019-03-13 11:57:58 +01:00
Niels Lohmann
d39842e68f Merge pull request #1330 from ax3l/topic-installEmbed
CMake: Optional Install if Embedded
2019-03-13 11:13:09 +01:00
Niels Lohmann
670f42b561 🔥 removing Xcode 6.4 builder 2019-03-11 22:59:22 +01:00
Niels Lohmann
c983b67112 Merge pull request #1469 from garethsb-sony/json_pointer-append
Add operator/= and operator/ to construct a JSON pointer by appending two JSON pointers
2019-03-11 22:47:08 +01:00
Niels Lohmann
c11bead2ae 👷 removing more retired Travis images 2019-03-11 21:22:30 +01:00
Niels Lohmann
3cd1dac653 🚨 fix MSVC warning #1502 2019-03-11 15:33:23 +01:00
Niels Lohmann
cabe2357b8 Merge pull request #1492 from stac47/fix_gcc9_allocator
Fix gcc9 build error test/src/unit-allocator.cpp (Issue #1472)
2019-03-11 15:21:54 +01:00
Niels Lohmann
16d9cdce45 📝 updated documentation of CI 2019-03-11 15:19:50 +01:00
Niels Lohmann
e3729ba0a5 💚 fix compiler selection 2019-03-11 07:44:40 +01:00
Niels Lohmann
e5c7fd488d 👷 trying new Travis workers 2019-03-10 22:56:14 +01:00
Niels Lohmann
5047c7a217 🐛 added missing include #1500 2019-03-10 22:26:57 +01:00
Niels Lohmann
8eb7db7277 Merge pull request #1441 from iwanders/support-cmake-older-than-3-8-with-if
Use C++11 features supported by CMake 3.1.
2019-03-10 22:08:16 +01:00
Niels Lohmann
393410e61a Merge pull request #1495 from njlr/patch-1
Update Buckaroo instructions in README.md
2019-03-10 22:03:49 +01:00
Niels Lohmann
30edcaab3a Merge pull request #1496 from lieff/develop
fix GCC 7.1.1 - 7.2.1 on CentOS
2019-03-10 22:01:52 +01:00
lieff
7b31e56fbf fix GCC 7.1.1 - 7.2.1 on CentOS
closes https://github.com/nlohmann/json/issues/670
2019-02-25 16:38:22 +03:00
Andreas Schwab
bb22b1003f Do proper endian conversions
This fixes all testsuite failures on big endian hosts.
2019-02-25 12:09:13 +01:00
njlr
8aeee4f7e3 Update README.md
* Updates Buckaroo instructions to v2
2019-02-25 09:44:38 +00:00
garethsb-sony
d183bd0456 Tests for json_pointer::empty and json_pointer::parent_pointer 2019-02-25 09:26:08 +00:00
garethsb-sony
08de9eeaca Add json_pointer::parent_pointer (cf. std::filesystem::path::parent_path) 2019-02-25 09:26:08 +00:00
garethsb-sony
164e0e54d9 Rename private json_pointer::is_root as public json_pointer::empty for consistency with std::filesystem::path 2019-02-25 09:26:07 +00:00
Laurent Stacul
ddc9f201f4 Fix gcc9 build error test/src/unit-allocator.cpp (Issue #1472) 2019-02-22 16:05:41 +00:00
Niels Lohmann
21516f2bae Merge pull request #1491 from nickaein/patch-1
Fix typo in README.md
2019-02-22 09:50:45 +01:00
Isaac Nickaein
088a245218 Fix typo in README.ME
Fixes https://github.com/nlohmann/json/issues/1486.
2019-02-22 01:05:00 +03:30
Niels Lohmann
e326df211b Merge pull request #1474 from nickaein/develop
Implement contains() member function
2019-02-13 13:05:21 +01:00
Niels Lohmann
c55cacee1e Merge pull request #1477 from nickaein/fix-doc
Fix documentation
2019-02-13 13:03:46 +01:00
Isaac Nickaein
e93f305494 Add unit-test for contains() member function 2019-02-13 13:21:54 +03:30
Isaac Nickaein
6a5db00951 Implement contains() to check existence of a key 2019-02-13 13:21:54 +03:30
Isaac Nickaein
fb5ceb26ac Fix documentation
Remove two instance of duplicate paragraphs.
2019-02-11 17:00:48 +03:30
Niels Lohmann
46ff13d39e Merge pull request #1468 from past-due/disable_Wmismatched_tags_on_tuple
Disable Clang -Wmismatched-tags warning on tuple_size / tuple_element
2019-02-10 21:50:12 +01:00
Niels Lohmann
eee3bc0c79 Merge pull request #1464 from elvisoric/update_meson_install_step
Disable installation when used as meson subproject. #1463
2019-02-10 21:48:20 +01:00
garethsb-sony
5da757bbb3 Attempt to satisfy Coveralls by adding a test for (unchanged) operator std::string 2019-01-31 23:39:57 +00:00
garethsb-sony
c850e9d82d Add operator/= and operator/ to construct a JSON pointer by appending two JSON pointers, as well as convenience op/= and op= to append a single unescaped token or array index; inspired by std::filesystem::path 2019-01-31 19:15:50 +00:00
past-due
45819dce54 Disable -Wmismatched-tags warning on tuple_size / tuple_element 2019-01-30 12:59:50 -05:00
Elvis Oric
77d1d37290 Disable installation when used as meson subproject. #1463 2019-01-30 11:40:14 +01:00
Isaac Nickaein
372c4d2125 Merge branch 'develop' into iterate-on-destruction 2019-01-28 02:41:22 +03:30
Niels Lohmann
68ec3eb8d6 Merge pull request #1451 from Afforix/Afforix-fix-extra-semicolon
remove extra semicolon from readme
2019-01-25 13:36:18 +01:00
Niels Lohmann
de14b5ee2f Merge pull request #1455 from wythe/patch-2
docs: README typo
2019-01-25 13:36:07 +01:00
Mark Beckwith
cca6d0dbae docs: README type
Just another small typo I found in the README.
2019-01-24 10:49:45 -06:00
Patrick Boettcher
a06e7f5d80 JSON-pointer: add operator+() returning a new json_pointer 2019-01-24 16:46:51 +01:00
Matěj Plch
dc21cbb751 remove extra semicolon
in example of NLOHMANN_JSON_SERIALIZE_ENUM
2019-01-22 10:13:12 +01:00
Niels Lohmann
e89c946451 Merge branch 'feature/nodiscard' into develop 2019-01-20 15:41:30 +01:00
Niels Lohmann
6de4df23e4 🐛 fixed integer overflow in dump function #1447
Closes #1447.
2019-01-20 12:26:01 +01:00
Niels Lohmann
e17e0d031f Merge pull request #1446 from scinart/develop
attempt to fix #1445, flush buffer in serializer::dump_escaped in UTF8_REJECT case.
2019-01-20 12:18:02 +01:00
Niels Lohmann
e36593e960 🔨 trying code from https://godbolt.org/z/-tLO1K 2019-01-20 11:12:20 +01:00
scinart
20db020c1f move newly-added tests in unit-regression.cpp 2019-01-19 11:36:50 -05:00
Niels Lohmann
d359fd3a8d 🚧 trying nodiscard attribute #1433 2019-01-19 17:32:23 +01:00
Niels Lohmann
b9a39b38bf Merge pull request #1434 from pboettch/develop
allow push_back() and pop_back() calls on json_pointer
2019-01-19 17:07:36 +01:00
scinart
83e84446d6 fix typo 2019-01-18 20:55:01 -05:00
scinart
899bd94b43 flush buffer in serializer::dump_escaped case UTF8_REJECT
serializer use fixed buffer. Whenever it is nearly full, it is flushed to `output_adapter_t<char> o`
But the code forgets to flush when there is a invalid utf8 code point
So there will be buffer overflow.
2019-01-18 20:35:48 -05:00
Ivor Wanders
4fd9b52fc2 Use C++11 features supported by CMake 3.1. 2019-01-16 08:50:58 -05:00
Niels Lohmann
dffae1082f Merge pull request #1435 from pboettch/warning-fix
🚨 fixed unused variable warning
2019-01-15 22:18:13 +01:00
Niels Lohmann
851fe8a5ef Merge pull request #1430 from nicoddemus/conda-docs
Add instructions about using nlohmann/json with the conda package manager
2019-01-15 22:16:49 +01:00
onqtam
a2c074fd4d this should really fix the XCode 6/7 builds 2019-01-15 22:58:12 +02:00
onqtam
3340162efd fixing osx builds - had forgotten to define this for the object file where the test runner is compiled 2019-01-15 22:48:37 +02:00
onqtam
2f44ac1def moved from Catch to doctest for unit tests 2019-01-15 22:02:16 +02:00
Isaac Nickaein
f0883dda8f During destruction, flatten children of objects to avoid recursion 2019-01-15 20:29:51 +03:30
Isaac Nickaein
47fe4b9cee Add unit test for parsing deeply-nested array 2019-01-15 20:22:11 +03:30
Patrick Boettcher
d0c0d16110 🚨 fixed unused variable warning
Since 6503e83e74 "Improve dump_integer performance by implementing a more efficient int2ascii"
an unused variable and thus a warning existed.
2019-01-15 15:21:02 +01:00
Patrick Boettcher
9225cf2f57 allow push_back() and pop_back() calls on json_pointer
Putting pop_back() to public and creating a trivial push_back()
method allows users of nlohmann::json_pointer to manipulate an
existing json-pointer by adding or removing keys at the end.

This is useful for traversing a JSON-instance and keeping track
of its "absolute path" at any moment.

In my case for a schema-validator error-handler.
2019-01-15 14:43:46 +01:00
Bruno Oliveira
b025d66eb5 Add instructions about using nlohmann/json with the conda package manager 2019-01-15 11:06:26 -02:00
Niels Lohmann
e5753b14a8 🚨 fixed another linter warning #1400
Closes #1400.
2019-01-13 15:40:49 +01:00
Niels Lohmann
5c04cc1009 🔨 fixed includes 2019-01-13 15:31:22 +01:00
Niels Lohmann
8e9ad346d9 🚨 fixed another linter warning 2019-01-13 13:00:54 +01:00
Niels Lohmann
ad01736d55 💡 improved documentation for parsing without exceptions #1405
Closes #1405
2019-01-13 11:46:05 +01:00
Niels Lohmann
06731b14d7 ⬆️ upgraded Catch and Google Benchmark
- Catch 1.12.0 -> 1.12.2
- Google Benchmark 1.3.0 -> 1.4.1
2019-01-13 11:29:39 +01:00
Niels Lohmann
daeb48b01a Merge pull request #1411 from nickaein/develop
Improve dump_integer performance
2019-01-13 11:11:51 +01:00
Niels Lohmann
29a03f465e Merge pull request #1414 from nickaein/mydevel-appveyor-x64
Fix x64 target platform for appveyor
2019-01-12 23:09:19 +01:00
Isaac Nickaein
c9dd260a4c Add unit tests for dump_integer
Add some unit tests for formatting integers
to keep code coverage as before.
2019-01-12 08:58:30 -08:00
Isaac Nickaein
be9b4cbd60 Add benchmark for small integers
This benchmark is a sample of 1 million "small" integers
in range [-1000000 1000000) sampled from uniform distribution.
2019-01-12 08:58:30 -08:00
Isaac Nickaein
6503e83e74 Improve dump_integer performance by implementing a more efficient int2ascii
This commits implements a faster int2ascii inspired by "Fastware" talk given
by Andrei Alexandrescu.
See: https://www.youtube.com/watch?v=o4-CwDo2zpg
2019-01-12 08:58:30 -08:00
Isaac Nickaein
f16432832c Increase stack size for VS2017 Win x64 on Appveyor 2019-01-12 19:27:26 +03:30
Niels Lohmann
b39f34e046 Merge pull request #1425 from hijxf/patch-1
Updated year in README.md
2019-01-12 10:23:31 +01:00
Jef LeCompte
7f73915d4f Updated year in README.md 2019-01-11 08:54:03 -05:00
Niels Lohmann
df460c96cf Merge pull request #1423 from skypjack/patch-1
Fixed broken links in the README file
2019-01-10 13:52:52 +01:00
Michele Caini
6546cad7bf Fixed broken links in the README file 2019-01-10 08:54:53 +01:00
Niels Lohmann
847dd2a954 Merge pull request #1420 from skypjack/patch-1
Fixed broken links in the README file
2019-01-09 22:33:40 +01:00
Niels Lohmann
937b642e0e 📝 added description on how to use NuGet package #1132
Closes #1132.
2019-01-09 21:08:06 +01:00
Niels Lohmann
975dc970d1 Merge pull request #1417 from wythe/patch-1
docs: typo in README
2019-01-09 20:35:49 +01:00
Michele Caini
b8be0f64ae Fixed broken links to operator[]() and at() 2019-01-09 15:11:54 +01:00
Michele Caini
619bf9c20d Fixed broke links to RFC7159 2019-01-09 15:05:09 +01:00
Mark Beckwith
a559ff8fc6 typo in README
inintended -> unintended
2019-01-08 13:24:07 -06:00
Isaac Nickaein
2c0c2ca698 Specify target platform in generator name 2019-01-05 14:15:33 -08:00
Niels Lohmann
676c847c55 Merge pull request #1409 from yann-morin-1998/yem/cmake-version
buildsystem: relax requirement on cmake version
2019-01-01 17:17:38 +01:00
Yann E. MORIN
e8b6b7adc1 buildsystem: relax requirement on cmake version
Commit 73cc5089 (Using target_compile_features to specify C++ 11
standard) bumped the required cmake version, from 3.0 to 3.8, so
as to get the definition of target_compile_features().

However, target_compile_features() was introduced in cmake-3.1:
    https://cmake.org/cmake/help/v3.1/command/target_compile_features.html

And using cmake-3.1 is indeed sufficient to properly build.

As such, relax the minimum required version down to cmake-3.1,
so we can build on oldish, entreprise-grade distributions that
only have cmake-3.1 (or at least, don't have up to cmake-3.8).

Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
2018-12-31 18:52:04 +01:00
Niels Lohmann
c682b9879b 🚨 fixed PVS V567 warning
"V567 The modification of the 'position.chars_read_current_line' variable is unsequenced relative to another operation on the same variable. This may lead to undefined behavior."
2018-12-30 23:00:15 +01:00
Niels Lohmann
6f89613acd 🚨 fixed some warnings 2018-12-23 13:56:18 +01:00
Niels Lohmann
db53bdac19 Merge branch 'release/3.5.0' into develop 2018-12-22 00:01:28 +01:00
Niels Lohmann
78348afeb6 🔖 set version to 3.5.0 2018-12-21 23:52:29 +01:00
Niels Lohmann
1107f8cd82 📝 updated documentation for items() function 2018-12-21 22:51:12 +01:00
Niels Lohmann
98f4e31c3e 📝 formatted picture 2018-12-21 18:33:46 +01:00
Niels Lohmann
58c269b039 📝 updated documentation 2018-12-21 18:27:56 +01:00
Niels Lohmann
2182157dc1 📝 update documentation 2018-12-21 09:32:35 +01:00
Niels Lohmann
45f5611d9b 🚨 fixed two warnings 2018-12-20 22:41:48 +01:00
Niels Lohmann
117c1d14fb 📝 added contributors to 3.5.0 2018-12-20 22:20:47 +01:00
Niels Lohmann
d584ab269a 🎨 fixed header 2018-12-20 21:58:16 +01:00
Niels Lohmann
45a8a093d7 🚨 fixed a warning 2018-12-20 21:40:47 +01:00
Niels Lohmann
85849940ba Merge pull request #1391 from pratikpc/develop
Added Support for Structured Bindings
2018-12-20 08:58:08 +01:00
Pratik Chowdhury
ebd3f45808 Added Support for Structured Bindings
For further details, read https://github.com/nlohmann/json/issues/1388 and https://blog.tartanllama.xyz/structured-bindings/
2018-12-19 20:17:52 +05:30
Niels Lohmann
4f270e38cc Merge pull request #1342 from davedissian/bugfix/sfinae-iterator-traits
Add a SFINAE friendly iterator_traits and use that instead.
2018-12-19 08:24:18 +01:00
David Avedissian
f1080d7c39 Code review. 2018-12-18 20:44:37 +00:00
Niels Lohmann
5d390e91ff Merge pull request #1392 from mtalliance/feature/addFileInputAdapter
Feature/add file input adapter
2018-12-16 22:10:03 +01:00
Jonathan Dumaresq
c1c85b025c Forget one std::FILE 2018-12-14 07:33:28 -05:00
Jonathan Dumaresq
635a4fc344 use namespace std when possible. Change the name of private variable. 2018-12-12 16:33:25 -05:00
Jonathan Dumaresq
cf31193de2 create single json.hpp file 2018-12-12 14:46:52 -05:00
Jonathan Dumaresq
a794cfdba3 refactor unit test in case of throw, the fclose will not be called. using unique_ptr with custom destructor will ensure that 2018-12-12 14:46:17 -05:00
Jonathan Dumaresq
91ff96a737 remove the const attribute 2018-12-12 14:16:12 -05:00
Jonathan Dumaresq
b7a2642fba remove comment 2018-12-12 14:15:49 -05:00
Jonathan Dumaresq
fa7f1a524e new unified json.hpp generated with make amalgamate 2018-12-12 10:19:22 -05:00
Jonathan Dumaresq
ef283e0cf8 add tests to cover the new input adapter 2018-12-12 10:18:37 -05:00
Jonathan Dumaresq
3335da622a remove non usefull code. 2018-12-12 09:32:52 -05:00
Jonathan Dumaresq
ae48acbb23 remove non usefull code. Add small description 2018-12-12 09:28:42 -05:00
Jonathan Dumaresq
52f6fd1d91 Add the possibility of using FILE * from cstdio library to read a file. This enable the possibility of using low eand device with this library. 2018-12-11 13:17:13 -05:00
Jonathan Dumaresq
67b0daf27b Add the possibility of using FILE * from cstdio library to read a file. This enable the possibility of using low eand device with this library. 2018-12-11 09:33:30 -05:00
David Avedissian
2c23f0a346 Changes requested from code review. 2018-12-08 15:46:33 +00:00
Niels Lohmann
e73dfef6e5 Merge pull request #1382 from kjpus/patch-1
Link to issue #958 broken
2018-12-04 20:02:38 +01:00
kjpus
767a3a327d Link to issue #958 broken 2018-12-04 10:03:10 -05:00
Niels Lohmann
d53873a251 Merge pull request #1363 from theodelrieu/doc/implicit_conversions
recommend using explicit from JSON conversions
2018-12-02 17:27:46 +01:00
Niels Lohmann
7a56f5a42b Merge pull request #1380 from manu-chroma/patch-1
readme: fix typo
2018-12-02 17:25:38 +01:00
Manvendra Singh
5de184b8fb readme: fix typo 2018-12-02 01:50:57 +05:30
Niels Lohmann
ef90d62ddf 🚨 fixed warning #1364 2018-11-21 21:17:38 +01:00
Théo DELRIEU
7b961368d5 recommend using explicit from JSON conversions 2018-11-20 14:14:07 +01:00
Niels Lohmann
da81e7be22 🏁 adding parentheses around std::snprintf calls #1337 2018-11-09 21:18:02 +01:00
Niels Lohmann
f80efd3954 💄 cleanup 2018-11-09 21:10:32 +01:00
Niels Lohmann
35829928da Merge pull request #1343 from mefyl/develop
Set eofbit on exhausted input stream.
2018-11-09 21:07:36 +01:00
Niels Lohmann
f86090aafc Merge pull request #1345 from mpoquet/feature/meson-install-pkgconfig
Allow installation via Meson
2018-11-08 18:39:26 +01:00
Niels Lohmann
30e1cbb0df Merge pull request #1346 from ax3l/fix-mergePatchShadowParam
Fix merge_patch shadow warning
2018-11-08 18:38:40 +01:00
mefyl
aa10382629 Set eofbit on exhausted input stream.
Fix issue #1340.

        The eofbit is set manually since we don't go through the
	stream interface. We could maybe use the stream interface
	instead, but there are some assumptions regarding which
	exception go through, so this seems to be the most prudent
	approach for now.
2018-11-08 11:41:17 +01:00
Axel Huebl
798754dfb6 Amalgamate Headers 2018-11-08 10:35:45 +01:00
Axel Huebl
97b81da840 merge_patch: rename parameter
Avoid shadowing a member of `this` by choosing the same name as
parameter (`-Wshadow`). Instead, make name of parameter more
expressive.
2018-11-08 10:31:47 +01:00
Millian Poquet
ffe08983dd :meson: install headers + pkg-config 2018-11-08 00:25:42 +01:00
David Avedissian
f665a92330 Implement SFINAE friendly iterator_traits and use that instead. 2018-11-07 18:39:25 +00:00
Niels Lohmann
d2e6e1bf58 Merge pull request #1329 from ax3l/fix-typosWhitespaces
Fix EOL Whitespaces & CMake Spelling
2018-11-02 18:23:42 +01:00
Axel Huebl
a7567bc596 Remove EOL whitespaces in natvis 2018-11-02 10:42:48 +01:00
Axel Huebl
f049836d68 CMake: Optional Install if Embedded
When adding this library as embedded library with private
"target link", e.g. only used inside private source files, the
library does not need to be installed when the main project gets
installed.

This adds an additional option `JSON_Install` similar to the
test-build control switch in order to skip installing headers and
CMake config files if requested.

Avoids using
```cmake
add_subdirectory(path/to/nlohmann_json EXCLUDE_FROM_ALL)
```

which has further side-effects:
https://cmake.org/cmake/help/v3.0/command/add_subdirectory.html
2018-11-02 10:18:00 +01:00
Axel Huebl
689382a722 Fix EOL Whitespaces & CMake Spelling
Fix little leftover EOL whitespaces in `CMakeLists.txt` and
a spelling of CMake in README.md
2018-11-02 09:35:17 +01:00
Niels Lohmann
2f73a4d1f3 🚨 fixed a linter warning 2018-10-31 20:30:24 +01:00
Niels Lohmann
e3c28afb61 Merge branch 'release/3.4.0' into develop 2018-10-30 22:20:29 +01:00
Niels Lohmann
0f3c74d821 🔖 set version to 3.4.0 2018-10-30 22:18:45 +01:00
Niels Lohmann
7b2f8cce03 🔖 set version to 3.4.0 2018-10-30 21:30:20 +01:00
Niels Lohmann
8cee0e38d9 🚑 fixed #1319 2018-10-30 17:29:05 +01:00
Niels Lohmann
856fc31d0a 💄 fixed indentation 2018-10-29 19:44:19 +01:00
Niels Lohmann
39419cd5c4 🚨 fixed another linter warning 2018-10-29 18:51:30 +01:00
Niels Lohmann
86b5ce953a 📝 added examples for BSON functions 2018-10-28 15:09:26 +01:00
Niels Lohmann
d2e4f0b0d9 ✏️ fixed some typos 2018-10-28 14:20:20 +01:00
Niels Lohmann
f0c1459554 🐛 fixed a bug parsing BSON strings #1320 2018-10-28 09:16:40 +01:00
Niels Lohmann
24946f67f1 🚨 fixed some more linter warnings 2018-10-28 09:15:41 +01:00
Niels Lohmann
7d0dc10169 🚨 fixed a linter warning 2018-10-27 18:34:35 +02:00
Niels Lohmann
45a761bd60 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2018-10-27 18:31:06 +02:00
Niels Lohmann
4e765596f7 🔨 small improvements 2018-10-27 18:31:03 +02:00
Niels Lohmann
1308ea055d Merge pull request #1315 from nlohmann/feature/convert_char
Properly convert constants to CharType
2018-10-27 16:56:00 +02:00
Niels Lohmann
0e7be06bef Merge pull request #1323 from nlohmann/feature/enum_json_mapping
Add macro to define enum/JSON mapping
2018-10-27 16:55:39 +02:00
Niels Lohmann
85aaf91b85 Merge branch 'develop' into feature/enum_json_mapping 2018-10-27 16:52:59 +02:00
Niels Lohmann
5a6bdf5934 Merge branch 'develop' into feature/convert_char 2018-10-27 16:48:48 +02:00
Niels Lohmann
037e93f5c0 Merge pull request #1320 from nlohmann/julian-becker-feature/bson
Add BSON support
2018-10-27 16:37:54 +02:00
Niels Lohmann
9f48bb6937 replaced vector by array #1323 2018-10-27 09:58:23 +02:00
Niels Lohmann
6384fe28db 🚨 fixed another linter warning 2018-10-26 23:12:41 +02:00
Niels Lohmann
ad639ad5e6 added NLOHMANN_JSON_SERIALIZE_ENUM marco #1208 2018-10-26 14:48:20 +02:00
Niels Lohmann
544150d5a5 🚨 fixed another linter warning 2018-10-26 11:10:49 +02:00
Niels Lohmann
c2e175763c 👌 added another conversion function #1315 2018-10-25 22:47:08 +02:00
Niels Lohmann
d97fa30795 👌 fixed comment #1320 2018-10-25 22:29:27 +02:00
Niels Lohmann
7ce720b700 🚨 fixed coverage 2018-10-25 18:21:50 +02:00
Niels Lohmann
19647e083c 🚨 fixed compiler warnings 2018-10-25 14:27:55 +02:00
Niels Lohmann
62126278a6 🔨 added fix for arrays 2018-10-25 13:01:18 +02:00
Niels Lohmann
1968e5c793 🎨 clean up binary formats 2018-10-24 23:39:30 +02:00
Niels Lohmann
4d1eaace8c 🔨 fixed fuzz code to avoid false positives in case of discarded values 2018-10-24 18:55:08 +02:00
Niels Lohmann
e2c5913a50 🚧 some changes to the BSON code
- added fuzz testers
- added some reference files
- made an exception text more clear
2018-10-24 15:43:37 +02:00
Niels Lohmann
bba159121f Merge branch 'feature/bson' of https://github.com/julian-becker/json into julian-becker-feature/bson 2018-10-24 15:03:15 +02:00
Niels Lohmann
f102df3cba 📝 updated documentation #1314 2018-10-24 09:28:57 +02:00
Niels Lohmann
7b501de054 Merge pull request #1314 from nlohmann/feature/codec_errors
Allow to set error handler for decoding errors
2018-10-24 08:40:58 +02:00
Niels Lohmann
20038e2703 📝 added a note to the discussion #1286 2018-10-23 23:00:43 +02:00
Niels Lohmann
87ef3f25f2 ✏️ fixed a typo #1314 2018-10-23 22:56:10 +02:00
Niels Lohmann
b49f76931f 👌 replaced static_cast to CharType by conversion function #1286 2018-10-23 17:49:04 +02:00
Niels Lohmann
2343d9caeb 💚 additional tests from the Unicode spec #1198
Thanks @abolz!
2018-10-23 17:22:13 +02:00
Niels Lohmann
951a7a6455 🚧 fixed test cases #1198 2018-10-22 18:20:45 +02:00
Niels Lohmann
c51b1e6fab 🚧 fixed an issue with ensure_ascii #1198 2018-10-22 15:53:36 +02:00
Niels Lohmann
c7af027cbb 🚧 respect ensure_ascii parameter #1198 2018-10-22 09:18:16 +02:00
Niels Lohmann
e5dce64115 💚 added tests #1198
Test every prefix of Unicode sequences against the different dump functions.
2018-10-21 23:26:25 +02:00
Niels Lohmann
c5821d91e5 🚧 overworked error handlers #1198 2018-10-21 11:49:37 +02:00
Julian Becker
ad11b6c35e BSON: Improved exception-related tests and report location of U+0000 in the key-string as part of out_of_range.409-message 2018-10-18 20:05:46 +02:00
Niels Lohmann
9294e25c98 Merge pull request #1301 from theodelrieu/fix/1299
add new is_constructible_* traits used in from_json
2018-10-18 19:18:48 +02:00
Niels Lohmann
b553a8a93c Merge pull request #1305 from koponomarenko/add-meson-info
Add Meson related info to README
2018-10-18 10:55:25 +02:00
Julian Becker
5ba812d518 BSON: fixed incorrect casting in unit-bson.cpp 2018-10-18 06:38:34 +02:00
Julian Becker
8de10c518b BSON: Hopefully fixing ambiguity (on some compilers) to call to string::find() 2018-10-17 21:47:01 +02:00
Kostiantyn Ponomarenko
f0c55ce0e0 Add Meson related info to README
Add more information about how one can get a Meson wrap file.

Signed-off-by: Kostiantyn Ponomarenko <konstantin.ponomarenko@gmail.com>
2018-10-17 21:46:45 +03:00
Julian Becker
2a63869159 Merge branch 'develop' of https://github.com/nlohmann/json into feature/bson
Conflicts:
	include/nlohmann/detail/input/binary_reader.hpp
	single_include/nlohmann/json.hpp
	src/unit-bson.cpp
2018-10-17 20:26:00 +02:00
Niels Lohmann
4b2a00641c Merge pull request #1303 from nlohmann/feature/binary_errors
Improve diagnostic messages for binary formats
2018-10-17 17:54:14 +02:00
Niels Lohmann
dbb0b63187 improved error messages for binary formats #1288
This commit is the equivalent of #1282 for CBOR, MessagePack, and UBJSON.
2018-10-17 12:15:58 +02:00
Théo DELRIEU
a946dfc19c add a note to maintainers in type_traits.hpp 2018-10-17 12:03:10 +02:00
Julian Becker
978c3c4116 BSON: throw json.exception.out_of_range.409 in case a key to be serialized to BSON contains a U+0000 2018-10-16 20:42:00 +02:00
Niels Lohmann
0671e92ced 🚧 proposal for different error handlers #1198
Proof of concept; currently only as parameter to the internal dump_escaped function; that is, not yet exposed to the dump function.
2018-10-16 20:38:50 +02:00
Julian Becker
daa3ca8a2e BSON: Adjusted documentation of binary_writer::to_bson() 2018-10-16 19:29:42 +02:00
Julian Becker
5bccacda30 BSON: throw json.exception.out_of_range.407 in case a value of type std::uint64_t is serialized to BSON. Also, added a missing EOF-check to binary_reader. 2018-10-16 19:13:07 +02:00
Théo DELRIEU
45c8af2c46 add new is_constructible_* traits used in from_json
is_compatible_* traits were used in from_json, but it made no sense
whatsoever.

It used to work because of non-SFINAE correctness + json_ref
unconstrained variadic template constructor.

SFINAE checks are becoming quite complex, we need a specification of
some sort describing:

* which concepts the library uses
* how the conversion to/from json works in detail

Having such a specification would really help simplifying the current
code (as well as having meaningful checks).

Fixes !1299
2018-10-16 14:00:34 +02:00
Niels Lohmann
dd672939a0 Merge pull request #1294 from theodelrieu/fix/json_ref_ctor
add constraints for variadic json_ref constructors
2018-10-12 17:35:41 +02:00
Théo DELRIEU
11fecc25af add constraints for variadic json_ref constructors
Fixes #1292
2018-10-12 10:54:58 +02:00
Niels Lohmann
e426219256 Merge pull request #1282 from nlohmann/feature/lines_columns
Improve diagnostic messages
2018-10-08 22:17:33 +02:00
Niels Lohmann
adfa961ed0 Merge pull request #1280 from nlohmann/feature/linter
Removed linter warnings
2018-10-08 21:05:33 +02:00
Niels Lohmann
6d34d64bfd 🚑 fixed compilation error 2018-10-08 06:54:51 +02:00
Niels Lohmann
74a31075e3 improved parse error messages 2018-10-07 22:39:17 +02:00
Niels Lohmann
6e49d9f5ff 🚑 fixed compilation error 2018-10-07 21:34:40 +02:00
Niels Lohmann
f8158997b5 📝 fixed documentation 2018-10-07 21:30:58 +02:00
Julian Becker
df0f612d1b BSON: allow and discard values and object entries of type value_t::discarded 2018-10-07 20:08:05 +02:00
Niels Lohmann
3abb788139 🚨 fixed some more clang-tidy warnings 2018-10-07 19:07:58 +02:00
Niels Lohmann
858e75c4df 🚨 fixed some clang-tidy warnings 2018-10-07 18:39:18 +02:00
Julian Becker
062aeaf7b6 BSON: Reworked the binary_writer such that it precomputes the size of the BSON-output.
This way, the output_adapter can work on simple output iterators and no longer requires random access iterators.
2018-10-07 18:02:51 +02:00
Niels Lohmann
6d09cdec34 🐛 fixed a bug in the unget function 2018-10-07 16:48:45 +02:00
Niels Lohmann
011b15dd08 added line positions to error messages
This is a follow-up to #1210.
2018-10-07 12:27:24 +02:00
Julian Becker
81f4b34e06 BSON: Improved documentation and error handling/reporting 2018-10-07 09:57:55 +02:00
Niels Lohmann
ac38e95780 Merge pull request #1277 from performous/fix-clang-detection
Thirdparty benchmark: Fix Clang detection.
2018-10-06 16:29:26 +02:00
Niels Lohmann
fa722d5ac3 🚨 fixed another linter warning 2018-10-06 16:26:47 +02:00
Niels Lohmann
ec95438a59 🚨 fixed some linter warnings 2018-10-06 13:49:02 +02:00
Niels Lohmann
f1768a540a Merge branch 'release/3.3.0' into develop 2018-10-05 12:59:41 +02:00
Niels Lohmann
cdfe6ceda6 🔖 set version to 3.3.0 2018-10-05 11:20:10 +02:00
Niels Lohmann
b968faa882 🔖 set version to 3.3.0 2018-10-05 10:59:33 +02:00
Niels Lohmann
cd518fbbab 📝 small update to pass test suite 2018-10-05 08:58:38 +02:00
Gregorio Litenstein
e8427061a0 Thirdparty benchmark: Fix Clang detection.
CMake 3.0+ refers to macOS’ Clang as AppleClang, which would fail a STREQUAL check. Fixed by changing it to MATCHES.
2018-10-05 02:01:43 -03:00
Niels Lohmann
b911654857 📝 updated contributor list 2018-10-04 22:30:18 +02:00
Niels Lohmann
bb55885215 💄 cleaned code 2018-10-04 20:42:19 +02:00
Niels Lohmann
5c7d27c338 Merge pull request #1272 from antonioborondo/fix_warning
Fix warning C4127: conditional expression is constant
2018-10-04 20:33:26 +02:00
Antonio Borondo
b6fdad9acd Remove anonymous namespace 2018-10-03 13:51:49 +01:00
Antonio Borondo
7c385a4844 Fix error: 'wide_string_input_helper' was not declared in this scope 2018-10-03 12:41:34 +01:00
Antonio Borondo
9ba3f79667 Fix error: explicit specialization in non-namespace scope 2018-10-03 12:26:24 +01:00
Antonio Borondo
8d1585f065 Change implementation to use templates 2018-10-03 11:44:02 +01:00
Antonio Borondo
ad3c216bb5 Generate header 2018-10-03 11:27:53 +01:00
Antonio Borondo
0231059290 Fix warning 2018-10-03 11:27:53 +01:00
Niels Lohmann
9f18e17063 Merge pull request #1270 from chuckatkins/add-more-cmake-docs
docs: Add additional CMake documentation
2018-10-03 10:11:27 +02:00
Niels Lohmann
53ec0a16f3 Merge pull request #1271 from chuckatkins/cleanup-deprecated-warnings
Turn off additional deprecation warnings for GCC.
2018-10-02 22:07:18 +02:00
Chuck Atkins
4c617611e2 docs: Add additional CMake documentation 2018-10-02 14:28:20 -04:00
Chuck Atkins
829571ab5c Turn off additional deprecation warnings for GCC.
In follow up from the conversation in #1269, this adds the
`-Wno-deprecate-declarations` flag to unit tests to allow them to
test deprecated APIs without all the noisy compiler warnings.
This also refactors the setting of build properties for test targets
to use `target_<...>` commands instead of `set_target_properties()`.
2018-10-02 13:01:19 -04:00
Niels Lohmann
c8231eff75 Merge pull request #1260 from chuckatkins/fix-cmake-target-alias
Fix broken cmake imported target alias
2018-10-01 17:44:50 +02:00
Chuck Atkins
02e653bdf7 docs: add a note in the readme about using the CMake imported target 2018-09-30 22:52:54 -04:00
Chuck Atkins
564506a885 cmake: add import config tests 2018-09-30 22:52:47 -04:00
Chuck Atkins
1729db85c1 cmake: fix package config to deal with versioning and namespaces 2018-09-30 09:56:33 -04:00
Niels Lohmann
910a895027 Merge pull request #1238 from theodelrieu/fix/1237
Fix issue #1237
2018-09-29 14:50:54 +02:00
Niels Lohmann
1fae82b7a7 Merge branch 'develop' into fix/1237 2018-09-29 14:50:36 +02:00
Niels Lohmann
22e55349a6 📝 added Wandbox link #1227 2018-09-29 14:33:39 +02:00
Niels Lohmann
70e587c3da 📝 added Wandbox link #1227 2018-09-29 14:33:21 +02:00
Niels Lohmann
d26f39466e Merge pull request #1231 from theodelrieu/feature/get_with_parameter
Add a get overload taking a parameter.
2018-09-29 14:30:04 +02:00
Niels Lohmann
c61a9071ae 🚨 fixed a compilation issue with ICPC #755
Closes #1222
2018-09-29 11:50:14 +02:00
Julian Becker
e8730e5e82 BSON: Reworked binary_reader::get_bson_cstr() 2018-09-29 11:50:01 +02:00
Niels Lohmann
b59a58406e Merge branch 'develop' of https://github.com/nlohmann/json into develop 2018-09-29 11:48:52 +02:00
Niels Lohmann
4e54c9a13d 🚨 fixed a compilation issue with ICPC #755
Closes #1222
2018-09-29 11:48:49 +02:00
Julian Becker
0a09db9cc2 BSON: Extend binary_reader::get_number to be able to hanlde little endian input to get rid of binary_reader::get_number_little_endian 2018-09-29 11:33:01 +02:00
Niels Lohmann
95432c34f9 Merge pull request #1262 from knilch0r/patch-1
unit-testsuites.cpp: fix hangup if file not found
2018-09-29 10:58:10 +02:00
knilch
8c1387cfb3 unit-testsuites.cpp: fix hangup if file not found
If run from the wrong directory, std::ifstream f("test/data/big-list-of-naughty-strings/blns.json"); will not find the file and thus f.eof() will never return true.
Use canonical C++ file reading loop from https://gehrcke.de/2011/06/reading-files-in-c-using-ifstream-dealing-correctly-with-badbit-failbit-eofbit-and-perror/ instead.
2018-09-28 11:33:23 +02:00
Théo DELRIEU
521fe49fec Add basic_json::get_to function.
Takes an lvalue reference, and returns the same reference.

This allows non-default constructible types to be converted without
specializing adl_serializer.
This overload does not require CopyConstructible either.

Implements #1227
2018-09-28 11:25:23 +02:00
Niels Lohmann
680a4ab672 Merge pull request #1257 from henryiii/gcc48
GCC 48
2018-09-28 10:05:17 +02:00
Henry Fredrick Schreiner
7a37ba0c02 Adding 4.8 test to travis 2018-09-27 22:31:39 +02:00
Julian Becker
ef358ae695 BSON: Fixed hangup in case of incomplete bson input and improved test coverage 2018-09-25 20:34:25 +02:00
Chris Harris
99b7c7c8ef Patch nlohmann/json for GCC 4.8
See https://github.com/nlohmann/json/pull/212 for details
2018-09-25 18:10:20 +02:00
Julian Becker
bce4816275 BSON: Added test case for the different input/output_adapters 2018-09-24 23:35:19 +02:00
Julian Becker
763705c2a7 Fix: Add missing begin() and end() member functions to alt_string 2018-09-24 19:50:28 +02:00
Niels Lohmann
e184b6ecf2 Merge pull request #1252 from koponomarenko/fix-meson-build
Add version and license to meson.build
2018-09-22 14:49:03 +02:00
Niels Lohmann
88b055c2df Merge pull request #1249 from LEgregius/clang-3.4.2-crash-workaround
#1179 Reordered the code. It seems to stop clang 3.4.2 in RHEL 7 from crash…
2018-09-22 14:14:56 +02:00
Kostiantyn Ponomarenko
8799759b85 Add version and license to meson.build 2018-09-20 21:54:10 +03:00
Théo DELRIEU
4e52277b70 Fix issue #1237
* Make the conversion operator SFINAE correct.
* Workaround a GCC bug with some traits in type_traits.hpp

The first bullet-point implies that every `get`/`get_ptr` be SFINAE
correct as well.
2018-09-20 10:33:14 +02:00
Niels Lohmann
e4bc98d036 Merge pull request #1245 from chuckatkins/fix-target-namespace-backward-compatibility
Use a version check to provide backwards comatible CMake imported target names
2018-09-19 20:46:51 +02:00
David Guthrie
4d780b091b Reordered the code. It seems to stop clang 3.4.2 in RHEL 7 from crashing intermittently. 2018-09-18 16:38:59 -04:00
Chuck Atkins
3b1a5cafad Use a version check to provide backwards comatible imported target names. 2018-09-18 13:59:19 -04:00
Niels Lohmann
99939d6340 📝 added lgtm.com badge
See https://lgtm.com/projects/g/nlohmann/json
2018-09-18 19:27:52 +02:00
Niels Lohmann
4e2f35d4c2 👷 adding Xcode 10 worker
See https://blog.travis-ci.com/2018-09-13-xcode-10-is-now-available?utm_source=twitter&utm_medium=web&utm_campaign=xcode10_gm
2018-09-18 19:22:30 +02:00
Niels Lohmann
7fa3b8865c Merge pull request #1221 from rivertam/better-error-305
Better error 305
2018-09-18 12:49:07 +02:00
Ben Berman
8f07ab6392 Replace "key-style argument" with "string argument" 2018-09-17 15:36:38 -04:00
Julian Becker
df33a90774 BSON: Bugfix for non-empty arrays 2018-09-15 14:08:38 +02:00
Julian Becker
cf485c2907 BSON: Support for arrays 2018-09-15 13:54:08 +02:00
Julian Becker
120d1d77d4 BSON: test case for a more complex document 2018-09-15 13:41:05 +02:00
Julian Becker
5ce7d6bdd7 BSON: support objects with objects as members 2018-09-15 13:03:42 +02:00
Julian Becker
83b427ad67 BSON: unsigned integers 2018-09-15 12:20:30 +02:00
Julian Becker
c0d8921a67 BSON: support objects with int64 members 2018-09-15 12:00:53 +02:00
Julian Becker
7ee361f7ad BSON: support objects with int32 members 2018-09-15 11:54:17 +02:00
Julian Becker
c5ef023171 BSON: support objects with null members 2018-09-15 11:39:12 +02:00
Julian Becker
6c447de076 BSON: Support objects with string members 2018-09-15 11:33:24 +02:00
Julian Becker
0c0f2e44b5 BSON: support doubles 2018-09-15 10:32:03 +02:00
Julian Becker
9a0dddc5d2 BSON: Object with single boolean 2018-09-15 03:08:50 +02:00
Julian Becker
5f5836ce1c BSON: Support empty objects 2018-09-15 00:43:39 +02:00
Julian Becker
f06c8fd8e3 BSON: serialization of non-objects is not supported 2018-09-15 00:20:03 +02:00
Niels Lohmann
186c747a19 Merge pull request #1230 from mandreyel/lambda-unevaluated-context-fix
Move lambda out of unevaluated context
2018-09-10 20:52:11 +02:00
mandreyel
6b5334c167 Move lambda out of unevaluated context 2018-09-10 13:34:59 +02:00
Niels Lohmann
ebb3c03293 🎨 cleanup after #1228 2018-09-09 18:19:33 +02:00
Niels Lohmann
d3428b35c5 Merge pull request #1228 from theodelrieu/remove_static_asserts
Remove static asserts
2018-09-09 18:12:43 +02:00
Théo DELRIEU
aea648bb7a remove now-useless traits. check for is_basic_json where needed 2018-09-07 14:10:39 +02:00
Théo DELRIEU
4b4bbceebf make from_json SFINAE-correct 2018-09-07 14:10:37 +02:00
Théo DELRIEU
f7971f04a5 make to_json SFINAE-correct 2018-09-07 12:18:04 +02:00
Théo DELRIEU
f7c8a2145a refactor from/to_json(CompatibleArrayType) 2018-09-07 12:18:04 +02:00
Théo DELRIEU
628f76729e do not check for compatible_object_type in compatible_array_type 2018-09-07 12:18:03 +02:00
Théo DELRIEU
29f72966c3 refactor is_compatible_type, remove conjunction & co 2018-09-07 12:18:03 +02:00
Théo DELRIEU
77967e6548 refactor is_compatible_integer_type 2018-09-07 12:18:03 +02:00
Théo DELRIEU
13760857ff refactor is_compatible_array_type 2018-09-07 12:18:02 +02:00
Théo DELRIEU
924e95c6e8 refactor is_compatible_string_type 2018-09-07 12:18:02 +02:00
Théo DELRIEU
e84195ab7b refactor is_compatible_object_type 2018-09-07 12:18:02 +02:00
Théo DELRIEU
b59c3367c9 use detected instead of has_* traits 2018-09-07 12:17:59 +02:00
Théo DELRIEU
1ea8cd128c fix void_t for older compilers 2018-09-07 12:17:33 +02:00
Niels Lohmann
eb30ff0615 🚨 fixed a compiler warning #1224 2018-09-06 07:25:19 +02:00
Ben Berman
ad053ef09c Fix tests for improved error 305(hopefully) 2018-08-30 13:21:55 -04:00
Ben Berman
bbdfe7dea6 Improve error messages for error 305
Addresses #1220
2018-08-30 12:35:51 -04:00
Niels Lohmann
d713727f22 Merge pull request #1202 from dennisfischer/develop
Export package to allow builds without installing
2018-08-25 10:56:30 +02:00
Niels Lohmann
04597c3a66 Merge pull request #1214 from devsisters/fix-1213
Fix #1213
2018-08-24 17:54:28 +02:00
Hyeon Kim
aada309f61 Fix #1213 2018-08-24 21:55:13 +09:00
Niels Lohmann
359f98d140 Merge branch 'release/3.2.0' into develop 2018-08-20 19:36:25 +02:00
Dennis Fischer
dfe607c6ff Export package to allow builds without installing 2018-08-20 09:23:12 +02:00
Niels Lohmann
9f3857ef6f 🔖 set version to 3.2.0 2018-08-18 18:46:15 +02:00
Niels Lohmann
7608a64e1e 🔨 fixed amalgamation 2018-08-18 18:14:12 +02:00
Niels Lohmann
a7b02bdce0 🔖 preparing 3.2.0 release 2018-08-18 17:48:49 +02:00
Niels Lohmann
c6a482b16c 📝 added example for sax_parse 2018-08-18 15:42:18 +02:00
Niels Lohmann
5ad52f4167 ⬆️ Catch 1.12.0 2018-08-18 12:02:12 +02:00
Niels Lohmann
3811daa8a3 📝 release preparation 2018-08-18 12:00:14 +02:00
Niels Lohmann
6899fa304c Merge branch 'develop' of https://github.com/nlohmann/json into develop 2018-08-18 08:15:06 +02:00
Niels Lohmann
57faaf42ca 🚨 fixed a compiler warning 2018-08-18 08:15:03 +02:00
Niels Lohmann
f78ac4fbd3 Merge pull request #1200 from thyu/develop
Fix -Wno-sometimes-uninitialized by initializing "result" in parse_sax
2018-08-18 08:14:04 +02:00
Tsz-Ho Yu
3004a73951 Fix -Wno-sometimes-uninitialized by initializing "result" in parse_sax
The function parse_sax() returns sometimes-uninitialized warnings in
some compilers. This commit fixes that.
2018-08-18 01:12:19 +01:00
Niels Lohmann
e33b31e6aa 🐛 fixed callback-related issue (https://github.com/nlohmann/json/issues/971#issuecomment-413678360) 2018-08-17 23:09:45 +02:00
Niels Lohmann
b5c54b41fd 📝 overworked documentation 2018-08-16 21:53:47 +02:00
Niels Lohmann
07494e06d7 🚨 fixed some compiler warnings 2018-08-16 18:20:30 +02:00
Niels Lohmann
d5b21b051c Merge pull request #1153 from theodelrieu/refactor/no_virtual_sax
Refactor/no virtual sax
2018-08-16 17:47:55 +02:00
Théo DELRIEU
0cc3db4f15 add static_asserts on SAX interface 2018-08-16 11:59:57 +02:00
Théo DELRIEU
38f8a51a8f use abstract sax class in parser tests 2018-08-16 11:59:49 +02:00
Théo DELRIEU
9bbb133094 remove no_limit constant and default values 2018-08-16 11:59:05 +02:00
Théo DELRIEU
442886d040 use templates in the sax interface instead of virtuals 2018-08-16 11:58:52 +02:00
Théo DELRIEU
f6febbe359 split meta.hpp, add detected_t (used to define concepts) 2018-08-16 11:58:42 +02:00
Niels Lohmann
3ac2d81a95 🔨 fixed a MinGW error #1193 2018-08-14 22:13:56 +02:00
Niels Lohmann
be2065dce9 🚨 fixing a MinGW warning #1192 2018-08-14 22:11:47 +02:00
Niels Lohmann
fed70f6bff 🎨 reindented code 2018-08-14 22:11:08 +02:00
Niels Lohmann
0e748f2f8c Merge pull request #1187 from devsisters/json-internal-catch
[RFC] Introduce a new macro function: JSON_INTERNAL_CATCH
2018-08-14 21:56:29 +02:00
Niels Lohmann
861ee400cc Merge pull request #1176 from grembo/develop
Fix unit tests that were silently skipped or crashed (depending on the compiler)
2018-08-14 21:48:49 +02:00
Niels Lohmann
3ce4325350 📝 updated documentation of used compilers 2018-08-01 22:31:51 +02:00
Niels Lohmann
ba4a19d4af 👷 added more CI workers 2018-08-01 20:59:58 +02:00
Niels Lohmann
043eff5ba8 👷 added more CI workers 2018-07-31 21:18:33 +02:00
Michael Gmelin
05b27e83b7 Exclude bytewise comparison in certain tests.
These tests never worked - they weren't run before
d5aaeb4.

Note that these tests would fail because of this library
ordering dictionary keys (which is legal). So changing the
input files (or modifying stored cbor/msgpack/ubjson files)
would make the tests work and they could get removed from
"exclude_packaged".

Also move parsing of files in these unit tests to within
the inner sections, so that they're only parsed
number_of_files * number_of_sections instead of
number_of_files * number_of_files * number_of_sections
(so, instead of close to 100k parses about 700).
2018-07-29 14:52:52 +02:00
Michael Gmelin
d5aaeb4cce Make section names unique in loops, as catch doesn't support duplicate
sections, see also https://github.com/catchorg/Catch2/issues/816#issuecomment-278268122

As a result, when built with gcc, loop iterations were skipped. When
built with clang, the test aborted with an assertion in catch.hpp
line 6222.

This also addresses the issues discussed here:
https://github.com/nlohmann/json/issues/1032#issuecomment-378707696

and here:
https://github.com/catchorg/Catch2/issues/1241

Please note that this introduces new problems, as some of
the unit tests fail now - the library stores keys in
lexographical order, while the cbor/msgpack/ubjson examples
store them in original order.
2018-07-29 10:44:36 +02:00
Niels Lohmann
3760a38b7e 🏁 implicit conversion is not allowed with MSVC 2018-07-21 11:47:05 +02:00
Niels Lohmann
5b14411669 🏁 trying to fix C2440 error
Error in AppVeyor:

unit-conversions.cpp(441): error C2440: 'initializing': cannot convert from 'nlohmann::json' to 'std::nullptr_t'

(https://ci.appveyor.com/project/nlohmann/json/build/2838/job/wo7im01sq6tvhe9m)
2018-07-21 10:59:00 +02:00
Niels Lohmann
347e77bdc1 🚑 fix for #1169 2018-07-21 10:31:55 +02:00
Niels Lohmann
04372a8c56 🏁 fix for #1168 2018-07-19 17:31:50 +02:00
Hyeon Kim
d0e60de433 Add new JSON_INTERNAL_CATCH macro function 2018-07-19 15:43:41 +09:00
Niels Lohmann
7bfc406ded 📝 added note about CocoaPods #1148 2018-07-05 21:18:46 +02:00
Niels Lohmann
d456a2d777 Merge pull request #1151 from sonulohani/bigObjFix
Fixed compiler error in VS 2015 for debug mode
2018-06-29 09:03:43 +02:00
Sonu Lohani
b8ad3388ec Fixed compiler error in VS 2015 for debug mode
https://github.com/nlohmann/json/issues/1114
2018-06-29 09:34:41 +05:30
Niels Lohmann
39dd775e38 🔨 cleanup after #1134 2018-06-28 21:32:32 +02:00
Niels Lohmann
86a96b059d Merge pull request #1134 from Daniel599/feature/items_iterator
fixed compile error for #1045
2018-06-28 21:21:17 +02:00
Niels Lohmann
396a914f9e 🔨 added macro to disable compiler check #1128 2018-06-26 22:47:40 +02:00
Niels Lohmann
bab5826504 Merge pull request #1144 from jrakow/cppreference-link-fix
Fix links to cppreference named requirements (formerly concepts)
2018-06-26 07:58:45 +02:00
Niels Lohmann
515cfc2d89 Merge pull request #1142 from jrakow/develop
meson: fix include directory
2018-06-24 23:33:30 +02:00
Julius Rakow
963d06a13c 📝 fix links to cppreference named requirements
"Concepts" have been renamed to "named requirements".
This is because P0898R3 Standard Library Concepts has been merged into
C++20.
Cppreference have moved their links accordingly.
2018-06-24 22:36:19 +02:00
Julius Rakow
9f00db48d9 📝 link to cppreference via HTTPS 2018-06-24 22:34:47 +02:00
Julius Rakow
ec2ebd5ec9 meson: add multiple headers target 2018-06-24 18:07:30 +02:00
Julius Rakow
0bb36bb140 meson: fix include directory 2018-06-24 18:07:30 +02:00
Niels Lohmann
62457729e8 📝 mentioned MinGW in README 2018-06-24 18:03:59 +02:00
Niels Lohmann
09c0df4a21 👷 choosing correct image 2018-06-24 17:40:16 +02:00
Niels Lohmann
1bbc4a0859 👷 using Ninja to speed up build 2018-06-24 17:10:13 +02:00
Niels Lohmann
d8fe13fc83 🔨 fixed escaping for MinGW 2018-06-24 16:57:53 +02:00
Niels Lohmann
e59b930927 👷 trying a more recent compiler 2018-06-24 16:40:47 +02:00
Niels Lohmann
937d68e2e5 👷 forgot old PATH 2018-06-24 16:37:02 +02:00
Niels Lohmann
989ad9b759 👷 using help from https://stackoverflow.com/a/48509334/266378 2018-06-24 16:35:16 +02:00
Niels Lohmann
067e288289 👷 set build type 2018-06-24 16:29:03 +02:00
Niels Lohmann
7bbc06b487 👷 forgot quotes 2018-06-24 16:18:44 +02:00
Niels Lohmann
441e5d87e6 👷 experimenting with AppVeyor and MinGW 2018-06-24 16:17:06 +02:00
Niels Lohmann
7fa4ddf93e 💄 fixed indentation 2018-06-23 17:27:40 +02:00
Niels Lohmann
bf348ca8a4 Merge pull request #1028 from gracicot/develop
Added support for string_view in C++17
2018-06-23 17:10:04 +02:00
Niels Lohmann
ed6a0686df 🔨 small refactoring to improve branch coverage
The branch coverage reported by lcov is weird. The code before and after has the same Godbolt assembler, but the code with the lambda has a better branch coverage.
2018-06-23 17:05:04 +02:00
Niels Lohmann
c8bfdfd961 👷 tryping different platforms for AppVeyor 2018-06-23 11:12:32 +02:00
Niels Lohmann
c02de445bf 🚨 fixed more compiler warnings 2018-06-23 11:00:42 +02:00
Niels Lohmann
66dd1a846d 🚨 fixed more compiler warnings 2018-06-23 10:47:55 +02:00
Niels Lohmann
850922269d 🚨 removed compiler warnings 2018-06-23 10:28:04 +02:00
Niels Lohmann
0460b90977 📝 fix for #1052 #1139 2018-06-22 22:35:48 +02:00
Niels Lohmann
85f35a1d59 📝 documentation fix 2018-06-22 22:34:42 +02:00
Niels Lohmann
e7c1638d11 💄 cleanup 2018-06-18 22:03:46 +02:00
Niels Lohmann
1c81e9f5ae Merge pull request #1130 from agrianius/develop
test (non)equality for alt_string implementation
2018-06-18 22:01:53 +02:00
Niels Lohmann
d505ed7b31 Merge pull request #1138 from theodelrieu/feature/unordered_map_conversion
Feature/unordered map conversion
2018-06-18 21:59:46 +02:00
Théo DELRIEU
2c920a1032 run make amalgamate 2018-06-18 15:14:10 +02:00
Théo DELRIEU
2b37d7ed86 from_json: add overload for std::unordered_map
Fixes #1133
2018-06-18 15:14:10 +02:00
Théo DELRIEU
299469cfd5 from_json: add missing template arguments for std::map 2018-06-18 10:52:11 +02:00
Danielc
1566ad4053 fixed compile error for #1045; to_json for iternation_proxy_internal was needed 2018-06-16 12:01:49 +03:00
Vitaliy
f574d7e084 simplify templates for operators, add more checks 2018-06-14 15:07:06 +03:00
Vitaliy
cd28d872e7 forward declarations to make new compilers happy 2018-06-11 20:50:39 +03:00
Vitaliy
3d3055909c define global operator< for const char* and alt_string 2018-06-11 19:09:57 +03:00
Vitaliy
4feb8211ca test (non)equality for alt_string implementation 2018-06-11 18:03:46 +03:00
Guillaume Racicot
14e6278c2f Merge branch 'develop' of github.com:gracicot/json into develop 2018-06-04 11:18:25 -04:00
Guillaume Racicot
7acd90b651 Fixed check for compatible string type 2018-06-04 11:18:19 -04:00
Guillaume Racicot
5676a2a076 Aligned template declaration 2018-06-03 23:51:07 -04:00
Guillaume Racicot
e0e7fa39e7 Re-added external_constructor with string compatible types 2018-06-03 23:49:13 -04:00
Guillaume Racicot
4778c02ab5 Set MSVC version from 1514 and older 2018-06-01 14:42:25 -04:00
Guillaume Racicot
714c592680 Disabled implicit conversion to string_view on MSVC 15.13 and older 2018-06-01 14:22:57 -04:00
Niels Lohmann
e830bc502f Merge pull request #1117 from TinyTinni/develop
remove stringstream dependency
2018-06-01 08:05:45 +02:00
Matthias Möller
ecadcdb593 added char cast
should fix the GCC unittest
2018-05-31 16:36:16 +02:00
Matthias Möller
48656a49f5 typo 2018-05-31 15:32:21 +02:00
Matthias Möller
64acb42aa7 remove stringstream dependency 2018-05-31 13:45:58 +02:00
Niels Lohmann
8efbf8d7bb 📝 documentation to avoid future issues like #1108 2018-05-28 18:14:44 +02:00
Niels Lohmann
e5a67fc3f8 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2018-05-28 17:57:46 +02:00
Niels Lohmann
a49644ab74 🚑 adjusted Fuzzer to new parser
out_of_range exceptions where unexpected before - the parser used to crash in these situations...
2018-05-28 17:57:22 +02:00
Niels Lohmann
0efaf891e5 Merge pull request #1089 from theodelrieu/feature/map_conversion
Provide a from_json overload for std::map
2018-05-28 14:53:23 +02:00
Théo DELRIEU
c5e63fd684 Provide a from_json overload for std::map
This overload is chosen only when BasicJsonType::string_t
is not constructible from std::map::key_type.

Currently, converting a map to json treats it as an array of pairs.

fixes #1079
2018-05-28 11:06:24 +02:00
Niels Lohmann
db03d09312 Merge branch 'feature/key_ref' into develop (fixes #1098) 2018-05-27 22:26:00 +02:00
Niels Lohmann
cf9299d222 Merge branch 'feature/sax2' into develop #971 2018-05-27 18:12:59 +02:00
Niels Lohmann
3cdc4d784b 📝 added documentation 2018-05-27 18:07:53 +02:00
Niels Lohmann
adf09726b0 Merge branch 'develop' into feature/sax2 2018-05-27 14:26:13 +02:00
Niels Lohmann
481ace65c4 🔨 only calculate array index string when needed #1098 2018-05-27 12:04:22 +02:00
Niels Lohmann
1c6b332dcd 👌 mitigating cppcheck bug #1101 2018-05-26 14:10:13 +02:00
Niels Lohmann
90eb0a91e0 keys are now returned as const reference #1098 2018-05-26 13:26:40 +02:00
Niels Lohmann
1f84cc2c88 adjusted test cases 2018-05-17 16:50:37 +02:00
Niels Lohmann
717301d1bc Merge branch 'testsuite' into feature/sax2 2018-05-17 16:36:43 +02:00
Niels Lohmann
4639bb2c8f added more tests from recent nst's JSONTestSuite 2018-05-17 10:10:01 +02:00
Niels Lohmann
e94862a649 🚑 fixed error in callback logic 2018-05-06 19:00:49 +02:00
Niels Lohmann
ae213721b1 🔨 removed unget function for wstring parsers 2018-05-06 14:05:29 +02:00
Niels Lohmann
5ff2abb90d Merge branch 'develop' into feature/sax2 2018-05-06 13:29:23 +02:00
Niels Lohmann
567fe9b7a0 Merge pull request #1078 from martin-mfg/patch-1
fix typo in README
2018-05-04 17:04:35 +02:00
martin-mfg
377e956655 fix typo in readme
The README says:
> "The library itself contains of a single header file ..."

I guess "consists of a" is the wording that was intended here. Alternatively, "contains a" might also be what was intended. Either way, I think both versions work equally well and thus choose the one that I believe was intended.
2018-05-03 22:42:52 +02:00
Niels Lohmann
5da596385b Update issue templates 2018-05-03 18:35:56 +02:00
Niels Lohmann
7bbe7bb98f 🔥 removed old issue template 2018-05-03 18:35:21 +02:00
Niels Lohmann
14f01e1981 🔧 update issue templates 2018-05-03 18:32:53 +02:00
Niels Lohmann
86b0732a10 📝 added public key used for commits and releases 2018-05-03 18:11:42 +02:00
Niels Lohmann
ed69e50ad2 📄 added SPDX-License-Identifier 2018-05-03 17:41:45 +02:00
Niels Lohmann
5bc4ff9da3 Merge branch 'feature/wstring' into develop 2018-04-29 17:29:57 +02:00
Niels Lohmann
fa3e42f826 Merge branch 'develop' into feature/wstring 2018-04-29 13:16:12 +02:00
Niels Lohmann
b5d1755dfb 🔥 removed commented-out test cases #1060 2018-04-22 15:41:42 +02:00
Niels Lohmann
0ab8fab338 Merge pull request #1058 from dns13/patch-1
Fix typo
2018-04-17 23:26:00 +05:30
Jan Schöppach
65b4d8251b Fix typo in single_include, too 2018-04-17 13:02:36 +02:00
Jan Schöppach
53fb230098 Fix typo 2018-04-17 12:08:44 +02:00
Niels Lohmann
46ec2fddf8 📝 updated THANKS list 2018-04-10 18:13:37 +02:00
Niels Lohmann
b8bfd1140d Merge pull request #1048 from chuckatkins/misc-cmake-packaging-enhancements
Misc cmake packaging enhancements
2018-04-10 17:57:21 +02:00
Chuck Atkins
33a2154f8d Enable target namespaces and build dir project config
CMake convention is to use a project namespace, i.e. Foo::, for imported
targets.  When multiple targets are imported from a project, this looks
like Foo::Bar1 Foo::Bar2, etc.  This adds the nlohmann_json:: namespace to
the exported target names.

This also allows the generated project config files to be used from the
build directory instead of just the install directory.
2018-04-10 09:08:38 -04:00
Niels Lohmann
29362c6ace Merge pull request #1047 from jammehcow/patch-1
Fixed incorrect LLVM version number in README
2018-04-10 08:39:58 +02:00
Niels Lohmann
c02a3155d4 👷 added Xcode 9.3 builder
See https://blog.travis-ci.com/2018-04-09-say-bonjour-to-xcode-93-and-macos-high-sierra.
2018-04-10 08:39:28 +02:00
Niels Lohmann
8d8f890771 💩 first try on #1045 2018-04-10 08:29:07 +02:00
James Upjohn
7f20e9ddc7 Fixed incorrect version number in README
clang-900.0.39.2 is from LLVM 9.0.0, not 8.1.0
2018-04-10 17:16:44 +12:00
Chuck Atkins
031b88d315 Make the CMake install dir user-configurable 2018-04-09 11:31:25 -04:00
Guillaume Racicot
aaee18ce90 Added test for string conversion with string_view 2018-04-09 11:15:33 -04:00
Niels Lohmann
7c503c64b7 Merge pull request #1043 from coryan/patch-1
Fix trivial typo in comment.
2018-04-09 08:19:56 +02:00
Carlos O'Ryan
4286b16b71 Fix trivial typo in comment.
Not really important, but since I saw it.
2018-04-08 15:46:25 -04:00
Niels Lohmann
cf91b4f2bb Merge branch 'develop' into feature/wstring 2018-04-08 11:36:58 +02:00
Niels Lohmann
f924df1835 Merge branch 'develop' into feature/sax2 2018-04-08 11:36:44 +02:00
Niels Lohmann
acf10d9af7 Merge pull request #1041 from ax3l/topic-spack
Package Manager: Spack
2018-04-08 11:32:35 +02:00
Niels Lohmann
e1ea8369ad Merge branch 'develop' into feature/sax2 2018-04-08 09:31:59 +02:00
Niels Lohmann
40f279c59d Merge branch 'feature/issue1021' into develop 2018-04-08 09:28:37 +02:00
Niels Lohmann
18a0271a95 Merge branch 'develop' into feature/issue1021 2018-04-08 09:21:43 +02:00
Axel Huebl
1ae9896387 Package Manager: Spack
I contributed a package to the Spack package manager.

Spack is a flexible package manager that supports multiple versions,
configurations, platforms, and compilers. It is popular in
high-performance computing.
2018-04-08 01:12:49 +02:00
Niels Lohmann
83b143382e Merge pull request #1040 from ax3l/topic-debugViewMSVCcmakeMin
CMake: 3.8+ is Sufficient
2018-04-07 15:14:59 +02:00
Axel Huebl
e439a1a9a7 CMake: 3.8+ is Sufficient
The current CMake scripts depend on CMake 3.8+.
This allows us to remove previous work-arounds.
2018-04-07 13:15:44 +02:00
Niels Lohmann
495436a5d5 Merge pull request #1026 from ktonon/develop
Added public target_compile_features for auto and constexpr
2018-04-03 17:34:42 +02:00
Kevin Tonon
a35d414c39 Update CMake to latest on Travis 2018-04-03 08:28:07 -04:00
Niels Lohmann
08a7233d1b 🚑 fixed commit 1e08654 2018-04-02 22:38:44 +02:00
Niels Lohmann
1e08654f99 🔨 cleanup 2018-04-02 22:25:17 +02:00
Niels Lohmann
aa89c5e048 🔨 removing unget_character() function from input adapters #834 2018-04-02 21:10:48 +02:00
Niels Lohmann
6678eb2b4a improved test coverage #1031 2018-04-02 15:38:49 +02:00
Niels Lohmann
16c5bfeaad 👌 fixed compiler warnings #1031 2018-04-02 13:01:56 +02:00
Niels Lohmann
727dd4664b 🔨 trying to make tests run with MSVC #1031 2018-04-02 12:27:07 +02:00
Niels Lohmann
ab89ae4e50 🔨 trying to make tests run with MSVC #1031 2018-04-02 11:34:36 +02:00
Niels Lohmann
eb06d0531a 🚧 added input adapter for wide strings #1031 2018-04-01 19:12:36 +02:00
Niels Lohmann
ba6edd5634 🔨 cleanup 2018-03-30 00:38:18 +02:00
Niels Lohmann
850671b9f1 🔨 using a vector<bool> for the parser hierarchy 2018-03-29 18:45:43 +02:00
Niels Lohmann
4efa8cdb4c 💚 fixed Valgrind options #1030 2018-03-29 17:19:21 +02:00
Niels Lohmann
830c93fd09 📝 fixed example for operator> #1029 2018-03-29 17:07:55 +02:00
Guillaume Racicot
c78dbc366c Added test for conversion to string_view 2018-03-29 01:03:57 -04:00
Guillaume Racicot
53d8d57921 Amalgamate single include 2018-03-29 01:03:36 -04:00
Niels Lohmann
5f723bbec6 🔨 realized callback parser wirh SAX interface #971 2018-03-28 23:39:39 +02:00
Niels Lohmann
896a9db461 🔨 improved code #1021 2018-03-28 19:37:21 +02:00
Kevin Tonon
73cc5089e3 Using target_compile_features to specify C++ 11 standard 2018-03-28 13:11:49 -04:00
Niels Lohmann
a9baab76c2 🚑 fix for #1021 2018-03-28 18:20:55 +02:00
Niels Lohmann
4f6b2b6429 🔨 changed SAX interface 2018-03-21 20:12:06 +01:00
Niels Lohmann
2537677e4c improved test coverage 2018-03-20 23:40:01 +01:00
Niels Lohmann
9e1abb4842 improved coverage 2018-03-20 22:39:08 +01:00
Niels Lohmann
1e38ffc014 more tests 2018-03-20 20:04:11 +01:00
Niels Lohmann
25f56ff207 📝 updated documentation 2018-03-20 19:22:18 +01:00
Niels Lohmann
99ecca55c4 improved test coverage 2018-03-20 18:49:10 +01:00
Niels Lohmann
9e07e9b4ec implemented non-throwing binary reader 2018-03-19 22:48:13 +01:00
Niels Lohmann
a271ee5f16 ♻️ proper use of SAX parser for binary formats 2018-03-18 23:00:45 +01:00
Niels Lohmann
943d641054 🔨 some refactoring 2018-03-18 16:07:21 +01:00
Niels Lohmann
22929fe189 🚧 started a SAX/DOM/callback parser 2018-03-18 15:13:53 +01:00
Niels Lohmann
375b05a17d 🔨 cleanup 2018-03-17 23:31:18 +01:00
Niels Lohmann
606a25195f improved test coverage 2018-03-17 19:15:59 +01:00
Niels Lohmann
c87ffad45c ♻️ implemented a non-recursive parser 2018-03-17 14:46:50 +01:00
Guillaume Racicot
2a5506ed98 Amalgamated headers 2018-03-16 13:16:10 -04:00
Guillaume Racicot
8165707990 basic_json now supports getting many type of strings 2018-03-15 15:35:00 -04:00
Niels Lohmann
27cf05af8d Merge branch 'develop' into feature/sax2 2018-03-14 22:02:19 +01:00
Niels Lohmann
d2dd27dc3b Merge branch 'release/3.1.2' into develop 2018-03-14 21:48:03 +01:00
Niels Lohmann
8a6c8cb0f7 🔖 set version to 3.1.2 2018-03-14 21:32:03 +01:00
Niels Lohmann
afef474c0d 🔖 set version to 3.1.2 2018-03-14 21:09:27 +01:00
Niels Lohmann
a52e8355b8 oops 2018-03-14 17:32:48 +01:00
Niels Lohmann
21410d50af 🏁 moved /Wall to CMake 2018-03-14 17:21:31 +01:00
Niels Lohmann
829ed74d66 🏁 experimenting with /Wall 2018-03-14 07:38:22 +01:00
Niels Lohmann
1262d474eb 🏁 fixed an MSVC warning 2018-03-14 07:32:28 +01:00
Niels Lohmann
282bafae4f 🔨 fixed compilation error 2018-03-14 07:18:42 +01:00
Niels Lohmann
abac6a0e84 Merge branch 'develop' into feature/sax2 2018-03-13 23:58:17 +01:00
Niels Lohmann
919d1fef8f Merge pull request #1009 from nlohmann/user_string_parser
Allowing for user-defined string type in lexer/parser
2018-03-13 14:52:59 +01:00
Niels Lohmann
8557151d90 ♻️ adjusting lexer/parser in symmetry to #1006 2018-03-12 19:15:11 +01:00
Niels Lohmann
b56ac86471 📝 thanks for #1006 2018-03-12 18:44:19 +01:00
Niels Lohmann
0cab3b2c8e Merge pull request #1006 from agrianius/dump-template
dump to alternative string type, as defined in basic_json template
2018-03-12 18:41:59 +01:00
Niels Lohmann
3d4f6a2940 🔨 cleaner exception interface 2018-03-11 22:47:25 +01:00
Niels Lohmann
ad47b0fbde ♻️ refactored binary readers to use a SAX parser 2018-03-11 18:47:38 +01:00
Vitaliy Manushkin
392c033805 test refactoring 2018-03-11 00:29:04 +03:00
Vitaliy Manushkin
51349537fc add unit test: checking dump to alternative string type 2018-03-10 23:59:10 +03:00
Vitaliy Manushkin
830f3e5290 forward alternative string class from output_adapter to output_string_adapter 2018-03-10 23:58:16 +03:00
Vitaliy Manushkin
ed6b1464f9 dump to alternate implementation of string, as defined in basic_json template (changes to amalgamated code) 2018-03-10 17:36:51 +03:00
Vitaliy Manushkin
faccc37d0d dump to alternate implementation of string, as defined in basic_json template 2018-03-10 17:19:28 +03:00
Niels Lohmann
149d2fd09c 💚 improved test coverage 2018-03-10 11:24:00 +01:00
Niels Lohmann
6399cd3039 Merge branch 'develop' into feature/sax2 2018-03-10 11:07:36 +01:00
Niels Lohmann
6151dfaed7 👌 made changes proposed in #1001 2018-03-10 11:02:58 +01:00
Niels Lohmann
35e43df625 Merge branch 'develop' into feature/sax2 2018-03-09 21:56:30 +01:00
Niels Lohmann
9918523077 📝 cleanup after #1001 2018-03-09 21:31:46 +01:00
Niels Lohmann
e737de8941 Merge pull request #1001 from nlohmann/leak
Fix memory leak during parser callback
2018-03-09 21:23:00 +01:00
Niels Lohmann
aa8fc2a41c 🚑 hopefully fixed the memory leak 2018-03-08 17:11:15 +01:00
Niels Lohmann
7c1a788893 Merge branch 'develop' into feature/sax2 2018-03-08 07:39:37 +01:00
Niels Lohmann
cf60e18c89 🔥 removing failing test (work on this in branch "leak") 2018-03-08 07:39:21 +01:00
Niels Lohmann
97559bb1b2 🔨 trying to fix the leak
Part 1: properly use forwarding
2018-03-08 07:36:56 +01:00
Niels Lohmann
38345fd06c 👌 fixed some more warnings 2018-03-07 22:51:22 +01:00
Niels Lohmann
8b379948d0 🔥 replaced acceptor with SAX parser 2018-03-07 22:40:48 +01:00
Niels Lohmann
303a0c5843 Merge branch 'develop' into feature/sax2 2018-03-07 22:26:01 +01:00
Niels Lohmann
d183d34b96 💚 added another test case 2018-03-07 22:25:25 +01:00
Niels Lohmann
d2d65bb25b ♻️ refined SFINAE to fix some warnings 2018-03-07 22:01:44 +01:00
Niels Lohmann
476b2e09be 💚 added regression tests for #972 and #977 2018-03-06 20:13:31 +01:00
Niels Lohmann
62030615a0 Merge pull request #986 from theodelrieu/fix/basic_json_conversion
Fix/basic json conversion
2018-03-06 19:27:39 +01:00
Niels Lohmann
5beab80553 🔨 using the SAX-DOM parser 2018-03-06 18:17:07 +01:00
Niels Lohmann
faf2546a15 🔨 simplified SAX-DOM parser 2018-03-06 07:19:05 +01:00
Niels Lohmann
5b9d03cfdb 🔨 added SAX-DOM-Parser 2018-03-05 21:06:00 +01:00
Niels Lohmann
9d27429527 🔨 added error messages to SAX interface 2018-03-05 16:46:35 +01:00
Niels Lohmann
86991d5204 Merge branch 'develop' into feature/sax2 2018-03-05 16:16:43 +01:00
Niels Lohmann
fdecbf6e1e Merge pull request #992 from bogemic/pvs_studio_fix_misprinted_condition
fixed misprinted condition detected by PVS Studio.
2018-03-05 15:57:57 +01:00
Mike Bogdanov
fd30ad8a14 did make amalgamate 2018-03-02 11:47:35 +03:00
Mike Bogdanov
2a2ed799b1 pvs_studio fix. misprinted condition 2018-03-02 11:12:44 +03:00
Niels Lohmann
8d104e6fe3 💚 fixed test case 2018-02-28 22:40:48 +01:00
Niels Lohmann
5773e164bb 🚨 fixed a linter warning 2018-02-28 19:59:54 +01:00
Théo DELRIEU
8711ec6034 support construction from other basic_json types
Before this patch, `basic_json` types with different template arguments
were treated as `CompatibleArrayType`. Which sometimes leads to recursive
calls and stack overflows.

This patch adds a constructor and a `get` overload to deal with
different `basic_json` types.
2018-02-27 16:48:09 +01:00
Théo DELRIEU
c22f2d41f3 missing CHECK_NOTHROW in unit-udt 2018-02-27 11:09:53 +01:00
Niels Lohmann
3ff9455332 🔨 added a SAX-DOM-Parser 2018-02-26 23:39:23 +01:00
Niels Lohmann
21352c4d8e ♻️ refactored SAX parser 2018-02-26 20:08:12 +01:00
Niels Lohmann
981e226ca2 Merge branch 'develop' into feature/sax2 2018-02-26 20:07:52 +01:00
Niels Lohmann
1f3d2a3be7 📝 overworked README 2018-02-26 17:37:24 +01:00
Niels Lohmann
13ca723c38 Merge pull request #981 from wla80/develop
Make integration section concise
2018-02-26 16:51:51 +01:00
Wilson
05d3bf1699 Make integration section concise 2018-02-25 22:12:44 -08:00
Niels Lohmann
8d6b3d44d6 👌 fixed some compiler warnings 2018-02-25 18:35:16 +01:00
Niels Lohmann
8c7f46f7d0 🔨 removed a logic error and improved coverage 2018-02-25 17:10:30 +01:00
Niels Lohmann
922f7a3d0e added more tests for SAX parsing 2018-02-25 14:21:30 +01:00
Niels Lohmann
ac230e8b4b 🔨 fixed test cases to be more robust 2018-02-25 10:44:47 +01:00
Niels Lohmann
374ebacc51 added a SAX parser #971 2018-02-24 18:04:07 +01:00
Niels Lohmann
8968adcd53 Merge branch 'release/3.1.1' into develop 2018-02-13 19:36:35 +01:00
Niels Lohmann
8424d10e45 🔖 set version to 3.1.1 2018-02-13 15:59:32 +01:00
Niels Lohmann
938c861a09 🔖 set version to 3.1.1 2018-02-12 22:59:36 +01:00
Niels Lohmann
94b7a8da66 💄 fixed indentation 2018-02-12 20:46:14 +01:00
Niels Lohmann
20b5f4d89c Merge pull request #969 from theodelrieu/fix/924
Fix constraints on from_json(CompatibleArrayType)
2018-02-12 18:17:59 +01:00
Théo DELRIEU
01d6118828 Fix constraints on from_json(CompatibleArrayType)
Fixes #924
2018-02-12 15:37:33 +01:00
Niels Lohmann
b02e3bb0b6 Merge pull request #957 from theodelrieu/fix_coveralls
Make coveralls watch the include folder
2018-02-12 15:02:21 +01:00
Théo DELRIEU
41db7cd818 Make the coveralls job use the multiple header version 2018-02-12 10:23:33 +01:00
Niels Lohmann
447f5421eb 🔨 overworked release target 2018-02-11 16:50:01 +01:00
Niels Lohmann
61f0bfb15c 🔨 enforce using Python 2 for the wandbox script 2018-02-11 14:46:15 +01:00
Niels Lohmann
548f488941 🔨 overworked Makefile 2018-02-10 14:46:39 +01:00
Niels Lohmann
865ff00de0 📝 updated documentation wrt. objects #963 2018-02-09 23:37:20 +01:00
Niels Lohmann
addbbbe136 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2018-02-09 23:32:37 +01:00
Niels Lohmann
0a64982e86 📝 cleanup after #954 2018-02-09 23:32:28 +01:00
Niels Lohmann
e5d538c5ea Merge pull request #954 from pfultz2/patch-1
Add a note about installing the library with cget
2018-02-09 23:28:54 +01:00
Niels Lohmann
2dda87c3b7 Merge branch 'feature/coverage_multi' into develop 2018-02-09 23:01:56 +01:00
Paul Fultz II
5731695d7b Clarify dev version and add space after the word flag. 2018-02-09 15:45:20 -06:00
Niels Lohmann
74675dd69c back to the original version 2018-02-09 22:40:52 +01:00
Paul Fultz II
50863c5a09 Latest updates based on feedback 2018-02-09 15:35:46 -06:00
Niels Lohmann
ab05df3a48 🔨 another try 2018-02-09 22:27:08 +01:00
Niels Lohmann
b455154cc9 🔨 another try 2018-02-09 22:18:51 +01:00
Niels Lohmann
1e8f4d6ab3 🔨 more trying 2018-02-09 22:11:05 +01:00
Niels Lohmann
316634e129 🔨 added quotes around parameters 2018-02-09 21:54:32 +01:00
Niels Lohmann
0111f3187e 🔨 working on #953 2018-02-09 21:30:15 +01:00
Niels Lohmann
83db7876c5 🏁 removing test case that fails on MSVC #962 2018-02-09 18:32:12 +01:00
Niels Lohmann
33a9b00ce6 🐛 fix for #962
Added out_of_range exception for UBJSON containers with sizes that exceed the target container's max_size.
2018-02-06 22:38:53 +01:00
Niels Lohmann
8b457ace25 🐛 fixing CBOR's indefinity length strings #961
Beside the fix discussed in #961, we also had to re-adjust a test case. It seems that it was failing before, and I "fixed" it to work with the broken implementation...
2018-02-06 20:43:03 +01:00
Niels Lohmann
556e30f759 Merge pull request #955 from patrikhuber/patch-1
Fix links in README.md
2018-02-06 20:18:14 +01:00
Patrik Huber
ee76436592 Change to angle brackets 2018-02-06 11:29:37 +00:00
Niels Lohmann
737cffe0cb 🔨 fixed directory for lcov coverage 2018-02-04 20:58:50 +01:00
Patrik Huber
ae688016f6 Changed links from master to develop branch 2018-02-04 12:41:46 +00:00
Niels Lohmann
2b7b39c72d 🚀 added release target #956 2018-02-04 13:29:23 +01:00
Patrik Huber
44b40d7c6a Fix links in README.md 2018-02-03 15:48:02 +00:00
Paul Fultz II
3402260983 Add a note about installing the library with cget 2018-02-02 11:13:13 -06:00
Niels Lohmann
3a887dc9fe 👷 fixed coveralls 2018-02-02 07:56:30 +01:00
Niels Lohmann
5c2a0a511e 👷 fixed coveralls 2018-02-02 07:31:57 +01:00
Niels Lohmann
b779666916 👷 re-added homebrew tests 2018-02-02 00:20:04 +01:00
Niels Lohmann
97309f0da9 Merge branch 'release/3.1.0' into develop 2018-02-02 00:06:17 +01:00
Niels Lohmann
a8fcfd9880 👷 fixed travis file 2018-02-01 22:34:14 +01:00
Niels Lohmann
f5c03999d0 🔨 fixed benchmark compilation 2018-02-01 22:26:26 +01:00
Niels Lohmann
0258484626 🔖 set version to 3.1.0
- updated documentation wrt. new repository layout
- temporarily switched off Homebrew --HEAD building (can only be switched on after release)
- set copyright date to 2018
2018-02-01 22:20:26 +01:00
Niels Lohmann
ce7d0ebf5d Merge pull request #944 from theodelrieu/fix/cmake_install
fix cmake install directory (for real this time)
2018-02-01 18:39:07 +01:00
Théo DELRIEU
14cd019861 fix cmake install directory (for real this time)
* Rename 'develop' folder to 'include/nlohmann'
* Rename 'src' folder to 'single_include/nlohmann'
* Use <nlohmann/*> headers in sources and tests
* Change amalgamate config file
2018-02-01 11:06:51 +01:00
Niels Lohmann
9958dde3da Merge pull request #950 from kaidokert/develop
Templatize std::string in binary_reader #941
2018-02-01 09:29:53 +01:00
Kaido
aed4a080bf Templatize std::string in binary_reader #941 2018-01-31 23:01:01 -08:00
Niels Lohmann
e8bf1f62f7 added define for library version #948 #943 2018-01-31 22:36:18 +01:00
Niels Lohmann
552d153842 📝 added more statistics on binary formats 2018-01-31 21:54:38 +01:00
Niels Lohmann
60e2d28eb7 🐛 fix for #947 2018-01-31 20:53:13 +01:00
Niels Lohmann
51c774f208 📝 added documentation for binary formats 2018-01-31 17:23:11 +01:00
Niels Lohmann
57e6fddd90 🚨 fixed warnings 2018-01-30 23:57:49 +01:00
Niels Lohmann
f7131715b1 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2018-01-30 23:20:39 +01:00
Niels Lohmann
ce273af9b6 📝 added documentation for binary formats 2018-01-30 23:20:36 +01:00
Niels Lohmann
ae235139b9 Merge pull request #940 from kaidokert/develop
Allow overriding THROW/CATCH/TRY macros with no-exceptions #938
2018-01-29 22:04:26 +01:00
Niels Lohmann
8049442c2a 🔨 rename yytext to token_buffer (fixes #933) 2018-01-29 21:56:13 +01:00
Kaido
d0c9e5fffc Allow overriding THROW/CATCH/TRY macros with no-exceptions (redo) #938 2018-01-28 14:42:13 -08:00
Niels Lohmann
b3bd3b726b 📝 added link to OSS-Fuzz project repository 2018-01-28 21:02:02 +01:00
Niels Lohmann
52e9449563 📝 added more functions to overview 2018-01-28 20:44:45 +01:00
Niels Lohmann
cb4a9c85cb 🔨 excluded code from coverage 2018-01-28 17:55:40 +01:00
Niels Lohmann
1483d39c91 🔨 moved class json_pointer into separate file #920 2018-01-28 15:36:56 +01:00
Niels Lohmann
e95578f884 📝 documented JSON Merge Patch (RFC 7386) 2018-01-28 14:36:17 +01:00
Niels Lohmann
102c474397 🔨 clean up 2018-01-28 14:13:02 +01:00
Niels Lohmann
6855bbb902 🔨 split "parsing" directory to "input" and "output" 2018-01-28 13:15:03 +01:00
Niels Lohmann
05f49fa401 added roundtrip tests for UBJSON 2018-01-27 18:47:32 +01:00
Niels Lohmann
f0b26c8f38 added fuzzer for UBJSON input 2018-01-27 18:38:11 +01:00
Niels Lohmann
b0a68f540f added roundtrip tests for UBJSON 2018-01-27 18:37:55 +01:00
Niels Lohmann
1be3935e9d 📝 cleanup after #936 2018-01-27 17:43:44 +01:00
Niels Lohmann
7aace7c976 Merge pull request #936 from zerodefect/improvement/fix_kmin_compiler_warning
Removed compiler warning about unused variable 'kMinExp'
2018-01-27 16:51:52 +01:00
Niels Lohmann
0e2211df0e Merge pull request #925 from zerodefect/improvement/improve_readme_json_fwd
Howto installation of json_fwd.hpp (fixes #923)
2018-01-25 17:11:21 +01:00
zerodefect
95cf1fefaa Removed compiler warning about unused variable 'kMinExp'. 2018-01-25 12:51:48 +00:00
Niels Lohmann
355c1e946b 👷 added task to check amalgamation #906
- Builds and runs test cases from individual sources rather than from amalgamation.
- Checks whether amalgamation would create the same single-header file as checked in.
2018-01-23 18:00:12 +01:00
Niels Lohmann
dbfd7e532b Merge branch 'develop' of https://github.com/nlohmann/json into develop 2018-01-23 16:33:10 +01:00
Niels Lohmann
3c68a796df 🔥 deprecated iterator_wrapper #874
Also fixed some warnings from GCC.
2018-01-23 16:33:08 +01:00
Niels Lohmann
f05c3edc21 Merge pull request #930 from Pipeliner/develop
Fix a typo in README.md
2018-01-23 07:32:23 +01:00
Niels Lohmann
f5c4e9f3a1 Merge pull request #919 from theodelrieu/fix/sfinae_for_incomplete_types
fix sfinae on basic_json UDT constructor
2018-01-23 07:32:06 +01:00
Niels Lohmann
7eabb6ba36 📝 updated documentation for UBJSON functions 2018-01-22 23:23:17 +01:00
Vadim Evard
fc32b8a9bc Fix a typo in README.md 2018-01-22 13:14:39 +03:00
Niels Lohmann
3cca630836 🔨 cleanup after #915 2018-01-21 15:55:35 +01:00
Niels Lohmann
010e596001 Merge pull request #915 from abolz/dtoa
Floating-point formatting
2018-01-21 15:02:57 +01:00
Niels Lohmann
3d776b0582 📝 updated README 2018-01-21 14:13:42 +01:00
Niels Lohmann
9e5d901f55 Merge branch 'feature/ubjson' into develop 2018-01-21 14:04:29 +01:00
Niels Lohmann
327b8bb09e Merge branch 'feature/strings' into develop 2018-01-21 13:55:52 +01:00
zerodefect
d2b3fd156e Updated README.md to explain how installation of json_fwd.hpp can be achieved as part of install step. 2018-01-19 11:42:53 +00:00
Niels Lohmann
b406e3704b using Google Benchmark #921 2018-01-18 22:00:32 +01:00
Niels Lohmann
a8f711a2f1 using Google Benchmark #921 2018-01-18 21:57:21 +01:00
Niels Lohmann
6402077ac2 Merge pull request #876 from nlohmann/feature/rfc7396
JSON Merge Patch (RFC 7396)
2018-01-18 06:49:31 +01:00
Théo DELRIEU
dcee778c1e fix sfinae on basic_json UDT constructor
Avoid compiler errors when performing SFINAE checks on basic_json
and incomplete types.
2018-01-17 12:17:38 +01:00
Niels Lohmann
7456f1d87b ♻️ re-used existing UTF-8 decoder to simplfy string serialization 2018-01-16 20:42:00 +01:00
Niels Lohmann
afe4571309 🔨 cleanup + some noexcept 2018-01-16 20:41:04 +01:00
Niels Lohmann
b182308eff 🔨 cleanup 2018-01-16 20:40:24 +01:00
abolz
9b9919d460 Use max_digits10 in dump_float for float->text->float round-trip 2018-01-15 21:26:03 +01:00
abolz
810f81bbd9 Regenerate src/json.hpp 2018-01-15 21:24:59 +01:00
abolz
787204f076 Add unit-tests for detail::to_chars 2018-01-15 21:13:17 +01:00
abolz
9f7c2c04c8 Use the Grisu2 algorithm for formatting 'float's and 'double's 2018-01-15 21:07:26 +01:00
abolz
332f352033 Add an implementation of the Grisu2 algorithm for binary to decimal floating-point conversion
This is an attempt to fix #360. The algorithm produces
decimal representations which are guaranteed to roundtrip
and in ~99.8% actually produces the shortest possible
representation. So this is a nice compromise between using
a precision of digits10 and max_digits10.

Note 1:

The implementation only works for IEEE single/double precision
numbers. So the old implementation is kept for compatibility
with non-IEEE implementations and 'long double'.

Note 2:

If number_float_t is 'float', not all serialized numbers can
be recovered using strtod (strtof works, though). (There is
exactly one such number and the result is off by 1 ulp.)
This can be avoided by changing the implementation (the fix
is trivial), but then the resulting decimal numbers are not
exactly short.
2018-01-15 21:07:26 +01:00
abolz
0695ac4001 Add tests for #360 2018-01-15 21:07:25 +01:00
abolz
68a9736738 Tests: Re-enable some round-trip tests 2018-01-15 21:07:25 +01:00
abolz
6e2e466c27 Tests: Don't rely on the format used for floating-point formatting 2018-01-15 21:07:25 +01:00
abolz
107c21a488 Tests: Exponents are formatted with a leading '+' sign 2018-01-15 21:07:25 +01:00
abolz
3ae82d91a2 Tests: Floating-point formatting uses lower case 'e' 2018-01-15 21:07:24 +01:00
Niels Lohmann
92f7295063 🔨 cleanup 2018-01-15 13:21:33 +01:00
Niels Lohmann
3ac674562f 🔨 clean up 2018-01-14 22:26:20 +01:00
Niels Lohmann
d9446b0e6e Merge pull request #911 from theodelrieu/fix/cmake_install
Fix/cmake install
2018-01-14 20:08:49 +01:00
Niels Lohmann
9d6b3731b9 improved test coverage 2018-01-14 20:07:38 +01:00
Niels Lohmann
06cddd371b 🔨 removed failing amalgamation test 2018-01-14 17:22:42 +01:00
Niels Lohmann
f85f4967fe improved test coverage 2018-01-14 17:22:06 +01:00
Niels Lohmann
6965ff00c8 Merge branch 'develop' into feature/ubjson 2018-01-14 13:58:06 +01:00
Niels Lohmann
411c16cbb2 📝 overworked documentation wrt. amalgamation #906 2018-01-14 13:08:28 +01:00
Niels Lohmann
fea5f3792b 📝 it's 2018 2018-01-14 10:41:59 +01:00
Niels Lohmann
541b46132d ♻️ adjusted code to split headers 2018-01-14 10:34:43 +01:00
Niels Lohmann
0e8f01a963 Merge branch 'develop' into feature/rfc7396 2018-01-14 10:28:09 +01:00
Niels Lohmann
c772c01a48 ♻️ refactored code to split headers 2018-01-14 10:27:30 +01:00
Niels Lohmann
1b54d4a5aa Merge branch 'develop' into feature/ubjson 2018-01-14 10:10:56 +01:00
Niels Lohmann
420dcf1f25 🚧 added check whether code is amalgamated 2018-01-14 10:10:23 +01:00
Théo DELRIEU
5775084ffc cmake: add option to use/install the non-amalgamated version 2018-01-13 13:07:03 +01:00
Théo DELRIEU
84bffd5d36 move amalgamate tool to third_party folder 2018-01-13 13:05:42 +01:00
Théo DELRIEU
922b56e492 cmake: add back trailing slash to NLOHMANN_JSON_SOURCE_DIR 2018-01-13 12:27:33 +01:00
Niels Lohmann
a66b2d20c6 🚨 removed linter warnings for Python code 2018-01-13 11:15:23 +01:00
Niels Lohmann
f4a55f26b0 added amalgamate Python script 2018-01-13 10:59:49 +01:00
Niels Lohmann
241eea0c0e 📝 documentation 2018-01-12 09:23:33 +01:00
Niels Lohmann
10bad9381d 🚧 added size benchmark for binary formats 2018-01-10 23:13:48 +01:00
Niels Lohmann
3a7585e738 added more tests 2018-01-10 22:47:07 +01:00
Niels Lohmann
31bfabc4c0 🔨 optimized input format 2018-01-10 16:14:43 +01:00
Niels Lohmann
965a70e38d 🔨 optimized output format 2018-01-10 11:22:19 +01:00
Niels Lohmann
85173f5627 🔨 some clean up 2018-01-10 10:18:31 +01:00
Niels Lohmann
ce53537ba2 replaces amalgamation tool
The tool used before created a lot of duplicates inside the generated amalgamation. The new tool is a single Python file which seems to do the same job.
2018-01-09 23:15:06 +01:00
Niels Lohmann
0a2920e0fd ♻️ reorganized code 2018-01-09 18:30:02 +01:00
Niels Lohmann
b67e00b9b5 Merge pull request #700 from theodelrieu/refactor/split_it
Refactor/split it
2018-01-09 07:57:01 +01:00
Niels Lohmann
fd04967676 🐛 fixed copy-paste error 2018-01-08 21:37:51 +01:00
Niels Lohmann
fb1154c237 🚧 debug 2018-01-08 21:26:41 +01:00
Niels Lohmann
97e0d20ce9 🚧 debug 2018-01-08 21:16:20 +01:00
Niels Lohmann
ebf28a26ee 🚧 another try 2018-01-08 20:49:02 +01:00
Théo DELRIEU
7e4ee23f40 add single_header CMake target 2018-01-08 20:09:43 +01:00
Théo DELRIEU
57d822b6e2 add missing includes, put back include comments 2018-01-08 20:09:41 +01:00
Théo DELRIEU
9cab30cfce add adl_serializer.hpp 2018-01-08 20:09:38 +01:00
Théo DELRIEU
8e9714fe3d add detail/json_ref.hpp 2018-01-08 20:09:35 +01:00
Théo DELRIEU
a3473fda6a add detail/serializer.hpp 2018-01-08 20:09:33 +01:00
Théo DELRIEU
c117515e31 add detail/parsing/binary_writer.hpp 2018-01-08 20:09:29 +01:00
Théo DELRIEU
d620f76f0d add detail/parsing/binary_reader.hpp 2018-01-08 20:09:27 +01:00
Théo DELRIEU
4dbb433a79 add detail/parsing/output_adapters.hpp 2018-01-08 20:09:24 +01:00
Théo DELRIEU
ae6f66048c add detail/iterators/json_reverse_iterator.hpp 2018-01-08 20:09:21 +01:00
Théo DELRIEU
5fc9ef2b90 add detail/iterators/iteration_proxy.hpp 2018-01-08 20:09:18 +01:00
Théo DELRIEU
bf06cf6c22 add detail/iterators/iter_impl.hpp 2018-01-08 20:09:15 +01:00
Théo DELRIEU
3e65a65290 add detail/iterators/internal_iterator.hpp 2018-01-08 20:09:13 +01:00
Théo DELRIEU
51ecc31db7 add detail/iterators/primitive_iterator.hpp 2018-01-08 20:09:10 +01:00
Théo DELRIEU
9ea25685a8 add detail/parsing/parser.hpp 2018-01-08 20:09:06 +01:00
Théo DELRIEU
3a0743db97 add detail/parsing/lexer.hpp 2018-01-08 20:09:04 +01:00
Théo DELRIEU
7ab3e8d7b3 add detail/parsing/input_adapters.hpp 2018-01-08 20:09:01 +01:00
Théo DELRIEU
21881606f2 add detail/conversions/to_json.hpp 2018-01-08 20:08:58 +01:00
Théo DELRIEU
e0c02c14f0 add detail/conversions/from_json.hpp 2018-01-08 20:08:55 +01:00
Théo DELRIEU
7056b375c4 add detail/value_t.hpp 2018-01-08 20:08:52 +01:00
Théo DELRIEU
8c555db970 add detail/exceptions.hpp 2018-01-08 20:08:50 +01:00
Théo DELRIEU
f364f5ac5a add detail/meta.hpp 2018-01-08 20:08:47 +01:00
Théo DELRIEU
d686713f91 add detail/macro_{un}scope.hpp 2018-01-08 20:08:44 +01:00
Théo DELRIEU
5bffc95773 add json_fwd.hpp 2018-01-08 20:08:38 +01:00
Niels Lohmann
3d7658da89 🚧 working on AppVeyor's errors 2018-01-08 19:48:18 +01:00
Niels Lohmann
126ce2e56c 🚧 further UBJSON 2018-01-08 18:54:17 +01:00
Niels Lohmann
c9938ea838 🚧 started UBJSON implementation 2018-01-07 22:09:12 +01:00
Niels Lohmann
15b6421d07 added UTF-8 decoder capability and stress test
As described in http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt; Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> - 2015-08-28 - CC BY 4.0
2018-01-05 23:26:22 +01:00
Niels Lohmann
78f8f837e6 added items() function #874 2018-01-05 18:34:10 +01:00
Niels Lohmann
96b40b27a5 📝 fixed Doxygen warnings
Apparently, using "\n" inside an alias is an error now, but "^^" basically means the same.
2018-01-05 18:33:42 +01:00
Niels Lohmann
337e9824ea Merge pull request #900 from Dobiasd/patch-1
fix link to the documentation of the emplace function
2018-01-04 17:11:18 +01:00
Tobias Hermann
ba2316372a fix link to the documentation of the emplace function 2018-01-03 11:06:32 +01:00
Niels Lohmann
ce1dccf347 Merge branch 'release/3.0.1' into develop 2017-12-29 20:24:49 +01:00
Niels Lohmann
92484f0caf 🔖 set version to 3.0.1 2017-12-29 18:31:13 +01:00
Niels Lohmann
ebc6849b71 added test for #894 2017-12-29 16:53:04 +01:00
Niels Lohmann
3c76ff353d 📝 updated docs after PRs 2017-12-29 16:52:09 +01:00
Niels Lohmann
d45183d426 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-12-28 13:52:26 +01:00
Niels Lohmann
3b3b6e8e69 🚑 fix for #894
- Implemented "copy" in terms of "add".
- Added check for JSON Pointer array indices to make sure the complete reference token was processed.
- Added test suite from https://github.com/json-patch/json-patch-tests
2017-12-28 13:52:23 +01:00
Niels Lohmann
f28fc2261a Merge pull request #858 from mattismyname/develop
🔧 Fix up a few more effc++ items
2017-12-28 12:13:19 +01:00
Matthew K. Gumbel
72bff90ed9 🔧 Fix up a few more effc++ items 2017-12-24 10:03:36 -08:00
Niels Lohmann
3113a52a7d 📝 added exception 403 to documentation of at (#888)
The at function throws json::out_of_range.403 when a nonexistent object key is provided (just like the usual at function). This was not documented and users could assume json::out_of_range.404 would be thrown instead.

- Updated documentation.
- Added example code.
2017-12-23 18:38:18 +01:00
Niels Lohmann
184e9c6aa7 Merge pull request #885 from TinyTinni/develop
Includes CTest module/adds BUILD_TESTING option
2017-12-23 11:09:46 +01:00
Matthias Möller
d1cda6888e includes CTest module resp. BUILD_TESTING option 2017-12-20 17:54:45 +01:00
Niels Lohmann
88ddb12afc 📝 fix for #883
- Adjusted table to user-defined exceptions. This was forgotten in the 3.0.0 update.
- Added update function to the table.
2017-12-18 19:46:53 +01:00
Niels Lohmann
e54b6ace94 Merge pull request #882 from erengy/fix-msvc-c4819
Fix MSVC warning C4819
2017-12-17 19:52:57 +01:00
Eren Okka
ab0e8b2f3a Fix MSVC warning C4819
Replaces a U+00A0 character with regular space, and fixes a typo.
2017-12-17 18:02:55 +03:00
Niels Lohmann
1ca6ec1dc0 Merge pull request #880 from nlohmann/coverity_scan
Merge branch 'develop' into coverity_scan
2017-12-17 11:24:40 +01:00
Niels Lohmann
1856f38c85 📝 removed paragraph on version 3.0.0 2017-12-17 11:22:35 +01:00
Niels Lohmann
afebb6a3bb Merge branch 'release/3.0.0' into develop 2017-12-17 11:04:53 +01:00
Niels Lohmann
106f9f5436 ⬆️ updated git-update-ghpages script 2017-12-17 10:20:30 +01:00
Niels Lohmann
9eb5e2c271 🔖 set version to 3.0.0 2017-12-17 08:40:19 +01:00
Niels Lohmann
9e3c4ad11f 🔖 set version to 3.0.0 2017-12-17 08:31:18 +01:00
Niels Lohmann
314e4e7699 📝 improved documentation for dump and iterator_wrapper 2017-12-16 23:58:10 +01:00
Niels Lohmann
9a51fb4da2 🚨 fixed some warnings 2017-12-16 22:19:30 +01:00
Niels Lohmann
7bf007f2bc Merge pull request #879 from nlohmann/feature/algorithms
 re-added tests for algorithms
2017-12-16 12:41:07 +01:00
Niels Lohmann
980795b644 ✏️ fixed typos 2017-12-16 12:37:44 +01:00
Niels Lohmann
f3bd755cab removing <iomanip> header 2017-12-16 12:37:25 +01:00
Niels Lohmann
4c871c58f8 re-added tests for algorithms 2017-12-16 11:16:34 +01:00
Niels Lohmann
c23f5dcea6 📝 fixed year 2017-12-15 23:49:37 +01:00
Niels Lohmann
2e1b1061cd Merge pull request #875 from nlohmann/feature/spelling
Overworked library toward 3.0.0 release
2017-12-14 22:31:19 +01:00
Niels Lohmann
261caec2de 👥 added contributor image 2017-12-14 22:29:39 +01:00
Niels Lohmann
f80827d068 Merge pull request #873 from nlohmann/feature/issue872
🚨 remove C4996 warnings #872
2017-12-14 09:35:48 +01:00
Niels Lohmann
9a70c60fa5 Revert "⬆️ updated to Catch 2.0.1"
This reverts commit 920f64c01c.
2017-12-14 07:49:16 +01:00
Niels Lohmann
fb8482db76 👌 fixed some issues from the last commit #875 2017-12-13 23:44:53 +01:00
Niels Lohmann
c6e7eae394 implemented JSON Merge Patch (RFC 7396)
SQLite's json1 extension (https://www.sqlite.org/json1.html) supports JSON Merge Patch (https://tools.ietf.org/html/rfc7396). As the implementation is trivial and we already support JSON Patch, I think this could be a nice extension to the library.
2017-12-13 23:36:22 +01:00
Niels Lohmann
920f64c01c ⬆️ updated to Catch 2.0.1
Update required all CHECK_THROWS_AS macros to pass the exception type without reference, because this is now done by Catch2.
2017-12-13 22:18:05 +01:00
Niels Lohmann
293748a9a9 📝 overworked README
- Added recent contributors to thanks list.
- Linked PGP key for private mails.
- Updated compiler list.
2017-12-13 22:17:02 +01:00
Niels Lohmann
e8d9963abe 👌 cosmetic changes and overworked spelling
- All hex literals use upper case letters after the x.
- Fixed sime typos.
- Documented some more functions.
2017-12-13 22:15:53 +01:00
Niels Lohmann
a9a4ff61c6 🚨 remove C4996 warnings #872
These were the remaining direct calls to alloc.
2017-12-13 17:01:39 +01:00
Niels Lohmann
f7ae143a93 Merge pull request #870 from nlohmann/feature/issue838
💥 throwing an exception in case dump encounters a non-UTF-8 string #838
2017-12-13 06:34:11 +01:00
Niels Lohmann
8419bfbbd2 improved test coverage
As we guarantee proper UTF-8 before, we do not need to cope with it later.
2017-12-12 20:44:57 +01:00
Niels Lohmann
569d275f65 💥 throwing an exception in case dump encounters a non-UTF-8 string #838
We had a lot of issues with failing roundtrips (i.e., parse errors from serializations) in case string were stored in the library that were not UTF-8 encoded. This PR adds an exception in this case.
2017-12-11 22:38:05 +01:00
Niels Lohmann
383743c6c0 Merge pull request #868 from nlohmann/feature/issue867
📝 fixing documentation #867
2017-12-11 08:55:26 +01:00
Niels Lohmann
7de009edd1 ✏️ fixing typos #869 2017-12-10 13:07:47 +01:00
Niels Lohmann
772bb3cc20 📝 fixing documentation #867
The example in the documentation on how to "force" an array of arrays was wrong since the first release. Fixed the documentation and added checks for the README unit tests.
2017-12-10 12:32:20 +01:00
Niels Lohmann
0693945230 Merge pull request #860 from bogemic/std_iterator_conformance_cpp17
iter_impl template conformance with C++17
2017-12-08 07:55:47 +01:00
Mike Bogdanov
64d6daa76e iter_impl template conformance with C++17 2017-12-07 11:30:17 +03:00
Niels Lohmann
7c2d4f1852 👷 added Xcode 9.1 and 9.2 2017-12-06 22:32:03 +01:00
Niels Lohmann
9e2f185ac6 💄 reformatted code after PRs 2017-12-06 22:21:11 +01:00
Niels Lohmann
c5e731774a Merge pull request #856 from bogemic/std_allocator_conformance_cpp17
Std allocator conformance cpp17
2017-12-06 21:52:52 +01:00
Niels Lohmann
25d205c16d 📝 clarified difference between serialization and string value retrieval #853 2017-12-06 21:42:36 +01:00
Niels Lohmann
fa76f2efd7 Merge pull request #855 from theodelrieu/fix/cmake_include_directories
cmake: use BUILD_INTERFACE/INSTALL_INTERFACE
2017-12-06 20:47:38 +01:00
Mike Bogdanov
8890b935fd fixed merge conflicts 2017-12-06 12:24:50 +03:00
Mike Bogdanov
daba1b6a0b fixed conformance with C++17, some members of allocator are depricated and should be used via allocator_traits 2017-12-06 11:20:42 +03:00
Niels Lohmann
0e3a0b730b Merge pull request #854 from theodelrieu/fix/force_msvc_stacktrace
to/from_json: add a MSVC-specific static_assert to force a stacktrace
2017-12-05 19:36:31 +01:00
Théo DELRIEU
541ee62a05 cmake: use BUILD_INTERFACE/INSTALL_INTERFACE in target_include_directories 2017-12-05 11:27:03 +01:00
Théo DELRIEU
c9a02cbc59 to/from_json: add a MSVC-specific static_assert to force a stacktrace 2017-12-05 10:52:55 +01:00
Niels Lohmann
f4c01601fa Merge pull request #844 from TinyTinni/develop
Add .natvis for MSVC debug view
2017-12-04 21:43:22 +01:00
Matthias Möller
24fe572d98 missing new line 2017-11-30 13:37:58 +01:00
Matthias Möller
8e9a8792a9 moved natis to root dir 2017-11-30 13:26:45 +01:00
Matthias Möller
af775ddbb8 add compiler & cmake version check 2017-11-28 23:43:39 +01:00
Matthias Möller
48d7a32daa add .natvis for MSVC debug view 2017-11-26 10:31:33 +01:00
Matthias Möller
5b4855dea2 fix targetname 2017-11-26 10:29:51 +01:00
Niels Lohmann
cc937deaf6 🚑 the last commit contained a bug #821 2017-11-26 10:15:23 +01:00
Niels Lohmann
430f03512c 🚨 fixed some warnings #821 2017-11-25 22:06:18 +01:00
Niels Lohmann
ea5aed0769 Merge branch 'feature/to_array' into develop 2017-11-25 19:41:11 +01:00
Niels Lohmann
de75cf89f7 improved test coverage 2017-11-25 19:41:02 +01:00
Niels Lohmann
52ca35b2b0 Merge pull request #829 from jowr/patch-1
Updated hunter package links
2017-11-18 13:35:21 +01:00
Jorrit Wronski
7b8ddadd83 removed hunter badge 2017-11-16 21:01:27 +01:00
Jorrit Wronski
b5ddd99adf Updated hunter package links 2017-11-15 08:48:11 +01:00
Niels Lohmann
4c4f60f438 📝 fixes #820 2017-11-06 20:35:05 +01:00
Niels Lohmann
1af5601a2a Merge pull request #811 from Itja/patch-1
Typos README
2017-10-31 18:23:42 +01:00
Itja
e423aea64a Typos README
Hey, thanks for this great library which I've used in many occasions now. I know it's not much, but I wanted to contribute at least a tiny bit back to you by this PR :-) Keep up the good work!
2017-10-31 16:31:14 +01:00
Niels Lohmann
5696660eba 🔨 another try to fix #714
adding std::ios_base::binary when opening all_unicode.json.cbor
2017-10-31 15:04:14 +01:00
Niels Lohmann
c4d6626745 🚀 installed Request Info Bot 2017-10-30 16:04:34 +01:00
Niels Lohmann
6d2981db82 📝 overworked templates 2017-10-29 16:32:23 +01:00
Niels Lohmann
87df1d6708 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-10-29 11:55:04 +01:00
Niels Lohmann
fa1425b87c 🚀 installed Sentiment Bot 2017-10-29 11:54:53 +01:00
Niels Lohmann
73d0095154 Merge pull request #807 from theodelrieu/fix/805
add forwarding references to json_ref constructor
2017-10-28 15:33:22 +02:00
Théo DELRIEU
4b46abf97c add forwarding references to json_ref constructor
fixes #805
2017-10-28 14:22:57 +02:00
Niels Lohmann
8e067c0c3c 🔨 set bidirectional iterator tag #593 2017-10-28 09:41:35 +02:00
Niels Lohmann
cea3f24ff9 📝 comment to address #561 2017-10-27 16:39:52 +02:00
Niels Lohmann
61cc07ff38 📝 some documentation 2017-10-27 16:07:04 +02:00
Niels Lohmann
734e2b73cf 🔨 cleanup 2017-10-27 11:49:24 +02:00
Niels Lohmann
7820b5eccb 📝 thanks for #795 2017-10-27 11:49:17 +02:00
Niels Lohmann
77f8e2f987 Merge pull request #795 from jseward/develop
Add transparent comparator and perfect forwarding support to find() and count()
2017-10-27 11:47:23 +02:00
Niels Lohmann
c215b77936 🚀 installed Stale Bot 2017-10-25 11:37:33 +02:00
Jamie Seward
992c836b30 Add missing spaces 2017-10-24 00:14:25 -07:00
Jamie Seward
715c98b404 Remove extra spaces 2017-10-24 00:06:22 -07:00
Jamie Seward
6c9a401ebc Remove old non-perfect forwarding find and count 2017-10-24 00:01:56 -07:00
Jamie Seward
16ffdbcb20 Remove c++17 support flag in cmake
Already covered by AppVeyor
2017-10-23 23:50:06 -07:00
Jamie Seward
73b1629a15 Remove tabs for spaces 2017-10-23 23:45:39 -07:00
Niels Lohmann
1b1bd0e3e6 #714 is still not fixed 2017-10-23 12:01:50 +02:00
Jamie Seward
33c6511dd0 Remove JSON_HAS_STRING_VIEW
Instead implement @gregmarr's PR comments that perfect forwarding should be used. Also cleaned up cpp language standard detection.
2017-10-23 00:43:26 -07:00
Niels Lohmann
89650c99dd 🚧 checking if #714 is now fixed with MSVC
Hopefully, #764 fixed this.
2017-10-22 11:16:33 +02:00
Niels Lohmann
b0c380b0f8 📝 cleanup after the last PRs 2017-10-22 09:12:35 +02:00
Niels Lohmann
be4fba7baf Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-10-22 08:53:46 +02:00
Niels Lohmann
f193427e91 🔨 some simplifications 2017-10-22 08:53:43 +02:00
Niels Lohmann
24b6e028a9 improved test coverage 2017-10-22 08:53:27 +02:00
Niels Lohmann
3094640446 Merge pull request #764 from pjkundert/develop-simplify-istream
Simplified istream handing #367
2017-10-22 08:52:28 +02:00
Niels Lohmann
ef40673acb Merge branch 'develop' into develop-simplify-istream 2017-10-22 08:52:15 +02:00
Jamie Seward
d468f8c4e6 Use consistent logic to determine if string_view exists 2017-10-21 16:36:05 -07:00
Jamie Seward
59cde1ad6e Fix for _HAS_CXX17 == 0
Copied from solution to https://github.com/nlohmann/json/issues/464
2017-10-21 16:29:37 -07:00
Jamie Seward
1a66679929 Add string_view support
This avoids unnecessary string copies on often used
find().
2017-10-21 15:20:13 -07:00
Niels Lohmann
33df3250c3 Merge pull request #793 from sonulohani/develop
Error : 'identifier "size_t" is undefined' in linux
2017-10-21 10:58:27 +02:00
Sonu Lohani
92da334862 Error : 'identifier "size_t" is undefined' in linux 2017-10-21 12:52:44 +05:30
Niels Lohmann
2e281ba64b Merge pull request #788 from jseward/develop
Fix Visual Studio 2017 warnings
2017-10-18 15:04:24 +02:00
Jamie Seward
a99fcb4e7d Add comments and newline 2017-10-17 22:53:35 -07:00
Jamie Seward
917d9d8bc3 Fix Visual Studio 2017 warnings 2017-10-16 23:23:55 -07:00
Niels Lohmann
7c8f0a4186 Merge pull request #785 from jseward/develop
Fix warning C4706 on Visual Studio 2017 - fixes #784
2017-10-16 19:48:17 +02:00
Niels Lohmann
b27a142ec0 Merge pull request #783 from eld00d/patch-1
Set GENERATE_TAGFILE in Doxyfile
2017-10-16 17:54:28 +02:00
Perry Kundert
a8cc7a1bc8 Consistently use std::char_traits int_type-->char conversion intrinsics 2017-10-16 08:06:10 -07:00
Jamie Seward
af99090742 Disable warning C4389: '==': signed/unsigned mismatch
Lots of tests have this warning.

Also moved out of for loop, doesn't need to be done every loop.
2017-10-16 01:02:48 -07:00
Jamie Seward
8ba7f69ab4 Fix whitespace 2017-10-16 00:49:59 -07:00
Jamie Seward
8a4af820c7 Fix warning C4706 2017-10-16 00:41:58 -07:00
Jamie Seward
19f8f1c075 Add missing "u8"
This causes test-udt to crash due to bad iterator
2017-10-16 00:21:38 -07:00
Jamie Seward
5ec44fe9e3 Add /W4 for MSVS 2017-10-15 22:56:38 -07:00
Nate Vargas
727ee7d03e Set GENERATE_TAGFILE in Doxyfile
Allows documentation to be linked from other projects to https://nlohmann.github.io/json using Doxygen with the tag:
TAGFILES = $(SOME_PATH)/nlohmann_json.tag=https://nlohmann.github.io/json
2017-10-14 19:06:38 -05:00
Niels Lohmann
d300a8e268 🚨 fixed warnings #776 2017-10-13 08:46:29 +02:00
Perry Kundert
0b803d0a5f Simplify the json/src/benchmarks.cpp to allow more optimal code gen.
o For some unknown reason, the complexity of the benchmark platform
  prevented some C++ compilers from generating optimal code, properly
  reflective of the real performance in actual deployment.
o Added the json_benchmarks_simple target, which performs the same
  suite of tests as json_benchmarks.
o Simplified the benchmark platform, and emit an "Average" TPS
  (Transactions Per Second) value reflective of aggregate parse/output
  performance.
2017-10-07 15:50:19 -07:00
Perry Kundert
23440eb86e Remove outdated commentary about the value of eof(), retain input type
o We assume the same character int_type as the unerlying std::istream
o There are no assumptions on the value of eof(), other than that it
  will not be a valid unsigned char value.
o To retain performance, we do not allow swapping out the underlying
  std::streambuf during our use of the std::istream for parsing.
2017-10-06 12:54:43 -07:00
Perry Kundert
45e1e3d48a Revert some unnecessary member initializer changes. 2017-10-06 07:53:31 -07:00
Perry Kundert
5e480b56d8 Further simplify character type handling 2017-10-06 07:37:49 -07:00
Perry Kundert
1b43a45bec Implement correct handling of std::streambuf int_type, eof()
o Make no assumptions about eof(), other than that it is somewhere
  outside of the valid range of char_type.
2017-10-05 16:16:41 -07:00
Perry Kundert
184dab60e6 Accelerate access to underlying std::istream streambuf 2017-10-05 16:16:41 -07:00
Perry Kundert
f775922ca8 Specify initializers for yytest, token_string using initializer-lists
o We can retain -Weffc++ and specify default initializers by using
  initializer lists.  The risks are low (of additional non-conformat
  compilers), because there is already one other such initialization
  used in the code-base.
2017-10-05 16:16:41 -07:00
Perry Kundert
546e148b24 Further performance improvements, and corrections in get_token_string
o An (-'ve valued, typically -1) EOF must never be allowed in
  token_string, as it be converted to 255 -- a legitimate value.
o Comparing against a specific eof() (-1, typically) is more costly than
  detecting +'ve/-'ve.  Since EOF is the only non-positive value allowed
  we can use the simpler test.
o Removed unnecessary test for token_string size, as it is already
  tested in the method, and must never occur in correct code; used an
  assert instead.
2017-10-05 16:16:41 -07:00
Perry Kundert
8665e25942 Rename get_string to move_string to imply side-effect 2017-10-05 16:16:41 -07:00
Perry Kundert
e0d890cc23 Corrected unnnecessary const restriction on returned std::string 2017-10-05 16:16:41 -07:00
Perry Kundert
97a388802d Improve performance by constructing yytext as a std::string
o Return its contents when necessary.  In many cases, this avoids
  construction of multiple copies of the yytext token.  Exceeds
  performance of current develop branch.
2017-10-05 16:15:46 -07:00
Perry Kundert
7c523338c5 Remove unnnecessary NUL termination of yytext (as it may contain NULs) 2017-10-05 16:01:41 -07:00
Perry Kundert
14ca1f6f09 Restore istream performance #764
o Use std::streambuf I/O instead of std::istream; does not maintain
  (unused) istream flags.
o Further simplify get/unget handling.
o Restore original handling of NUL in input stream; ignored during
  token_string escaping.
2017-10-05 16:01:41 -07:00
Perry Kundert
12efeadc2e Further simplify istream handling; use native unget 2017-10-05 16:01:41 -07:00
Perry Kundert
f585fe4eec Test to confirm parsing of multiple JSON records in a istream #367 2017-10-05 16:01:41 -07:00
Perry Kundert
90adf6ec20 Simplify get_token_string, unnecessary buffering, handle Byte Order Mark 2017-10-05 16:01:41 -07:00
Niels Lohmann
0c0851dbea 📝 comment how to integrate tsl::ordered_map (#546) 2017-10-05 20:36:18 +02:00
Niels Lohmann
bab4a15748 📝 comment how to integrate fifo_map (#485) 2017-10-05 20:33:27 +02:00
Niels Lohmann
60439aff05 📝 different cmake call 2017-10-05 19:43:59 +02:00
Niels Lohmann
73d1b55aba 🔧 executing tests in parallel 2017-10-05 19:43:39 +02:00
Niels Lohmann
615366447a 🔧 removing -Weffc++ warnings 2017-10-05 19:43:19 +02:00
Niels Lohmann
73727c989c Merge branch 'feature/coveralls' into develop 2017-10-05 19:08:28 +02:00
Niels Lohmann
75f4678b96 🔨 added filter script for branch coverage 2017-10-05 19:08:15 +02:00
Niels Lohmann
c204ac82e0 🔨 adjusted Coverity script to work without Makefile 2017-10-05 07:13:59 +02:00
Niels Lohmann
7b82e4b4c8 🔨 added Makefile target to calculate lcov coverage 2017-10-05 00:17:09 +02:00
Niels Lohmann
1b3df3a63f 🔨 trying to use Coveralls with CMake #698 2017-10-04 22:18:21 +02:00
Niels Lohmann
99ee4c1eaf 🔨 cleaned up Makefiles and docs #698 2017-10-04 19:27:35 +02:00
Niels Lohmann
5cb6d7187d 🚨 fixing last warning in #755 2017-10-04 17:28:35 +02:00
Niels Lohmann
4e81c1db47 Merge pull request #765 from nlohmann/feature/issue698
using more CMake
2017-10-04 10:39:56 +02:00
Niels Lohmann
e2045eae53 🏁 and another try 2017-10-03 18:47:08 +02:00
Niels Lohmann
a85bc358f7 🏁 another try 2017-10-03 18:21:40 +02:00
Niels Lohmann
3457e7bc5b 🏁 try to get MSVC 2017 running again 2017-10-03 17:57:40 +02:00
Niels Lohmann
54bd1b5124 Merge branch 'develop' into feature/issue698 2017-10-03 17:23:05 +02:00
Niels Lohmann
7435d54e97 🔨 clean up 2017-10-02 23:06:41 +02:00
Niels Lohmann
4912231450 Merge branch 'develop' into feature/issue698 2017-10-02 18:25:25 +02:00
Niels Lohmann
b91805e1f0 🚨 removing a compiler warning #755 2017-10-02 18:11:36 +02:00
Niels Lohmann
f89f8b2d0b Merge branch 'develop' into feature/issue698 2017-10-02 17:47:53 +02:00
Niels Lohmann
8be303d4fb 🏁 fixing a min() call for MSVC #762 2017-10-02 13:54:14 +02:00
Niels Lohmann
1df836ce40 removed call to std::signbit #761 2017-10-01 15:48:29 +02:00
Niels Lohmann
8af49d4be5 🚨 removing compiler warnings #755 2017-09-30 11:00:26 +02:00
Niels Lohmann
1a66527dca 📝 fixed documentation #745 2017-09-30 10:18:18 +02:00
Niels Lohmann
b05ea3de55 Merge pull request #753 from gregmarr/patch-1
Add info for the vcpkg package.
2017-09-26 22:36:36 +02:00
gregmarr
ec60ff3451 Add info for the vcpkg package. 2017-09-26 08:39:38 -07:00
Niels Lohmann
647711fad1 improved test coverage 2017-09-14 17:31:28 +02:00
Niels Lohmann
737816d0cd 👷 another try with Travis 2017-09-14 17:31:14 +02:00
Niels Lohmann
e75adc21a5 Merge branch 'develop' into feature/issue698 2017-09-13 18:57:25 +02:00
Niels Lohmann
b90529c36d improved test coverage 2017-09-13 18:56:54 +02:00
Niels Lohmann
82c93680d1 Merge branch 'develop' into feature/issue698 2017-09-10 22:38:23 +02:00
Niels Lohmann
e2e0ecd867 improved test coverage 2017-09-10 22:38:04 +02:00
Niels Lohmann
248db1e423 Merge branch 'develop' into feature/issue698 2017-09-10 11:42:57 +02:00
Niels Lohmann
7410763731 improved test coverage 2017-09-10 11:42:43 +02:00
Niels Lohmann
cafc2d057a Merge branch 'develop' into feature/issue698 2017-09-10 10:22:10 +02:00
Niels Lohmann
da97cf7895 improved test coverage 2017-09-10 10:21:53 +02:00
Niels Lohmann
295d65ada7 Merge branch 'develop' into feature/issue698 2017-09-10 01:13:43 +02:00
Niels Lohmann
fcba9ec537 🔨 clean up 2017-09-10 01:12:03 +02:00
Niels Lohmann
41994ba028 Merge branch 'develop' into feature/issue698 2017-09-09 16:53:37 +02:00
Niels Lohmann
b21d7810fa improved test coverage 2017-09-09 16:53:27 +02:00
Niels Lohmann
c1d6478584 Merge branch 'develop' into feature/issue698 2017-09-09 13:07:40 +02:00
Niels Lohmann
9ae6796a38 improved test coverage 2017-09-09 13:07:10 +02:00
Niels Lohmann
31ce7e1e59 Merge branch 'develop' into feature/issue698 2017-09-09 11:05:20 +02:00
Niels Lohmann
fd250ae2b1 improved test coverage 2017-09-09 11:04:58 +02:00
Niels Lohmann
5c08b84dec back to previous MSVC 2017 2017-09-06 18:26:52 +02:00
Niels Lohmann
da14286abb 👷 try to use MSVC 2017 again 2017-09-06 18:13:35 +02:00
Niels Lohmann
c607b5c2ac 📝 improved documentation 2017-09-06 17:14:06 +02:00
Niels Lohmann
91e0032853 📝 improved documentation 2017-08-29 23:46:26 +02:00
Niels Lohmann
b41b13047c 👷 removed unneccessary test 2017-08-27 11:30:36 +02:00
Niels Lohmann
15e757c42b 🔨 trying to fix memory issue with valarray 2017-08-27 10:41:39 +02:00
Niels Lohmann
0e94ba8857 👷 using the same compilers 2017-08-26 08:56:34 +02:00
Niels Lohmann
4f5c345817 👷 run sanitizer another time to check if it works 2017-08-26 08:20:37 +02:00
Niels Lohmann
8608f42187 👷 trying to use libstdc++
https://github.com/travis-ci/apt-source-whitelist/issues/372#issuecomment-320547215
2017-08-25 22:49:18 +02:00
Niels Lohmann
5e7acbf05e 👷 adjusted flags for Clang sanitizer
we are overrding the CXXFLAGS provided by travis in order to use gcc's libstdc++
2017-08-25 22:34:00 +02:00
Niels Lohmann
268f5a3d0a 👷 added option to switch off exceptions 2017-08-25 21:29:27 +02:00
Niels Lohmann
839681ff9f 👷 using Ninja 2017-08-25 21:01:07 +02:00
Niels Lohmann
3dcd360139 👷 adding status messages 2017-08-25 20:19:58 +02:00
Niels Lohmann
05b97c473a 👷 added flags for Valgrind and Clang sanitizer 2017-08-25 20:12:21 +02:00
Niels Lohmann
c87b080cc5 👷 new cmake file for test cases 2017-08-25 18:06:22 +02:00
Niels Lohmann
5b71bf09a1 Merge pull request #708 from theodelrieu/fix/from_json_tuple_pair
fix from_json implementation for pair/tuple
2017-08-24 12:40:16 +02:00
Théo DELRIEU
bb1b4c934e fix from_json implementation for pair/tuple
Introduced by 6e4910d5c5

Fixes #707
2017-08-23 10:05:43 +02:00
Niels Lohmann
e45eaf6e30 Revert "👷 using libc++ with Clang"
This reverts commit 41b2c69bdb.
2017-08-23 08:39:19 +02:00
Niels Lohmann
0b5e8f859b 🔨 cleanup
Fixed some warning in Clion.
2017-08-23 00:42:15 +02:00
Niels Lohmann
9fd031b6f4 🐛 re-added support for std::valarray #702 2017-08-22 23:28:23 +02:00
Niels Lohmann
41b2c69bdb 👷 using libc++ with Clang 2017-08-22 22:04:38 +02:00
Niels Lohmann
cd53790993 👷 using Clang 5.0 2017-08-21 20:03:24 +02:00
Niels Lohmann
e569b9736b 👷 trying to fix build error
See http://help.appveyor.com/discussions/problems/7450-build-error-on-vs-2017-image-suddenly.
2017-08-21 17:31:14 +02:00
Niels Lohmann
ba5d37ba4b 👷 added Clang 5.0 (see https://docs.travis-ci.com/user/languages/cpp/#clang) 2017-08-21 17:27:35 +02:00
Niels Lohmann
64ef100ebf Revert "💥 changed iterators to andom_access_iterator #593"
This reverts commit c77a0be5f3.
2017-08-20 20:44:44 +02:00
Niels Lohmann
8acaf5bdbc 🚨 fixing two compiler warnings 2017-08-20 19:31:07 +02:00
Niels Lohmann
c77a0be5f3 💥 changed iterators to andom_access_iterator #593
This commit changes the iterator category to andom_access_iterator and allows offsets and subscript operators for object iterators.
2017-08-16 21:35:22 +02:00
Niels Lohmann
aba8b58492 🔨 approach to un-break the changes for #462 2017-08-16 20:11:05 +02:00
Niels Lohmann
22b59693f1 💥 CBOR/MessagePack input must end with EOF #505
The CBOR and MessagePack parsers now expect the input to be read until the end. Unless the new parameter "strict" is set to false (it is true by default), an exception is raised if the parser ends prematurely. This is a breaking change as the parsers ignored unread input so far.

Furthermore, the offset/startIndex paramter introduced in #462 was removed as this behavior can be mimicked with an iterator range. For instance, instead of calling "from_cbor(vec, 5);", you can write "from_cbor({vec.begin()+5, vec.end()});".
2017-08-16 14:48:23 +02:00
Niels Lohmann
1f31a5b808 ⬆️ Catch v1.9.7 2017-08-16 10:23:39 +02:00
Niels Lohmann
f5a53de845 👷 running sanitizer job in parallel 2017-08-16 09:21:20 +02:00
Niels Lohmann
21726d8d8f 👷 run sanitizer after tests 2017-08-16 08:11:02 +02:00
Niels Lohmann
df572aca79 👷 set sanitizer to clang4 2017-08-16 07:42:57 +02:00
Niels Lohmann
4391bf5615 Merge branch 'feature/update' into develop 2017-08-16 07:39:30 +02:00
Niels Lohmann
1e360bb32b 🔨 preparation for #505
Added a parameter to control whether parsing CBOR and MessagePack must completely consume the input.
2017-08-16 07:39:11 +02:00
Niels Lohmann
002410410f Merge branch 'develop' into feature/update 2017-08-15 21:42:58 +02:00
Niels Lohmann
72afe53fa0 📝 updated documentation for update() function #661 2017-08-15 21:42:50 +02:00
Niels Lohmann
76123fab76 📝 added note wrt. #667 2017-08-15 20:49:18 +02:00
Niels Lohmann
fdff42bc3d 👷 forgot to install Cmake on OSX 2017-08-15 20:30:01 +02:00
Niels Lohmann
039e2f03bc Merge branch 'develop' into feature/update 2017-08-15 19:54:22 +02:00
Niels Lohmann
7f4722a75d Merge branch 'feature/travis_clang' into develop 2017-08-15 19:52:47 +02:00
Niels Lohmann
08805f7f14 🔨 cleanup 2017-08-13 20:57:27 +02:00
Niels Lohmann
988077e046 Merge branch 'develop' into feature/travis_clang 2017-08-13 20:27:27 +02:00
Niels Lohmann
7d19aed567 🔨 cleanup 2017-08-13 19:02:58 +02:00
Niels Lohmann
569c00eb18 👷 changed c++17 to c++1z 2017-08-10 23:41:12 +02:00
Niels Lohmann
6151b056eb 🔨 cleanup 2017-08-10 23:40:30 +02:00
Niels Lohmann
bade3b3e6c 👷 cleanup 2017-08-10 21:17:40 +02:00
Niels Lohmann
76b195d7d1 👷 fix for coverity + clang-5.0 2017-08-10 20:54:59 +02:00
Niels Lohmann
cd34358e7c 👷 removing clang from source 2017-08-10 20:37:23 +02:00
Niels Lohmann
5eb9f5fd4f 👷 clang-3.4 2017-08-10 20:31:59 +02:00
Niels Lohmann
f49356e703 👷 clang-3.4 2017-08-10 20:26:49 +02:00
Niels Lohmann
e0f8eb1710 👷 clang-4.0 2017-08-10 20:21:41 +02:00
Niels Lohmann
6dc89e47fc 👷 clang-3.9 2017-08-10 20:16:35 +02:00
Niels Lohmann
8de710bbe7 👷 added source for gcc 2017-08-10 20:12:27 +02:00
Niels Lohmann
195d773bc5 👷 added gcc 2017-08-10 20:09:39 +02:00
Niels Lohmann
e7f2d2646a 👷 removed gcc 2017-08-10 20:06:47 +02:00
Niels Lohmann
6b20f6d1ef 👷 clang-3.8 2017-08-10 20:04:36 +02:00
Niels Lohmann
82cd8c8d02 👷 another try 2017-08-10 19:59:00 +02:00
Niels Lohmann
f256587c4f 👷 clang-3.4 2017-08-10 19:56:09 +02:00
Niels Lohmann
c06b5c5c10 👷 clang-3.5 2017-08-10 19:50:36 +02:00
Niels Lohmann
3283352db3 👷 using clang++ 2017-08-10 19:45:33 +02:00
Niels Lohmann
c20dd7522f 👷 another try 2017-08-10 19:40:09 +02:00
Niels Lohmann
94dfecd487 👷 removed g++ 2017-08-10 19:31:43 +02:00
Niels Lohmann
8963aae57d 👷 clang-3.6 2017-08-10 19:24:36 +02:00
Niels Lohmann
5aceb0e029 👷 clang-3.6 2017-08-10 19:23:55 +02:00
Niels Lohmann
e7a7e4f81f 👷 fixed compiler 2017-08-10 19:18:45 +02:00
Niels Lohmann
e333562633 👷 different source 2017-08-10 19:15:16 +02:00
Niels Lohmann
eb6de822bb 👷 clang-3.7 2017-08-10 19:12:04 +02:00
Niels Lohmann
c1642affaa 👷 clang-3.8 2017-08-10 19:03:35 +02:00
Niels Lohmann
a46afd4008 Merge pull request #679 from traits/patch-1
Digraph warning
2017-08-10 11:39:13 +02:00
traits
54c67dcfec Update json.hpp 2017-08-10 09:05:00 +02:00
Niels Lohmann
99ea12f304 📝 acknowledgements for #674, #678, #682, #685, and #686 2017-08-10 06:50:34 +02:00
Niels Lohmann
d26b3f1fe5 Merge pull request #686 from WebProdPP/patch-1
Update json.hpp
2017-08-10 06:44:59 +02:00
Niels Lohmann
345846b514 Merge pull request #685 from daixtrose/patch-1
Remove duplicate word
2017-08-09 15:32:33 +02:00
WebProdPP
c9509ccf97 Update json.hpp
mistake
2017-08-09 16:13:43 +03:00
Markus Werle
86b3d06a93 remove duplicate word
s/to to/to/
2017-08-09 11:56:48 +02:00
Niels Lohmann
6e5b895f87 Merge pull request #682 from kbthomp1/fix-intel-osx
To fix compilation issue for intel OSX compiler
2017-08-09 10:16:03 +02:00
Kyle Thompson
4b55f0ebd6 To fix compilation issue for intel OSX compiler
o To prevent the compilation issue on OSX with the intel compiler suite.  The
error was found with icpc version 15.0.3.187 where the "__clang_version__" was
not defined correctly, while "__clang__" was.
2017-08-08 18:43:03 -04:00
Niels Lohmann
c90bf5e0f1 👷 removed failing builders 2017-08-08 21:26:15 +02:00
Niels Lohmann
dd008545d1 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-08-08 19:15:49 +02:00
Niels Lohmann
054b0250be 👷 trying to install g++ to make clang work 2017-08-08 19:14:22 +02:00
traits
ab44a50d98 Digraph warning
The original version can trigger a digraph-related warning in VS2015. Is this namespace construct a typo or something deliberate?
2017-08-07 14:23:48 +02:00
Niels Lohmann
b32a6b8c75 Merge pull request #678 from DmitryKuk/develop
massage -> message
2017-08-05 13:42:43 +02:00
DmitryKuk
19437c15de massage -> message 2017-08-05 10:43:08 +03:00
Niels Lohmann
e523312fa2 improved test coverage 2017-08-03 17:47:42 +02:00
Niels Lohmann
d2c3592908 added test cases for update #661 2017-08-02 22:44:58 +02:00
Niels Lohmann
d1e13d5128 🎉 first draft for #661 2017-08-02 22:12:41 +02:00
Niels Lohmann
0ea0d7d860 Merge pull request #674 from wincent/patch-1
Fix "not constraint" grammar in docs
2017-08-01 20:21:04 +02:00
Niels Lohmann
efdfd3aa5b replaced by-value call #673 2017-08-01 19:37:25 +02:00
Greg Hurrell
391303521a Fix "not constraint" grammar in docs 2017-08-01 08:56:28 -07:00
Niels Lohmann
76ecb2bd60 Merge pull request #671 from dan-42/develop
Add documentation for integration with CMake and hunter
2017-08-01 07:15:55 +02:00
dan-42
db0b9732d4 DOC: add sort mentioning about support in hunter 2017-07-31 23:20:37 +02:00
Niels Lohmann
e60002a1b3 🔨 fixed GCC warnings in #663
https://github.com/nlohmann/json/pull/663#issuecomment-318931884
2017-07-31 23:17:14 +02:00
dan-42
966989a3f5 CONFIG: pin cmake to enable only C++ 2017-07-31 09:49:26 +02:00
Niels Lohmann
850d856aae 🔨 cleanup after #663 2017-07-30 20:30:05 +02:00
Niels Lohmann
3d67ec40a6 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-07-30 20:01:35 +02:00
Niels Lohmann
85c768084b 🔨 using emplace 2017-07-30 20:01:31 +02:00
Niels Lohmann
67fb517ccd Merge pull request #669 from dan-42/change_installed_cmake_include_path
REFACTOR: rewrite CMakeLists.txt for better inlcude and reuse
2017-07-30 20:01:03 +02:00
Niels Lohmann
80e95844f6 Merge pull request #663 from himikof/move-construction
Support moving from rvalues in std::initializer_list
2017-07-30 20:00:46 +02:00
Niels Lohmann
aad55219f8 Merge branch 'develop' into move-construction 2017-07-30 19:49:24 +02:00
Niels Lohmann
96dd4ffa19 🔨 simplified a call 2017-07-30 18:30:34 +02:00
Niels Lohmann
7737a29518 🔨 small parser performance improvements
- replaced list of pairs by flat list in next_byte_in_range
- implemented early exit in case of parse errors
- reused memory for object keys
- direct calls to embedded objects/arrays for insertions
2017-07-30 13:25:36 +02:00
dan-42
f434942371 REFACTOR: rewrite CMakeLists.txt for better inlcude and reuse
The rewrite uses more cmake build-in automatisms and build-in generates
variables to allow better generic reuse.
* cmake  files are installed to
``` <install_prefix>/lib/cmake/nlohmann_json/ ``` for best support on
most systems
* include path is set to ``` include ```  for usage as ``` #include
<nlohmann/json.hpp> ```
2017-07-29 11:59:09 +02:00
Niels Lohmann
c819a2d732 🔨 refactored some scanner internals 2017-07-28 19:18:50 +02:00
Niels Lohmann
5851daa576 binary formats can be stored in std::string, std::ofstreams or std::ostringstream #477 2017-07-28 00:21:55 +02:00
Niels Lohmann
c136b6f200 Merge pull request #666 from effolkronium/develop
enable_testing only if the JSON_BuildTests is ON
2017-07-27 20:48:56 +02:00
Niels Lohmann
7d51214045 implemented exception-free parser #458 #582
You can now pass a boolean "allow_exceptions" to the parse functions. If it is false, no exceptions are thrown in case of a parse error. Instead, parsing is stopped at the first error and a JSON value of type "discarded" (check with is_discarded()) is returned.
2017-07-27 20:33:11 +02:00
Ilya Polishchuk
a27dd3a6f6 enable_testing only if JSON_BuildTests is ON 2017-07-27 17:50:24 +03:00
Niels Lohmann
669ebf51bc 🔨 fixed an error in MSVC 2017-07-27 06:04:35 +02:00
Niels Lohmann
3d589fd032 🔨 fixed compilation error 2017-07-26 23:59:56 +02:00
Niels Lohmann
e6aa700360 🔨 cleanup 2017-07-26 23:44:55 +02:00
Nikita Ofitserov
93bb71232d Move from rvalues eagerly to work around MSVC problem
On MSVC compiler, temporaries that are constructed during a
list initialization, are sometimes destroyed even before calling
the initializing constructor, instead of at the end of the
containing full-expression. This is clearly non-conforming to
[class.temporary].
As the impact of this bug is silently producing incorrect
JSON values, move eagerly from rvalues to be safe.

See https://stackoverflow.com/questions/24586411
2017-07-25 12:17:32 +03:00
Nikita Ofitserov
897879bccb Make detail::json_ref do less work by deferring moves/copies 2017-07-24 12:29:06 +03:00
Nikita Ofitserov
0f4978e503 Fix an actually invalid test
C++ overload resolution/list initialization rules are hard.
2017-07-24 01:08:33 +03:00
Niels Lohmann
4414f94cd5 🔨 using input/output adapters for CBOR and MessagePack
- You can now pass a reference to a vector to the to_cbor and to_msgpack functions. The output will be written (appended) to the vector. #476

- You can now pass an output stream with uint8_t character type to the to_cbor and to_msgpack functions. #477

- You can now read from uint8_t */size in the to_cbor and to_msgpack functions. An input adapter will be created from this pair, so you need to use braces. #478
2017-07-23 23:02:24 +02:00
Nikita Ofitserov
f5cae64e52 Update tests while fixing possible UB
std::initializer_list does not own the temporaries created in
its initialization. Therefore, storing it in an independent
stack variable is unsafe.
2017-07-23 23:59:34 +03:00
Nikita Ofitserov
09cda57309 Support moving from rvalues in an std::initializer_list
This commit works around an issue in std::initializer_list design.
By using a detail::json_ref proxy with a mutable value inside,
rvalue-ness of an input to list initializer is remembered and
used later to move from the proxy instead of copying.
2017-07-23 23:57:17 +03:00
Nikita Ofitserov
cf3ca3b78c Optimize json construction from rvalue string_t/array_t/object_t 2017-07-23 23:50:59 +03:00
Nikita Ofitserov
7b3cbfff23 Add some tests for std::move from std::initializer_list 2017-07-23 23:47:15 +03:00
Niels Lohmann
9b1c058810 🔨 reorganized interfaces for parse/accept functions #623
We now rely on implicit conversions to an input_adapter object in the parse/accept functions.
2017-07-23 18:11:34 +02:00
Niels Lohmann
18e0430bfe 🔨 adding destroy function to discard values 2017-07-22 22:57:22 +02:00
Niels Lohmann
5b5f0090a1 🔨 trying to fix the sanitizer error
Travis found an error with Clang 3.8's sanitizers, see https://travis-ci.org/nlohmann/json/jobs/256366699. Unfortunately, I cannot reproduce this error with clang version 6.0.0 (trunk 308825) locally. However, this seems to be an issue, because so far, we did not reset a value after moving from it.
2017-07-22 16:41:42 +02:00
Niels Lohmann
d53ef95067 🔨 fixed some warnings 2017-07-22 15:33:31 +02:00
Niels Lohmann
c7a69ae03e started working on parser with provded result reference #418
Internally, the parser now writes its result into a JSON value provided as a reference. To be usable, the public interfaces need to be extended.
2017-07-22 15:18:38 +02:00
Niels Lohmann
f513c46749 🔨 further cleanup 2017-07-22 13:35:04 +02:00
Niels Lohmann
024fec8a9b 🔨 more cleanup using clang-tidy 2017-07-21 18:26:07 +02:00
Niels Lohmann
a09193e967 🔨 cleanup
- Replaced codepoint calculation by bit operations.
- Fixed several clang-tidy warnings.
2017-07-20 23:01:16 +02:00
Niels Lohmann
21d23982ca 🐛 fix for #656
A complete rewrite of the string escape function. It now provides codepoint-to-\uxxxx escaping. Invalid UTF-8 byte sequences are not escaped, but copied as-is. I haven’t spent much time optimizing the code - but the library now agrees with Python on every single Unicode character’s escaping (see file test/data/json_nlohmann_tests/all_unicode_ascii.json).

Other minor changes: replaced "size_t" by "std::size_t"
2017-07-17 07:53:02 +02:00
Niels Lohmann
8a9133c6b2 Merge pull request #652 from olegendo/develop
Rename BuildTests to JSON_BuildTests
2017-07-15 11:39:27 +02:00
Niels Lohmann
f1fabd1ba2 📄 added code of conduct
added Contributor Covenant Code of Conduct
2017-07-13 19:16:41 +02:00
Niels Lohmann
dad4916f9e Merge pull request #654 from ryanjmulder/develop
add ensure_ascii parameter to dump. #330
2017-07-12 07:58:45 +02:00
Ryan Mulder
486f3a2d16 restore necessary comman in documentation of dump 2017-07-11 14:18:02 -04:00
Ryan Mulder
40461c6c55 update comment on dump to not indicate that ensure_ascii is true by default 2017-07-11 13:59:07 -04:00
Ryan Mulder
71597be294 add ensure_ascii parameter to dump. #330 2017-07-11 13:48:08 -04:00
Oleg Endo
cd800522e4 Rename BuildTests to JSON_BuildTests
This avoids potential conflicts with other libraries when the library is
built from source and included in a bigger cmake build.
2017-07-11 22:57:49 +09:00
Niels Lohmann
7dee868a42 Merge pull request #643 from theodelrieu/refacto/split_basic_json
Refacto/split basic json
2017-07-09 23:12:35 +02:00
Théo DELRIEU
8585d35c92 move serializer outside of basic_json 2017-07-09 21:30:34 +02:00
Théo DELRIEU
acff23efb2 move binary_{reader,writer} outside of basic_json 2017-07-09 21:30:33 +02:00
Théo DELRIEU
bb752fd30c move json_reverse_iterator outside of basic_json 2017-07-09 21:30:33 +02:00
Théo DELRIEU
0ba98b6fe0 move internal_iterator/iter_impl/iteration_proxy outside of basic_json 2017-07-09 21:30:31 +02:00
Théo DELRIEU
00d6e27194 move primitive_iterator outside of basic_json 2017-07-09 21:22:16 +02:00
Théo DELRIEU
8e681d1e57 move lexer/parser outside of basic_json 2017-07-09 21:22:15 +02:00
Théo DELRIEU
15625ca4a7 move input adapters outside of basic_json 2017-07-09 21:21:12 +02:00
Théo DELRIEU
a332142194 move json_pointer outside of basic_json 2017-07-09 21:21:09 +02:00
Théo DELRIEU
fe086d7432 forward declare basic_json, add two macros
Those macros are used to reduce template argument boilerplate
2017-07-09 16:16:42 +02:00
Niels Lohmann
d3496347fc 👷 removing Clang 3.9 and 4.0
These versions are still not working properly: https://travis-ci.org/nlohmann/json/jobs/251675281
2017-07-09 12:19:14 +02:00
Niels Lohmann
504012a3db 📝 cleanup after #650
As <iostream> is not included in json.hpp any more, all code examples need to include <iostream> now.
2017-07-09 11:51:38 +02:00
Niels Lohmann
a0e0579374 Merge pull request #650 from olegendo/develop
Don't include <iostream>, use std::make_shared
2017-07-09 11:12:46 +02:00
Niels Lohmann
1b2fabe802 👷 adding two recent Clang versions
Maybe the simple approach is working now - at least it is in https://github.com/taocpp/PEGTL/blob/master/.travis.yml
2017-07-09 11:10:18 +02:00
Oleg Endo
e3bb156f82 fix typo 2017-07-09 15:20:28 +09:00
Oleg Endo
b753cb6ee7 use std::make_shared 2017-07-09 15:19:08 +09:00
Oleg Endo
f0ca96d462 include <iosfwd> instead of <iostream>
avoid bloat caused by <iostream> and std::cout and friends in apps where
iostream are not used.
2017-07-09 15:04:49 +09:00
Niels Lohmann
f1c543cb7b 👷 added GCC7 2017-07-08 22:59:19 +02:00
Niels Lohmann
7b05e1a687 🔨 improved performance in dump for deeply nested values 2017-07-08 22:59:04 +02:00
Niels Lohmann
f697fec522 📝 fixed documentation
There was an issue in the documentation example before. Unfortunately, I did not recreate the example outputs.
2017-07-08 22:16:45 +02:00
Niels Lohmann
87bccbc335 🔨 removed exception parse_error.111
It makes no sense to have this special exception. Instead of throwing when an input adapter is created, it is better to detect a parse error in later usage when an EOF is "read" unexpectedly.
2017-07-08 21:35:13 +02:00
Niels Lohmann
b38ecb5ca9 🔨 simplified binary write
Also added some comments and improved the documentation.
2017-07-08 20:31:13 +02:00
Niels Lohmann
b3ac36db93 🔨 excluded uncovered lines
These breaks were just added to silence a GCC warning - the GCC is right about warning as it cannot know that the expect function will not return in these two scenarios.
2017-07-08 18:34:08 +02:00
Niels Lohmann
e67df7c385 Merge branch 'feature/undo_171' into develop 2017-07-08 16:34:00 +02:00
Niels Lohmann
552622343e 📝 fixed typos 2017-07-08 16:18:27 +02:00
Niels Lohmann
566f6dcf30 🔥 removing usused functions #645
It seems these functions are not required any more. The code was added in commit 7e32457 to fix issue #171. There are still regression tests for #171, so when this commit passes the CI, the functions may be removed for good.
2017-07-08 13:33:13 +02:00
Niels Lohmann
6f12749ef6 📝 added version string for Xcode 9 2017-07-08 12:55:05 +02:00
Niels Lohmann
ac42333749 ⬆️ Catch v1.9.6 2017-07-08 12:11:45 +02:00
Niels Lohmann
015c88783e 🔨 fixed a pedantic warning 2017-07-08 12:03:12 +02:00
Niels Lohmann
df2feabb72 👷 added Xcode 9 beta
See https://twitter.com/travisci/status/880550780368855040
2017-07-08 11:57:09 +02:00
Niels Lohmann
63ecbfd36b re-added test
I have no idea why this test has been removed in the first place.
2017-07-07 23:38:04 +02:00
Niels Lohmann
07b78c993c 🐛 fixed undefined behavior bug
When an empty vector was passed to the parse function, an empty iterator range was used to construct an input iterator. Unfortunately, we then cannot use the start iterator to derive a pointer from.

Found with Xcode's undefined behavior sanitizer.
2017-07-07 23:37:16 +02:00
Niels Lohmann
8b123107c0 🔨 fixed some pedantic GCC warnings 2017-07-07 22:41:22 +02:00
Niels Lohmann
32065c8045 📝 fix for #639
Removed deprecated documentation of the comparison operator.
2017-07-07 21:16:33 +02:00
Niels Lohmann
e99b783def 🔨 simplifying scanner 2017-06-22 16:40:15 +02:00
Niels Lohmann
3dc5d95422 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-06-21 18:55:28 +02:00
Niels Lohmann
b9a8425cc8 📝 cleanup after #629 and #630 2017-06-21 18:55:25 +02:00
Niels Lohmann
5ee651c387 Merge pull request #630 from Chocobo1/doc_neq
fix typo in operator__notequal example
2017-06-21 18:54:18 +02:00
Niels Lohmann
dad6051f37 Merge pull request #629 from Chocobo1/c4819
Fix MSVC warning C4819
2017-06-21 18:54:03 +02:00
Niels Lohmann
4b5433578a added progress output for Unicode tests
Travis aborts tests if they do not produce output for 10 minutes. This commit shall fix this.
2017-06-21 18:50:11 +02:00
Chocobo1
0395f3fdfb fix typo 2017-06-21 21:41:34 +08:00
Chocobo1
66ffac9e8a Fix MSVC warning C4819
Replace unicode whitespaces by ASCII whitespace 0x20
2017-06-21 16:17:10 +08:00
Niels Lohmann
6f3bebff5c 🔨 removed unexpect function 2017-06-21 07:26:50 +02:00
Niels Lohmann
2fd214c14b 🔨 adjusted pedantic flags 2017-06-20 23:05:37 +02:00
Niels Lohmann
e7695306f1 🔨 fixed a warning 2017-06-20 22:58:02 +02:00
Niels Lohmann
84f2e64a7c improved coverage 2017-06-20 22:35:31 +02:00
Niels Lohmann
9add24ff10 🔨 fixed a warning 2017-06-20 22:20:41 +02:00
Niels Lohmann
2f007ca092 improved coverage 2017-06-20 22:03:36 +02:00
Niels Lohmann
a5c27ede32 🔨 fixed a warning 2017-06-20 21:39:36 +02:00
Niels Lohmann
7c2a187258 improved test coverage 2017-06-20 21:09:26 +02:00
Niels Lohmann
e191dd833f 🔨 fixed warning about pointer members 2017-06-20 21:09:05 +02:00
Niels Lohmann
82b95ca664 🔨 simplified error handling in parser 2017-06-20 20:14:18 +02:00
Niels Lohmann
f2cdb3d594 ⬆️ Catch v1.9.5 2017-06-20 20:13:56 +02:00
Niels Lohmann
c2044205ef 📝 updated used compilers 2017-06-20 16:12:14 +02:00
Niels Lohmann
c2db4a118d 👷 update Travis to use Ubuntu Trusty 14.04 images 2017-06-19 21:51:24 +02:00
Niels Lohmann
70b7455a13 🔨 minor change 2017-06-19 21:50:36 +02:00
Niels Lohmann
4e6f548c0b Merge pull request #624 from theodelrieu/feature/pair_tuple_conversions
add pair/tuple conversions
2017-06-19 17:31:10 +02:00
Théo DELRIEU
08d781058c add from_json support for std::array 2017-06-19 12:03:38 +02:00
Théo DELRIEU
6e4910d5c5 add pair/tuple conversions 2017-06-19 10:16:37 +02:00
Niels Lohmann
112a6f4e53 🔨 replaced lexer's error message by const char* 2017-06-18 13:03:14 +02:00
Niels Lohmann
747f7d36d1 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-06-18 00:00:36 +02:00
Niels Lohmann
b79a1a2678 📝 update after #626 2017-06-18 00:00:31 +02:00
Niels Lohmann
7b97100ffd Merge pull request #626 from koemeet/bugfix/vs2017-min-macro-fix
[BugFix] Add parentheses around std::min
2017-06-17 23:58:13 +02:00
Steffen Brem
04a1666ef2 Add parentheses around std::min so it bypasses the macro introduced by windows.h. 2017-06-17 22:01:18 +02:00
Niels Lohmann
1fbb82de89 🔨 using std::array to buffer input 2017-06-17 20:47:53 +02:00
Niels Lohmann
889006f006 regression test for #600 2017-06-17 13:37:04 +02:00
Niels Lohmann
e1ca484bc1 📝 added note about Conan #566 2017-06-17 11:20:09 +02:00
Niels Lohmann
b27d2adcbe accept functions to check if input is valid JSON #458 2017-06-16 19:23:55 +02:00
Niels Lohmann
d415293d41 Merge pull request #615 from theodelrieu/develop
remove std::pair support
2017-06-16 18:16:20 +02:00
Théo DELRIEU
c98364834f remove std::pair support 2017-06-13 11:11:29 +02:00
Niels Lohmann
fd4a0ecabc Merge branch 'feature/ifstream' into develop 2017-06-13 08:41:14 +02:00
Niels Lohmann
88dc7c11fa 🔨 fixed a warning 2017-06-12 19:58:44 +02:00
Niels Lohmann
afb959a083 🔨 removed nonportable code 2017-06-12 19:02:08 +02:00
Niels Lohmann
ac793e957f 🔨 trying to fix #367
Code from https://stackoverflow.com/a/44503794/266378 which is hopefully working with MSVC.
2017-06-12 18:58:58 +02:00
Niels Lohmann
5fa5c17bc6 ✏️ cleanup after #595 2017-06-10 18:29:16 +02:00
Niels Lohmann
6caad48e44 Merge pull request #595 from HenryRLee/iterator_arithmetic
Issue #593 Fix the arithmetic operators in the iterator and reverse iterator
2017-06-10 18:26:48 +02:00
HenryLee
e12c2ee6a8 Merge branch 'develop' into iterator_arithmetic 2017-06-09 20:47:42 +10:00
Niels Lohmann
52f934cbbf Merge pull request #609 from theodelrieu/develop
Add pair support, fix CompatibleObject conversions (fixes #600)
2017-06-07 16:38:23 +02:00
Théo DELRIEU
cea39dfaa8 fix #600
Instead of calling CompatibleObjectType iterator-range constructor,
first convert json::value_type to CompatibleObjectType::value_type
2017-06-07 10:24:59 +02:00
HenryLee
6661ec755b Merge branch 'develop' into iterator_arithmetic 2017-06-07 18:01:46 +10:00
HenryLee
0f065edff6 Revert a change in reverse iterator to pass the test cases 2017-06-07 18:01:01 +10:00
Niels Lohmann
92ef19696a ✏️ cleanup after #598 2017-06-06 20:48:11 +02:00
Niels Lohmann
bfdf0d1ce6 Merge pull request #598 from HenryRLee/issue550
#550 Fix iterator related compiling issues for Intel icc
2017-06-06 20:41:42 +02:00
Théo DELRIEU
85de93ba93 add std::pair<CompatibleStringType, T> support 2017-06-06 13:56:16 +02:00
HenryLee
c98169d0d5 Revert "Change iterator category to random access"
This reverts commit c4ab8f827e.
2017-06-05 21:59:17 +10:00
HenryLee
fb91aa81da Merge branch 'develop' into iterator_arithmetic 2017-06-05 20:24:21 +10:00
HenryLee
2ba554e442 Merge branch 'develop' into issue550 2017-06-05 20:24:08 +10:00
Niels Lohmann
1a9d76679a 🐛 fixed the issue with GCC7 #590 2017-06-04 18:40:32 +02:00
Niels Lohmann
d19c5ced4b 🐛 skipping BOM for iterators #602
I totally forgot about byte order marks in this scenario.
2017-06-02 12:38:32 +02:00
Niels Lohmann
c043ba6978 🔥 removed failing test #529 2017-06-01 07:32:39 +02:00
HenryLee
f2e1643039 Add test cases for iterator to const iterator assignment 2017-05-31 00:50:40 +10:00
HenryLee
2d5f0c0549 Redefine the converting assignment in iterator 2017-05-31 00:50:14 +10:00
HenryLee
c09a4cbbd7 Add test cases for iterator to const iterator conversion 2017-05-31 00:31:16 +10:00
HenryLee
0a51fb22ed Fix indentation 2017-05-30 23:37:24 +10:00
HenryLee
881cd3f420 Remove the iter_impl<const basic_json> copy constructor and copy assignment 2017-05-30 20:57:22 +10:00
HenryLee
790e7ca9e9 Add struct keyword in front of internal_iterator 2017-05-30 20:27:05 +10:00
HenryLee
ce39330ff8 Add converting constructors for iterator 2017-05-30 20:23:25 +10:00
HenryLee
c4ab8f827e Change iterator category to random access 2017-05-30 19:44:55 +10:00
HenryLee
daea213b44 Use static cast in the implementation of the operators of reverse iterator 2017-05-29 23:56:21 +10:00
HenryLee
0c2ed00ebe Add missing test cases for n + it arithmetic in iterators 2017-05-29 22:39:27 +10:00
HenryLee
5b245dae06 Comment out the exception message check in operator[] of reverse iterator 2017-05-29 22:19:10 +10:00
HenryLee
e42db27d6d Fix the indentation from the latest commit 2017-05-29 20:02:58 +10:00
HenryLee
3aef1a582e Change the definition of the operator override of reverse iterator to using the result of the base class directly 2017-05-29 19:45:34 +10:00
HenryLee
a3bf0131c4 Fix some more reverse iterator arithmetic test codes 2017-05-29 19:43:45 +10:00
HenryLee
adc73d6d5f Fix the arithmetic mistakes in reverse iterator 2017-05-29 18:52:53 +10:00
HenryLee
ed62129f8e Override n + iterator operator in the iterator 2017-05-27 13:44:14 +10:00
Niels Lohmann
52adf3fd5b 🔨 fixed compilation 2017-05-22 22:59:57 +02:00
Niels Lohmann
9a576fe1d9 added test for #367 2017-05-22 22:49:39 +02:00
Niels Lohmann
c7bd01edf2 🔨 trying something #367 2017-05-22 17:06:46 +02:00
Niels Lohmann
9e507dfad5 tests and fix for #367
operator>> now works as expected.
2017-05-21 16:36:51 +02:00
Niels Lohmann
16b63d3197 🔨 working toward #367 2017-05-20 12:44:13 +02:00
Niels Lohmann
8a35fdd8f5 🔨 overworked accept() function
Fixed to make sure no token is "overlooked".
2017-05-20 12:24:13 +02:00
Niels Lohmann
9ddc69f3a9 🐛 adjusting fix for future versions #586 2017-05-20 10:49:06 +02:00
Niels Lohmann
99cb095e89 🐛 fix for #586
Also added a Travis builder with -std=c++1z
2017-05-20 10:34:49 +02:00
Niels Lohmann
0f4131d138 Merge pull request #583 from zhaohuaxishi/doxygen_error
fix doxygen error of basic_json::get()
2017-05-15 21:09:43 +02:00
Niels Lohmann
0c3ffe12cd reverting first/second experiment #350 2017-05-15 21:07:58 +02:00
郭荣飞
b8dff3bc16 remove the redundant @ref command 2017-05-14 07:59:07 +08:00
Niels Lohmann
723c875604 💬 replaced "backspace" with "backslash" #509 2017-05-13 19:56:38 +02:00
郭荣飞
dfa371c436 fix doxygen error of basic_json::get() 2017-05-13 23:13:04 +08:00
Niels Lohmann
9b764ee5d6 🏁 fix for #581 2017-05-13 12:27:37 +02:00
Niels Lohmann
978255da8c 📝 updated contribution guidelines 2017-05-13 11:57:15 +02:00
Niels Lohmann
8b88e1b266 Merge pull request #579 from Type1J/develop_feature_first_second
Fixing assignement for iterator wrapper second, and adding unit test
2017-05-13 11:37:57 +02:00
Jay Sistar
b78457b792 Making comparison operators const. 2017-05-11 13:22:47 -04:00
Jay Sistar
00d841bfda Adding equal and not equal operators to proxys. 2017-05-11 14:51:06 +00:00
Jay Sistar
d6c78dacd8 Fixing assignement for iterator wrapper second, and adding unit test 2017-05-10 17:53:27 +00:00
Niels Lohmann
5beea35443 Merge pull request #578 from Type1J/develop_feature_first_second
Adding first and second properties to iteration_proxy_internal
2017-05-10 17:25:54 +02:00
Niels Lohmann
15ef9b8a35 Merge pull request #576 from Type1J/develop
Adding support for Meson.
2017-05-10 16:32:14 +02:00
Jay Sistar
6a656ed375 Adding first and second properties to iteration_proxy_internal 2017-05-10 13:20:52 +00:00
Niels Lohmann
2afbd33472 🔨 working on #367
Test cases succeed as expected, but the example in #367 is not fully
realized yet.
2017-05-10 12:06:24 +02:00
Jay Sistar
87744fd594 Missed one. 2017-05-09 02:04:02 +00:00
Jay Sistar
0719287e44 Reducing chatter about Meson. 2017-05-09 02:01:55 +00:00
Jay Sistar
31fe2f5825 Adding support for Meson. 2017-05-08 13:35:00 +00:00
Niels Lohmann
962da00171 implemented an indentation character #520
An optional parameter for dump() allows to set the character to use for
indentation (default: space). In case a JSON value is serialized to an
output stream, its fill character is used (and can be set with
std::setfill).
2017-05-07 19:27:40 +02:00
Niels Lohmann
fba1bcdd0b 🐛 fixing #575
I forgot to consider the offset.
2017-05-07 13:41:48 +02:00
Niels Lohmann
56ac7908f1 Merge branch 'feature/manual_lexer' into develop 2017-05-05 18:27:56 +02:00
Niels Lohmann
dbcb032f22 Merge branch 'develop' into feature/manual_lexer 2017-05-05 16:48:47 +02:00
Niels Lohmann
ecf895f2d1 📝 mentioned value function on main doc page #570 2017-05-05 16:42:22 +02:00
Niels Lohmann
19d2dec8b6 📝 added badge from isitmaintained.com 2017-05-03 22:49:21 +02:00
Niels Lohmann
8b9f51179e started working on #458
a simple acceptor function
2017-04-24 17:46:21 +02:00
Niels Lohmann
cfc2e8391c 🔨 removed too long running tests 2017-04-24 15:07:43 +02:00
Niels Lohmann
6d2c0a7928 added more Unicode test cases 2017-04-23 22:54:21 +02:00
Niels Lohmann
c42273d2a0 📝 fixed documentation #565
The documentation mismatched the actual code.
2017-04-23 21:46:30 +02:00
Niels Lohmann
2df8f12c09 🏁 another fix for MSVC #464
needed for VS2015.3 with /std:c++latest
2017-04-23 20:51:29 +02:00
Niels Lohmann
734297ff45 🔨 cleanup 2017-04-23 20:32:05 +02:00
Niels Lohmann
01e05d89e9 🔨 fixed a compiler warning
Default arguments are forbidden in lambdas.
2017-04-23 18:40:17 +02:00
Niels Lohmann
b686cc6ad9 🔨 removed #ifdefs 2017-04-23 18:34:14 +02:00
Niels Lohmann
5febd04a26 🐛 fixed test suite 2017-04-23 18:22:35 +02:00
Niels Lohmann
4aedae400e added exhaustive UTF-8 tests
Creates all well-formed sequences of bytes up to length 4. Furthermore,
creates ill-formed sequences by removing required trailing bytes or
changing bytes. As the tests can take a lot of time, preprocessor
symbols are introduced.
2017-04-23 15:12:50 +02:00
Niels Lohmann
e24df7eca9 📝 improved documentation 2017-04-23 15:10:40 +02:00
Niels Lohmann
2a21146160 Merge branch 'develop' into feature/manual_lexer 2017-04-22 11:35:58 +02:00
Niels Lohmann
4b316ec528 Merge branch 'feature/insert' into develop 2017-04-22 09:58:37 +02:00
Niels Lohmann
9b32f72584 📝 fixed examples for Wandbox
As I learned in https://github.com/melpon/wandbox/issues/209, this
library is already installed at Wandbox, so we need to adjust the
examples to use `#include "json.hpp"` insteas of `#include <json.hpp>`.
2017-04-21 22:07:07 +02:00
Niels Lohmann
db9bf953f3 🔨 improved diagnostic output 2017-04-15 10:40:10 +02:00
Niels Lohmann
717106eced 🔨 templated output_adapter and used in class serializer 2017-04-14 19:49:05 +02:00
Niels Lohmann
aea47422a2 📝 updated links and output 2017-04-14 18:13:01 +02:00
Niels Lohmann
6b6e554067 🐛 added missing header
std::setw needs the iomanip header (at least with GCC).
2017-04-14 17:37:28 +02:00
Niels Lohmann
951d0920fc 🐛 fixed README example
The example with the size() operator is bad: using operator[] already
changes the size of the object. The fix makes it clearer.
2017-04-14 17:36:45 +02:00
Niels Lohmann
e2f6cf7f46 🔥 removed .test files
These files were never meant to be versioned.
2017-04-14 17:35:31 +02:00
Niels Lohmann
2d2b98a50a Merge branch 'develop' into feature/manual_lexer 2017-04-12 18:07:25 +02:00
Niels Lohmann
d4469233ac Merge branch 'develop' into feature/insert 2017-04-12 18:01:06 +02:00
Niels Lohmann
42b4cdd4d0 👷 Travis is very picky 2017-04-11 22:13:26 +02:00
Niels Lohmann
ef55626296 👷 added Clang 3.9-5.0
Taken from
https://github.com/travis-ci/docs-travis-ci-com/pull/746/files.
2017-04-11 20:37:38 +02:00
Niels Lohmann
5bea6f383a ✏️ fixed a typo 2017-04-11 18:57:53 +02:00
Niels Lohmann
4c161161f0 Merge branch 'feature/vs2017' into develop 2017-04-10 19:51:58 +02:00
Niels Lohmann
d7e57e3b73 🔨 added an output adapter for the binary writer 2017-04-09 22:13:26 +02:00
Niels Lohmann
f3e43d7c6f 🔨 some cleanup 2017-04-09 21:14:51 +02:00
Niels Lohmann
186a9fd44d 🔨 simplified interface for parser, lexer, and binary_reader
These classes are now constructed with an interface adapter. This moves
complexity from various places into the interface adapter class, or to
some factories which now implement the different flavors of input.

Furthermore, input adapters are kept in std::shared_ptr to avoid the
need of manual deletion.
2017-04-09 19:28:15 +02:00
Niels Lohmann
e48114bbd6 🔨 check for value of _HAS_CXX17 2017-04-09 14:02:04 +02:00
Niels Lohmann
628be157a2 🐛 added fix for #464 2017-04-09 13:52:04 +02:00
Niels Lohmann
c40c8ac92e 👷 excluding MSVC 2015 with "/permissive- /std:c++latest /utf-8" 2017-04-09 12:00:30 +02:00
Niels Lohmann
a9f4094580 👷 another try 2017-04-09 11:47:31 +02:00
Niels Lohmann
180d249f6c 👷 another try 2017-04-09 11:38:42 +02:00
Niels Lohmann
d3d87674c8 👷 fixed AppVeyor syntax 2017-04-09 11:00:39 +02:00
Niels Lohmann
9d9c5216d7 👷 additional flags for MSVC #464
To test a fix for issue #464 (not yet implemented), we first need to
have  an MSVC build with “/permissive- /std:c++latest /utf-8”.
2017-04-09 10:59:45 +02:00
Niels Lohmann
6f99d5b2e9 🔨 fixed test case
One test case for CBOR and MessagePack assumed little endianess.
2017-04-08 23:39:17 +02:00
Niels Lohmann
d4e49873b7 👷 experimenting with configurations 2017-04-08 21:56:42 +02:00
Niels Lohmann
97a25de938 proposal for #428
This implementation forwards the iterators to std::map::insert.
2017-04-07 18:29:09 +02:00
Niels Lohmann
d62d48fc48 🔀 merge branch 'develop' into feature/manual_lexer 2017-04-07 17:19:52 +02:00
Niels Lohmann
90273e930c 🐛 fix for #512
We totally forgot to implement the comparison operators other than ==
and != for scalar types. Consequently, comparing a JSON value with a
scalar type led to compile errors.
2017-04-07 15:44:41 +02:00
Niels Lohmann
ff72f38863 🔨 fixed another warning
Do not store eof() in a char buffer…
2017-04-06 19:54:08 +02:00
Niels Lohmann
b992acc2e7 🔨 fixed a compiler warning 2017-04-05 20:39:27 +02:00
Niels Lohmann
08fdfcca9a 🔨 implemented a binary writer 2017-04-04 23:17:43 +02:00
Niels Lohmann
c28bf823bc 🔨 added endianess check 2017-04-04 17:30:43 +02:00
Niels Lohmann
b15fc13dd1 🔨 implemented MessagePack in binary_reader 2017-04-04 16:59:19 +02:00
Niels Lohmann
3a34f2d82c Merge branch 'develop' into feature/manual_lexer 2017-04-04 15:55:40 +02:00
Niels Lohmann
782570d46f 🔨 cleanup 2017-04-03 22:58:46 +02:00
Niels Lohmann
4f6b63e492 Merge pull request #545 from theodelrieu/feature/enum_class_support
add enum class default conversions
2017-04-03 22:13:59 +02:00
Niels Lohmann
ea667db446 🔨 fixed compilation errors
TIL about C++:

executing m[key()]=val(); for a std::map executes

First key() then val() with Clang

First val() then key() with GCC

#wat
2017-04-03 21:53:23 +02:00
Niels Lohmann
89efe627fe 🔨 a lot of restructuring
- removed uncached input stream adapter; it was too slow anyway
- implemented a class binary_read which parses CBOR based on input
adapters
- in the CBOR parser, numbers are created via memcpy to avoid undefined
behavior
2017-04-02 18:46:21 +02:00
Théo DELRIEU
af9b21151c add enum class default conversions 2017-04-02 13:10:15 +02:00
Niels Lohmann
3a5cf9bd0a 🔨 improved code coverage 2017-04-01 08:34:58 +02:00
Niels Lohmann
c32d2e5b3c 🔨 removed unget() function 2017-04-01 00:36:05 +02:00
Niels Lohmann
8d393b5eff Merge branch 'develop' into feature/manual_lexer 2017-03-31 23:58:45 +02:00
Niels Lohmann
3fa0610856 🔨 added minibench to ignore list 2017-03-31 23:57:24 +02:00
Niels Lohmann
50ee0a62f5 🔨 replaced lookup-tables by switches 2017-03-31 23:24:33 +02:00
Niels Lohmann
4c821c9e9c 🔨 moved buffer size to interface 2017-03-31 17:11:51 +02:00
Niels Lohmann
d07596a0ea 📝 mentioned #540 and fixed #538 2017-03-30 17:39:02 +02:00
Niels Lohmann
7881783745 Merge pull request #540 from tinloaf/diagnostics
Properly pop diagnostics
2017-03-30 17:25:29 +02:00
Lukas Barth
0b1b6307a5 Also change the re2c file 2017-03-30 16:14:02 +02:00
Lukas Barth
40aff4182f Pop for every push 2017-03-30 16:10:03 +02:00
Niels Lohmann
60057a4728 🔨 fixed bugs introduced by merging from develop 2017-03-29 07:54:26 +02:00
Niels Lohmann
a690a9f2d2 Merge branch 'develop' into feature/manual_lexer 2017-03-29 00:57:09 +02:00
Niels Lohmann
c2e80a72d7 🔨 deprecated j << istream / j >> ostream functions #367
The implementation is non-standard. Deprecation allows a simpler API in
the future without removing any features.
2017-03-29 00:39:47 +02:00
Niels Lohmann
9578c0f700 Merge branch 'develop' into feature/manual_lexer 2017-03-28 23:47:17 +02:00
Niels Lohmann
b4dbebffcd added regression test for #464 2017-03-28 23:28:54 +02:00
Niels Lohmann
62dfdf3f5d 📝 addressed #514
NaN values never compare equal to themselves or to other NaN values.
2017-03-28 23:24:59 +02:00
Niels Lohmann
5d586b0192 🔨 cleanup 2017-03-28 23:20:45 +02:00
Niels Lohmann
19d119e18c 🔨 fixed a warning in MSVC 2017-03-28 22:10:24 +02:00
Niels Lohmann
6b12e40478 🏁 removed __builtin_expect for MSVC 2017-03-28 21:55:26 +02:00
Niels Lohmann
d025b6aaf7 Merge branch 'develop' into feature/manual_lexer 2017-03-28 21:39:36 +02:00
Niels Lohmann
19cd206d99 📝 documented Xcode 8.3 2017-03-28 21:39:16 +02:00
Niels Lohmann
a0aa6ad2b2 👷 added Xcode 8.3
https://blog.travis-ci.com/2017-03-28-xcode-83-ga-is-here
2017-03-28 20:42:12 +02:00
Niels Lohmann
d37ca2eba8 🔨 fixed test case 2017-03-28 20:29:27 +02:00
Niels Lohmann
50e251f5f6 🔨 adjusted test case to new signature of token_type_name() 2017-03-28 20:17:00 +02:00
Niels Lohmann
6a6fbea62c 🔨 some cleanup 2017-03-28 20:08:08 +02:00
Niels Lohmann
1e495945f1 🔨 fixed buffer overflow 2017-03-28 18:06:43 +02:00
Niels Lohmann
bbb6bd9de5 🔨 fixing last failing test cases 2017-03-28 17:00:03 +02:00
Niels Lohmann
b0c47abd88 🔨 rewrote string parser to cope with UTF-8 2017-03-27 22:58:44 +02:00
Niels Lohmann
f75e195db3 🔨 added code for user-defined number types 2017-03-26 18:45:04 +02:00
Niels Lohmann
3425527970 🔨 added code for locale-independent number parsing 2017-03-26 18:12:58 +02:00
Niels Lohmann
06e2a291b1 🔨 fixed number parsing 2017-03-26 17:26:41 +02:00
Niels Lohmann
3b069b4b4c 🔨 adjusted more expected exceptions 2017-03-26 16:19:07 +02:00
Niels Lohmann
99e0d8b339 🔨 fixed \uxxxx parsing 2017-03-26 15:29:08 +02:00
Niels Lohmann
f47cf152a8 Merge branch 'develop' into feature/manual_lexer 2017-03-26 13:14:14 +02:00
Niels Lohmann
d4d51460ab Merge branch 'feature/noexcept_exceptions' into develop 2017-03-26 12:54:22 +02:00
Niels Lohmann
3336194306 🔨 reverted changes that led to Travis failures 2017-03-26 12:23:10 +02:00
Niels Lohmann
53b501a785 🔨 cleanup 2017-03-25 23:31:03 +01:00
Niels Lohmann
cf7786887c 🔨 fixed check for is_nothrow_copy_constructible
We now only demand our exceptions to be is_nothrow_copy_constructible
if std::runtime_exception is.
2017-03-25 17:35:57 +01:00
Niels Lohmann
c333679a96 🔨 small refactoring
The solution with a std::runtime_error member is more elegant. It
allows to have std::exception as base class again. However, I still
have no idea why GCC thinks the copy constructor may throw...
2017-03-25 17:25:39 +01:00
Niels Lohmann
cc36c65a89 🚑 made exceptions nothrow-copy-constructible #531
To have nothrow-copy-constructible exceptions, we inherit from
std::runtime_error which can cope with arbitrary-length error messages.
Intermediate strings are built with static functions and then passed to
the actual constructor.
2017-03-25 16:22:52 +01:00
Niels Lohmann
a58ed3cd17 💄 cleanup 2017-03-25 14:47:23 +01:00
Niels Lohmann
20bcf1015b 📝 cleanup after #536 2017-03-25 14:19:05 +01:00
Niels Lohmann
dc6e9b6188 Merge branch 'develop' into feature/manual_lexer 2017-03-25 14:12:58 +01:00
Niels Lohmann
0f9585685a Merge pull request #536 from vpetrigo/feature/VS17_appveyor_support
Add Visual Studio 17 image to appveyor build matrix
2017-03-25 14:12:30 +01:00
Vladimir Petrigo
8edb0cd15c Add VS17 image to appveyor matrix 2017-03-25 14:57:58 +03:00
Niels Lohmann
a93ec07c8c Merge branch 'develop' into feature/manual_lexer 2017-03-24 19:53:19 +01:00
Niels Lohmann
3d597dda5d 📝 update after #534 2017-03-24 19:51:11 +01:00
Niels Lohmann
40160f482a 🚧 manual lexer
This commit removed the re2c lexer and replaced it by a manual version.
Its integration is not yet complete: number parsing does not respect
locales or overflows. Furthermore, parsing does not need to end with
EOF. Therefore, a lot of test cases fail. The idea is to push this
branch forward so we can conduct performance comparisons. So far, a
nice side effect are better diagnosis messages in case of parse errors.
2017-03-24 19:49:02 +01:00
Niels Lohmann
bba688f53e Merge pull request #534 from TedLyngmo/utf8_encoding_enhancement
UTF8 encoding enhancement
2017-03-24 19:38:29 +01:00
Ted Lyngmo
cea2426731 UTF8 encoding enhancement 2017-03-24 14:56:48 +01:00
Niels Lohmann
8a872927e8 Merge pull request #530 from berkus/patch-1
Fix typo
2017-03-23 13:57:54 +01:00
Berkus Decker
b14629b0a6 Fix typo 2017-03-23 14:50:41 +02:00
Niels Lohmann
54db53c230 📝 update after #527 and #525 2017-03-22 08:10:31 +01:00
Niels Lohmann
d60851168e 🚨 fixed a compiler warning #527
The result of snprintf is later used in situations where a long may
overflow.
2017-03-22 08:10:02 +01:00
Niels Lohmann
67a06834b0 Merge pull request #526 from krzysztofwos/feature/exception-base-class
Make exception base class visible in basic_json
2017-03-22 07:50:34 +01:00
Krzysztof Woś
b9c3b8d688 Exit with an error if re2c is not available
Instead of overwriting src/json.hpp with an empty file
2017-03-20 16:00:58 +09:00
Krzysztof Woś
86579209c8 Make exception base class visible in basic_json 2017-03-20 16:00:58 +09:00
Niels Lohmann
31a6c0910e 🚑 fix for #519
Added catch branch for out_of_range exception that can occur if input
file contains a number overflow.
2017-03-17 22:18:48 +01:00
Niels Lohmann
f547679de5 🚑 fix for #516 and #518
We should compare the binary serializations rather than the JSON values
themselves. This fix was already done for CBOR and apparently forgotten
for MessagePack.
2017-03-17 22:18:05 +01:00
Niels Lohmann
2d474b5273 Merge pull request #510 from alex-weej/patch-1
🎨 Namespace `uint8_t` from the C++ stdlib
2017-03-17 06:47:11 +01:00
Alexander “weej” Jones
836f1c4189 🎨 Namespace uint8_t from the C++ stdlib 2017-03-16 18:24:41 +00:00
Niels Lohmann
cd43600e6f 💄 cleanup after #508 2017-03-16 19:02:05 +01:00
Niels Lohmann
773b33e016 Merge pull request #508 from theodelrieu/feature/c_array_conversion
add to_json method for C arrays
2017-03-16 19:00:58 +01:00
Niels Lohmann
c5711f3072 🚧 a lot of minor changes
- Removed unused headers.
- Added override where needed.
- Added description for parse_error.113 exception.
- Fixed some conversion warnings.
- Integrated cbor_expect_string function for CBOR maps.
- Added documentation on the supported CBOR/MessagePack features.
- Added test to check all initial bytes for CBOR input.
2017-03-16 18:39:33 +01:00
Niels Lohmann
483a58f625 🚨 added pedantic flags for GCC
With GCC 7, there are even more diagnostic flags.
2017-03-16 18:35:45 +01:00
Théo DELRIEU
dbebf8de47 add to_json method for C arrays
If the array can be converted to basic_json::string_t, the overload
in this commit is not chosen.
2017-03-16 15:20:39 +01:00
Niels Lohmann
100bf3ef2c Merge branch 'feature/getline' into develop 2017-03-14 23:08:19 +01:00
Niels Lohmann
710f8a2686 📝 improved documentation for to-CBOR and to-msgpack functions 2017-03-14 23:08:05 +01:00
Niels Lohmann
1de80e8af4 🔨 added user-defined exception #493
Replaced old std::invalid_argument exception by parse_error.111 to have
unified exceptions in case of input stream errors.
2017-03-14 21:31:36 +01:00
Niels Lohmann
63c2c62f19 🔨 changed call from "not good()" to "fail()" #493
Also merged develop into this feature branch.
2017-03-14 21:24:53 +01:00
Niels Lohmann
95474e420d 🏁 added parentheses around max/min calls #506
When <Windows.h> is included with MSVC, a macro NOMINMAX is defined
that yields compilation errors when max/min calls are encountered. This
can be fixed by un-defining NOMINMAX, or by placing parentheses around
all min/max calls. We chose the latter.
2017-03-14 21:11:20 +01:00
Niels Lohmann
b026591e9e 🚑 added special case to fuzzers to fix #504
Since #329, NaN and inf numbers do not yield an exception, but are
stored internally and are dumped as “null”. This commit adjusts the
fuzz testers to deal with this special case.
2017-03-14 21:05:38 +01:00
Niels Lohmann
bfe4788e32 🚑 fix for #500
Removed a check that already failed in MSVC.
2017-03-14 16:14:05 +01:00
Niels Lohmann
84072fbd6d 💄 fixed indentation 2017-03-14 16:07:28 +01:00
Niels Lohmann
b8b4362ca4 🔥 removed accidentally committed binaries 2017-03-13 19:04:19 +01:00
Niels Lohmann
c5cf32e34d 🔨 added user-defined exception 406 2017-03-12 20:59:33 +01:00
Niels Lohmann
43b8285249 🔀 merge branch 'feature/exceptions_3.0.0' into develop 2017-03-12 20:34:30 +01:00
Niels Lohmann
855cdcf05c 🔀 merge branch 'develop' into feature/exceptions_3.0.0 2017-03-12 20:22:30 +01:00
Niels Lohmann
8feaf8dc94 💥 implemented new handling of NaN and INF #70 #329 #388
- If an overflow occurs during parsing a number from a JSON text, an
exception (std::out_of_range for the moment, to be replaced by a
user-defined exception #244) is thrown so that the overflow is detected
early and roundtripping is guaranteed.
- NaN and INF floating-point values can be stored in a JSON value and
are not replaced by null. That is, the basic_json class behaves like
double in this regard (no exception occurs). However, NaN and INF are
serialized to “null”.
- Adjusted test cases appropriately.
2017-03-12 18:38:05 +01:00
Niels Lohmann
9355f05888 🔨 cleaned up array from_json methods #473
Removed some code that is not needed any more. Thus, streamlining the
array from_json methods.
2017-03-12 17:05:02 +01:00
Niels Lohmann
87eafd8d6a added regression tests for #473
These tests currently pass without any adjustments to the source code.
2017-03-12 15:20:17 +01:00
Niels Lohmann
80dcf22fc3 🔨 added a check function for MsgPack strings #497
To avoid the error described in #497, I added a function
msgpack_expect_string that is executed every time a string is expected
during the parsing of a map. In case the current byte does not belong
to a MsgPack string, an exception is thrown.
2017-03-12 14:39:20 +01:00
Niels Lohmann
28dbe4e651 📝 overworked documentation for the at functions
Added all possible exceptions to the examples of the at functions.
2017-03-12 13:49:39 +01:00
Niels Lohmann
89f6068385 Merge branch 'develop' into feature/exceptions_3.0.0 2017-03-12 11:51:24 +01:00
Niels Lohmann
dfa4e83cd8 Merge branch 'feature/no_exceptions' into develop 2017-03-12 11:49:52 +01:00
Niels Lohmann
e3e941ef2b 👷 fixed a syntax error 2017-03-12 11:19:27 +01:00
Niels Lohmann
01470f388b 👷 fixed no_exceptions test case
This test case relied on logics that have been replaced by CMake with
#461. This change enables compilation and execution of the test suite
without exceptions by adding an after_success task.
2017-03-12 11:04:26 +01:00
Niels Lohmann
4d7c29923e 🚑 fix for #486
Implemented std::less<value_t> to allow using value_t as std::map key
in MSVC.
2017-03-12 10:40:36 +01:00
Niels Lohmann
4b9c2f1287 🔨 added __EXCEPTIONS to the list 2017-03-11 20:16:13 +01:00
Niels Lohmann
4e49829851 🚑 fix for #493
Added a test to check if the input stream is good() before executing
getline on it. Also added two test cases that set the failbit and
badbit before calling file_line_buffer.
2017-03-11 19:26:12 +01:00
Niels Lohmann
122afbf128 🔨 added defined() check 2017-03-11 18:43:21 +01:00
Niels Lohmann
e3e6cbecc7 🏁 added check for _CPPUNWIND
MSVC does not define __cpp_exceptions, but seems to use _CPPUNWIND when
exception support is switched on, see
https://msdn.microsoft.com/en-us/library/b0084kay.aspx.
2017-03-11 17:59:24 +01:00
Niels Lohmann
65dfc97d40 🔨 using __cpp_exceptions to detect exception support #498
I used __EXCEPTIONS to detect whether exceptions are supported.
Apparently, this is a macro that is only used by libstdc++
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64276). It’s much cleaner
to use __cpp_exceptions as it is in the standard since C++98.

Note that compiling the unit-tests with “-fno-exceptions” still does
not work, because Catch uses throw internally. However, the library’s
exceptions can be switched off by defining JSON_NOEXCEPTION.
2017-03-11 17:44:54 +01:00
Niels Lohmann
ff0b18d10c Merge branch 'feature/vector_bool' into develop 2017-03-11 17:22:14 +01:00
Niels Lohmann
c7afb34e57 🎨 cleanup after #496
Ran “make pretty” and added a note to the README file.
2017-03-11 16:01:26 +01:00
Niels Lohmann
754ce0b991 Merge pull request #496 from TedLyngmo/fix_effcplusplus_warnings
Fix -Weffc++ warnings (GNU 6.3.1)
2017-03-11 15:57:10 +01:00
Niels Lohmann
d9e2dd03bf 🔨 fixed interface for to_json function 2017-03-11 15:46:52 +01:00
Niels Lohmann
f4126e4dd8 added overload for std::less<value_t> #486
MSVC needs this overload to compile code containing a std::map that
uses nlohmann::detail::operator as key.
2017-03-11 15:44:14 +01:00
Niels Lohmann
f5f6dac800 added overload for std::vector<bool> #494
Adds a to_json function for std::vector<bool> to allow implicit
conversion from bit vectors to basic_json.
2017-03-11 15:32:44 +01:00
Ted Lyngmo
70bbf19527 Fix -Weffc++ warnings (GNU 6.3.1) 2017-03-11 15:16:26 +01:00
Ted Lyngmo
5b809b9737 Fix -Weffc++ warnings (GNU 6.3.1) 2017-03-11 15:05:21 +01:00
Ted Lyngmo
9cfb777b65 Fix -Weffc++ warnings (GNU 6.3.1) 2017-03-11 13:56:38 +01:00
Niels Lohmann
f9fe0193d5 Merge branch 'develop' into coverity_scan 2017-03-09 18:55:27 +01:00
Niels Lohmann
758c4addc1 🚑 fix for #492
The original test case relied on an invalidated iterator. This error
did not occur before, but only with GCC with -D_GLIBCXX_DEBUG. This
commit fixes the test case. The library is unaffected by this change.
2017-03-09 18:20:26 +01:00
Niels Lohmann
0f6b8aa718 📝 more documentation for the new exceptions 2017-03-08 23:30:38 +01:00
Niels Lohmann
1ab580d6e9 📝 more documentation for the new exceptions 2017-03-08 23:12:13 +01:00
Niels Lohmann
fe71e7df1f 📝 overworked documentation
Replacing references to std exceptions with user-defined exceptions.
Also changed some examples to the new exceptions.
2017-03-08 21:03:19 +01:00
Niels Lohmann
9374eaa013 🔨 added user-defined exception 501 2017-03-08 19:16:53 +01:00
Niels Lohmann
c8a6ce79ea 🚑 fixing fuzzers to work with new exceptions 2017-03-08 18:37:03 +01:00
Niels Lohmann
fc9b528ec9 🔨 changed an exception 2017-03-08 18:07:21 +01:00
Niels Lohmann
8fcd01631f improved test coverage
Tests for parse_error.109 were missing.
2017-03-08 16:39:17 +01:00
Niels Lohmann
625cf7e3f7 🔨 added user-defined exception 112 2017-03-07 20:05:34 +01:00
Niels Lohmann
757d2c6c7a 🔨 replaced at() calls in msgpack/cbor 2017-03-06 23:45:08 +01:00
Niels Lohmann
5407333224 🔨 added user-defined exception 111 2017-03-06 22:37:46 +01:00
Niels Lohmann
21ec0e7806 🔨 added user-defined exception 110 2017-03-06 21:00:13 +01:00
Niels Lohmann
a186106bde 🔨 user-defined exception 302
Also moved all exception classes into the detail namespace and
introduced them via “using” into basic_json.
2017-03-06 19:34:44 +01:00
Niels Lohmann
38c2e20ce8 added user-defined exceptions 404-405 2017-03-05 23:25:22 +01:00
Niels Lohmann
30331fa21f 🔨 added user-defined exception 403 2017-03-05 23:16:17 +01:00
Niels Lohmann
60da36aee2 🔨 added user-defined exceptions 401-402 2017-03-05 22:56:39 +01:00
Niels Lohmann
491c9780a7 🔨 added user-defined exception 311 2017-03-05 22:39:21 +01:00
Niels Lohmann
6751d650be 🔨 added user-defined exception 311 2017-03-05 22:31:08 +01:00
Niels Lohmann
9e560ca40c 🔨 added user-defined exceptions 313-315 2017-03-05 19:58:26 +01:00
Niels Lohmann
144cf6a4c7 🔨 added user-defined exceptions 310 2017-03-05 19:48:11 +01:00
Niels Lohmann
5cca44c161 🔨 added user-defined exceptions 309 2017-03-05 19:42:05 +01:00
Niels Lohmann
70b2c3f45e 🔨 added user-defined exceptions 308 2017-03-05 19:35:24 +01:00
Niels Lohmann
2a9393af00 🔨 added user-defined exceptions 307 2017-03-05 19:26:44 +01:00
Niels Lohmann
bb740c43fb 🔨 added user-defined exceptions 306 2017-03-05 19:15:56 +01:00
Niels Lohmann
aa842b4a27 🔨 added user-defined exceptions 305 2017-03-05 19:08:12 +01:00
Niels Lohmann
f473f74fb0 🔨 added user-defined exceptions 303-304 2017-03-05 18:56:35 +01:00
Niels Lohmann
068c7acda9 🔨 added user-defined exceptions 301 2017-03-05 18:40:09 +01:00
Niels Lohmann
0c40c8e3be 🔨 added user-defined exceptions 2xx 2017-03-03 14:34:57 +01:00
Niels Lohmann
a4274d7766 🔨 added user-defined exceptions 205-206 2017-03-03 14:00:42 +01:00
Niels Lohmann
875b2da95d 🔨 added user-defined exceptions 203-204 2017-03-03 13:38:14 +01:00
Niels Lohmann
9381f6c4da 🔨 added user-defined exceptions 201-202
Started implementing exceptions for invalid iterators.
2017-03-03 13:19:45 +01:00
Niels Lohmann
e291c6c3d2 Merge branch 'develop' into feature/exceptions_3.0.0 2017-03-03 12:59:37 +01:00
Niels Lohmann
a1354184ce 📝 fixed typo #481 2017-03-03 12:56:54 +01:00
Niels Lohmann
0c6b1f8a24 Merge branch 'develop' into feature/exceptions_3.0.0 2017-03-03 12:54:45 +01:00
Niels Lohmann
776758d7a2 🔨 added user-defined exception 109
This exception occurs when a JSON pointer contains an array index that
can not be converted into a number.
2017-03-03 12:54:37 +01:00
Niels Lohmann
b86d2148ef 🔨 added user-defined exceptions 106-108
These exceptions occur when JSON pointers are malformed.
2017-03-03 11:56:58 +01:00
Niels Lohmann
06c788e4fd 📝 added missing word 2017-03-03 10:01:16 +01:00
Niels Lohmann
01d3a006b1 ⬆️ updated Catch to v1.8.1 2017-03-02 18:13:19 +01:00
Niels Lohmann
06815d274e 🔨 added user-defined exceptions 104 and 105
These exceptions are thrown in case of parse errors in JSON patch
documents.
2017-03-02 17:55:13 +01:00
Niels Lohmann
c085e3bac2 🔨 started with user-defined exceptions #301 #244
Added class hierarchy for user-defined exceptions (#244). Integrated
parse exceptions 101-103. Parse exceptions include the byte count of
the last read character to locate the position of the error (#301).
2017-03-01 21:28:44 +01:00
Niels Lohmann
7b8fd864e2 🔥 removed deprecated constructor #480
The constructor basic_json(std::istream&, const parser_callback_t) has
been deprecated since version 2.0.0. This commit removes it together
with its code example, deprecation macro, and test cases. The code now
also compiles with -W-deprecated-declarations.
2017-03-01 17:49:03 +01:00
Niels Lohmann
6b3912d936 📝 added note to 3.0.0 wiki page #474
I created a wiki page
https://github.com/nlohmann/json/wiki/Road-toward-3.0.0 to describe the
transition toward version 3.0.0. On this page, all API-breaking changes
shall be documented.
2017-03-01 17:26:32 +01:00
Niels Lohmann
f84ac523aa 📝 added a note to ordered maps
The library does not preserve the insertion order of object keys. There
are frequent requests to change the library in this aspect. The README
and the contribution guidelines now contain links to containers that
can be used to replace std::map to preserve the insertion order.
2017-03-01 10:15:07 +01:00
Niels Lohmann
41f9b32554 🔀 merge branch 'feature/serialization_class' into develop (#418)
Moved all dump()-related functions into a class "serializer". This fix includes a lot of performance improvements yielding a 7% speedup for serialization. Details on the individual steps can be found in the commit messages.

Individual benchmark numbers:

before:

dump jeopardy.json                            5   374555228 ns/op
dump jeopardy.json with indent                5   430953700 ns/op
dump numbers/floats.json                      5   622938509 ns/op
dump numbers/signed_ints.json                20    82177979 ns/op

after:

dump jeopardy.json                            5   335449757 ns/op -11%
dump jeopardy.json with indent                5   375467773 ns/op -13%
dump numbers/floats.json                      5   584611852 ns/op -7%
dump numbers/signed_ints.json                20    68289574 ns/op -17%
2017-02-28 21:04:16 +01:00
Niels Lohmann
d69242c6ba 💄 cleanup
- Added comments for the serializer class.
- Added test case for resizing of the indentation string.
- Using std::none_of to check if “.0” needs to be added to
floating-point number.
2017-02-28 19:20:50 +01:00
Niels Lohmann
059f21aada 💄 fixed a warning
snprintf returns an int, but we later assign it a difference_type which
is usually a long.
2017-02-28 17:24:03 +01:00
Niels Lohmann
224f99070b micro-optimization of dump()
A lot of small changes to avoid memory allocations:

- The locale is only queried once rather than with every number
serialization.
- The indentation string is recycled between different calls.
- The string escape function avoids a copy if no escaping is necessary.
- The string escape and the space function use a complete switch case
instead of cascaded ifs.

Cachegrind measures some 15% performance improvement.
2017-02-28 16:28:22 +01:00
Niels Lohmann
fc48b8ac2b 🐛 fixed a logical error
Treated the size of the range as the number of thousand separators.
This logical error yielded a negative value for written_bytes and
eventually an infinite loop, as written_bytes was converted to an
unsigned value.
2017-02-28 11:45:38 +01:00
Niels Lohmann
af070744ae 🔨 integrating numtostr into serializer class
By merging numtostr into serializer, we can write directly to the
output stream. As a consequence, all stream calls are now unformatted.
2017-02-27 22:10:57 +01:00
Niels Lohmann
54ef5f7b47 🔨 moved serialization functions to serializer class
The class is currently just a wrapper for an std::ostream and collects
all functions related to serialization. The next step should be
recycling of variables to avoid repetitive initialization for each
recursive dump call.
2017-02-27 21:22:39 +01:00
Niels Lohmann
9c4919ff34 " micro-optimizations for dump()"
This reverts commit 909b439b03.
For some strange reason, the test suite crashes when compiled
with GCC.
2017-02-27 16:19:07 +01:00
Niels Lohmann
909b439b03 micro-optimizations for dump()
numtostr now directly writes to a stream. Return value of snprintf is
reused to avoid finding end of string. Cachegrind suggests a 1%
performance increase.
2017-02-27 14:58:10 +01:00
Niels Lohmann
0f04e42dd5 micro-optimizations for dump()
All ‘<<‘ calls have been replaced by write()/put() calls. The
indentation strings needs not to be resized. Cachegrind measures 1%
performance improvement.
2017-02-27 01:22:24 +01:00
Niels Lohmann
b1441f3485 micro-optimizations for dump()
Indentation string is recycled to avoid allocations. Comma-separation
in objects does not need an if any more. Cachegrind measures 1%
performance improvement.
2017-02-26 20:58:00 +01:00
Niels Lohmann
bd0326cbc1 micro-optimizations for dump()
Added separate code paths for normal output and pritty-printed output.
This allowed to remove most of the ifs along the way. Benchmarks and
cachegrind suggest a 10% performance improvement.
2017-02-26 16:55:54 +01:00
Niels Lohmann
ae155c4734 💄 cleanup 2017-02-26 14:45:41 +01:00
Niels Lohmann
bf4d744d1a more tests for meta() call 2017-02-26 14:34:58 +01:00
Niels Lohmann
d1b30250d6 added missing tests 2017-02-26 11:50:52 +01:00
Niels Lohmann
f1cd15ce7e avoid copying a string 2017-02-26 11:22:18 +01:00
Niels Lohmann
9ff0cc0f02 📝 updated documentation 2017-02-25 16:43:15 +01:00
Niels Lohmann
03f06e1993 Merge branch 'develop' into coverity_scan 2017-02-25 16:38:18 +01:00
Niels Lohmann
1b5867bdcf 🔀 merge branch 'release/2.1.1' into develop 2017-02-25 16:37:28 +01:00
Niels Lohmann
27c65b860b 🔖 version 2.1.1 2017-02-25 16:34:38 +01:00
Niels Lohmann
0234e53e23 📝 added section on used third-party tools 2017-02-22 20:48:52 +01:00
Niels Lohmann
b49ce351eb 💄 fixed some warnings 2017-02-22 20:48:29 +01:00
Niels Lohmann
a646c9c599 🔀 merge branch 'cotire' of https://github.com/tusharpm/json into tusharpm-cotire 2017-02-22 19:45:10 +01:00
Niels Lohmann
8cec55a271 🚧 fixed more warnings 2017-02-22 18:14:29 +01:00
Niels Lohmann
345a106d73 💄 cleanup 2017-02-22 16:56:56 +01:00
Niels Lohmann
967f9144d4 🚧 overworked fix for #465 2017-02-21 19:11:34 +01:00
Niels Lohmann
7d14f167b8 🚑 fix for #465 2017-02-20 22:48:27 +01:00
Niels Lohmann
b04543ecc5 🎨 fixed newlines 2017-02-20 21:56:10 +01:00
Niels Lohmann
1a6d7f5bca 🚧 try to fix some warnings in MSVC 2017-02-20 18:32:11 +01:00
Niels Lohmann
f7075be93a 🐛 reverted change for #464 2017-02-20 18:15:50 +01:00
Niels Lohmann
f2dfa09aec 🐛 fix for #464 2017-02-20 18:05:52 +01:00
Niels Lohmann
83a9c60dbd 🔨 refactored code to avoid using strcpy/strlen/strcat (#463) 2017-02-20 17:37:34 +01:00
Niels Lohmann
716485a965 🚧 removed decay (#448) 2017-02-20 16:27:16 +01:00
Niels Lohmann
7a4a16a7db 💄 updated header list 2017-02-20 16:20:45 +01:00
Niels Lohmann
1f72c38861 🚑 fix for #448 2017-02-19 21:26:53 +01:00
Niels Lohmann
83f1d2c81b added start index for from_cbor and from_msgpack (#462) 2017-02-19 21:17:05 +01:00
Niels Lohmann
4151f2d297 added test with thousands_sep 2017-02-19 20:08:01 +01:00
Niels Lohmann
5b53f03e7c Merge branch 'develop' into TurpentineDistillery-feature/locale_independent_num_to_str 2017-02-19 19:24:55 +01:00
Niels Lohmann
9a9d0ba3df 🚧 fixing warning C4293 (#453) 2017-02-19 17:47:20 +01:00
Tushar Maheshwari
5436407b7e 👷 Add cmake logic to Travis config
- get CMake for XCode 8.1 image
2017-02-19 13:38:08 +05:30
Tushar Maheshwari
85ce4d7b53 cmake compile time reduce using cotire
- Add prefix header
  - Include catch.hpp
  - Include json.hpp
    - Replace private with public for all json_unit files
- Move `unit.cpp` to an object library
- cotire issue: strip whitespace from CMAKE_INCLUDE_SYSTEM_FLAG_CXX
2017-02-19 13:35:54 +05:30
Niels Lohmann
d1479e47bb 💄 added assertion message 2017-02-18 11:01:03 +01:00
Niels Lohmann
513eb3ab5f 🚧 clean up 2017-02-18 11:00:18 +01:00
Niels Lohmann
0200f2dc62 🚧 fixing warning C4267 (#453) 2017-02-17 19:14:21 +01:00
Niels Lohmann
6408402ad2 🔀 merge #378 (for #362 and #454) 2017-02-16 09:24:45 +01:00
Niels Lohmann
057b1e606b 🔀 merged #415 (fix for #414) 2017-02-16 08:50:20 +01:00
Niels Lohmann
2c17c1b1b2 💄 cleanup 2017-02-16 08:01:01 +01:00
Niels Lohmann
973402c11e 🚧 replaced throws (#440) and _MAX/_MIN macros (#451) 2017-02-15 22:44:18 +01:00
Niels Lohmann
b9f3149451 🚑 fix for #452 2017-02-15 21:30:28 +01:00
Mihai STAN
6bf93b3d06 Merge remote-tracking branch 'upstream/develop' into develop 2017-02-15 15:00:25 +02:00
Niels Lohmann
82fb613763 📝 update after #302 2017-02-14 07:28:30 +01:00
Niels Lohmann
22b9a301d6 Merge pull request #450 from nlohmann/TurpentineDistillery-feature/locale_independent_str_to_num
TurpentineDistillery feature/locale independent str to num
2017-02-14 07:18:35 +01:00
Niels Lohmann
c95ff863bf ⬆️ updated Catch to v1.7.2 2017-02-13 18:55:11 +01:00
Niels Lohmann
265c5b5207 🔨 more work on the number parser 2017-02-13 18:51:23 +01:00
Niels Lohmann
b84705d557 improved test coverage 2017-02-12 20:14:43 +01:00
Niels Lohmann
c8191c8172 🔨 further cleanup 2017-02-12 18:50:17 +01:00
Niels Lohmann
c2d55109c1 🔨 make lexer distinguishes number types 2017-02-11 16:54:25 +01:00
Niels Lohmann
9f5dccbab5 💄 cleanup 2017-02-11 15:55:53 +01:00
Niels Lohmann
926af6d50b 🔀 merge branch 'develop' into TurpentineDistillery-feature/locale_independent_str_to_num 2017-02-11 15:17:47 +01:00
Niels Lohmann
ed8516dc39 👷 added Codacy badge 2017-02-09 17:38:02 +01:00
Niels Lohmann
c485d46cea 📝 screenshoots look ugly 2017-02-08 20:00:46 +01:00
Niels Lohmann
6fd77cea4a 📝 added screenshots 2017-02-08 19:22:19 +01:00
Niels Lohmann
0ffa18aab8 📝 listing projects using the library 2017-02-08 19:16:38 +01:00
Niels Lohmann
662a9b8f3c ✏️ fixed more typos 2017-02-08 18:19:41 +01:00
Niels Lohmann
4746a4c536 💄 minor change 2017-02-08 17:56:43 +01:00
Niels Lohmann
163f8397fd ✏️ fixed a typo #446 2017-02-05 17:11:26 +01:00
Niels Lohmann
8d88a1da2a 🔀 merged #379 and fixed conflicts 2017-02-05 13:13:41 +01:00
Niels Lohmann
d284c86dd1 uncommented some tests 2017-02-04 21:00:41 +01:00
Niels Lohmann
922fe693e1 ⬆️ updated Catch to v1.7.0 2017-02-04 15:30:28 +01:00
Niels Lohmann
1cfdc2a753 🐛 fixed test compilation 2017-02-04 08:25:55 +01:00
Niels Lohmann
77d6f70602 📝 acknowledgments for #442 and #445 2017-02-03 18:28:22 +01:00
Niels Lohmann
d6afaa8e16 📝 fixing a documentation issue #442 2017-02-03 18:15:37 +01:00
Niels Lohmann
5976caf032 improved test compilation speed #445 2017-02-03 18:09:55 +01:00
Niels Lohmann
16af771277 added roundtrip test for the Big List of Naughty Strings 2017-02-01 17:34:39 +01:00
Niels Lohmann
bf8fdac99a 👷 dropped Doozer.io support 2017-02-01 16:41:05 +01:00
Niels Lohmann
7bb7033383 Merge branch 'develop' into coverity_scan 2017-02-01 16:03:51 +01:00
Niels Lohmann
c75865d88c 🐛 fixed -Weffc++ warnings 2017-02-01 15:13:21 +01:00
Niels Lohmann
b210f2dbf4 💄 minor refactoring 2017-01-29 21:40:37 +01:00
Niels Lohmann
0164b10e10 added missing tests found by mutate++ 2017-01-29 17:18:58 +01:00
Niels Lohmann
affa3bf4e9 Merge pull request #439 from jaredgrubb/patch-2
README: adjust boost::optional example
2017-01-29 08:18:44 +01:00
Jared Grubb
f2873e6d3a README: adjust boost::optional example
The "from_json" example for boost::optional is not complete and should also handle the 'none' case.
2017-01-29 02:46:58 +00:00
Niels Lohmann
c7f366520c Merge branch 'develop' into coverity_scan 2017-01-28 18:43:48 +01:00
Niels Lohmann
f642934b18 🔀 merge branch 'release/2.1.0' into develop 2017-01-28 18:43:01 +01:00
Niels Lohmann
6746a57524 📝 updated slides 2017-01-28 18:41:30 +01:00
Niels Lohmann
eb08e8b09b 📝 updated documentation 2017-01-28 18:20:12 +01:00
Niels Lohmann
4b5c61075f 📄 changes to let Github detect the license 2017-01-28 18:17:57 +01:00
Niels Lohmann
38e4935db0 📝 added example and documentation for the meta function 2017-01-28 17:12:29 +01:00
Niels Lohmann
cdde1a9436 🔖 set version to 2.1.0 2017-01-28 16:46:03 +01:00
Niels Lohmann
d870826811 🔖 set version to 2.1.0 2017-01-28 16:03:35 +01:00
Niels Lohmann
2f6260751c 📝 fixed #434 2017-01-27 18:50:52 +01:00
Niels Lohmann
42fa3f0568 🔀 merge pull request #435 (based on #338, #355, and #423)
conversion from/to user-defined types
2017-01-27 06:22:10 +01:00
Niels Lohmann
cd9701b123 💄 cleanup 2017-01-26 20:51:30 +01:00
Niels Lohmann
1305e03557 📝 fixed documentation 2017-01-26 19:39:34 +01:00
Niels Lohmann
77bb7af5d9 📝 added more documentation 2017-01-26 07:29:37 +01:00
Niels Lohmann
4d3053cd42 💄 some cleanup 2017-01-25 22:21:07 +01:00
Niels Lohmann
94d9b7bc86 📝 overworked documentation (re-added constructor examples) 2017-01-25 21:59:54 +01:00
Niels Lohmann
ec03c9c53e 📝 overworked docs #435 2017-01-25 19:01:31 +01:00
Mihai STAN
6198439f59 fix #414 - comparing to 0 literal
Overload comparison operators for all types that could be converted
to nullptr.
2017-01-24 22:33:37 +02:00
Niels Lohmann
4139bb6572 📝 adjusted test count 2017-01-24 15:20:20 +01:00
Niels Lohmann
c154f3133d 🚧 rephrased assertions 2017-01-24 15:02:35 +01:00
Niels Lohmann
50a3f3b301 📝 added nicer example 2017-01-24 14:55:51 +01:00
Niels Lohmann
781fd09f2d 📝 cleanup 2017-01-24 14:45:32 +01:00
Niels Lohmann
daf8dcdb32 📝 overworked README 2017-01-24 14:37:25 +01:00
Niels Lohmann
250e5bf43d 💄 overworked documentation and indentation 2017-01-24 13:47:33 +01:00
Niels Lohmann
030cf674ef 🚧 fixed a warning 2017-01-24 12:49:38 +01:00
Niels Lohmann
3857e55290 💄 ran "make pretty" 2017-01-24 12:43:43 +01:00
Théo DELRIEU
9f103d19d7 add implicit conversions test (operator T()) 2017-01-22 14:23:24 +01:00
Théo DELRIEU
9f8b270ed9 fix some warnings 2017-01-22 14:07:28 +01:00
Théo DELRIEU
9c6ef74a28 add static_asserts/remove the need for CopyConstructible in get 2017-01-21 19:12:40 +01:00
Théo DELRIEU
ba0b35f414 use typename U = uncvref_t where appropriate 2017-01-21 19:12:40 +01:00
Théo DELRIEU
37fd20b2eb put uncvref_t, enable_if_t, value_t and operator<(value_t) in detail 2017-01-21 19:12:40 +01:00
Théo DELRIEU
7d771c71ed put back type_name in basic_json
This can however not be done easily for value_t, since
external_constructor depends on it, as is operator< which was moved
outside basic_json too.
This is not really an issue, since all basic_json classes share the same
enum
2017-01-21 19:12:40 +01:00
Théo DELRIEU
f997758cad remove useless forward declaration of primitive_iterator_t 2017-01-21 19:12:40 +01:00
Théo DELRIEU
40ba5a8b7b remove inline keyword from anonymous namespace (not needed) 2017-01-21 19:12:40 +01:00
Théo DELRIEU
7f359017d2 rename template argument Json -> BasicJsonType 2017-01-21 19:12:40 +01:00
Théo DELRIEU
708eb9613b disable reserve tests when exceptions are disabled 2017-01-21 19:12:40 +01:00
Théo DELRIEU
889b269a4f rename template argument: BasicJson -> Json 2017-01-21 16:14:23 +01:00
Théo DELRIEU
a6b028286b move conjunction/disjunction to the top of detail 2017-01-21 16:14:23 +01:00
Théo DELRIEU
d566bb81c4 use switchs where appropriate 2017-01-21 16:14:23 +01:00
Théo DELRIEU
1e20887cff use JSON_THROW 2017-01-21 16:14:22 +01:00
Théo DELRIEU
447c6a670f run make re2c 2017-01-21 16:14:22 +01:00
Théo DELRIEU
3e15b551e0 run make pretty 2017-01-21 16:14:22 +01:00
Théo DELRIEU
fbac056c38 add readme 2017-01-21 16:14:22 +01:00
Théo DELRIEU
b56117b148 add noexcept tests 2017-01-21 16:14:22 +01:00
Théo DELRIEU
af94e712c7 add basic doxygen documentations 2017-01-21 16:14:22 +01:00
Théo DELRIEU
1d87097741 remove some boilerplate 2017-01-21 16:14:22 +01:00
Théo DELRIEU
e60e458a7e move static_const to the detail namespace 2017-01-21 16:14:22 +01:00
Théo DELRIEU
794dae8911 apply changes to json.hpp.re2c 2017-01-21 16:14:22 +01:00
Théo DELRIEU
68081cd112 remove useless file 2017-01-21 16:14:22 +01:00
Théo DELRIEU
07bc82d3a7 put const to the left 2017-01-21 16:14:22 +01:00
Théo DELRIEU
f1482d1f01 more tests in unit-udt 2017-01-21 16:14:22 +01:00
Théo DELRIEU
f2c71fafda minor message/comments tweak 2017-01-21 16:14:22 +01:00
Théo DELRIEU
63e4249e9f use a priority_tag instead of int and longs with sfinae-dispatch 2017-01-21 16:14:22 +01:00
Théo DELRIEU
b8012876a5 add noexcept checks, and some missing noexcepts 2017-01-21 16:14:22 +01:00
Théo DELRIEU
1554baa01d attempting to fix coverage. testing that reserve is called 2017-01-21 16:14:22 +01:00
Théo DELRIEU
a9d5ae4fad put back a specialization for containers with a reserve method 2017-01-21 16:14:22 +01:00
Théo DELRIEU
e247e01a6e use static_casts to silence MSVC warnings
Those warnings are not "fixed", but that's intentional.
Truncations are expected when ArithmeticType is not the same type than
number_unsigned_t (or another basic_json template argument)
2017-01-21 16:14:22 +01:00
Théo DELRIEU
d0d8070422 add static_asserts
remove some useless trailing return types and && to help MSVC
2017-01-21 16:14:22 +01:00
Théo DELRIEU
e678c075dd check for is_number_unsigned before is_number_integer 2017-01-21 16:14:22 +01:00
Théo DELRIEU
cb3d455bd2 do not const_cast when calling get_ptr 2017-01-21 16:14:22 +01:00
Théo DELRIEU
3494014ba0 new unit-udt.cpp tests 2017-01-21 16:14:22 +01:00
Théo DELRIEU
1f25ec5d36 add some constexpr + noexcept 2017-01-21 16:14:22 +01:00
Théo DELRIEU
29f9fe6ae9 remove one has_to/from_json template parameter 2017-01-21 16:14:22 +01:00
Théo DELRIEU
5839795725 remove useless helpers 2017-01-21 16:14:22 +01:00
Théo DELRIEU
b4cea6825d remove is_compatible_array_type_impl trait 2017-01-21 16:14:22 +01:00
Théo DELRIEU
b2543e06d8 removed is_compatible_float_type trait 2017-01-21 16:14:22 +01:00
Théo DELRIEU
be6b417c87 tweak SFINAE checks for internal types (see commit body)
only check for public types (iterators, json_pointer)

for private ones (m_array.iterator, primitive_iterator) simply double
parentheses on relevant Catch checks
2017-01-21 16:14:22 +01:00
Théo DELRIEU
317883b21b cleanup, details in body
removes:
- is_basic_json_compatible_type traits
- a useless operator=
- void_t
- disjunction

changes:
- is_compatible_object_type's first argument is BasicJson
2017-01-21 16:14:22 +01:00
Théo DELRIEU
4e8089b9de remove old get/get_impl overloads (doc removal is of course temporary) 2017-01-21 16:14:22 +01:00
Théo DELRIEU
7e6a6f978e replace constructor by from/to_json: array_t 2017-01-21 16:14:22 +01:00
Théo DELRIEU
c847e0eea2 replace constructor by from/to_json: array_t
- tweaked a bit how `get<container<json>>` is handled
- added a from_json overload for forward list
2017-01-21 16:14:22 +01:00
Théo DELRIEU
6d427acdde replace constructor by from/to_json: unscoped enum types
this also means that one can do: j.get<unscoped_enum>();
2017-01-21 16:14:22 +01:00
Théo DELRIEU
f00898331e replace constructor by from/to_json: number_integer_t 2017-01-21 16:14:22 +01:00
Théo DELRIEU
a32de3b528 replace constructor by from/to_json: number_unsigned_t
This commit forces a design change in custom JSONSerializer, which might
be temporary
2017-01-21 16:14:21 +01:00
Théo DELRIEU
d257149f36 replace constructor by from/to_json: number_float_t 2017-01-21 16:14:21 +01:00
Théo DELRIEU
bbe40641a3 replace constructor by from/to_json: string_t 2017-01-21 16:14:21 +01:00
Théo DELRIEU
6b89785fba replace constructor by from/to_json: boolean_t 2017-01-21 16:14:21 +01:00
Théo DELRIEU
c833b22b7b move type_name outside of basic_json, make it a friend 2017-01-21 16:14:21 +01:00
Théo DELRIEU
d359684f2b move enum class value_t outside of basic_json 2017-01-21 16:14:21 +01:00
Niels Lohmann
034d5ed97e 💄 some cleanup 2017-01-21 16:14:21 +01:00
Niels Lohmann
be1d3de49b 💄 moved changes to re2c file and ran make pretty 2017-01-21 16:14:21 +01:00
Théo DELRIEU
aa2679a8ce fix tests, avoid instantiating JSONSerializer when it will not be used 2017-01-21 16:14:21 +01:00
Théo DELRIEU
d5ee5830ed add more tests 2017-01-21 16:14:21 +01:00
Théo DELRIEU
1c21c87e6f use u8 prefix in unit-udt.cpp 2017-01-21 16:14:21 +01:00
Théo DELRIEU
7e750ec1fa fix msvc, by doubling parenthesis on catch assertions 2017-01-21 16:14:21 +01:00
Théo DELRIEU
3d405c6883 add support for enum classes 2017-01-21 16:14:21 +01:00
Théo DELRIEU
8e43d476d3 add more tests to unit-udt.cpp 2017-01-21 16:14:21 +01:00
Théo DELRIEU
f5cb089f89 add an enum constructor (quickfix) 2017-01-21 16:14:21 +01:00
Théo DELRIEU
1eafac7220 remove explicit keyword on udt-constructor 2017-01-21 16:14:21 +01:00
Théo Delrieu
c0c72b5b62 rewrite unit-udt: basic usage 2017-01-21 16:14:21 +01:00
Théo DELRIEU
60e6f822fa add support for non-default-constructible udt 2017-01-21 16:14:21 +01:00
Théo DELRIEU
e5999c6c82 add a few tests 2017-01-21 16:14:21 +01:00
Théo Delrieu
74bb11d92c remove some useless checks, format a bit, added some comments 2017-01-21 16:14:21 +01:00
Théo DELRIEU
907484fb43 format biggest lines 2017-01-21 16:14:21 +01:00
Théo Delrieu
47bc402113 only use conjunction & co when needed to avoid MSVC crashing 2017-01-21 16:14:21 +01:00
Théo DELRIEU
ee19acaf05 add is_compatible_basic_json_type trait 2017-01-21 16:14:21 +01:00
Théo Delrieu
9b401972a0 add a macro for has_xxx types 2017-01-21 16:14:21 +01:00
Théo DELRIEU
e2dbe7a69f correctly constrain basic_json udt constructor 2017-01-21 16:14:21 +01:00
Théo DELRIEU
0d91113ccf add negation, disjunction, and conjunction from C++17 2017-01-21 16:14:21 +01:00
Théo DELRIEU
88819449c2 remove constraints on JSONSerializer instances, constrain correctly new methods 2017-01-21 16:14:21 +01:00
Théo DELRIEU
23bd2bce35 add is_compatible_* traits 2017-01-21 16:14:21 +01:00
Théo DELRIEU
178441cdfd add basic test for custom serializer 2017-01-21 16:14:21 +01:00
Théo DELRIEU
2bc685f6b4 to_json and from_json takes both two arguments now
the first is the basic_json type, the second the user-defined type
2017-01-21 16:14:21 +01:00
Théo DELRIEU
837b81d672 renamed unit-constructor3.cpp to unit-udt.cpp 2017-01-21 16:14:21 +01:00
Théo DELRIEU
33abccf847 add template arguments for JSONSerializer 2017-01-21 16:14:21 +01:00
Théo DELRIEU
7dc268ef42 add first version for alternate implementation 2017-01-21 16:14:21 +01:00
Théo DELRIEU
4cdc61e493 move most SFINAE trickery in to/from_json_fn 2017-01-21 16:14:21 +01:00
Théo DELRIEU
03b391c37b remove has_destructor and has_json_traits, use decltype instead 2017-01-21 16:14:21 +01:00
Théo DELRIEU
12b4555b13 use uncvref_t<T> instead of remove_cv_t<remove_reference_t<T>>> 2017-01-21 16:14:21 +01:00
Théo DELRIEU
877d96c1d8 rename __static_const to _static_const (reserved identifier) 2017-01-21 16:14:21 +01:00
Théo DELRIEU
d54d6bb84c add alias templates to reduce boilerplate 2017-01-21 16:14:21 +01:00
Théo DELRIEU
fe628b585b anonymous namespace renamed to detail 2017-01-21 16:14:21 +01:00
Théo Delrieu
b443edf49e add first version support for user-defined types 2017-01-21 16:14:20 +01:00
Niels Lohmann
ce0b3fe5a3 🚧 made type_name() public 2017-01-21 16:12:17 +01:00
Niels Lohmann
145188f264 renaming did not help 2017-01-19 19:23:56 +01:00
Niels Lohmann
69be3fa842 📝 small documentation update 2017-01-19 18:19:20 +01:00
Niels Lohmann
5e3f9c8969 📄 help Github find the license 2017-01-19 17:09:55 +01:00
Niels Lohmann
e951d198f4 🔀 merge pull request #430 from vjon/patch-1
Fix documentation error
2017-01-19 07:42:29 +01:00
Jonathan Lee
046f6da82f Fix documentation error
Move comparison before "j.clear()" function call, such that the intended return value "true" is actually correct.
2017-01-18 11:43:14 -08:00
Niels Lohmann
bae8e70137 🔀 merge branch 'feature/noexceptions_2' into develop 2017-01-18 20:41:17 +01:00
Niels Lohmann
87c5e32e1f 🐛 fixed escaping 2017-01-16 22:46:49 +01:00
Niels Lohmann
a00149f8ee 🐛 fixed logic error 2017-01-16 22:36:58 +01:00
Niels Lohmann
1ab26ab367 option to switch off exceptions 2017-01-16 22:11:07 +01:00
Niels Lohmann
74cbd30cd0 📄 it's 2017 2017-01-16 20:04:47 +01:00
Niels Lohmann
a7f3938391 added Big List of Naughty Strings 2017-01-16 20:03:50 +01:00
Niels Lohmann
a9b4cb8bf8 🔀 merge branch 'feature/release_information' into develop #397 2017-01-12 21:37:31 +01:00
Niels Lohmann
3a9ccfac22 🚧 cleanup 2017-01-12 21:35:27 +01:00
Niels Lohmann
98ad3c3ac1 Merge branch 'develop' into feature/release_information 2017-01-12 21:30:08 +01:00
Niels Lohmann
0f03543861 ⬆️ upgraded to Catch 1.6.0 2017-01-11 22:23:02 +01:00
Niels Lohmann
e9bbf5aaba 🐛 forgot to remove a test case 2017-01-08 09:31:40 +01:00
Niels Lohmann
dd45ba6f89 🚧 renamed version() to meta() 2017-01-08 09:19:44 +01:00
Alex Astashyn
c236b596c9 Merge upstream/develop into feature/locale_independent_str_to_num 2017-01-04 19:20:16 -05:00
Alex Astashyn
949061079a Merge upstream/develop into feature/locale_independent_num_to_str 2017-01-04 18:55:19 -05:00
Niels Lohmann
e1b89dd1d6 Merge branch 'develop' into feature/release_information 2017-01-04 20:06:23 +01:00
Niels Lohmann
9f6c86f233 🐛 fix for #417 2017-01-04 18:54:44 +01:00
Niels Lohmann
4765070318 📝 added documentation wrt. UTF-8 strings #406 2017-01-04 18:07:46 +01:00
Niels Lohmann
cdd3b5a68c 🚑 fix for #416 2017-01-03 23:52:01 +01:00
Niels Lohmann
767637877b 💄 cleanup 2017-01-03 22:37:07 +01:00
Niels Lohmann
f8d640b185 👷 better support for OSS-Fuzz 2017-01-03 22:35:31 +01:00
Niels Lohmann
245a69d554 💄 ran clang-tidy 2017-01-03 21:33:23 +01:00
Niels Lohmann
ea4d71ee21 Merge branch 'develop' into feature/release_information 2017-01-02 17:26:00 +01:00
Niels Lohmann
0f36541d65 Merge branch 'develop' into coverity_scan 2017-01-02 16:39:52 +01:00
Niels Lohmann
9755cc75b1 🔀 merge branch 'release/2.0.10' into develop 2017-01-02 16:38:23 +01:00
Niels Lohmann
7e2c4b3ead 📝 updated online link 2017-01-02 16:37:29 +01:00
Niels Lohmann
69c615e127 🔖 version bump to 2.0.10 2017-01-02 10:00:44 +01:00
Niels Lohmann
4d3bf433b4 🔖 updated ChangeLog 2017-01-02 09:56:21 +01:00
Niels Lohmann
8b46eb8ec0 📄 it's 2017 already 2017-01-02 09:40:00 +01:00
Niels Lohmann
6a20790056 📝 updated test count 2017-01-02 09:36:30 +01:00
Niels Lohmann
60b3703c62 🔖 version bump to 2.0.10 2017-01-02 09:35:57 +01:00
Niels Lohmann
d173517212 💄 clean up 2017-01-02 09:21:26 +01:00
Niels Lohmann
a3063c2419 🚧 added target to build all fuzzers 2017-01-01 21:51:36 +01:00
Niels Lohmann
db33629990 💄 cleanup after #410 2017-01-01 21:34:58 +01:00
Niels Lohmann
712529cd32 🔀 merge pull request #400 from andoma/develop
Add Doozer build badge
2017-01-01 19:47:33 +01:00
Niels Lohmann
09b91406c6 🔀 merge pull request #410 from Daniel599/feature/clang_sanitize
Feature/clang sanitize
2017-01-01 19:45:11 +01:00
Niels Lohmann
ab7d55e7ae 👷 removed failing test suites 2017-01-01 19:38:54 +01:00
Niels Lohmann
cf9bf2d913 🚑 fix for #411 and #412 2017-01-01 15:28:01 +01:00
Daniel Cohen
ff3221a375 #394 fixed memory leak in unit-allocator, found by clang's fsanitize 2016-12-30 15:21:25 +02:00
Niels Lohmann
328eb55dc4 🚧 started working on #397 2016-12-30 14:02:51 +01:00
Daniel Cohen
010ea126f3 going to try clang_sanitize with libstdc++ with g++-6 implementation
Conflicts:
	.travis.yml
	Makefile
2016-12-30 14:24:22 +02:00
Niels Lohmann
d7029c37aa improved test coverage 2016-12-30 13:04:33 +01:00
Niels Lohmann
f7575dee94 Merge branch 'develop' into feature/release_information 2016-12-30 12:29:01 +01:00
Niels Lohmann
42a8c64499 🔖 added version information 2016-12-30 12:28:52 +01:00
Niels Lohmann
f0edab2363 🚑 fix for #408 2016-12-29 17:00:02 +01:00
Niels Lohmann
383a29a924 🚑 fix for #407 2016-12-29 16:14:15 +01:00
Niels Lohmann
871cebaf84 🚑 fix for #405 2016-12-29 15:39:16 +01:00
Niels Lohmann
8381cd6020 🚑 removed unsafe call to strerror #403 2016-12-28 14:19:08 +01:00
Niels Lohmann
e4c2829aea 🔀 merge branch 'feature/fuzzer' into develop 2016-12-28 12:26:00 +01:00
Niels Lohmann
1dd99d04b6 Merge branch 'develop' into feature/fuzzer 2016-12-28 12:19:12 +01:00
Niels Lohmann
888f5b9f60 🚚 renamed test files to allow windows build 2016-12-28 12:18:48 +01:00
Niels Lohmann
55be721615 Merge branch 'develop' into feature/fuzzer 2016-12-28 12:11:51 +01:00
Niels Lohmann
acb7e0558d 🚑 fixed bugs detected by AFL-Fuzz 2016-12-28 12:09:15 +01:00
Niels Lohmann
e3b036348b 🚧 added targets for parallel AFL fuzzing 2016-12-25 16:36:43 +01:00
Niels Lohmann
1399abc583 🚧 added MessagePack fuzz target 2016-12-25 16:18:56 +01:00
Niels Lohmann
e4cc62e653 🐛 fixed Makefile to work with proper CBOR files 2016-12-25 16:07:10 +01:00
Niels Lohmann
6de9d4035a 🐛 fixed AFL driver to also read binary data 2016-12-25 16:06:56 +01:00
Niels Lohmann
dbdcb3fec8 🐛 fixed bug in CBOR/MessagePack deserialization 2016-12-25 16:06:36 +01:00
Niels Lohmann
6e129fbfb7 📝 some small documentation fixes 2016-12-25 14:39:08 +01:00
Niels Lohmann
f87f4c06f9 🚧 cleanup 2016-12-22 12:10:52 +01:00
Niels Lohmann
33be4e7f1f 🚧 cleanup 2016-12-22 12:08:36 +01:00
Niels Lohmann
a084e90f39 🔨 split AFL test in driver and test file 2016-12-22 11:09:26 +01:00
Niels Lohmann
048330b14b ⬆️ Catch v1.5.9 2016-12-22 09:37:15 +01:00
Niels Lohmann
22a6b956e8 📄 added license for Catch 2016-12-22 09:36:34 +01:00
Niels Lohmann
ad241a2260 🔨 moved third-party code into separate folder 2016-12-22 09:35:53 +01:00
Niels Lohmann
6e8791912f 🚧 added fuzzer from OSS-Fuzz 2016-12-22 09:09:40 +01:00
Niels Lohmann
69ed19e483 added libFuzzer 2016-12-22 09:08:50 +01:00
Niels Lohmann
09fd1a04b8 Merge branch 'develop' into coverity_scan 2016-12-21 16:19:26 +01:00
Niels Lohmann
7107072f71 👷 clang for fedora 2016-12-21 10:33:36 +01:00
Niels Lohmann
2cf0f299ad 👷 using clang where GCC is too old 2016-12-21 10:13:59 +01:00
Niels Lohmann
937cca762f 👷 forgot to install make 2016-12-21 09:54:11 +01:00
Niels Lohmann
91e45a8dd0 👷 the cmake of trusty is too old 2016-12-21 09:47:31 +01:00
Niels Lohmann
f78671de8e 👷 Fedora has no package "build-essential" 2016-12-21 09:33:16 +01:00
Niels Lohmann
2e5208d5cd 👷 there is no cmake in the osx image 2016-12-21 09:19:53 +01:00
Niels Lohmann
c6fbd305b0 👷 trying more doozer workers 2016-12-21 09:17:17 +01:00
Niels Lohmann
38597ac628 👷 added more builders 2016-12-20 23:04:07 +01:00
Andreas Smas
57b32d9773 Add Doozer build badge 2016-12-20 21:38:01 +01:00
Niels Lohmann
73b28e8f92 👷 fixing build command 2016-12-20 19:16:52 +01:00
Niels Lohmann
1178a8152a 👷 using cmake with Doozer 2016-12-20 19:13:19 +01:00
Niels Lohmann
0fffbb8488 👷 trying Doozer 2016-12-20 19:06:15 +01:00
Niels Lohmann
ab64419bb6 Merge branch 'develop' into coverity_scan 2016-12-18 18:17:51 +01:00
Niels Lohmann
9952a3c456 👷 trying to fix coverity task 2016-12-18 18:17:26 +01:00
Niels Lohmann
03b78fee63 Merge branch 'develop' into coverity_scan 2016-12-16 21:42:34 +01:00
Niels Lohmann
0e55af23fc 🔀 Merge branch 'release/2.0.9' into develop 2016-12-16 21:35:28 +01:00
Niels Lohmann
57afd293aa 🔖 updated documentation 2016-12-16 21:34:37 +01:00
Niels Lohmann
a507b9b46a 🔖 updated documentation 2016-12-16 21:25:20 +01:00
Niels Lohmann
36dc786106 🔖 updated Changelog 2016-12-16 21:09:14 +01:00
Niels Lohmann
706be50596 📝 updated number of tests 2016-12-16 20:54:43 +01:00
Niels Lohmann
303e873ae8 🔖 bumped version to 2.0.9 2016-12-16 20:45:46 +01:00
Niels Lohmann
f6f7fed99a 🚨 removed some warnings 2016-12-16 18:57:19 +01:00
Niels Lohmann
f24e4f680e 🎨 cleanup after PR #395 2016-12-14 22:30:09 +01:00
Niels Lohmann
fe00b368ae 🔀 merge pull request #395 from Bosswestfalen/develop
Replace class iterator and const_iterator by using a single template class to reduce code.
2016-12-14 21:56:43 +01:00
Niels Lohmann
2f94c30bad added a regression test for #380 / #390 2016-12-13 21:46:07 +01:00
Niels Lohmann
4e2fb1a533 Merge pull request #390 from qwename/integer-overflow
🔀 fix issue #380: Signed integer overflow check
2016-12-13 21:26:53 +01:00
Niels Lohmann
dfafd2c259 👷 can't get clang sanitizer to work #394
See https://travis-ci.org/nlohmann/json/jobs/183684093 for a failing
build.
2016-12-13 21:23:59 +01:00
Bosswestfalen
92e28c3153 added missing changes in json.hpp.re2c 2016-12-13 20:30:56 +01:00
Niels Lohmann
c3fac19692 👷 another try for sanitizers #394 2016-12-13 19:41:36 +01:00
Niels Lohmann
3f089cab2b 👷 moved instructed build to "before_script" #394 2016-12-13 18:24:16 +01:00
Niels Lohmann
9b5411db57 👷 clang 3.9.0 is not working #394 2016-12-13 17:55:41 +01:00
Niels Lohmann
f5d4a9c4eb 👷 added Clang 3.9.0 and sanitizer build #394 2016-12-13 17:51:46 +01:00
Yixin Zhang
703d4baf8b Fixed conversion warnings
Use static_cast on digit.
2016-12-12 21:12:08 -05:00
Yixin Zhang
bd6422f583 Ran make pretty 2016-12-12 21:12:08 -05:00
Yixin Zhang
1e981115c9 Fix issue #380: Signed integer overflow check
Instead of checking something like `x * y + z > max` where `x * y` can
overflow, check for `x > (max - z) / y` instead.
2016-12-12 21:12:08 -05:00
Alex Astashyn
6fba52b6da Merged upstream/develop into feature/locale_independent_str_to_num 2016-12-12 20:27:15 -05:00
Alex Astashyn
5cad2006eb Tweaked check for preserved sign; added LCOV_EXCL_LINE 2016-12-12 20:15:57 -05:00
Alex Astashyn
65b9b0c429 Disabling snprintf pre-check, since can't get locale-specific behavior to manifest in AppVeyor 2016-12-12 19:50:21 -05:00
Alex Astashyn
0f8de48ddb Disabling strtod pre-check, since can't get locale-specific behavior to manifest in AppVeyor 2016-12-12 19:48:14 -05:00
Alex Astashyn
cd0b651d43 Tweaked check for preserved sign; added LCOV_EXCL_LINE 2016-12-12 19:46:47 -05:00
Niels Lohmann
79fa8b2f41 🚑 fix to address #389 2016-12-12 23:19:43 +01:00
Bosswestfalen
dd3f4f9b92 Replaced class iterator and class const_iterator with aliases of template <typename U> iter_impl. iter_impl has operator const_iterator to create an const_iterator from an iterator. 2016-12-12 19:26:45 +01:00
Niels Lohmann
447e01427d 🚨 fixed some warnings 2016-12-12 18:21:17 +01:00
Niels Lohmann
b8776e8613 🚑 fix for #393 2016-12-12 17:39:56 +01:00
Niels Lohmann
f6c21a1f20 📝 added note to example files 2016-12-12 08:25:08 +01:00
Niels Lohmann
5402458ff5 🚑 fixed an AddressSanitizer warning 2016-12-12 08:13:26 +01:00
Niels Lohmann
a25d570040 📝 added TOC to README #383 2016-12-11 19:42:36 +01:00
Niels Lohmann
ea7b40687b 📝 updated FAQ of the contribution guidelines #382 2016-12-11 16:36:39 +01:00
Niels Lohmann
b2991950a5 📝 added not wrt re2c version #390 2016-12-11 16:21:53 +01:00
Niels Lohmann
e906933f39 🔀 Merge branch 'feature/messagepack' into develop 2016-12-11 16:11:59 +01:00
Niels Lohmann
a59eb4868a 🔀 Merge branch 'develop' into feature/messagepack 2016-12-11 16:11:43 +01:00
Niels Lohmann
a9d7d315a5 📝 cleanup after #391 2016-12-11 16:06:52 +01:00
Niels Lohmann
446019aefd 🔀 merge pull request #391 from jaredgrubb/jgrubb-clang-doc-warning
Clang: quiet a warning
2016-12-11 16:04:27 +01:00
Niels Lohmann
6fa4f96ba3 📝 fixed two documentation warnings 2016-12-11 16:03:23 +01:00
Niels Lohmann
dc6fc3e079 📝 clean up and added documentation for #358 2016-12-11 13:36:08 +01:00
Niels Lohmann
fdce38fa79 fixed a test case 2016-12-11 00:39:26 +01:00
Niels Lohmann
e8c903294f more test cases for CBOR and msgpack 2016-12-11 00:05:29 +01:00
Niels Lohmann
41673e8fed 🐛 fixed CBOR code and added test cases 2016-12-10 23:12:57 +01:00
Jared Grubb
98d6e6e523 Clang: quiet a warning 2016-12-10 13:19:56 -08:00
Niels Lohmann
7e5d6af5c1 🔨 refactored msgpack code 2016-12-10 21:30:18 +01:00
Niels Lohmann
f1b95d78f9 🔨 refactored CBOR code to a switch 2016-12-10 19:29:45 +01:00
Niels Lohmann
d99c230f51 implemented indefinite-length CBOR types (#387) 2016-12-10 18:32:56 +01:00
Alex Astashyn
01930357f7 Tweaking unit test, as digits grouping is failing to be invoked in CI 2016-12-08 22:39:38 -05:00
Alex Astashyn
343c9f9baa Addressing compiler warnings 2016-12-08 22:36:18 -05:00
Alex Astashyn
1c029b97c0 Still trying to invoke locale-specific behavior in CI 2016-12-08 22:13:05 -05:00
Alex Astashyn
38499e84fc Removed unused struct; fixed comments 2016-12-08 21:38:14 -05:00
Niels Lohmann
6b84c4155c 🔨 refactored get_from_vector function
Snippet from http://stackoverflow.com/a/41031865/266378
2016-12-08 09:37:23 +01:00
Alex Astashyn
50f0484ad5 Added unit test for issue #378 2016-12-07 20:23:25 -05:00
Alex Astashyn
27d9740ad6 Tweaks to unit-test for issue #379 2016-12-07 19:55:07 -05:00
Alex Astashyn
0a4a6a8399 Refactored to avoid using exceptions, as there are plans to support exceptionless mode 2016-12-07 19:53:27 -05:00
Niels Lohmann
81a4272444 more test cases for CBOR 2016-12-07 23:14:37 +01:00
Niels Lohmann
3a0f5398a2 more CBOR test cases 2016-12-07 22:50:10 +01:00
Niels Lohmann
b7e0c12966 CBOR support for half-precision floats 2016-12-07 21:43:59 +01:00
Niels Lohmann
17c9b17a7e test cases from RFC 7049 #384 2016-12-07 21:25:22 +01:00
Niels Lohmann
aab9bbbb93 🐛 fix for CBOR (small integers) 2016-12-07 21:24:42 +01:00
Niels Lohmann
de289ea336 💚 another approach to the AppVeyor error 2016-12-07 19:15:05 +01:00
Niels Lohmann
81c43dca6a 💚 more AppVeyor fixes 2016-12-07 16:51:15 +01:00
Niels Lohmann
3f14a09e73 💚 another try to fix the AppVeyor build 2016-12-07 16:43:55 +01:00
Niels Lohmann
74571d531c 💚 still fixing the AppVeyor error 2016-12-07 16:34:02 +01:00
Niels Lohmann
2c7946f2bc 💚 hopefully fixed an error on AppVeyor 2016-12-07 16:21:22 +01:00
Niels Lohmann
8f6bfe5b32 🔨 refactored function to get numbers from byte vector 2016-12-07 14:47:06 +01:00
Niels Lohmann
474da6b28f :white_check_mark: more msgpack test cases 2016-12-07 13:47:08 +01:00
Niels Lohmann
be973e52bb more msgpack test cases 2016-12-07 09:19:46 +01:00
Niels Lohmann
a1693bfe48 Merge branch 'develop' into feature/messagepack 2016-12-07 08:39:57 +01:00
Alex Astashyn
6774457733 Trying to coerce setlocale to make snprintf use commas as delimiter some more 2016-12-06 22:59:12 -05:00
Alex Astashyn
d169598c6c simplified code a bit based on @gregmarr's suggestions 2016-12-06 22:20:48 -05:00
Alex Astashyn
d2e9ce270a Trying to coerce setlocale to make snprintf use commas as delimiter; the behavior appears to be compiler/platform-specific 2016-12-06 22:18:20 -05:00
Alex Astashyn
6e8da7d8c4 Added unit-test for issue #379 (locale-independent str-to-num) 2016-12-06 19:45:48 -05:00
Alex Astashyn
7a081244a5 Refactored preprocessing with a lambda instead of do{...}while(0) 2016-12-06 19:41:31 -05:00
Alex Astashyn
0c87d5d6b3 Refactored preprocessing with a lambda instead of do{...}while(0) 2016-12-06 19:41:05 -05:00
Alex Astashyn
d643360575 Bugfix: when working with C formatting functions we need to query C locales (localeconv) rather than std::locale 2016-12-06 00:43:12 -05:00
Alex Astashyn
738d462955 Bugfix: when working with C formatting functions we need to query C locales (localeconv) rather than std::locale 2016-12-06 00:23:58 -05:00
Alex Astashyn
82b82fd487 Addressing msvc-specific compilation issues. 2016-12-05 20:33:28 -05:00
Alex Astashyn
509447b4d5 Small bufix related to creation of fmt string for snprintf 2016-12-05 19:03:39 -05:00
Alex Astashyn
e41a956782 Alternative handling of integer types relying on strto[u]ll 2016-12-04 13:23:39 -05:00
Alex Astashyn
2197856395 Fixed suffixing .0 and modified the unit tests accordingly 2016-12-04 01:38:23 -05:00
Alex Astashyn
21cae35930 Added locale-independent numtostr 2016-12-04 01:27:22 -05:00
Alex Astashyn
c75efedc6e stylistic changes 2016-12-03 23:19:43 -05:00
Alex Astashyn
4eafaab816 Improved overflow detection; removed debugging output statements. 2016-12-03 22:54:36 -05:00
Alex Astashyn
6b78b5c2be Added strtonum for locale-independent number parsing 2016-12-03 19:05:09 -05:00
Niels Lohmann
f9a19af7a8 Merge branch 'develop' into coverity_scan 2016-12-02 20:30:20 +01:00
Niels Lohmann
bc28942101 🔖 Merge branch 'release/2.0.8' into develop 2016-12-02 20:07:43 +01:00
Niels Lohmann
44c0f811b1 🔖 version 2.0.8 2016-12-02 20:05:53 +01:00
Niels Lohmann
6c24caf282 📝 updated ChangeLog 2016-12-02 19:04:36 +01:00
Niels Lohmann
4adb8a81bf 📝 version bump 2016-12-02 18:39:35 +01:00
Niels Lohmann
60b7299fe1 📝 updated README 2016-12-02 18:02:38 +01:00
Niels Lohmann
8f563a5f81 Merge branch 'feature/emplace' into develop 2016-12-01 21:22:23 +01:00
Niels Lohmann
5c811b91f1 Merge branch 'develop' into feature/emplace 2016-12-01 21:17:40 +01:00
Niels Lohmann
ba3c5e1a25 more test cases 2016-11-29 09:49:05 +01:00
Niels Lohmann
c46b4ea990 more test cases 2016-11-29 08:37:27 +01:00
Niels Lohmann
e717492019 Merge branch 'feature/issue365' into develop 2016-11-29 07:46:14 +01:00
Niels Lohmann
bd252b2a09 Merge branch 'develop' into feature/issue365 2016-11-28 23:24:52 +01:00
Niels Lohmann
50f647c866 Merge branch 'develop' into feature/messagepack 2016-11-28 23:24:35 +01:00
Niels Lohmann
7b6bd585c1 Merge branch 'develop' into feature/emplace 2016-11-28 23:23:56 +01:00
Niels Lohmann
d563c21afe 📝 update documentation of Travis builders 2016-11-28 23:23:45 +01:00
Niels Lohmann
ee0f23fdc6 🚧 bug fixes and more tests 2016-11-28 23:20:03 +01:00
Niels Lohmann
286025497f 👷 removed retired images (https://blog.travis-ci.com/2016-11-17-retiring-some-osx-images/) 2016-11-28 22:16:33 +01:00
Niels Lohmann
aeb4f87a27 added return value for emplace (#349) 2016-11-28 18:33:46 +01:00
Niels Lohmann
6ecff31b7f Merge branch 'develop' into feature/emplace 2016-11-28 18:00:10 +01:00
Niels Lohmann
bc238124ee 🚧 further simplifications 2016-11-27 21:42:21 +01:00
Niels Lohmann
4c232fe12b 👷 added precondition for individual tests 2016-11-27 19:11:58 +01:00
Niels Lohmann
a820d688eb 🔨 refactored number-to-vector calls 2016-11-27 19:11:32 +01:00
Niels Lohmann
56843eb7ba Merge branch 'feature/individual_tests' into feature/messagepack 2016-11-27 18:28:23 +01:00
Niels Lohmann
93589e630c CBOR roundtrip tests 2016-11-27 17:47:56 +01:00
Niels Lohmann
2477b09cb9 🐛 Clang 3.9.0 seems to not work right now 2016-11-27 17:29:19 +01:00
Niels Lohmann
f860f323be 🚧 falling back to single unit test for coveralls 2016-11-27 17:09:05 +01:00
Niels Lohmann
71c1232e32 🐛 fixed YAML 2016-11-27 16:46:33 +01:00
Niels Lohmann
36c79113fb 🚧 fixing coveralls and valgrind targets 2016-11-27 16:45:24 +01:00
Niels Lohmann
e1f98fbfc0 🚧 splitting tests into several binaries 2016-11-27 16:19:26 +01:00
Niels Lohmann
a73f43a7a2 🚧 CBOR support (#358) 2016-11-27 00:10:04 +01:00
Niels Lohmann
eef408e5fb tests for CBOR 2016-11-27 00:09:24 +01:00
Niels Lohmann
87e088990b Merge branch 'develop' into feature/messagepack 2016-11-26 18:17:18 +01:00
Niels Lohmann
a8522f391a Merge branch 'develop' into feature/issue365 2016-11-26 12:45:50 +01:00
Niels Lohmann
2773038cf9 added improvements (#365) 2016-11-26 12:43:23 +01:00
Niels Lohmann
a791af30b4 Merge branch 'feature/filenotfound' into develop 2016-11-25 17:39:38 +01:00
Niels Lohmann
1ed510c232 Merge branch 'develop' into feature/filenotfound 2016-11-25 17:39:24 +01:00
Niels Lohmann
f194db9aa6 added assertion for warning from #368 2016-11-24 22:07:35 +01:00
Niels Lohmann
c39c36e6ad 💄 fixed indentation 2016-11-24 22:05:29 +01:00
Niels Lohmann
472d0045ba 📝 updating README after fixing #299 2016-11-24 21:56:21 +01:00
Niels Lohmann
1407bbf94c 💄 fixed indentation 2016-11-24 21:54:05 +01:00
Niels Lohmann
8014637ad1 added a test for EOF error (#367) 2016-11-24 21:53:41 +01:00
Niels Lohmann
dfc49e7afe 🐛 fixed a bug if parser was called with a stream at EOF (#367) 2016-11-24 21:45:10 +01:00
Niels Lohmann
2819b555c8 Merge branch 'develop' into coverity_scan 2016-11-24 20:01:55 +01:00
Niels Lohmann
4bd3b1b0ef Merge branch 'develop' into feature/issue365 2016-11-24 18:25:00 +01:00
Niels Lohmann
e3450cac72 📈 removing more variance of the benchmarks 2016-11-24 18:24:26 +01:00
Niels Lohmann
c3a610d32a 🔧 ignoring Clion files 2016-11-24 17:45:01 +01:00
Niels Lohmann
739f8eefb7 Merge branch 'develop' into coverity_scan 2016-11-24 17:26:11 +01:00
Niels Lohmann
25548f85c9 👷 trying Coverity with Clang 3.6 (#299) 2016-11-24 17:25:05 +01:00
Niels Lohmann
4bb41d065b 🐛 parsing erroneous files yields an exception (#366) 2016-11-23 16:57:01 +01:00
Niels
5f4becb0f5 Merge branch 'develop' into feature/issue365 2016-11-23 08:48:54 +01:00
Niels
ed611119d9 📈 reducing benchmark variance (#365) 2016-11-23 08:47:40 +01:00
Niels
6cc2d58d69 🐛 hopefully fixing the crashes on Linux (#365) 2016-11-22 20:13:47 +01:00
Niels
f620d74919 added performance fixes (#365) 2016-11-22 07:26:11 +01:00
Niels
869f4c68d4 📝 updated thanks section 2016-11-22 07:25:40 +01:00
Niels
c34b41acd6 🐛 fixes crash in dump from static object (#359)
Merge branch 'feature/issue359' into develop
2016-11-22 06:57:58 +01:00
Niels
abce5c25bb 📝 cleaned comments and updated README 2016-11-21 23:38:17 +01:00
Niels
43dbe02d5b 🐛 fixing #359 2016-11-21 21:53:10 +01:00
Niels
edc81f3bc1 💚 restored test call 2016-11-16 22:49:25 +01:00
Niels
d362a07239 💚 moved sample.json to standard test suite to run it with Valgrind 2016-11-16 22:49:16 +01:00
Niels
a9744f3937 💚 is sample.json killing AppVeyor? 2016-11-16 22:08:21 +01:00
Niels
0c9ab9427f 💚 added verbose message to check AppVeyor build 2016-11-16 22:02:38 +01:00
Niels
05e916717b Merge branch 'develop' into feature/messagepack 2016-11-16 19:16:36 +01:00
Niels
693bfe439b Merge branch 'develop' into feature/emplace 2016-11-16 19:16:16 +01:00
Niels
0d72767b3e ⬆️ updated to Catch v1.5.8 2016-11-16 19:15:54 +01:00
Niels
56667af823 🎨 stating the name of the library in the license 2016-11-16 19:08:25 +01:00
Niels
0a908ce8e2 Merge branch 'develop' into feature/messagepack 2016-11-16 09:04:37 +01:00
Niels
b0f896558f Merge branch 'develop' into feature/emplace 2016-11-16 09:04:25 +01:00
Niels
425b9834a8 🐛 removed the wrong compiler 2016-11-16 08:25:08 +01:00
Niels
56671a88c6 🍎 removed Xcode 8.0 due to repeated problems 2016-11-16 08:01:48 +01:00
Niels
5316f0fff2 🍎 added Xcode 8.1 build for travis 2016-11-16 06:42:26 +01:00
Niels
1be73b903e proposal for emplace/emplace_back (#349) 2016-11-11 19:29:14 +01:00
Niels
d1e73ce954 hid an expensive test case 2016-11-11 17:31:37 +01:00
Niels
543745a10e starting to integrate MessagePack (#358) 2016-11-11 17:11:13 +01:00
Niels
9ca00e4880 readded missing header 2016-11-03 07:27:32 +01:00
Niels
e385417047 documented and cleaned up headers (#314) 2016-11-02 21:27:19 +01:00
Niels
6d2b5e3771 Merge branch 'release/2.0.7' into develop 2016-11-02 20:52:42 +01:00
Niels
700977d73e version bump 2016-11-02 20:52:15 +01:00
Niels
79015b9d0a Merge branch 'feature/jsontestsuite' into develop 2016-11-02 17:03:17 +01:00
Niels
3716a2fbe8 Merge branch 'develop' into feature/jsontestsuite 2016-11-02 17:03:12 +01:00
Niels
737d43724f Merge branch 'feature/issue329' into develop 2016-11-02 16:59:23 +01:00
Niels
59c8343851 cleanup 2016-11-02 15:44:46 +01:00
Niels
94c16b2c31 fixed coverage 2016-11-01 17:01:04 +01:00
Niels
8f70525374 more test coverage 2016-10-30 17:46:00 +01:00
Niels
7adccde714 improved coverage and updated README 2016-10-30 17:10:11 +01:00
Niels
8d1e65f297 evaluated i-tests (#344) 2016-10-30 16:07:17 +01:00
Niels
7b4e6cf705 added implementation-specific tests (#344) 2016-10-30 12:08:29 +01:00
Niels
a8136c578a fixed BOM handling #344 2016-10-29 21:08:30 +02:00
Niels
b820bb3b1f fixed a lot of unicode errors (#344)
BOMs currently yield an error.
2016-10-29 19:35:17 +02:00
Niels
b03bbe724d added n test cases (#344) 2016-10-29 14:02:33 +02:00
Niels
7da182472d Merge branch 'develop' into feature/jsontestsuite 2016-10-29 13:37:17 +02:00
Niels
42ea4fb751 fixed a bug for short input files (#344)
For input files with less than 5 bytes, the parser had a bug so that
refilling the input buffer led to erasing it.
2016-10-29 13:32:36 +02:00
Niels
2fdba9de19 added "y" cases 2016-10-26 23:45:11 +02:00
Niels
a2808322c6 add test files from https://github.com/nst/JSONTestSuite 2016-10-26 18:57:56 +02:00
Niels Lohmann
a29fcae409 fixed Cmake link 2016-10-26 09:20:40 +02:00
Niels
3ebe28970a small fixes 2016-10-23 17:25:07 +02:00
Niels
79d9fdc016 user-defined string literals exploit string length (#340) 2016-10-22 18:57:58 +02:00
Niels
e310850353 cleanup after #336 2016-10-16 23:46:24 +02:00
Niels Lohmann
8057782bb8 Merge pull request #336 from seeekr/patch-1
fix minor grammar/style issue in README.md
2016-10-16 23:40:17 +02:00
Denis Andrejew
cb2d41e3a0 fix minor grammar/style issue in README.md 2016-10-16 02:46:43 +02:00
Niels
542a48a16a Merge branch 'release/2.0.6' into develop 2016-10-15 16:48:08 +02:00
Niels
606098f45d release 2.0.6 2016-10-15 16:47:45 +02:00
Niels
d91067220f added missing overflow check for #329 2016-10-13 21:00:48 +02:00
Niels
67b9f1936d cleanup after closing #324 2016-10-12 22:05:45 +02:00
Niels Lohmann
bb9d87ad55 Merge pull request #324 from vpetrigo/has_mapped_improve
make has_mapped_type struct friendly
2016-10-12 21:59:56 +02:00
Niels
e7a60d8961 Merge branch 'feature/issue323' into develop 2016-10-12 21:21:59 +02:00
Niels
470197bd0b improve test coverage 2016-10-10 21:58:31 +02:00
Niels
d3e7f9da67 code cleanup for #323 2016-10-10 20:38:50 +02:00
Niels
97280bbcfc added missing header 2016-10-09 16:32:01 +02:00
Vladimir Petrigo
e9fde3e116 make has_mapped_type struct friendly 2016-10-08 16:50:23 +03:00
Niels
54bf5f20e9 adjusted README 2016-10-08 14:33:10 +02:00
Niels
2fa8ea0f74 started fixing #323 2016-10-08 14:27:28 +02:00
Niels
a0ef5a194c addressed #319, #321, and #318 2016-10-06 23:27:43 +02:00
Niels Lohmann
04b11d78ff Merge pull request #318 from ChristophJud/include_dir_relocation
Include dir relocation
2016-10-06 22:35:36 +02:00
Niels Lohmann
8173c370f6 Merge pull request #321 from vasild/develop
Fix usage examples' comments for std::multiset
2016-10-06 22:33:58 +02:00
Niels
b6550b35c3 fix after #313 2016-10-04 18:20:36 +02:00
Vasil Dimov
b5128b1610 Fix usage examples' comments for std::multiset 2016-10-04 18:53:44 +03:00
Niels Lohmann
963efb1f09 Merge pull request #313 from 5tefan/develop
trivial documentation fix
2016-10-02 11:29:49 +02:00
Niels
d6005e59a5 added fuzzing results 2016-10-02 11:23:47 +02:00
Christoph Jud
e1b6a23049 relocation of install-include directory for other packages 2016-09-26 12:15:03 +02:00
Stefan Codrescu
be61091401 trivial documentation fix 2016-09-16 18:15:36 -06:00
Niels
e4366688f7 v2.0.5 2016-09-14 23:42:12 +02:00
Niels
5dfd2c9bdf Merge branch 'release/2.0.5' into develop 2016-09-14 23:07:14 +02:00
Niels
5879eb0be3 Merge branch 'release/2.0.5' 2016-09-14 23:06:53 +02:00
Niels
3d104f1d43 version bump 2016-09-14 23:06:39 +02:00
Niels
6bbcdc1ec5 fixes #310 2016-09-14 22:48:12 +02:00
Niels
7b6cba23f3 results for #307 2016-09-12 21:23:12 +02:00
Niels
24c588cd25 Merge branch 'release/2.0.4' into develop 2016-09-11 23:37:30 +02:00
Niels
f209be1142 Merge branch 'release/2.0.4' 2016-09-11 23:37:11 +02:00
Niels
768d66560e version bump 2016-09-11 23:36:59 +02:00
Niels
625370a1ad Merge branch 'develop' 2016-09-02 16:05:38 +02:00
Niels
2c82f25272 Merge branch 'release/2.0.3' 2016-08-31 21:27:32 +02:00
Niels
8fbf635dd3 Merge branch 'develop' into coverity_scan 2016-08-21 23:20:05 +02:00
Niels
c1a5a30285 Merge branch 'develop' into coverity_scan 2016-07-31 14:38:52 +02:00
Niels
3586767c05 Merge branch 'release/v2.0.2' 2016-07-31 13:37:26 +02:00
Niels
5bab89fb22 Merge branch 'develop' into coverity_scan 2016-07-20 20:27:55 +02:00
Niels
ea19be1736 Merge branch 'develop' into coverity_scan 2016-07-19 22:49:17 +02:00
Niels
8b39570009 Merge branch 'develop' 2016-06-28 21:40:23 +02:00
Niels
e29d6b5f41 Merge branch 'release/2.0.1' 2016-06-28 21:33:43 +02:00
Niels
25ccf7f908 Merge branch 'release/2.0.0' 2016-06-24 00:46:36 +02:00
Niels
3c27678963 Merge branch 'develop' into coverity_scan 2016-06-24 00:28:10 +02:00
Niels
0e90bcb539 Merge branch 'develop' into coverity_scan 2016-06-23 18:28:29 +02:00
Niels
804160e659 Merge branch 'develop' into coverity_scan 2016-06-19 22:39:05 +02:00
Niels
3948021b6c Merge branch 'develop' into coverity_scan 2016-06-19 22:07:16 +02:00
Niels
550475b5e1 Merge branch 'develop' into coverity_scan 2016-06-19 18:33:46 +02:00
Niels
d4ff1bbaec Merge branch 'develop' into coverity_scan 2016-05-29 14:56:36 +02:00
Niels
5666bd0e2d Merge branch 'develop' into coverity_scan 2016-05-29 14:06:54 +02:00
Niels
03db7b0dbb Merge branch 'develop' into coverity_scan 2016-05-29 13:32:48 +02:00
Niels
53603500ed Merge branch 'develop' into coverity_scan 2016-05-29 13:06:40 +02:00
Niels
97ea5ae403 Merge branch 'develop' into coverity_scan 2016-05-29 12:57:30 +02:00
946 changed files with 124309 additions and 1219371 deletions

48
.circleci/config.yml Normal file
View File

@@ -0,0 +1,48 @@
version: 2
jobs:
build_stable:
docker:
- image: debian:stretch
steps:
- checkout
- run:
name: Install required tools
command: 'apt-get update && apt-get install -y gcc g++ git cmake'
- run:
name: Run CMake
command: 'mkdir build ; cd build ; cmake .. -DJSON_BuildTests=On'
- run:
name: Compile
command: 'cmake --build build'
- run:
name: Execute test suite
command: 'cd build ; ctest --output-on-failure -j 2'
build_bleeding_edge:
docker:
- image: archlinux
steps:
- checkout
- run:
name: Install required tools
command: 'pacman -Sy --noconfirm base base-devel gcc git cmake'
- run:
name: Run CMake
command: 'mkdir build ; cd build ; cmake .. -DJSON_BuildTests=On'
- run:
name: Compile
command: 'cmake --build build'
- run:
name: Execute test suite
command: 'cd build ; ctest --output-on-failure -j 2'
workflows:
version: 2
build_and_test_all:
jobs:
- build_stable
- build_bleeding_edge

84
.clang-format Normal file
View File

@@ -0,0 +1,84 @@
#AccessModifierOffset: 2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
#AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignEscapedNewlines: Right
#AlignOperands: AlignAfterOperator
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
#AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
#BitFieldColonSpacing: Both
BreakBeforeBraces: Custom # or Allman
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
#BeforeLambdaBody: false
#BeforeWhile: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: false
ColumnLimit: 0
CompactNamespaces: false
ConstructorInitializerIndentWidth: 2
Cpp11BracedListStyle: true
PointerAlignment: Left
FixNamespaceComments: true
IncludeBlocks: Preserve
#IndentCaseBlocks: false
IndentCaseLabels: true
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ReflowComments: false
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++11
TabWidth: 4
UseTab: Never

23
.clang-tidy Normal file
View File

@@ -0,0 +1,23 @@
Checks: '*,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-macro-usage,
-fuchsia-default-arguments-calls,
-fuchsia-default-arguments-declarations,
-fuchsia-overloaded-operator,
-google-explicit-constructor,
-google-runtime-references,
-hicpp-avoid-goto,
-hicpp-explicit-conversions,
-hicpp-no-array-decay,
-hicpp-uppercase-literal-suffix,
-llvm-header-guard,
-llvm-include-order,
-misc-non-private-member-variables-in-classes,
-modernize-use-trailing-return-type,
-readability-magic-numbers,
-readability-uppercase-literal-suffix'
CheckOptions:
- key: hicpp-special-member-functions.AllowSoleDefaultDtor
value: 1

6
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1,6 @@
# JSON for Modern C++ has been originally written by Niels Lohmann.
# Since 2013 over 140 contributors have helped to improve the library.
# This CODEOWNERS file is only to make sure that @nlohmann is requested
# for a code review in case of a pull request.
* @nlohmann

View File

@@ -4,17 +4,15 @@
This project started as a little excuse to exercise some of the cool new C++11 features. Over time, people actually started to use the JSON library (yey!) and started to help improve it by proposing features, finding bugs, or even fixing my mistakes. I am really [thankful](https://github.com/nlohmann/json/blob/master/README.md#thanks) for this and try to keep track of all the helpers.
To make it as easy as possible for you to contribute and for me to keep an overview, here are a few guidelines which should help us avoid all kinds of unnecessary work or disappointment. And of course, this document is subject to discussion, so please [create an issue](https://github.com/nlohmann/json/issues/new) or a pull request if you find a way to improve it!
To make it as easy as possible for you to contribute and for me to keep an overview, here are a few guidelines which should help us avoid all kinds of unnecessary work or disappointment. And of course, this document is subject to discussion, so please [create an issue](https://github.com/nlohmann/json/issues/new/choose) or a pull request if you find a way to improve it!
## Private reports
Usually, all issues are tracked publicly on [Github](https://github.com/nlohmann/json/issues). If you want to make a private report (e.g., for a vulnerability or to attach an example that is not meant to be publisheed), please send an email to <mail@nlohmann.me>.
Usually, all issues are tracked publicly on [GitHub](https://github.com/nlohmann/json/issues). If you want to make a private report (e.g., for a vulnerability or to attach an example that is not meant to be published), please send an email to <mail@nlohmann.me>.
## Prerequisites
Please [create an issue](https://github.com/nlohmann/json/issues/new), assuming one does not already exist, and describe your concern. Note you need a [GitHub account](https://github.com/signup/free) for this.
If you want propose changes to the code, you need to download the [`re2c`](http://re2c.org) tool.
Please [create an issue](https://github.com/nlohmann/json/issues/new/choose), assuming one does not already exist, and describe your concern. Note you need a [GitHub account](https://github.com/signup/free) for this.
## Describe your issue
@@ -24,33 +22,30 @@ Clearly describe the issue:
- If you propose a change or addition, try to give an **example** how the improved code could look like or how to use it.
- If you found a compilation error, please tell us which **compiler** (version and operating system) you used and paste the (relevant part of) the error messages to the ticket.
Please stick to the provided issue templates ([bug report](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/Bug_report.md), [feature request](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/Feature_request.md), or [question](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/question.md)) if possible.
## Files to change
There are currently two files which need to be edited:
:exclamation: Before you make any changes, note the single-header file [`single_include/nlohmann/json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is **generated** from the source files in the [`include/nlohmann` directory](https://github.com/nlohmann/json/tree/develop/include/nlohmann). Please **do not** edit file `single_include/nlohmann/json.hpp` directly, but change the `include/nlohmann` sources and regenerate file `single_include/nlohmann/json.hpp` by executing `make amalgamate`.
1. [`src/json.hpp.re2c`](https://github.com/nlohmann/json/blob/master/src/json.hpp.re2c) (note the `.re2c` suffix) - This file contains a comment section which describes the JSON lexic. This section is translated by [`re2c`](http://re2c.org) into file [`src/json.hpp`](https://github.com/nlohmann/json/blob/master/src/json.hpp) which is plain "vanilla" C++11 code. (In fact, the generated lexer consists of some hundred lines of `goto`s, which is a hint you never want to edit this file...).
To make changes, you need to edit the following files:
If you only edit file `src/json.hpp` (without the `.re2c` suffix), your changes will be overwritten as soon as the lexer is touched again. To generate the `src/json.hpp` file which is actually used during compilation of the tests and all other code, please execute
1. [`include/nlohmann/*`](https://github.com/nlohmann/json/tree/develop/include/nlohmann) - These files are the sources of the library. Before testing or creating a pull request, execute `make amalgamate` to regenerate `single_include/nlohmann/json.hpp`.
```sh
make re2c
```
To run [`re2c`](http://re2c.org) and generate/overwrite file `src/json.hpp` with your changes in file `src/json.hpp.re2c`.
2. [`test/src/unit.cpp`](https://github.com/nlohmann/json/blob/master/test/unit.cpp) - This contains the [Catch](https://github.com/philsquared/Catch) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code.
2. [`test/src/unit-*.cpp`](https://github.com/nlohmann/json/tree/develop/test/src) - These files contain the [doctest](https://github.com/onqtam/doctest) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code.
If you add or change a feature, please also add a unit test to this file. The unit tests can be compiled and executed with
```sh
make check
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build .
$ ctest
```
The test cases are also executed with several different compilers on [Travis](https://travis-ci.org/nlohmann/json) once you open a pull request.
Please understand that I cannot accept pull requests changing only file `src/json.hpp`.
## Note
@@ -59,16 +54,18 @@ Please understand that I cannot accept pull requests changing only file `src/jso
## Please don't
- Only make changes to file `src/json.hpp` -- please read the paragraph above and understand why `src/json.hpp.re2c` exists.
- The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.8 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means.
- The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means.
- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
- Please refrain from proposing changes that would **break [JSON](http://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
- Please refrain from proposing changes that would **break [JSON](https://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
- We shall not extend the library to **support comments**. There is quite some [controversy](https://www.reddit.com/r/programming/comments/4v6chu/why_json_doesnt_support_comments_douglas_crockford/) around this topic, and there were quite some [issues](https://github.com/nlohmann/json/issues/376) on this. We believe that JSON is fine without comments.
- We do not preserve the **insertion order of object elements**. The [JSON standard](https://tools.ietf.org/html/rfc7159.html) defines objects as "an unordered collection of zero or more name/value pairs". To this end, this library does not preserve insertion order of name/value pairs. (In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default.) Note this behavior conforms to the standard, and we shall not change it to any other order. If you do want to preserve the insertion order, you can specialize the object type with containers like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map).
- Please do not open pull requests that address **multiple issues**.
## Wanted
The following areas really need contribution:
- Extending the **continuous integration** toward more exotic compilers such as Android NDK, Intel's Compiler, or the bleeding-edge versions of GCC or Clang.
- Extending the **continuous integration** toward more exotic compilers such as Android NDK, Intel's Compiler, or the bleeding-edge versions Clang.
- Improving the efficiency of the **JSON parser**. The current parser is implemented as a naive recursive descent parser with hand coded string handling. More sophisticated approaches like LALR parsers would be really appreciated. That said, parser generators like Bison or ANTLR do not play nice with single-header files -- I really would like to keep the parser inside the `json.hpp` header, and I am not aware of approaches similar to [`re2c`](http://re2c.org) for parsing.
- Extending and updating existing **benchmarks** to include (the most recent version of) this library. Though efficiency is not everything, speed and memory consumption are very important characteristics for C++ developers, so having proper comparisons would be interesting.

2
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,2 @@
github: nlohmann
custom: http://paypal.me/nlohmann

57
.github/ISSUE_TEMPLATE/Bug_report.md vendored Normal file
View File

@@ -0,0 +1,57 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'kind: bug'
assignees: ''
---
<!-- Provide a concise summary of the issue in the title above. -->
#### What is the issue you have?
<!-- Provide a detailed introduction to the issue itself, and why you consider it to be a bug. -->
<!-- If possible, be specific and add stack traces, error messages, etc. Avoid vague terms like "crash" or "doesn't work". -->
#### Please describe the steps to reproduce the issue.
<!-- Provide a link to a live example, or an unambiguous set of steps to -->
<!-- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
#### Can you provide a small but working code example?
<!-- Please understand that we cannot analyze and debug large code bases. -->
#### What is the expected behavior?
<!-- Tell us what should happen -->
#### And what is the actual behavior instead?
<!-- Tell us what happens instead. -->
#### Which compiler and operating system are you using?
<!-- Include as many relevant details about the environment you experienced the bug in. -->
<!-- Make sure you use a supported compiler, see https://github.com/nlohmann/json#supported-compilers. -->
- Compiler: ___
- Operating system: ___
#### Which version of the library did you use?
<!-- Please add an `x` to the respective line. -->
- [ ] latest release version 3.9.0
- [ ] other release - please state the version: ___
- [ ] the `develop` branch
#### If you experience a compilation error: can you [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests)?
- [ ] yes
- [ ] no - please copy/paste the error message below

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Ask a question
url: https://github.com/nlohmann/json/discussions
about: Ask questions and discuss with other community members

View File

@@ -1,46 +1,19 @@
[Describe your pull request here. Please read the text below the line, and make sure you follow the checklist.]
## Files to change
* * *
There are currently two files which need to be edited:
## Pull request checklist
1. [`src/json.hpp.re2c`](https://github.com/nlohmann/json/blob/master/src/json.hpp.re2c) (note the `.re2c` suffix) - This file contains a comment section which describes the JSON lexic. This section is translated by [`re2c`](http://re2c.org) into file [`src/json.hpp`](https://github.com/nlohmann/json/blob/master/src/json.hpp) which is plain "vanilla" C++11 code. (In fact, the generated lexer consists of some hundred lines of `goto`s, which is a hint you never want to edit this file...).
Read the [Contribution Guidelines](https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md) for detailed information.
If you only edit file `src/json.hpp` (without the `.re2c` suffix), your changes will be overwritten as soon as the lexer is touched again. To generate the `src/json.hpp` file which is actually used during compilation of the tests and all other code, please execute
```sh
make re2c
```
To run [`re2c`](http://re2c.org) and generate/overwrite file `src/json.hpp` with your changes in file `src/json.hpp.re2c`.
2. [`test/src/unit.cpp`](https://github.com/nlohmann/json/blob/master/test/unit.cpp) - This contains the [Catch](https://github.com/philsquared/Catch) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code.
If you add or change a feature, please also add a unit test to this file. The unit tests can be compiled with
```sh
make
```
and can be executed with
```sh
./json_unit
```
The test cases are also executed with several different compilers on [Travis](https://travis-ci.org/nlohmann/json) once you open a pull request.
Please understand that I cannot accept pull requests changing only file `src/json.hpp`.
## Note
- If you open a pull request, the code will be automatically tested with [Valgrind](http://valgrind.org)'s Memcheck tool to detect memory leaks. Please be aware that the execution with Valgrind _may_ in rare cases yield different behavior than running the code directly. This can result in failing unit tests which run successfully without Valgrind.
- [ ] Changes are described in the pull request, or an [existing issue is referenced](https://github.com/nlohmann/json/issues).
- [ ] The test suite [compiles and runs](https://github.com/nlohmann/json/blob/develop/README.md#execute-unit-tests) without error.
- [ ] [Code coverage](https://coveralls.io/github/nlohmann/json) is 100%. Test cases can be added by editing the [test suite](https://github.com/nlohmann/json/tree/develop/test/src).
- [ ] The source code is amalgamated; that is, after making changes to the sources in the `include/nlohmann` directory, run `make amalgamate` to create the single-header file `single_include/nlohmann/json.hpp`. The whole process is described [here](https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md#files-to-change).
## Please don't
- Only make changes to file `src/json.hpp` -- please read the paragraph above and understand why `src/json.hpp.re2c` exists.
- The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.8 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means.
- The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means.
- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
- Please refrain from proposing changes that would **break [JSON](http://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
- Please refrain from proposing changes that would **break [JSON](https://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
- Please do not open pull requests that address **multiple issues**.

5
.github/SECURITY.md vendored Normal file
View File

@@ -0,0 +1,5 @@
# Security Policy
## Reporting a Vulnerability
Usually, all issues are tracked publicly on [GitHub](https://github.com/nlohmann/json/issues). If you want to make a private report (e.g., for a vulnerability or to attach an example that is not meant to be published), please send an email to <mail@nlohmann.me>. You can use [this key](https://keybase.io/nlohmann/pgp_keys.asc?fingerprint=797167ae41c0a6d9232e48457f3cea63ae251b69) for encryption.

19
.github/config.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
# Configuration for sentiment-bot - https://github.com/behaviorbot/sentiment-bot
# *Required* toxicity threshold between 0 and .99 with the higher numbers being the most toxic
# Anything higher than this threshold will be marked as toxic and commented on
sentimentBotToxicityThreshold: .7
# *Required* Comment to reply with
sentimentBotReplyComment: >
Please be sure to review the [code of conduct](https://github.com/nlohmann/json/blob/develop/CODE_OF_CONDUCT.md) and be respectful of other users. cc/ @nlohmann
# Configuration for request-info - https://github.com/behaviorbot/request-info
# *Required* Comment to reply with
requestInfoReplyComment: >
We would appreciate it if you could provide us with more info about this issue or pull request! Please check the [issue template](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE.md) and the [pull request template](https://github.com/nlohmann/json/blob/develop/.github/PULL_REQUEST_TEMPLATE.md).
# *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given
requestInfoLabelToAdd: "state: needs more info"

17
.github/stale.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 30
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: "state: stale"
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

54
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,54 @@
name: "Code scanning - action"
on:
push:
branches: [develop, ]
pull_request:
# The branches below must be a subset of the branches above
branches: [develop]
schedule:
- cron: '0 19 * * 1'
jobs:
CodeQL-Build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

17
.github/workflows/macos.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: macOS
on: [push, pull_request]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
- name: build
run: cmake --build build --parallel 10
- name: test
run: cd build ; ctest -j 10 --output-on-failure

17
.github/workflows/ubuntu.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: Ubuntu
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
- name: build
run: cmake --build build --parallel 10
- name: test
run: cd build ; ctest -j 10 --output-on-failure

68
.github/workflows/windows.yml vendored Normal file
View File

@@ -0,0 +1,68 @@
name: Windows
on: [push, pull_request]
jobs:
msvc2019:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: cmake
run: cmake -S . -B build -G "Visual Studio 16 2019" -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
- name: build
run: cmake --build build --parallel 10
- name: test
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
clang9:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: install Clang
run: curl -fsSL -o LLVM9.exe https://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe ; 7z x LLVM9.exe -y -o"C:/Program Files/LLVM"
- name: cmake
run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
- name: build
run: cmake --build build --parallel 10
- name: test
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
clang10:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: install Clang
run: curl -fsSL -o LLVM10.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/LLVM-10.0.0-win64.exe ; 7z x LLVM10.exe -y -o"C:/Program Files/LLVM"
- name: cmake
run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
- name: build
run: cmake --build build --parallel 10
- name: test
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
clang-cl-10-x64:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: cmake
run: cmake -S . -B build -G "Visual Studio 16 2019" -A x64 -T ClangCL -DJSON_BuildTests=On
- name: build
run: cmake --build build --config Debug --parallel 10
- name: test
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
clang-cl-10-x86:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: cmake
run: cmake -S . -B build -G "Visual Studio 16 2019" -A Win32 -T ClangCL -DJSON_BuildTests=On
- name: build
run: cmake --build build --config Debug --parallel 10
- name: test
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure

21
.gitignore vendored
View File

@@ -1,5 +1,6 @@
json_unit
json_benchmarks
json_benchmarks_simple
fuzz-testing
*.dSYM
@@ -7,10 +8,28 @@ fuzz-testing
*.gcno
*.gcda
working
build
build_coverage
clang_analyze_build
doc/xml
doc/html
me.nlohmann.json.docset
benchmarks/files/numbers/*.json
.wsjcpp-logs/*
.wsjcpp/*
.idea
/cmake-build-*
test/test-*
/.vs
doc/mkdocs/venv/
doc/mkdocs/docs/images
doc/mkdocs/docs/examples
doc/mkdocs/site
doc/mkdocs/docs/__pycache__/
doc/xml

View File

@@ -7,17 +7,7 @@ language: cpp
dist: trusty
sudo: required
###################
# global settings #
###################
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA="
group: edge
################
@@ -28,21 +18,31 @@ matrix:
include:
# Valgrind
- os: linux
compiler: gcc
env:
- COMPILER=g++-4.9
- SPECIAL=valgrind
- CMAKE_OPTIONS=-DJSON_Valgrind=ON
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: [g++-4.9, valgrind]
after_success:
- valgrind --error-exitcode=1 --leak-check=full test/json_unit
packages: ['g++-4.9', 'valgrind', 'ninja-build']
# clang sanitizer
- os: linux
compiler: clang
env:
- COMPILER=clang++-7
- CMAKE_OPTIONS=-DJSON_Sanitizer=ON
- UBSAN_OPTIONS=print_stacktrace=1,suppressions=$(pwd)/test/src/UBSAN.supp
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
packages: ['g++-6', 'clang-7', 'ninja-build']
before_script:
- export PATH=$PATH:/usr/lib/llvm-7/bin
# cppcheck
- os: linux
compiler: gcc
env:
@@ -51,92 +51,122 @@ matrix:
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: [g++-4.9, cppcheck]
packages: ['g++-4.9', 'cppcheck', 'ninja-build']
after_success:
- make cppcheck
# no exceptions
- os: linux
compiler: gcc
env:
- COMPILER=g++-4.9
- CMAKE_OPTIONS=-DJSON_NoExceptions=ON
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'ninja-build']
# check amalgamation
- os: linux
compiler: gcc
env:
- COMPILER=g++-4.9
- SPECIAL=amalgamation
- MULTIPLE_HEADERS=ON
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'astyle', 'ninja-build']
after_success:
- make check-amalgamation
# Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/)
- os: linux
compiler: gcc
dist: bionic
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'ruby']
packages: ['g++-7', 'ninja-build']
before_script:
- wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz
- tar xf lcov_1.11.orig.tar.gz
- sudo make -C lcov-1.11/ install
- gem install coveralls-lcov
- pip install --user cpp-coveralls
after_success:
- make clean
- CXXFLAGS="--coverage -g -O0" CPPFLAGS="-DNDEBUG" make
- test/json_unit "*"
- coveralls --build-root test --exclude src/catch.hpp --exclude src/unit-algorithms.cpp --exclude src/unit-allocator.cpp --exclude src/unit-capacity.cpp --exclude src/unit-class_const_iterator.cpp --exclude src/unit-class_iterator.cpp --exclude src/unit-class_lexer.cpp --exclude src/unit-class_parser.cpp --exclude src/unit-comparison.cpp --exclude src/unit-concepts.cpp --exclude src/unit-constructor1.cpp --exclude src/unit-constructor2.cpp --exclude src/unit-convenience.cpp --exclude src/unit-conversions.cpp --exclude src/unit-deserialization.cpp --exclude src/unit-element_access1.cpp --exclude src/unit-element_access2.cpp --exclude src/unit-inspection.cpp --exclude src/unit-iterator_wrapper.cpp --exclude src/unit-iterators1.cpp --exclude src/unit-iterators2.cpp --exclude src/unit-json_patch.cpp --exclude src/unit-json_pointer.cpp --exclude src/unit-modifiers.cpp --exclude src/unit-pointer_access.cpp --exclude src/unit-readme.cpp --exclude src/unit-reference_access.cpp --exclude src/unit-regression.cpp --exclude src/unit-serialization.cpp --exclude src/unit-testsuites.cpp --exclude src/unit-unicode.cpp --include ../src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9'
- lcov --directory src --directory test/src --capture --output-file coverage.info --rc lcov_branch_coverage=1 --no-external
- lcov --remove coverage.info 'test/src/*' --output-file coverage.info --rc lcov_branch_coverage=1
- lcov --list coverage.info --rc lcov_branch_coverage=1
- coveralls-lcov --repo-token F9bs4Nop10JRgqPQXRcifyQKYhb3FczkS coverage.info
- coveralls --build-root test --include include/nlohmann --gcov 'gcov-7' --gcov-options '\-lp'
env:
- COMPILER=g++-4.9
- SPECIAL=coveralls
- COMPILER=g++-7
- CMAKE_OPTIONS=-DJSON_Coverage=ON
- MULTIPLE_HEADERS=ON
# Coverity (only for branch coverity_scan)
- os: linux
compiler: gcc
compiler: clang
before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5', 'valgrind']
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: ['g++-6', 'clang-3.6', 'ninja-build']
coverity_scan:
project:
name: "nlohmann/json"
description: "Build submitted via Travis CI"
notification_email: niels.lohmann@gmail.com
build_command_prepend: "make clean ; sudo cp $(which g++-5) $(which g++)"
build_command: "make"
build_command_prepend: "mkdir coverity_build ; cd coverity_build ; cmake .. ; cd .."
build_command: "make -C coverity_build"
branch_pattern: coverity_scan
env:
- COMPILER=g++-5
- SPECIAL=coverity
- COMPILER=clang++-3.6
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA="
# OSX / Clang
- os: osx
osx_image: beta-xcode6.1
osx_image: xcode9.3
- os: osx
osx_image: beta-xcode6.2
osx_image: xcode9.4
- os: osx
osx_image: beta-xcode6.3
osx_image: xcode10
- os: osx
osx_image: xcode6.4
osx_image: xcode10.1
- os: osx
osx_image: xcode7.1
osx_image: xcode10.2
- os: osx
osx_image: xcode7.2
osx_image: xcode11.2
- os: osx
osx_image: xcode7.3
osx_image: xcode12
- os: osx
osx_image: xcode8
osx_image: xcode12
env:
- IMPLICIT_CONVERSIONS=OFF
# Linux / GCC
- os: linux
compiler: gcc
env: COMPILER=g++-4.8
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.8', 'ninja-build']
- os: linux
compiler: gcc
env: COMPILER=g++-4.9
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: g++-4.9
packages: ['g++-4.9', 'ninja-build']
- os: linux
compiler: gcc
@@ -144,7 +174,7 @@ matrix:
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: g++-5
packages: ['g++-5', 'ninja-build']
- os: linux
compiler: gcc
@@ -152,157 +182,167 @@ matrix:
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: g++-6
packages: ['g++-6', 'ninja-build']
- os: linux
compiler: gcc
env: COMPILER=g++-7
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-7', 'ninja-build']
- os: linux
compiler: gcc
env: COMPILER=g++-8
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-8', 'ninja-build']
- os: linux
compiler: gcc
env: COMPILER=g++-9
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-9', 'ninja-build']
- os: linux
compiler: gcc
env:
- COMPILER=g++-9
- IMPLICIT_CONVERSIONS=OFF
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-9', 'ninja-build']
- os: linux
compiler: gcc
env:
- COMPILER=g++-9
- CXXFLAGS=-std=c++2a
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-9', 'ninja-build']
# Linux / Clang
- os: linux
env: LLVM_VERSION=3.6.0
compiler: clang
env: COMPILER=clang++-3.5
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5']
packages: ['g++-6', 'clang-3.5', 'ninja-build']
- os: linux
env: LLVM_VERSION=3.6.1
compiler: clang
env: COMPILER=clang++-3.6
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: ['g++-6', 'clang-3.6', 'ninja-build']
- os: linux
env: LLVM_VERSION=3.6.2
compiler: clang
env: COMPILER=clang++-3.7
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
packages: ['g++-6', 'clang-3.7', 'ninja-build']
- os: linux
env: LLVM_VERSION=3.7.0
compiler: clang
env: COMPILER=clang++-3.8
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6', 'clang-3.8', 'ninja-build']
- os: linux
env: LLVM_VERSION=3.7.1
compiler: clang
env: COMPILER=clang++-3.9
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6', 'clang-3.9', 'ninja-build']
- os: linux
env: LLVM_VERSION=3.8.0
compiler: clang
env: COMPILER=clang++-4.0
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0']
packages: ['g++-6', 'clang-4.0', 'ninja-build']
- os: linux
env: LLVM_VERSION=3.8.1
compiler: clang
env: COMPILER=clang++-5.0
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
packages: ['g++-6', 'clang-5.0', 'ninja-build']
#####################
# installation step #
#####################
- os: linux
compiler: clang
env: COMPILER=clang++-6.0
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0']
packages: ['g++-6', 'clang-6.0', 'ninja-build']
# set directories to cache
cache:
directories:
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.2
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.1
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.0
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.7.0
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.7.1
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.8.0
- ${TRAVIS_BUILD_DIR}/deps/llvm-3.8.1
- os: linux
compiler: clang
env: COMPILER=clang++-7
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
packages: ['g++-6', 'clang-7', 'ninja-build']
install:
# create deps dir if not existing
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
- mkdir -p ${DEPS_DIR}
# make sure CXX is correctly set
- if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi
# install LLVM/clang when LLVM_VERSION is set
- |
if [[ "${LLVM_VERSION}" != "" ]]; then
LLVM_DIR=${DEPS_DIR}/llvm-${LLVM_VERSION}
if [[ -z "$(ls -A ${LLVM_DIR})" ]]; then
travis_retry wget --quiet https://cmake.org/files/v3.6/cmake-3.6.1.tar.gz
tar xfz cmake-3.6.1.tar.gz
(cd cmake-3.6.1 && ./configure --prefix=${LLVM_DIR}/cmake && make install)
export PATH="${LLVM_DIR}/cmake/bin:${PATH}"
LLVM_URL="http://llvm.org/releases/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.xz"
LIBCXX_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxx-${LLVM_VERSION}.src.tar.xz"
LIBCXXABI_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxxabi-${LLVM_VERSION}.src.tar.xz"
CLANG_URL="http://llvm.org/releases/${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz"
mkdir -p ${LLVM_DIR} ${LLVM_DIR}/build ${LLVM_DIR}/projects/libcxx ${LLVM_DIR}/projects/libcxxabi ${LLVM_DIR}/clang
travis_retry wget --quiet -O - ${LLVM_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}
travis_retry wget --quiet -O - ${LIBCXX_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/projects/libcxx
travis_retry wget --quiet -O - ${LIBCXXABI_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/projects/libcxxabi
travis_retry wget --quiet -O - ${CLANG_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/clang
(cd ${LLVM_DIR}/build && cmake .. -DCMAKE_INSTALL_PREFIX=${LLVM_DIR}/install -DCMAKE_CXX_COMPILER=clang++)
(cd ${LLVM_DIR}/build/projects/libcxx && make install -j2)
(cd ${LLVM_DIR}/build/projects/libcxxabi && make install -j2)
fi
export CXXFLAGS="-nostdinc++ -isystem ${LLVM_DIR}/install/include/c++/v1"
export LDFLAGS="-L ${LLVM_DIR}/install/lib -l c++ -l c++abi"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LLVM_DIR}/install/lib"
export PATH="${LLVM_DIR}/clang/bin:${PATH}"
fi
- os: linux
compiler: clang
env:
- COMPILER=clang++-7
- CXXFLAGS=-std=c++1z
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
packages: ['g++-6', 'clang-7', 'ninja-build']
################
# build script #
################
script:
# show OS/compiler version
- uname -a
- $CXX --version
# get CMake and Ninja (only for systems with brew - macOS)
- |
if [[ (-x $(which brew)) ]]; then
brew update
brew install cmake ninja
brew upgrade cmake
cmake --version
fi
# compile
- make
# make sure CXX is correctly set
- if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi
# by default, use the single-header version
- if [[ "${MULTIPLE_HEADERS}" == "" ]]; then export MULTIPLE_HEADERS=OFF; fi
# by default, use implicit conversions
- if [[ "${IMPLICIT_CONVERSIONS}" == "" ]]; then export IMPLICIT_CONVERSIONS=ON; fi
# execute unit tests
- test/json_unit "*"
# compile and execute unit tests
- mkdir -p build && cd build
- cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_ImplicitConversions=${IMPLICIT_CONVERSIONS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release
- ctest -C Release --timeout 2700 -V -j
- cd ..
# check if homebrew works (only checks develop branch)
- if [ `which brew` ]; then
brew update ;
brew tap nlohmann/json ;
brew install nlohmann_json --HEAD ;
brew test nlohmann_json ;
# check if homebrew works (only checks develop branch)
- if [ `which brew` ]; then
brew update ;
brew tap nlohmann/json ;
brew install nlohmann_json --HEAD ;
brew test nlohmann_json ;
fi
#language: cpp
#
#dist: trusty
#sudo: required
#
#env:
# global:
# # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# # via the "travis encrypt" command using the project repo's public key
# - secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA="
#
## from http://stackoverflow.com/a/32127147/266378
#matrix:
# include:
# - os: linux
# compiler: gcc
# addons:
# apt:
# sources: ['ubuntu-toolchain-r-test']
# packages: ['g++-4.9', 'valgrind', 'python-pip', 'python-yaml']
# before_script:
# - pip install --user git+git://github.com/eddyxu/cpp-coveralls.git
# after_success:
# - make clean
# - touch src/json.hpp
# - make json_unit CXXFLAGS="-fprofile-arcs -ftest-coverage -std=c++11 -lstdc++" CXX=$COMPILER
# - test/json_unit "*"
# - coveralls --build-root test --exclude src/catch.hpp --exclude src/unit-algorithms.cpp --exclude src/unit-allocator.cpp --exclude src/unit-capacity.cpp --exclude src/unit-class_const_iterator.cpp --exclude src/unit-class_iterator.cpp --exclude src/unit-class_lexer.cpp --exclude src/unit-class_parser.cpp --exclude src/unit-comparison.cpp --exclude src/unit-concepts.cpp --exclude src/unit-constructor1.cpp --exclude src/unit-constructor2.cpp --exclude src/unit-convenience.cpp --exclude src/unit-conversions.cpp --exclude src/unit-deserialization.cpp --exclude src/unit-element_access1.cpp --exclude src/unit-element_access2.cpp --exclude src/unit-inspection.cpp --exclude src/unit-iterator_wrapper.cpp --exclude src/unit-iterators1.cpp --exclude src/unit-iterators2.cpp --exclude src/unit-json_patch.cpp --exclude src/unit-json_pointer.cpp --exclude src/unit-modifiers.cpp --exclude src/unit-pointer_access.cpp --exclude src/unit-readme.cpp --exclude src/unit-reference_access.cpp --exclude src/unit-regression.cpp --exclude src/unit-serialization.cpp --exclude src/unit-testsuites.cpp --exclude src/unit-unicode.cpp --include ../src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9'
# env: COMPILER=g++-4.9
#
# - os: linux
# compiler: gcc
# before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
# addons:
# apt:
# sources: ['ubuntu-toolchain-r-test']
# packages: ['g++-5', 'valgrind']
# coverity_scan:
# project:
# name: "nlohmann/json"
# description: "Build submitted via Travis CI"
# notification_email: niels.lohmann@gmail.com
# build_command_prepend: "make clean ; sudo cp $(which g++-5) $(which g++)"
# build_command: "make"
# branch_pattern: coverity_scan
# env: COMPILER=g++-5
#

View File

@@ -1,54 +1,163 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.1)
# define the project
project(nlohmann_json VERSION 2.0.3 LANGUAGES CXX)
##
## PROJECT
## name and version
##
project(nlohmann_json VERSION 3.9.0 LANGUAGES CXX)
enable_testing()
##
## INCLUDE
##
##
include(ExternalProject)
option(BuildTests "Build the unit tests" ON)
##
## OPTIONS
##
# define project variables
set(JSON_TARGET_NAME ${PROJECT_NAME})
set(JSON_PACKAGE_NAME ${JSON_TARGET_NAME})
set(JSON_TARGETS_FILENAME "${JSON_PACKAGE_NAME}Targets.cmake")
set(JSON_CONFIG_FILENAME "${JSON_PACKAGE_NAME}Config.cmake")
set(JSON_CONFIGVERSION_FILENAME "${JSON_PACKAGE_NAME}ConfigVersion.cmake")
set(JSON_CONFIG_DESTINATION "cmake")
set(JSON_INCLUDE_DESTINATION "include/nlohmann")
if (POLICY CMP0077)
# Allow CMake 3.13+ to override options when using FetchContent / add_subdirectory.
cmake_policy(SET CMP0077 NEW)
endif ()
# create and configure the library target
add_library(${JSON_TARGET_NAME} INTERFACE)
target_include_directories(${JSON_TARGET_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${JSON_INCLUDE_DESTINATION}>)
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ON)
option(JSON_Install "Install CMake targets during install step." ON)
option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF)
option(JSON_ImplicitConversions "Enable implicit conversions." ON)
# create and configure the unit test target
if (BuildTests)
##
## CONFIGURATION
##
include(GNUInstallDirs)
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE INTERNAL "")
set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in")
set(NLOHMANN_JSON_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
set(NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake")
set(NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Targets.cmake")
if (JSON_MultipleHeaders)
set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include/")
message(STATUS "Using the multi-header code from ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}")
else()
set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/single_include/")
message(STATUS "Using the single-header code from ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}")
endif()
if (NOT JSON_ImplicitConversions)
message(STATUS "Implicit conversions are disabled")
endif()
##
## TARGET
## create target and add include path
##
add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE)
add_library(${PROJECT_NAME}::${NLOHMANN_JSON_TARGET_NAME} ALIAS ${NLOHMANN_JSON_TARGET_NAME})
if (${CMAKE_VERSION} VERSION_LESS "3.8.0")
target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_range_for)
else()
target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11)
endif()
target_compile_definitions(
${NLOHMANN_JSON_TARGET_NAME}
INTERFACE
JSON_USE_IMPLICIT_CONVERSIONS=$<BOOL:${JSON_ImplicitConversions}>
)
target_include_directories(
${NLOHMANN_JSON_TARGET_NAME}
INTERFACE
$<BUILD_INTERFACE:${NLOHMANN_JSON_INCLUDE_BUILD_DIR}>
$<INSTALL_INTERFACE:include>
)
## add debug view definition file for msvc (natvis)
if (MSVC)
set(NLOHMANN_ADD_NATVIS TRUE)
set(NLOHMANN_NATVIS_FILE "nlohmann_json.natvis")
target_sources(
${NLOHMANN_JSON_TARGET_NAME}
INTERFACE
$<INSTALL_INTERFACE:${NLOHMANN_NATVIS_FILE}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${NLOHMANN_NATVIS_FILE}>
)
endif()
# Install a pkg-config file, so other tools can find this.
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
)
##
## TESTS
## create and configure the unit test target
##
include(CTest) #adds option BUILD_TESTING (default ON)
if(BUILD_TESTING AND JSON_BuildTests)
enable_testing()
add_subdirectory(test)
endif()
# generate a config and config version file for the package
##
## INSTALL
## install header files, generate and install cmake config files for find_package()
##
include(CMakePackageConfigHelpers)
configure_package_config_file("cmake/config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIG_FILENAME}"
INSTALL_DESTINATION ${JSON_CONFIG_DESTINATION})
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIGVERSION_FILENAME}"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
# use a custom package version config file instead of
# write_basic_package_version_file to ensure that it's architecture-independent
# https://github.com/nlohmann/json/issues/1697
configure_file(
"cmake/nlohmann_jsonConfigVersion.cmake.in"
${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE}
@ONLY
)
configure_file(
${NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE}
${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE}
@ONLY
)
# export the library target and store build directory in package registry
export(TARGETS ${JSON_TARGET_NAME}
FILE "${CMAKE_CURRENT_BINARY_DIR}/${JSON_TARGETS_FILENAME}")
export(PACKAGE ${JSON_PACKAGE_NAME})
# install library target and config files
install(TARGETS ${JSON_TARGET_NAME}
EXPORT ${JSON_PACKAGE_NAME})
install(FILES "src/json.hpp"
DESTINATION ${JSON_INCLUDE_DESTINATION})
install(EXPORT ${JSON_PACKAGE_NAME}
FILE ${JSON_TARGETS_FILENAME}
DESTINATION ${JSON_CONFIG_DESTINATION})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIG_FILENAME}"
"${CMAKE_CURRENT_BINARY_DIR}/${JSON_CONFIGVERSION_FILENAME}"
DESTINATION ${JSON_CONFIG_DESTINATION})
if(JSON_Install)
install(
DIRECTORY ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}
DESTINATION ${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}
)
install(
FILES ${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE} ${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE}
DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
)
if (NLOHMANN_ADD_NATVIS)
install(
FILES ${NLOHMANN_NATVIS_FILE}
DESTINATION .
)
endif()
export(
TARGETS ${NLOHMANN_JSON_TARGET_NAME}
NAMESPACE ${PROJECT_NAME}::
FILE ${NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE}
)
install(
TARGETS ${NLOHMANN_JSON_TARGET_NAME}
EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME}
INCLUDES DESTINATION ${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}
)
install(
EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME}
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
)
install(
FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
DESTINATION lib/pkgconfig
)
endif()

46
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at mail@nlohmann.me. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,13 @@
The library is licensed under the MIT License
<http://opensource.org/licenses/MIT>:
MIT License
Copyright (c) 2013-2016 Niels Lohmann
Copyright (c) 2013-2020 Niels Lohmann
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

649
Makefile
View File

@@ -1,35 +1,66 @@
.PHONY: pretty clean ChangeLog.md
.PHONY: pretty clean ChangeLog.md release
# used programs
RE2C = re2c
SED = sed
##########################################################################
# configuration
##########################################################################
# directory to recent compiler binaries
COMPILER_DIR=/usr/local/opt/llvm/bin
# find GNU sed to use `-i` parameter
SED:=$(shell command -v gsed || which sed)
##########################################################################
# source files
##########################################################################
# the list of sources in the include folder
SRCS=$(shell find include -type f | sort)
# the single header (amalgamated from the source files)
AMALGAMATED_FILE=single_include/nlohmann/json.hpp
##########################################################################
# documentation of the Makefile's targets
##########################################################################
# main target
all: json_unit
# clean up
clean:
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM
rm -fr benchmarks/files/numbers/*.json
$(MAKE) clean -Cdoc
$(MAKE) clean -Ctest
all:
@echo "amalgamate - amalgamate file single_include/nlohmann/json.hpp from the include/nlohmann sources"
@echo "ChangeLog.md - generate ChangeLog file"
@echo "check-amalgamation - check whether sources have been amalgamated"
@echo "clean - remove built files"
@echo "coverage - create coverage information with lcov"
@echo "cppcheck - analyze code with cppcheck"
@echo "cpplint - analyze code with cpplint"
@echo "clang_tidy - analyze code with Clang-Tidy"
@echo "clang_analyze - analyze code with Clang-Analyzer"
@echo "doctest - compile example files and check their output"
@echo "fuzz_testing - prepare fuzz testing of the JSON parser"
@echo "fuzz_testing_bson - prepare fuzz testing of the BSON parser"
@echo "fuzz_testing_cbor - prepare fuzz testing of the CBOR parser"
@echo "fuzz_testing_msgpack - prepare fuzz testing of the MessagePack parser"
@echo "fuzz_testing_ubjson - prepare fuzz testing of the UBJSON parser"
@echo "pedantic_clang - run Clang with maximal warning flags"
@echo "pedantic_gcc - run GCC with maximal warning flags"
@echo "pretty - beautify code with Artistic Style"
@echo "run_benchmarks - build and run benchmarks"
##########################################################################
# unit tests
# coverage
##########################################################################
# build unit tests
json_unit:
@$(MAKE) -C test
# run unit tests
check: json_unit
test/json_unit "*"
check-fast: json_unit
test/json_unit
coverage:
rm -fr cmake-build-coverage
mkdir cmake-build-coverage
cd cmake-build-coverage ; cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON
cd cmake-build-coverage ; ninja
cd cmake-build-coverage ; ctest -j10
cd cmake-build-coverage ; ninja lcov_html
open cmake-build-coverage/test/html/index.html
##########################################################################
# documentation tests
@@ -40,6 +71,315 @@ doctest:
$(MAKE) check_output -C doc
##########################################################################
# warning detector
##########################################################################
# calling Clang with all warnings, except:
# -Wno-c++2a-compat: u8 literals will behave differently in C++20...
# -Wno-deprecated-declarations: the library deprecated some functions
# -Wno-documentation-unknown-command: code uses user-defined commands like @complexity
# -Wno-exit-time-destructors: warning in json code triggered by NLOHMANN_JSON_SERIALIZE_ENUM
# -Wno-float-equal: not all comparisons in the tests can be replaced by Approx
# -Wno-keyword-macro: unit-tests use "#define private public"
# -Wno-missing-prototypes: for NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE
# -Wno-padded: padding is nothing to warn about
# -Wno-range-loop-analysis: items tests "for(const auto i...)"
# -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches
# -Wno-weak-vtables: exception class is defined inline, but has virtual method
pedantic_clang:
rm -fr cmake-build-pedantic
CXXFLAGS=" \
-std=c++11 -Wno-c++98-compat -Wno-c++98-compat-pedantic \
-Werror \
-Weverything \
-Wno-c++2a-compat \
-Wno-deprecated-declarations \
-Wno-documentation-unknown-command \
-Wno-exit-time-destructors \
-Wno-float-equal \
-Wno-keyword-macro \
-Wno-missing-prototypes \
-Wno-padded \
-Wno-range-loop-analysis \
-Wno-switch-enum -Wno-covered-switch-default \
-Wno-weak-vtables" cmake -S . -B cmake-build-pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On
cmake --build cmake-build-pedantic
# calling GCC with most warnings
pedantic_gcc:
rm -fr cmake-build-pedantic
CXXFLAGS=" \
-std=c++11 \
-pedantic \
-Werror \
--all-warnings \
--extra-warnings \
-W \
-Wno-abi-tag \
-Waddress \
-Waddress-of-packed-member \
-Wno-aggregate-return \
-Waggressive-loop-optimizations \
-Waligned-new=all \
-Wall \
-Walloc-zero \
-Walloca \
-Wanalyzer-double-fclose \
-Wanalyzer-double-free \
-Wanalyzer-exposure-through-output-file \
-Wanalyzer-file-leak \
-Wanalyzer-free-of-non-heap \
-Wanalyzer-malloc-leak \
-Wanalyzer-null-argument \
-Wanalyzer-null-dereference \
-Wanalyzer-possible-null-argument \
-Wanalyzer-possible-null-dereference \
-Wanalyzer-stale-setjmp-buffer \
-Wanalyzer-tainted-array-index \
-Wanalyzer-too-complex \
-Wanalyzer-unsafe-call-within-signal-handler \
-Wanalyzer-use-after-free \
-Wanalyzer-use-of-pointer-in-stale-stack-frame \
-Warith-conversion \
-Warray-bounds \
-Warray-bounds=2 \
-Wattribute-alias=2 \
-Wattribute-warning \
-Wattributes \
-Wbool-compare \
-Wbool-operation \
-Wbuiltin-declaration-mismatch \
-Wbuiltin-macro-redefined \
-Wc++0x-compat \
-Wc++11-compat \
-Wc++14-compat \
-Wc++17-compat \
-Wc++1z-compat \
-Wc++20-compat \
-Wc++2a-compat \
-Wcannot-profile \
-Wcast-align \
-Wcast-align=strict \
-Wcast-function-type \
-Wcast-qual \
-Wcatch-value=3 \
-Wchar-subscripts \
-Wclass-conversion \
-Wclass-memaccess \
-Wclobbered \
-Wcomma-subscript \
-Wcomment \
-Wcomments \
-Wconditionally-supported \
-Wconversion \
-Wconversion-null \
-Wcoverage-mismatch \
-Wcpp \
-Wctor-dtor-privacy \
-Wdangling-else \
-Wdate-time \
-Wdelete-incomplete \
-Wdelete-non-virtual-dtor \
-Wdeprecated \
-Wdeprecated-copy \
-Wdeprecated-copy-dtor \
-Wdeprecated-declarations \
-Wdisabled-optimization \
-Wdiv-by-zero \
-Wdouble-promotion \
-Wduplicated-branches \
-Wduplicated-cond \
-Weffc++ \
-Wempty-body \
-Wendif-labels \
-Wenum-compare \
-Wexpansion-to-defined \
-Wextra \
-Wextra-semi \
-Wfloat-conversion \
-Wfloat-equal \
-Wformat -Wformat-contains-nul \
-Wformat -Wformat-extra-args \
-Wformat -Wformat-nonliteral \
-Wformat -Wformat-security \
-Wformat -Wformat-y2k \
-Wformat -Wformat-zero-length \
-Wformat-diag \
-Wformat-overflow=2 \
-Wformat-signedness \
-Wformat-truncation=2 \
-Wformat=2 \
-Wframe-address \
-Wfree-nonheap-object \
-Whsa \
-Wif-not-aligned \
-Wignored-attributes \
-Wignored-qualifiers \
-Wimplicit-fallthrough=5 \
-Winaccessible-base \
-Winherited-variadic-ctor \
-Winit-list-lifetime \
-Winit-self \
-Winline \
-Wint-in-bool-context \
-Wint-to-pointer-cast \
-Winvalid-memory-model \
-Winvalid-offsetof \
-Winvalid-pch \
-Wliteral-suffix \
-Wlogical-not-parentheses \
-Wlogical-op \
-Wno-long-long \
-Wlto-type-mismatch \
-Wmain \
-Wmaybe-uninitialized \
-Wmemset-elt-size \
-Wmemset-transposed-args \
-Wmisleading-indentation \
-Wmismatched-tags \
-Wmissing-attributes \
-Wmissing-braces \
-Wno-missing-declarations \
-Wmissing-field-initializers \
-Wmissing-include-dirs \
-Wmissing-profile \
-Wmultichar \
-Wmultiple-inheritance \
-Wmultistatement-macros \
-Wno-namespaces \
-Wnarrowing \
-Wno-noexcept \
-Wnoexcept-type \
-Wnon-template-friend \
-Wnon-virtual-dtor \
-Wnonnull \
-Wnonnull-compare \
-Wnonportable-cfstrings \
-Wnormalized=nfkc \
-Wnull-dereference \
-Wodr \
-Wold-style-cast \
-Wopenmp-simd \
-Woverflow \
-Woverlength-strings \
-Woverloaded-virtual \
-Wpacked \
-Wpacked-bitfield-compat \
-Wpacked-not-aligned \
-Wno-padded \
-Wparentheses \
-Wpedantic \
-Wpessimizing-move \
-Wplacement-new=2 \
-Wpmf-conversions \
-Wpointer-arith \
-Wpointer-compare \
-Wpragmas \
-Wprio-ctor-dtor \
-Wpsabi \
-Wredundant-decls \
-Wredundant-move \
-Wredundant-tags \
-Wregister \
-Wreorder \
-Wrestrict \
-Wreturn-local-addr \
-Wreturn-type \
-Wscalar-storage-order \
-Wsequence-point \
-Wshadow=compatible-local \
-Wshadow=global \
-Wshadow=local \
-Wshift-count-negative \
-Wshift-count-overflow \
-Wshift-negative-value \
-Wshift-overflow=2 \
-Wsign-compare \
-Wsign-conversion \
-Wsign-promo \
-Wsized-deallocation \
-Wsizeof-array-argument \
-Wsizeof-pointer-div \
-Wsizeof-pointer-memaccess \
-Wstack-protector \
-Wstrict-aliasing \
-Wstrict-aliasing=3 \
-Wstrict-null-sentinel \
-Wstrict-overflow \
-Wstrict-overflow=5 \
-Wstring-compare \
-Wstringop-overflow \
-Wstringop-overflow=4 \
-Wstringop-truncation \
-Wsubobject-linkage \
-Wsuggest-attribute=cold \
-Wsuggest-attribute=const \
-Wsuggest-attribute=format \
-Wsuggest-attribute=malloc \
-Wsuggest-attribute=noreturn \
-Wsuggest-attribute=pure \
-Wsuggest-final-methods \
-Wsuggest-final-types \
-Wsuggest-override \
-Wswitch \
-Wswitch-bool \
-Wswitch-default \
-Wno-switch-enum \
-Wswitch-outside-range \
-Wswitch-unreachable \
-Wsync-nand \
-Wsynth \
-Wno-system-headers \
-Wtautological-compare \
-Wno-templates \
-Wterminate \
-Wtrampolines \
-Wtrigraphs \
-Wtype-limits \
-Wundef \
-Wuninitialized \
-Wunknown-pragmas \
-Wunreachable-code \
-Wunsafe-loop-optimizations \
-Wunused \
-Wunused-but-set-parameter \
-Wunused-but-set-variable \
-Wunused-const-variable=2 \
-Wunused-function \
-Wunused-label \
-Wno-unused-local-typedefs \
-Wunused-macros \
-Wunused-parameter \
-Wunused-result \
-Wunused-value \
-Wunused-variable \
-Wuseless-cast \
-Wvarargs \
-Wvariadic-macros \
-Wvector-operation-performance \
-Wvirtual-inheritance \
-Wvirtual-move-assign \
-Wvla \
-Wvolatile \
-Wvolatile-register-var \
-Wwrite-strings \
-Wzero-as-null-pointer-constant \
-Wzero-length-bounds \
" cmake -S . -B cmake-build-pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On
cmake --build cmake-build-pedantic
##########################################################################
# benchmarks
##########################################################################
run_benchmarks:
rm -fr cmake-build-benchmarks
mkdir cmake-build-benchmarks
cd cmake-build-benchmarks ; cmake ../benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release -DJSON_BuildTests=On
cd cmake-build-benchmarks ; ninja
cd cmake-build-benchmarks ; ./json_benchmarks
##########################################################################
# fuzzing
##########################################################################
@@ -48,64 +388,257 @@ doctest:
fuzz_testing:
rm -fr fuzz-testing
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
$(MAKE) fuzz CXX=afl-clang++
mv fuzz fuzz-testing
$(MAKE) parse_afl_fuzzer -C test CXX=afl-clang++
mv test/parse_afl_fuzzer fuzz-testing/fuzzer
find test/data/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzz"
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
# the fuzzer binary
fuzz: test/src/fuzz.cpp src/json.hpp
$(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src $< $(LDFLAGS) -o $@
fuzz_testing_bson:
rm -fr fuzz-testing
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
$(MAKE) parse_bson_fuzzer -C test CXX=afl-clang++
mv test/parse_bson_fuzzer fuzz-testing/fuzzer
find test/data -size -5k -name *.bson | xargs -I{} cp "{}" fuzz-testing/testcases
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
fuzz_testing_cbor:
rm -fr fuzz-testing
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
$(MAKE) parse_cbor_fuzzer -C test CXX=afl-clang++
mv test/parse_cbor_fuzzer fuzz-testing/fuzzer
find test/data -size -5k -name *.cbor | xargs -I{} cp "{}" fuzz-testing/testcases
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
fuzz_testing_msgpack:
rm -fr fuzz-testing
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
$(MAKE) parse_msgpack_fuzzer -C test CXX=afl-clang++
mv test/parse_msgpack_fuzzer fuzz-testing/fuzzer
find test/data -size -5k -name *.msgpack | xargs -I{} cp "{}" fuzz-testing/testcases
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
fuzz_testing_ubjson:
rm -fr fuzz-testing
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
$(MAKE) parse_ubjson_fuzzer -C test CXX=afl-clang++
mv test/parse_ubjson_fuzzer fuzz-testing/fuzzer
find test/data -size -5k -name *.ubjson | xargs -I{} cp "{}" fuzz-testing/testcases
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
fuzzing-start:
afl-fuzz -S fuzzer1 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -S fuzzer2 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -S fuzzer3 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -S fuzzer4 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -S fuzzer5 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -S fuzzer6 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -S fuzzer7 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -M fuzzer0 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer
fuzzing-stop:
-killall fuzzer
-killall afl-fuzz
##########################################################################
# static analyzer
# Static analysis
##########################################################################
# call cppcheck on the main header file
# call cppcheck <http://cppcheck.sourceforge.net>
# Note: this target is called by Travis
cppcheck:
cppcheck --enable=warning --inconclusive --force --std=c++11 src/json.hpp --error-exitcode=1
cppcheck --enable=warning --inline-suppr --inconclusive --force --std=c++11 $(AMALGAMATED_FILE) --error-exitcode=1
# call Clang Static Analyzer <https://clang-analyzer.llvm.org>
clang_analyze:
rm -fr cmake-build-clang-analyze
mkdir cmake-build-clang-analyze
cd cmake-build-clang-analyze ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja -DJSON_BuildTests=On
cd cmake-build-clang-analyze ; \
$(COMPILER_DIR)/scan-build \
-enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull \
--use-c++=$(COMPILER_DIR)/clang++ -analyze-headers -o report ninja
open cmake-build-clang-analyze/report/*/index.html
# call cpplint <https://github.com/cpplint/cpplint>
# Note: some errors expected due to false positives
cpplint:
third_party/cpplint/cpplint.py \
--filter=-whitespace,-legal,-readability/alt_tokens,-runtime/references,-runtime/explicit \
--quiet --recursive $(SRCS)
# call Clang-Tidy <https://clang.llvm.org/extra/clang-tidy/>
clang_tidy:
$(COMPILER_DIR)/clang-tidy $(SRCS) -- -Iinclude -std=c++11
# call PVS-Studio Analyzer <https://www.viva64.com/en/pvs-studio/>
pvs_studio:
rm -fr cmake-build-pvs-studio
mkdir cmake-build-pvs-studio
cd cmake-build-pvs-studio ; cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DJSON_MultipleHeaders=ON
cd cmake-build-pvs-studio ; pvs-studio-analyzer analyze -j 10
cd cmake-build-pvs-studio ; plog-converter -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs
open cmake-build-pvs-studio/pvs/index.html
# call Infer <https://fbinfer.com> static analyzer
infer:
rm -fr cmake-build-infer
mkdir cmake-build-infer
cd cmake-build-infer ; infer compile -- cmake .. -DJSON_MultipleHeaders=ON ; infer run -- make -j 4
# call OCLint <http://oclint.org> static analyzer
oclint:
oclint $(SRCS) -report-type html -enable-global-analysis -o oclint_report.html -max-priority-1=10000 -max-priority-2=10000 -max-priority-3=10000 -- -std=c++11 -Iinclude
open oclint_report.html
# execute the test suite with Clang sanitizers (address and undefined behavior)
clang_sanitize:
rm -fr cmake-build-clang-sanitize
mkdir cmake-build-clang-sanitize
cd cmake-build-clang-sanitize ; CXX=$(COMPILER_DIR)/clang++ cmake .. -DJSON_Sanitizer=On -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On -GNinja
cd cmake-build-clang-sanitize ; ninja
cd cmake-build-clang-sanitize ; ctest -j10
clang_sanitize: clean
CXX=clang++ CXXFLAGS="-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" $(MAKE)
##########################################################################
# maintainer targets
# Code format and source amalgamation
##########################################################################
# create scanner with re2c
re2c: src/json.hpp.re2c
$(RE2C) -W --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp
# pretty printer
# call the Artistic Style pretty printer on all source files
pretty:
astyle --style=allman --indent=spaces=4 --indent-modifiers \
--indent-switches --indent-preproc-block --indent-preproc-define \
--indent-col1-comments --pad-oper --pad-header --align-pointer=type \
--align-reference=type --add-brackets --convert-tabs --close-templates \
--lineend=linux --preserve-date --suffix=none --formatted \
src/json.hpp src/json.hpp.re2c test/src/*.cpp \
benchmarks/benchmarks.cpp doc/examples/*.cpp
astyle \
--style=allman \
--indent=spaces=4 \
--indent-modifiers \
--indent-switches \
--indent-preproc-block \
--indent-preproc-define \
--indent-col1-comments \
--pad-oper \
--pad-header \
--align-pointer=type \
--align-reference=type \
--add-brackets \
--convert-tabs \
--close-templates \
--lineend=linux \
--preserve-date \
--suffix=none \
--formatted \
$(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp test/src/*.hpp benchmarks/src/benchmarks.cpp doc/examples/*.cpp
# call the Clang-Format on all source files
pretty_format:
for FILE in $(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp test/src/*.hpp benchmarks/src/benchmarks.cpp doc/examples/*.cpp; do echo $$FILE; clang-format -i $$FILE; done
# create single header file
amalgamate: $(AMALGAMATED_FILE)
# call the amalgamation tool and pretty print
$(AMALGAMATED_FILE): $(SRCS)
third_party/amalgamate/amalgamate.py -c third_party/amalgamate/config.json -s . --verbose=yes
$(MAKE) pretty
# check if file single_include/nlohmann/json.hpp has been amalgamated from the nlohmann sources
# Note: this target is called by Travis
check-amalgamation:
@mv $(AMALGAMATED_FILE) $(AMALGAMATED_FILE)~
@$(MAKE) amalgamate
@diff $(AMALGAMATED_FILE) $(AMALGAMATED_FILE)~ || (echo "===================================================================\n Amalgamation required! Please read the contribution guidelines\n in file .github/CONTRIBUTING.md.\n===================================================================" ; mv $(AMALGAMATED_FILE)~ $(AMALGAMATED_FILE) ; false)
@mv $(AMALGAMATED_FILE)~ $(AMALGAMATED_FILE)
# check if every header in nlohmann includes sufficient headers to be compiled individually
check-single-includes:
@for x in $(SRCS); do \
echo "Checking self-sufficiency of $$x..." ; \
echo "#include <$$x>\nint main() {}\n" | $(SED) 's|include/||' > single_include_test.cpp; \
$(CXX) $(CXXFLAGS) -Iinclude -std=c++11 single_include_test.cpp -o single_include_test; \
rm -f single_include_test.cpp single_include_test; \
done
##########################################################################
# benchmarks
# CMake
##########################################################################
# benchmarks
json_benchmarks: benchmarks/benchmarks.cpp benchmarks/benchpress.hpp benchmarks/cxxopts.hpp src/json.hpp
cd benchmarks/files/numbers ; python generate.py
$(CXX) -std=c++11 $(CXXFLAGS) -DNDEBUG -O3 -flto -I src -I benchmarks $< $(LDFLAGS) -o $@
./json_benchmarks
# grep "^option" CMakeLists.txt test/CMakeLists.txt | $(SED) 's/(/ /' | awk '{print $2}' | xargs
# check if all flags of our CMake files work
check_cmake_flags_do:
$(CMAKE_BINARY) --version
for flag in JSON_BuildTests JSON_Install JSON_MultipleHeaders JSON_Sanitizer JSON_Valgrind JSON_NoExceptions JSON_Coverage; do \
rm -fr cmake_build; \
mkdir cmake_build; \
echo "\n\n$(CMAKE_BINARY) .. -D$$flag=On\n" ; \
cd cmake_build ; \
$(CMAKE_BINARY) -Werror=dev .. -D$$flag=On -DCMAKE_CXX_COMPILE_FEATURES="cxx_std_11;cxx_range_for" -DCMAKE_CXX_FLAGS="-std=gnu++11" ; \
test -f Makefile || exit 1 ; \
cd .. ; \
done;
# call target `check_cmake_flags_do` twice: once for minimal required CMake version 3.1.0 and once for the installed version
check_cmake_flags:
wget https://github.com/Kitware/CMake/releases/download/v3.1.0/cmake-3.1.0-Darwin64.tar.gz
tar xfz cmake-3.1.0-Darwin64.tar.gz
CMAKE_BINARY=$(abspath cmake-3.1.0-Darwin64/CMake.app/Contents/bin/cmake) $(MAKE) check_cmake_flags_do
CMAKE_BINARY=$(shell which cmake) $(MAKE) check_cmake_flags_do
##########################################################################
# changelog
# ChangeLog
##########################################################################
# Create a ChangeLog based on the git log using the GitHub Changelog Generator
# (<https://github.com/github-changelog-generator/github-changelog-generator>).
# variable to control the diffs between the last released version and the current repository state
NEXT_VERSION ?= "unreleased"
ChangeLog.md:
github_changelog_generator -o ChangeLog.md --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s --future-release $(NEXT_VERSION)
gsed -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md
gsed -i '2i All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).' ChangeLog.md
github_changelog_generator -o ChangeLog.md --user nlohmann --project json --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s --future-release $(NEXT_VERSION)
$(SED) -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md
$(SED) -i '2i All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).' ChangeLog.md
##########################################################################
# Release files
##########################################################################
# Create the files for a release and add signatures and hashes. We use `-X` to make the resulting ZIP file
# reproducible, see <https://content.pivotal.io/blog/barriers-to-deterministic-reproducible-zip-files>.
release:
rm -fr release_files
mkdir release_files
zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) meson.build
gpg --armor --detach-sig include.zip
mv include.zip include.zip.asc release_files
gpg --armor --detach-sig $(AMALGAMATED_FILE)
cp $(AMALGAMATED_FILE) release_files
mv $(AMALGAMATED_FILE).asc release_files
cd release_files ; shasum -a 256 json.hpp > hashes.txt
cd release_files ; shasum -a 256 include.zip >> hashes.txt
##########################################################################
# Maintenance
##########################################################################
# clean up
clean:
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM test/*.dSYM oclint_report.html
rm -fr benchmarks/files/numbers/*.json
rm -fr cmake-3.1.0-Darwin64.tar.gz cmake-3.1.0-Darwin64
rm -fr cmake-build-coverage cmake-build-benchmarks fuzz-testing cmake-build-clang-analyze cmake-build-pvs-studio cmake-build-infer cmake-build-clang-sanitize cmake_build
$(MAKE) clean -Cdoc
##########################################################################
# Thirdparty code
##########################################################################
update_hedley:
rm -f include/nlohmann/thirdparty/hedley/hedley.hpp include/nlohmann/thirdparty/hedley/hedley_undef.hpp
curl https://raw.githubusercontent.com/nemequ/hedley/master/hedley.h -o include/nlohmann/thirdparty/hedley/hedley.hpp
$(SED) -i 's/HEDLEY_/JSON_HEDLEY_/g' include/nlohmann/thirdparty/hedley/hedley.hpp
grep "[[:blank:]]*#[[:blank:]]*undef" include/nlohmann/thirdparty/hedley/hedley.hpp | grep -v "__" | sort | uniq | $(SED) 's/ //g' | $(SED) 's/undef/undef /g' > include/nlohmann/thirdparty/hedley/hedley_undef.hpp
$(MAKE) amalgamate

1278
README.md

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,147 @@
version: '{build}'
os: Visual Studio 2015
init: []
install: []
build_script:
- set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
- cmake . -G "Visual Studio 14 2015"
- cmake --build . --config Release
test_script:
- ctest -C Release -V
version: '{build}'
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
configuration: Debug
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
CMAKE_OPTIONS: ""
GENERATOR: Visual Studio 14 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
configuration: Debug
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
CMAKE_OPTIONS: ""
GENERATOR: Visual Studio 15 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
configuration: Debug
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
CMAKE_OPTIONS: ""
GENERATOR: Visual Studio 16 2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
configuration: Debug
platform: x64
CXX_FLAGS: ""
LINKER_FLAGS: ""
CMAKE_OPTIONS: ""
GENERATOR: Visual Studio 16 2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
configuration: Debug
COMPILER: mingw
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
CMAKE_OPTIONS: ""
GENERATOR: Ninja
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
configuration: Release
COMPILER: mingw
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
CMAKE_OPTIONS: ""
GENERATOR: Ninja
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
configuration: Release
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
CMAKE_OPTIONS: ""
GENERATOR: Visual Studio 14 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
configuration: Release
platform: x86
name: with_win_header
CXX_FLAGS: ""
LINKER_FLAGS: ""
CMAKE_OPTIONS: ""
GENERATOR: Visual Studio 14 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
configuration: Release
platform: x86
CXX_FLAGS: "/permissive- /std:c++latest /utf-8"
LINKER_FLAGS: ""
CMAKE_OPTIONS: ""
GENERATOR: Visual Studio 15 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
configuration: Release
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
CMAKE_OPTIONS: "-DJSON_ImplicitConversions=OFF"
GENERATOR: Visual Studio 16 2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
configuration: Release
platform: x64
CXX_FLAGS: ""
LINKER_FLAGS: ""
CMAKE_OPTIONS: ""
GENERATOR: Visual Studio 16 2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
configuration: Release
platform: x64
CXX_FLAGS: ""
LINKER_FLAGS: ""
CMAKE_OPTIONS: ""
GENERATOR: Visual Studio 14 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
configuration: Release
platform: x64
CXX_FLAGS: "/permissive- /std:c++latest /Zc:__cplusplus /utf-8 /F4000000"
LINKER_FLAGS: "/STACK:4000000"
CMAKE_OPTIONS: ""
GENERATOR: Visual Studio 15 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
configuration: Release
platform: x64
CXX_FLAGS: ""
LINKER_FLAGS: ""
CMAKE_OPTIONS: ""
GENERATOR: Visual Studio 16 2019
init:
- cmake --version
- msbuild /version
install:
- if "%COMPILER%"=="mingw" appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip
- if "%COMPILER%"=="mingw" 7z x ninja.zip -oC:\projects\deps\ninja > nul
- if "%COMPILER%"=="mingw" set PATH=C:\projects\deps\ninja;%PATH%
- if "%COMPILER%"=="mingw" set PATH=C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;%PATH%
- if "%COMPILER%"=="mingw" g++ --version
- if "%platform%"=="x86" set GENERATOR_PLATFORM=Win32
before_build:
# for with_win_header build, inject the inclusion of Windows.h to the single-header library
- ps: if ($env:name -Eq "with_win_header") { $header_path = "single_include\nlohmann\json.hpp" }
- ps: if ($env:name -Eq "with_win_header") { "#include <Windows.h>`n" + (Get-Content $header_path | Out-String) | Set-Content $header_path }
- if "%GENERATOR%"=="Ninja" (cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%") else (cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%")
build_script:
- cmake --build . --config "%configuration%"
test_script:
- if "%configuration%"=="Release" ctest -C "%configuration%" -V -j
# On Debug builds, skip test-unicode_all
# as it is extremely slow to run and cause
# occasional timeouts on AppVeyor.
# More info: https://github.com/nlohmann/json/pull/1570
- if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode" -C "%configuration%" -V -j

25
benchmarks/CMakeLists.txt Normal file
View File

@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.8)
project(JSON_Benchmarks LANGUAGES CXX)
# set compiler flags
if((CMAKE_CXX_COMPILER_ID MATCHES GNU) OR (CMAKE_CXX_COMPILER_ID MATCHES Clang))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -DNDEBUG -O3")
endif()
# configure Google Benchmarks
set(BENCHMARK_ENABLE_TESTING OFF CACHE INTERNAL "" FORCE)
add_subdirectory(thirdparty/benchmark)
# header directories
include_directories(thirdparty)
include_directories(${CMAKE_SOURCE_DIR}/../single_include)
# download test data
include(${CMAKE_SOURCE_DIR}/../cmake/download_test_data.cmake)
# benchmark binary
add_executable(json_benchmarks src/benchmarks.cpp)
target_compile_features(json_benchmarks PRIVATE cxx_std_11)
target_link_libraries(json_benchmarks benchmark ${CMAKE_THREAD_LIBS_INIT})
add_dependencies(json_benchmarks download_test_data)
target_include_directories(json_benchmarks PRIVATE ${CMAKE_BINARY_DIR}/include)

View File

@@ -1,107 +0,0 @@
#define BENCHPRESS_CONFIG_MAIN
#include <fstream>
#include <benchpress.hpp>
#include <json.hpp>
BENCHMARK("parse jeopardy.json", [](benchpress::context* ctx)
{
for (size_t i = 0; i < ctx->num_iterations(); ++i)
{
std::ifstream input_file("benchmarks/files/jeopardy/jeopardy.json");
nlohmann::json j;
j << input_file;
}
})
BENCHMARK("parse canada.json", [](benchpress::context* ctx)
{
for (size_t i = 0; i < ctx->num_iterations(); ++i)
{
std::ifstream input_file("benchmarks/files/nativejson-benchmark/canada.json");
nlohmann::json j;
j << input_file;
}
})
BENCHMARK("parse citm_catalog.json", [](benchpress::context* ctx)
{
for (size_t i = 0; i < ctx->num_iterations(); ++i)
{
std::ifstream input_file("benchmarks/files/nativejson-benchmark/citm_catalog.json");
nlohmann::json j;
j << input_file;
}
})
BENCHMARK("parse twitter.json", [](benchpress::context* ctx)
{
for (size_t i = 0; i < ctx->num_iterations(); ++i)
{
std::ifstream input_file("benchmarks/files/nativejson-benchmark/twitter.json");
nlohmann::json j;
j << input_file;
}
})
BENCHMARK("parse numbers/floats.json", [](benchpress::context* ctx)
{
for (size_t i = 0; i < ctx->num_iterations(); ++i)
{
std::ifstream input_file("benchmarks/files/numbers/floats.json");
nlohmann::json j;
j << input_file;
}
})
BENCHMARK("parse numbers/signed_ints.json", [](benchpress::context* ctx)
{
for (size_t i = 0; i < ctx->num_iterations(); ++i)
{
std::ifstream input_file("benchmarks/files/numbers/signed_ints.json");
nlohmann::json j;
j << input_file;
}
})
BENCHMARK("parse numbers/unsigned_ints.json", [](benchpress::context* ctx)
{
for (size_t i = 0; i < ctx->num_iterations(); ++i)
{
std::ifstream input_file("benchmarks/files/numbers/unsigned_ints.json");
nlohmann::json j;
j << input_file;
}
})
BENCHMARK("dump jeopardy.json", [](benchpress::context* ctx)
{
std::ifstream input_file("benchmarks/files/jeopardy/jeopardy.json");
nlohmann::json j;
j << input_file;
std::ofstream output_file("jeopardy.dump.json");
ctx->reset_timer();
for (size_t i = 0; i < ctx->num_iterations(); ++i)
{
output_file << j;
}
std::remove("jeopardy.dump.json");
})
BENCHMARK("dump jeopardy.json with indent", [](benchpress::context* ctx)
{
std::ifstream input_file("benchmarks/files/jeopardy/jeopardy.json");
nlohmann::json j;
j << input_file;
std::ofstream output_file("jeopardy.dump.json");
ctx->reset_timer();
for (size_t i = 0; i < ctx->num_iterations(); ++i)
{
output_file << std::setw(4) << j;
}
std::remove("jeopardy.dump.json");
})

View File

@@ -1,401 +0,0 @@
/*
* Copyright (C) 2015 Christopher Gilbert.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef BENCHPRESS_HPP
#define BENCHPRESS_HPP
#include <algorithm> // max, min
#include <atomic> // atomic_intmax_t
#include <chrono> // high_resolution_timer, duration
#include <functional> // function
#include <iomanip> // setw
#include <iostream> // cout
#include <regex> // regex, regex_match
#include <sstream> // stringstream
#include <string> // string
#include <thread> // thread
#include <vector> // vector
namespace benchpress {
/*
* The options class encapsulates all options for running benchmarks.
*
* When including benchpress, a main function can be emitted which includes a command-line parser for building an
* options object. However from time-to-time it may be necessary for the developer to have to build their own main
* stub and construct the options object manually.
*
* options opts;
* opts
* .bench(".*")
* .benchtime(1)
* .cpu(4);
*/
class options {
std::string d_bench;
size_t d_benchtime;
size_t d_cpu;
public:
options()
: d_bench(".*")
, d_benchtime(1)
, d_cpu(std::thread::hardware_concurrency())
{}
options& bench(const std::string& bench) {
d_bench = bench;
return *this;
}
options& benchtime(size_t benchtime) {
d_benchtime = benchtime;
return *this;
}
options& cpu(size_t cpu) {
d_cpu = cpu;
return *this;
}
std::string get_bench() const {
return d_bench;
}
size_t get_benchtime() const {
return d_benchtime;
}
size_t get_cpu() const {
return d_cpu;
}
};
class context;
/*
* The benchmark_info class is used to store a function name / pointer pair.
*
* benchmark_info bi("example", [](benchpress::context* b) {
* // benchmark function
* });
*/
class benchmark_info {
std::string d_name;
std::function<void(context*)> d_func;
public:
benchmark_info(std::string name, std::function<void(context*)> func)
: d_name(name)
, d_func(func)
{}
std::string get_name() const { return d_name; }
std::function<void(context*)> get_func() const { return d_func; }
};
/*
* The registration class is responsible for providing a single global point of reference for registering
* benchmark functions.
*
* registration::get_ptr()->register_benchmark(info);
*/
class registration {
static registration* d_this;
std::vector<benchmark_info> d_benchmarks;
public:
static registration* get_ptr() {
if (nullptr == d_this) {
d_this = new registration();
}
return d_this;
}
void register_benchmark(benchmark_info& info) {
d_benchmarks.push_back(info);
}
std::vector<benchmark_info> get_benchmarks() { return d_benchmarks; }
};
/*
* The auto_register class is a helper used to register benchmarks.
*/
class auto_register {
public:
auto_register(const std::string& name, std::function<void(context*)> func) {
benchmark_info info(name, func);
registration::get_ptr()->register_benchmark(info);
}
};
#define CONCAT(x, y) x ## y
#define CONCAT2(x, y) CONCAT(x, y)
// The BENCHMARK macro is a helper for creating benchmark functions and automatically registering them with the
// registration class.
#define BENCHMARK(x, f) benchpress::auto_register CONCAT2(register_, __LINE__)((x), (f));
// This macro will prevent the compiler from removing a redundant code path which has no side-effects.
#define DISABLE_REDUNDANT_CODE_OPT() { asm(""); }
/*
* The result class is responsible for producing a printable string representation of a benchmark run.
*/
class result {
size_t d_num_iterations;
std::chrono::nanoseconds d_duration;
size_t d_num_bytes;
public:
result(size_t num_iterations, std::chrono::nanoseconds duration, size_t num_bytes)
: d_num_iterations(num_iterations)
, d_duration(duration)
, d_num_bytes(num_bytes)
{}
size_t get_ns_per_op() const {
if (d_num_iterations <= 0) {
return 0;
}
return d_duration.count() / d_num_iterations;
}
double get_mb_per_s() const {
if (d_num_iterations <= 0 || d_duration.count() <= 0 || d_num_bytes <= 0) {
return 0;
}
return ((double(d_num_bytes) * double(d_num_iterations) / double(1e6)) /
double(std::chrono::duration_cast<std::chrono::seconds>(d_duration).count()));
}
std::string to_string() const {
std::stringstream tmp;
tmp << std::setw(12) << std::right << d_num_iterations;
size_t npo = get_ns_per_op();
tmp << std::setw(12) << std::right << npo << std::setw(0) << " ns/op";
double mbs = get_mb_per_s();
if (mbs > 0.0) {
tmp << std::setw(12) << std::right << mbs << std::setw(0) << " MB/s";
}
return std::string(tmp.str());
}
};
/*
* The parallel_context class is responsible for providing a thread-safe context for parallel benchmark code.
*/
class parallel_context {
std::atomic_intmax_t d_num_iterations;
public:
parallel_context(size_t num_iterations)
: d_num_iterations(num_iterations)
{}
bool next() {
return (d_num_iterations.fetch_sub(1) > 0);
}
};
/*
* The context class is responsible for providing an interface for capturing benchmark metrics to benchmark functions.
*/
class context {
bool d_timer_on;
std::chrono::high_resolution_clock::time_point d_start;
std::chrono::nanoseconds d_duration;
std::chrono::seconds d_benchtime;
size_t d_num_iterations;
size_t d_num_threads;
size_t d_num_bytes;
benchmark_info d_benchmark;
public:
context(const benchmark_info& info, const options& opts)
: d_timer_on(false)
, d_start()
, d_duration()
, d_benchtime(std::chrono::seconds(opts.get_benchtime()))
, d_num_iterations(1)
, d_num_threads(opts.get_cpu())
, d_num_bytes(0)
, d_benchmark(info)
{}
size_t num_iterations() const { return d_num_iterations; }
void set_num_threads(size_t n) { d_num_threads = n; }
size_t num_threads() const { return d_num_threads; }
void start_timer() {
if (!d_timer_on) {
d_start = std::chrono::high_resolution_clock::now();
d_timer_on = true;
}
}
void stop_timer() {
if (d_timer_on) {
d_duration += std::chrono::high_resolution_clock::now() - d_start;
d_timer_on = false;
}
}
void reset_timer() {
if (d_timer_on) {
d_start = std::chrono::high_resolution_clock::now();
}
d_duration = std::chrono::nanoseconds::zero();
}
void set_bytes(int64_t bytes) { d_num_bytes = bytes; }
size_t get_ns_per_op() {
if (d_num_iterations <= 0) {
return 0;
}
return d_duration.count() / d_num_iterations;
}
void run_n(size_t n) {
d_num_iterations = n;
reset_timer();
start_timer();
d_benchmark.get_func()(this);
stop_timer();
}
void run_parallel(std::function<void(parallel_context*)> f) {
parallel_context pc(d_num_iterations);
std::vector<std::thread> threads;
for (size_t i = 0; i < d_num_threads; ++i) {
threads.push_back(std::thread([&pc,&f]() -> void {
f(&pc);
}));
}
for(auto& thread : threads){
thread.join();
}
}
result run() {
size_t n = 1;
run_n(n);
while (d_duration < d_benchtime && n < 1e9) {
size_t last = n;
if (get_ns_per_op() == 0) {
n = 1e9;
} else {
n = d_duration.count() / get_ns_per_op();
}
n = std::max(std::min(n+n/2, 100*last), last+1);
n = round_up(n);
run_n(n);
}
return result(n, d_duration, d_num_bytes);
}
private:
template<typename T>
T round_down_10(T n) {
int tens = 0;
while (n > 10) {
n /= 10;
tens++;
}
int result = 1;
for (int i = 0; i < tens; ++i) {
result *= 10;
}
return result;
}
template<typename T>
T round_up(T n) {
T base = round_down_10(n);
if (n < (2 * base)) {
return 2 * base;
}
if (n < (5 * base)) {
return 5 * base;
}
return 10 * base;
}
};
/*
* The run_benchmarks function will run the registered benchmarks.
*/
void run_benchmarks(const options& opts) {
std::regex match_r(opts.get_bench());
auto benchmarks = registration::get_ptr()->get_benchmarks();
for (auto& info : benchmarks) {
if (std::regex_match(info.get_name(), match_r)) {
context c(info, opts);
auto r = c.run();
std::cout << std::setw(35) << std::left << info.get_name() << r.to_string() << std::endl;
}
}
}
} // namespace benchpress
/*
* If BENCHPRESS_CONFIG_MAIN is defined when the file is included then a main function will be emitted which provides a
* command-line parser and then executes run_benchmarks.
*/
#ifdef BENCHPRESS_CONFIG_MAIN
#include "cxxopts.hpp"
benchpress::registration* benchpress::registration::d_this;
int main(int argc, char** argv) {
std::chrono::high_resolution_clock::time_point bp_start = std::chrono::high_resolution_clock::now();
benchpress::options bench_opts;
try {
cxxopts::Options cmd_opts(argv[0], " - command line options");
cmd_opts.add_options()
("bench", "run benchmarks matching the regular expression", cxxopts::value<std::string>()
->default_value(".*"))
("benchtime", "run enough iterations of each benchmark to take t seconds", cxxopts::value<size_t>()
->default_value("1"))
("cpu", "specify the number of threads to use for parallel benchmarks", cxxopts::value<size_t>()
->default_value(std::to_string(std::thread::hardware_concurrency())))
("help", "print help")
;
cmd_opts.parse(argc, argv);
if (cmd_opts.count("help")) {
std::cout << cmd_opts.help({""}) << std::endl;
exit(0);
}
if (cmd_opts.count("bench")) {
bench_opts.bench(cmd_opts["bench"].as<std::string>());
}
if (cmd_opts.count("benchtime")) {
bench_opts.benchtime(cmd_opts["benchtime"].as<size_t>());
}
if (cmd_opts.count("cpu")) {
bench_opts.cpu(cmd_opts["cpu"].as<size_t>());
}
} catch (const cxxopts::OptionException& e) {
std::cout << "error parsing options: " << e.what() << std::endl;
exit(1);
}
benchpress::run_benchmarks(bench_opts);
float duration = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::high_resolution_clock::now() - bp_start
).count() / 1000.f;
std::cout << argv[0] << " " << duration << "s" << std::endl;
return 0;
}
#endif
#endif // BENCHPRESS_HPP

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env python
import json
import random
import sys
random.seed(0)
# floats
result_floats = []
for x in range(0, 1000000):
result_floats.append(random.uniform(-100000000.0, 100000000.0))
json.dump(result_floats, open("floats.json", "w"), indent=2)
# unsigned integers
result_uints = []
for x in range(0, 1000000):
result_uints.append(random.randint(0, 18446744073709551615))
json.dump(result_uints, open("unsigned_ints.json", "w"), indent=2)
# signed integers
result_sints = []
for x in range(0, 1000000):
result_sints.append(random.randint(-9223372036854775808, 9223372036854775807))
json.dump(result_sints, open("signed_ints.json", "w"), indent=2)

View File

@@ -0,0 +1,110 @@
#include "benchmark/benchmark.h"
#include <nlohmann/json.hpp>
#include <fstream>
#include <test_data.hpp>
using json = nlohmann::json;
//////////////////////////////////////////////////////////////////////////////
// parse JSON from file
//////////////////////////////////////////////////////////////////////////////
static void ParseFile(benchmark::State& state, const char* filename)
{
while (state.KeepRunning())
{
state.PauseTiming();
auto* f = new std::ifstream(filename);
auto* j = new json();
state.ResumeTiming();
*j = json::parse(*f);
state.PauseTiming();
delete f;
delete j;
state.ResumeTiming();
}
std::ifstream file(filename, std::ios::binary | std::ios::ate);
state.SetBytesProcessed(state.iterations() * file.tellg());
}
BENCHMARK_CAPTURE(ParseFile, jeopardy, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json");
BENCHMARK_CAPTURE(ParseFile, canada, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json");
BENCHMARK_CAPTURE(ParseFile, citm_catalog, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json");
BENCHMARK_CAPTURE(ParseFile, twitter, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json");
BENCHMARK_CAPTURE(ParseFile, floats, TEST_DATA_DIRECTORY "/regression/floats.json");
BENCHMARK_CAPTURE(ParseFile, signed_ints, TEST_DATA_DIRECTORY "/regression/signed_ints.json");
BENCHMARK_CAPTURE(ParseFile, unsigned_ints, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json");
BENCHMARK_CAPTURE(ParseFile, small_signed_ints, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json");
//////////////////////////////////////////////////////////////////////////////
// parse JSON from string
//////////////////////////////////////////////////////////////////////////////
static void ParseString(benchmark::State& state, const char* filename)
{
std::ifstream f(filename);
std::string str((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
while (state.KeepRunning())
{
state.PauseTiming();
auto* j = new json();
state.ResumeTiming();
*j = json::parse(str);
state.PauseTiming();
delete j;
state.ResumeTiming();
}
state.SetBytesProcessed(state.iterations() * str.size());
}
BENCHMARK_CAPTURE(ParseString, jeopardy, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json");
BENCHMARK_CAPTURE(ParseString, canada, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json");
BENCHMARK_CAPTURE(ParseString, citm_catalog, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json");
BENCHMARK_CAPTURE(ParseString, twitter, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json");
BENCHMARK_CAPTURE(ParseString, floats, TEST_DATA_DIRECTORY "/regression/floats.json");
BENCHMARK_CAPTURE(ParseString, signed_ints, TEST_DATA_DIRECTORY "/regression/signed_ints.json");
BENCHMARK_CAPTURE(ParseString, unsigned_ints, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json");
BENCHMARK_CAPTURE(ParseString, small_signed_ints, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json");
//////////////////////////////////////////////////////////////////////////////
// serialize JSON
//////////////////////////////////////////////////////////////////////////////
static void Dump(benchmark::State& state, const char* filename, int indent)
{
std::ifstream f(filename);
std::string str((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
json j = json::parse(str);
while (state.KeepRunning())
{
j.dump(indent);
}
state.SetBytesProcessed(state.iterations() * j.dump(indent).size());
}
BENCHMARK_CAPTURE(Dump, jeopardy / -, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json", -1);
BENCHMARK_CAPTURE(Dump, jeopardy / 4, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json", 4);
BENCHMARK_CAPTURE(Dump, canada / -, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json", -1);
BENCHMARK_CAPTURE(Dump, canada / 4, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json", 4);
BENCHMARK_CAPTURE(Dump, citm_catalog / -, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json", -1);
BENCHMARK_CAPTURE(Dump, citm_catalog / 4, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json", 4);
BENCHMARK_CAPTURE(Dump, twitter / -, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json", -1);
BENCHMARK_CAPTURE(Dump, twitter / 4, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json", 4);
BENCHMARK_CAPTURE(Dump, floats / -, TEST_DATA_DIRECTORY "/regression/floats.json", -1);
BENCHMARK_CAPTURE(Dump, floats / 4, TEST_DATA_DIRECTORY "/regression/floats.json", 4);
BENCHMARK_CAPTURE(Dump, signed_ints / -, TEST_DATA_DIRECTORY "/regression/signed_ints.json", -1);
BENCHMARK_CAPTURE(Dump, signed_ints / 4, TEST_DATA_DIRECTORY "/regression/signed_ints.json", 4);
BENCHMARK_CAPTURE(Dump, unsigned_ints / -, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", -1);
BENCHMARK_CAPTURE(Dump, unsigned_ints / 4, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", 4);
BENCHMARK_CAPTURE(Dump, small_signed_ints / -, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json", -1);
BENCHMARK_CAPTURE(Dump, small_signed_ints / 4, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json", 4);
BENCHMARK_MAIN();

46
benchmarks/thirdparty/benchmark/AUTHORS vendored Executable file
View File

@@ -0,0 +1,46 @@
# This is the official list of benchmark authors for copyright purposes.
# This file is distinct from the CONTRIBUTORS files.
# See the latter for an explanation.
#
# Names should be added to this file as:
# Name or Organization <email address>
# The email address is not required for organizations.
#
# Please keep the list sorted.
Albert Pretorius <pretoalb@gmail.com>
Arne Beer <arne@twobeer.de>
Carto
Christopher Seymour <chris.j.seymour@hotmail.com>
David Coeurjolly <david.coeurjolly@liris.cnrs.fr>
Deniz Evrenci <denizevrenci@gmail.com>
Dirac Research
Dominik Czarnota <dominik.b.czarnota@gmail.com>
Eric Fiselier <eric@efcs.ca>
Eugene Zhuk <eugene.zhuk@gmail.com>
Evgeny Safronov <division494@gmail.com>
Felix Homann <linuxaudio@showlabor.de>
Google Inc.
International Business Machines Corporation
Ismael Jimenez Martinez <ismael.jimenez.martinez@gmail.com>
Jern-Kuan Leong <jernkuan@gmail.com>
JianXiong Zhou <zhoujianxiong2@gmail.com>
Joao Paulo Magalhaes <joaoppmagalhaes@gmail.com>
Jussi Knuuttila <jussi.knuuttila@gmail.com>
Kaito Udagawa <umireon@gmail.com>
Kishan Kumar <kumar.kishan@outlook.com>
Lei Xu <eddyxu@gmail.com>
Matt Clarkson <mattyclarkson@gmail.com>
Maxim Vafin <maxvafin@gmail.com>
MongoDB Inc.
Nick Hutchinson <nshutchinson@gmail.com>
Oleksandr Sochka <sasha.sochka@gmail.com>
Paul Redmond <paul.redmond@gmail.com>
Radoslav Yovchev <radoslav.tm@gmail.com>
Roman Lebedev <lebedev.ri@gmail.com>
Shuo Chen <chenshuo@chenshuo.com>
Steinar H. Gunderson <sgunderson@bigfoot.com>
Stripe, Inc.
Yixuan Qiu <yixuanq@gmail.com>
Yusuke Suzuki <utatane.tea@gmail.com>
Zbigniew Skowron <zbychs@gmail.com>

42
benchmarks/thirdparty/benchmark/BUILD.bazel vendored Executable file
View File

@@ -0,0 +1,42 @@
licenses(["notice"])
config_setting(
name = "windows",
values = {
"cpu": "x64_windows",
},
visibility = [":__subpackages__"],
)
cc_library(
name = "benchmark",
srcs = glob(
[
"src/*.cc",
"src/*.h",
],
exclude = ["src/benchmark_main.cc"],
),
hdrs = ["include/benchmark/benchmark.h"],
linkopts = select({
":windows": ["-DEFAULTLIB:shlwapi.lib"],
"//conditions:default": ["-pthread"],
}),
strip_include_prefix = "include",
visibility = ["//visibility:public"],
)
cc_library(
name = "benchmark_main",
srcs = ["src/benchmark_main.cc"],
hdrs = ["include/benchmark/benchmark.h"],
strip_include_prefix = "include",
visibility = ["//visibility:public"],
deps = [":benchmark"],
)
cc_library(
name = "benchmark_internal_headers",
hdrs = glob(["src/*.h"]),
visibility = ["//test:__pkg__"],
)

251
benchmarks/thirdparty/benchmark/CMakeLists.txt vendored Executable file
View File

@@ -0,0 +1,251 @@
cmake_minimum_required (VERSION 2.8.12)
project (benchmark)
foreach(p
CMP0054 # CMake 3.1
CMP0056 # export EXE_LINKER_FLAGS to try_run
CMP0057 # Support no if() IN_LIST operator
)
if(POLICY ${p})
cmake_policy(SET ${p} NEW)
endif()
endforeach()
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON)
option(BENCHMARK_ENABLE_EXCEPTIONS "Enable the use of exceptions in the benchmark library." ON)
option(BENCHMARK_ENABLE_LTO "Enable link time optimisation of the benchmark library." OFF)
option(BENCHMARK_USE_LIBCXX "Build and test using libc++ as the standard library." OFF)
option(BENCHMARK_BUILD_32_BITS "Build a 32 bit version of the library." OFF)
option(BENCHMARK_ENABLE_INSTALL "Enable installation of benchmark. (Projects embedding benchmark may want to turn this OFF.)" ON)
# Allow unmet dependencies to be met using CMake's ExternalProject mechanics, which
# may require downloading the source code.
option(BENCHMARK_DOWNLOAD_DEPENDENCIES "Allow the downloading and in-tree building of unmet dependencies" OFF)
# This option can be used to disable building and running unit tests which depend on gtest
# in cases where it is not possible to build or find a valid version of gtest.
option(BENCHMARK_ENABLE_GTEST_TESTS "Enable building the unit tests which depend on gtest" ON)
set(ENABLE_ASSEMBLY_TESTS_DEFAULT OFF)
function(should_enable_assembly_tests)
if(CMAKE_BUILD_TYPE)
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
if (${CMAKE_BUILD_TYPE_LOWER} MATCHES "coverage")
# FIXME: The --coverage flag needs to be removed when building assembly
# tests for this to work.
return()
endif()
endif()
if (MSVC)
return()
elseif(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
return()
elseif(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
# FIXME: Make these work on 32 bit builds
return()
elseif(BENCHMARK_BUILD_32_BITS)
# FIXME: Make these work on 32 bit builds
return()
endif()
find_program(LLVM_FILECHECK_EXE FileCheck)
if (LLVM_FILECHECK_EXE)
set(LLVM_FILECHECK_EXE "${LLVM_FILECHECK_EXE}" CACHE PATH "llvm filecheck" FORCE)
message(STATUS "LLVM FileCheck Found: ${LLVM_FILECHECK_EXE}")
else()
message(STATUS "Failed to find LLVM FileCheck")
return()
endif()
set(ENABLE_ASSEMBLY_TESTS_DEFAULT ON PARENT_SCOPE)
endfunction()
should_enable_assembly_tests()
# This option disables the building and running of the assembly verification tests
option(BENCHMARK_ENABLE_ASSEMBLY_TESTS "Enable building and running the assembly tests"
${ENABLE_ASSEMBLY_TESTS_DEFAULT})
# Make sure we can import out CMake functions
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Read the git tags to determine the project version
include(GetGitVersion)
get_git_version(GIT_VERSION)
# Tell the user what versions we are using
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION ${GIT_VERSION})
message("-- Version: ${VERSION}")
# The version of the libraries
set(GENERIC_LIB_VERSION ${VERSION})
string(SUBSTRING ${VERSION} 0 1 GENERIC_LIB_SOVERSION)
# Import our CMake modules
include(CheckCXXCompilerFlag)
include(AddCXXCompilerFlag)
include(CXXFeatureCheck)
if (BENCHMARK_BUILD_32_BITS)
add_required_cxx_compiler_flag(-m32)
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Turn compiler warnings up to 11
string(REGEX REPLACE "[-/]W[1-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
if (NOT BENCHMARK_ENABLE_EXCEPTIONS)
add_cxx_compiler_flag(-EHs-)
add_cxx_compiler_flag(-EHa-)
endif()
# Link time optimisation
if (BENCHMARK_ENABLE_LTO)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /GL")
string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO}")
set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /GL")
set(CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL "${CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL} /LTCG")
set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /LTCG")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /LTCG")
endif()
else()
# Try and enable C++11. Don't use C++14 because it doesn't work in some
# configurations.
add_cxx_compiler_flag(-std=c++11)
if (NOT HAVE_CXX_FLAG_STD_CXX11)
add_cxx_compiler_flag(-std=c++0x)
endif()
# Turn compiler warnings up to 11
add_cxx_compiler_flag(-Wall)
add_cxx_compiler_flag(-Wextra)
add_cxx_compiler_flag(-Wshadow)
add_cxx_compiler_flag(-Werror RELEASE)
add_cxx_compiler_flag(-Werror RELWITHDEBINFO)
add_cxx_compiler_flag(-Werror MINSIZEREL)
add_cxx_compiler_flag(-pedantic)
add_cxx_compiler_flag(-pedantic-errors)
add_cxx_compiler_flag(-Wshorten-64-to-32)
add_cxx_compiler_flag(-Wfloat-equal)
add_cxx_compiler_flag(-fstrict-aliasing)
if (NOT BENCHMARK_ENABLE_EXCEPTIONS)
add_cxx_compiler_flag(-fno-exceptions)
endif()
if (HAVE_CXX_FLAG_FSTRICT_ALIASING)
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel") #ICC17u2: Many false positives for Wstrict-aliasing
add_cxx_compiler_flag(-Wstrict-aliasing)
endif()
endif()
# ICC17u2: overloaded virtual function "benchmark::Fixture::SetUp" is only partially overridden
# (because of deprecated overload)
add_cxx_compiler_flag(-wd654)
add_cxx_compiler_flag(-Wthread-safety)
if (HAVE_CXX_FLAG_WTHREAD_SAFETY)
cxx_feature_check(THREAD_SAFETY_ATTRIBUTES)
endif()
# On most UNIX like platforms g++ and clang++ define _GNU_SOURCE as a
# predefined macro, which turns on all of the wonderful libc extensions.
# However g++ doesn't do this in Cygwin so we have to define it ourselfs
# since we depend on GNU/POSIX/BSD extensions.
if (CYGWIN)
add_definitions(-D_GNU_SOURCE=1)
endif()
# Link time optimisation
if (BENCHMARK_ENABLE_LTO)
add_cxx_compiler_flag(-flto)
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
find_program(GCC_AR gcc-ar)
if (GCC_AR)
set(CMAKE_AR ${GCC_AR})
endif()
find_program(GCC_RANLIB gcc-ranlib)
if (GCC_RANLIB)
set(CMAKE_RANLIB ${GCC_RANLIB})
endif()
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
include(llvm-toolchain)
endif()
endif()
# Coverage build type
set(BENCHMARK_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG}"
CACHE STRING "Flags used by the C++ compiler during coverage builds."
FORCE)
set(BENCHMARK_EXE_LINKER_FLAGS_COVERAGE "${CMAKE_EXE_LINKER_FLAGS_DEBUG}"
CACHE STRING "Flags used for linking binaries during coverage builds."
FORCE)
set(BENCHMARK_SHARED_LINKER_FLAGS_COVERAGE "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}"
CACHE STRING "Flags used by the shared libraries linker during coverage builds."
FORCE)
mark_as_advanced(
BENCHMARK_CXX_FLAGS_COVERAGE
BENCHMARK_EXE_LINKER_FLAGS_COVERAGE
BENCHMARK_SHARED_LINKER_FLAGS_COVERAGE)
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage.")
add_cxx_compiler_flag(--coverage COVERAGE)
endif()
if (BENCHMARK_USE_LIBCXX)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_cxx_compiler_flag(-stdlib=libc++)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
add_cxx_compiler_flag(-nostdinc++)
message("libc++ header path must be manually specified using CMAKE_CXX_FLAGS")
# Adding -nodefaultlibs directly to CMAKE_<TYPE>_LINKER_FLAGS will break
# configuration checks such as 'find_package(Threads)'
list(APPEND BENCHMARK_CXX_LINKER_FLAGS -nodefaultlibs)
# -lc++ cannot be added directly to CMAKE_<TYPE>_LINKER_FLAGS because
# linker flags appear before all linker inputs and -lc++ must appear after.
list(APPEND BENCHMARK_CXX_LIBRARIES c++)
else()
message(FATAL_ERROR "-DBENCHMARK_USE_LIBCXX:BOOL=ON is not supported for compiler")
endif()
endif(BENCHMARK_USE_LIBCXX)
# C++ feature checks
# Determine the correct regular expression engine to use
cxx_feature_check(STD_REGEX)
cxx_feature_check(GNU_POSIX_REGEX)
cxx_feature_check(POSIX_REGEX)
if(NOT HAVE_STD_REGEX AND NOT HAVE_GNU_POSIX_REGEX AND NOT HAVE_POSIX_REGEX)
message(FATAL_ERROR "Failed to determine the source files for the regular expression backend")
endif()
if (NOT BENCHMARK_ENABLE_EXCEPTIONS AND HAVE_STD_REGEX
AND NOT HAVE_GNU_POSIX_REGEX AND NOT HAVE_POSIX_REGEX)
message(WARNING "Using std::regex with exceptions disabled is not fully supported")
endif()
cxx_feature_check(STEADY_CLOCK)
# Ensure we have pthreads
find_package(Threads REQUIRED)
# Set up directories
include_directories(${PROJECT_SOURCE_DIR}/include)
# Build the targets
add_subdirectory(src)
if (BENCHMARK_ENABLE_TESTING)
enable_testing()
if (BENCHMARK_ENABLE_GTEST_TESTS)
include(HandleGTest)
endif()
add_subdirectory(test)
endif()

View File

@@ -0,0 +1,58 @@
# How to contribute #
We'd love to accept your patches and contributions to this project. There are
a just a few small guidelines you need to follow.
## Contributor License Agreement ##
Contributions to any Google project must be accompanied by a Contributor
License Agreement. This is not a copyright **assignment**, it simply gives
Google permission to use and redistribute your contributions as part of the
project.
* If you are an individual writing original source code and you're sure you
own the intellectual property, then you'll need to sign an [individual
CLA][].
* If you work for a company that wants to allow you to contribute your work,
then you'll need to sign a [corporate CLA][].
You generally only need to submit a CLA once, so if you've already submitted
one (even if it was for a different project), you probably don't need to do it
again.
[individual CLA]: https://developers.google.com/open-source/cla/individual
[corporate CLA]: https://developers.google.com/open-source/cla/corporate
Once your CLA is submitted (or if you already submitted one for
another Google project), make a commit adding yourself to the
[AUTHORS][] and [CONTRIBUTORS][] files. This commit can be part
of your first [pull request][].
[AUTHORS]: AUTHORS
[CONTRIBUTORS]: CONTRIBUTORS
## Submitting a patch ##
1. It's generally best to start by opening a new issue describing the bug or
feature you're intending to fix. Even if you think it's relatively minor,
it's helpful to know what people are working on. Mention in the initial
issue that you are planning to work on that bug or feature so that it can
be assigned to you.
1. Follow the normal process of [forking][] the project, and setup a new
branch to work in. It's important that each group of changes be done in
separate branches in order to ensure that a pull request only includes the
commits related to that bug or feature.
1. Do your best to have [well-formed commit messages][] for each change.
This provides consistency throughout the project, and ensures that commit
messages are able to be formatted properly by various git tools.
1. Finally, push the commits to your fork and submit a [pull request][].
[forking]: https://help.github.com/articles/fork-a-repo
[well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
[pull request]: https://help.github.com/articles/creating-a-pull-request

65
benchmarks/thirdparty/benchmark/CONTRIBUTORS vendored Executable file
View File

@@ -0,0 +1,65 @@
# People who have agreed to one of the CLAs and can contribute patches.
# The AUTHORS file lists the copyright holders; this file
# lists people. For example, Google employees are listed here
# but not in AUTHORS, because Google holds the copyright.
#
# Names should be added to this file only after verifying that
# the individual or the individual's organization has agreed to
# the appropriate Contributor License Agreement, found here:
#
# https://developers.google.com/open-source/cla/individual
# https://developers.google.com/open-source/cla/corporate
#
# The agreement for individuals can be filled out on the web.
#
# When adding J Random Contributor's name to this file,
# either J's name or J's organization's name should be
# added to the AUTHORS file, depending on whether the
# individual or corporate CLA was used.
#
# Names should be added to this file as:
# Name <email address>
#
# Please keep the list sorted.
Albert Pretorius <pretoalb@gmail.com>
Arne Beer <arne@twobeer.de>
Billy Robert O'Neal III <billy.oneal@gmail.com> <bion@microsoft.com>
Chris Kennelly <ckennelly@google.com> <ckennelly@ckennelly.com>
Christopher Seymour <chris.j.seymour@hotmail.com>
David Coeurjolly <david.coeurjolly@liris.cnrs.fr>
Deniz Evrenci <denizevrenci@gmail.com>
Dominic Hamon <dma@stripysock.com> <dominic@google.com>
Dominik Czarnota <dominik.b.czarnota@gmail.com>
Eric Fiselier <eric@efcs.ca>
Eugene Zhuk <eugene.zhuk@gmail.com>
Evgeny Safronov <division494@gmail.com>
Felix Homann <linuxaudio@showlabor.de>
Ismael Jimenez Martinez <ismael.jimenez.martinez@gmail.com>
Jern-Kuan Leong <jernkuan@gmail.com>
JianXiong Zhou <zhoujianxiong2@gmail.com>
Joao Paulo Magalhaes <joaoppmagalhaes@gmail.com>
John Millikin <jmillikin@stripe.com>
Jussi Knuuttila <jussi.knuuttila@gmail.com>
Kai Wolf <kai.wolf@gmail.com>
Kishan Kumar <kumar.kishan@outlook.com>
Kaito Udagawa <umireon@gmail.com>
Lei Xu <eddyxu@gmail.com>
Matt Clarkson <mattyclarkson@gmail.com>
Maxim Vafin <maxvafin@gmail.com>
Nick Hutchinson <nshutchinson@gmail.com>
Oleksandr Sochka <sasha.sochka@gmail.com>
Pascal Leroy <phl@google.com>
Paul Redmond <paul.redmond@gmail.com>
Pierre Phaneuf <pphaneuf@google.com>
Radoslav Yovchev <radoslav.tm@gmail.com>
Raul Marin <rmrodriguez@cartodb.com>
Ray Glover <ray.glover@uk.ibm.com>
Robert Guo <robert.guo@mongodb.com>
Roman Lebedev <lebedev.ri@gmail.com>
Shuo Chen <chenshuo@chenshuo.com>
Tobias Ulvgård <tobias.ulvgard@dirac.se>
Tom Madams <tom.ej.madams@gmail.com> <tmadams@google.com>
Yixuan Qiu <yixuanq@gmail.com>
Yusuke Suzuki <utatane.tea@gmail.com>
Zbigniew Skowron <zbychs@gmail.com>

202
benchmarks/thirdparty/benchmark/LICENSE vendored Executable file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

950
benchmarks/thirdparty/benchmark/README.md vendored Executable file
View File

@@ -0,0 +1,950 @@
# benchmark
[![Build Status](https://travis-ci.org/google/benchmark.svg?branch=master)](https://travis-ci.org/google/benchmark)
[![Build status](https://ci.appveyor.com/api/projects/status/u0qsyp7t1tk7cpxs/branch/master?svg=true)](https://ci.appveyor.com/project/google/benchmark/branch/master)
[![Coverage Status](https://coveralls.io/repos/google/benchmark/badge.svg)](https://coveralls.io/r/google/benchmark)
[![slackin](https://slackin-iqtfqnpzxd.now.sh/badge.svg)](https://slackin-iqtfqnpzxd.now.sh/)
A library to support the benchmarking of functions, similar to unit-tests.
Discussion group: https://groups.google.com/d/forum/benchmark-discuss
IRC channel: https://freenode.net #googlebenchmark
[Known issues and common problems](#known-issues)
[Additional Tooling Documentation](docs/tools.md)
[Assembly Testing Documentation](docs/AssemblyTests.md)
## Building
The basic steps for configuring and building the library look like this:
```bash
$ git clone https://github.com/google/benchmark.git
# Benchmark requires Google Test as a dependency. Add the source tree as a subdirectory.
$ git clone https://github.com/google/googletest.git benchmark/googletest
$ mkdir build && cd build
$ cmake -G <generator> [options] ../benchmark
# Assuming a makefile generator was used
$ make
```
Note that Google Benchmark requires Google Test to build and run the tests. This
dependency can be provided two ways:
* Checkout the Google Test sources into `benchmark/googletest` as above.
* Otherwise, if `-DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON` is specified during
configuration, the library will automatically download and build any required
dependencies.
If you do not wish to build and run the tests, add `-DBENCHMARK_ENABLE_GTEST_TESTS=OFF`
to `CMAKE_ARGS`.
## Installation Guide
For Ubuntu and Debian Based System
First make sure you have git and cmake installed (If not please install it)
```
sudo apt-get install git
sudo apt-get install cmake
```
Now, let's clone the repository and build it
```
git clone https://github.com/google/benchmark.git
cd benchmark
git clone https://github.com/google/googletest.git
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=RELEASE
make
```
We need to install the library globally now
```
sudo make install
```
Now you have google/benchmark installed in your machine
Note: Don't forget to link to pthread library while building
## Stable and Experimental Library Versions
The main branch contains the latest stable version of the benchmarking library;
the API of which can be considered largely stable, with source breaking changes
being made only upon the release of a new major version.
Newer, experimental, features are implemented and tested on the
[`v2` branch](https://github.com/google/benchmark/tree/v2). Users who wish
to use, test, and provide feedback on the new features are encouraged to try
this branch. However, this branch provides no stability guarantees and reserves
the right to change and break the API at any time.
##Prerequisite knowledge
Before attempting to understand this framework one should ideally have some familiarity with the structure and format of the Google Test framework, upon which it is based. Documentation for Google Test, including a "Getting Started" (primer) guide, is available here:
https://github.com/google/googletest/blob/master/googletest/docs/Documentation.md
## Example usage
### Basic usage
Define a function that executes the code to be measured.
```c++
#include <benchmark/benchmark.h>
static void BM_StringCreation(benchmark::State& state) {
for (auto _ : state)
std::string empty_string;
}
// Register the function as a benchmark
BENCHMARK(BM_StringCreation);
// Define another benchmark
static void BM_StringCopy(benchmark::State& state) {
std::string x = "hello";
for (auto _ : state)
std::string copy(x);
}
BENCHMARK(BM_StringCopy);
BENCHMARK_MAIN();
```
Don't forget to inform your linker to add benchmark library e.g. through
`-lbenchmark` compilation flag. Alternatively, you may leave out the
`BENCHMARK_MAIN();` at the end of the source file and link against
`-lbenchmark_main` to get the same default behavior.
The benchmark library will reporting the timing for the code within the `for(...)` loop.
### Passing arguments
Sometimes a family of benchmarks can be implemented with just one routine that
takes an extra argument to specify which one of the family of benchmarks to
run. For example, the following code defines a family of benchmarks for
measuring the speed of `memcpy()` calls of different lengths:
```c++
static void BM_memcpy(benchmark::State& state) {
char* src = new char[state.range(0)];
char* dst = new char[state.range(0)];
memset(src, 'x', state.range(0));
for (auto _ : state)
memcpy(dst, src, state.range(0));
state.SetBytesProcessed(int64_t(state.iterations()) *
int64_t(state.range(0)));
delete[] src;
delete[] dst;
}
BENCHMARK(BM_memcpy)->Arg(8)->Arg(64)->Arg(512)->Arg(1<<10)->Arg(8<<10);
```
The preceding code is quite repetitive, and can be replaced with the following
short-hand. The following invocation will pick a few appropriate arguments in
the specified range and will generate a benchmark for each such argument.
```c++
BENCHMARK(BM_memcpy)->Range(8, 8<<10);
```
By default the arguments in the range are generated in multiples of eight and
the command above selects [ 8, 64, 512, 4k, 8k ]. In the following code the
range multiplier is changed to multiples of two.
```c++
BENCHMARK(BM_memcpy)->RangeMultiplier(2)->Range(8, 8<<10);
```
Now arguments generated are [ 8, 16, 32, 64, 128, 256, 512, 1024, 2k, 4k, 8k ].
You might have a benchmark that depends on two or more inputs. For example, the
following code defines a family of benchmarks for measuring the speed of set
insertion.
```c++
static void BM_SetInsert(benchmark::State& state) {
std::set<int> data;
for (auto _ : state) {
state.PauseTiming();
data = ConstructRandomSet(state.range(0));
state.ResumeTiming();
for (int j = 0; j < state.range(1); ++j)
data.insert(RandomNumber());
}
}
BENCHMARK(BM_SetInsert)
->Args({1<<10, 128})
->Args({2<<10, 128})
->Args({4<<10, 128})
->Args({8<<10, 128})
->Args({1<<10, 512})
->Args({2<<10, 512})
->Args({4<<10, 512})
->Args({8<<10, 512});
```
The preceding code is quite repetitive, and can be replaced with the following
short-hand. The following macro will pick a few appropriate arguments in the
product of the two specified ranges and will generate a benchmark for each such
pair.
```c++
BENCHMARK(BM_SetInsert)->Ranges({{1<<10, 8<<10}, {128, 512}});
```
For more complex patterns of inputs, passing a custom function to `Apply` allows
programmatic specification of an arbitrary set of arguments on which to run the
benchmark. The following example enumerates a dense range on one parameter,
and a sparse range on the second.
```c++
static void CustomArguments(benchmark::internal::Benchmark* b) {
for (int i = 0; i <= 10; ++i)
for (int j = 32; j <= 1024*1024; j *= 8)
b->Args({i, j});
}
BENCHMARK(BM_SetInsert)->Apply(CustomArguments);
```
### Calculate asymptotic complexity (Big O)
Asymptotic complexity might be calculated for a family of benchmarks. The
following code will calculate the coefficient for the high-order term in the
running time and the normalized root-mean square error of string comparison.
```c++
static void BM_StringCompare(benchmark::State& state) {
std::string s1(state.range(0), '-');
std::string s2(state.range(0), '-');
for (auto _ : state) {
benchmark::DoNotOptimize(s1.compare(s2));
}
state.SetComplexityN(state.range(0));
}
BENCHMARK(BM_StringCompare)
->RangeMultiplier(2)->Range(1<<10, 1<<18)->Complexity(benchmark::oN);
```
As shown in the following invocation, asymptotic complexity might also be
calculated automatically.
```c++
BENCHMARK(BM_StringCompare)
->RangeMultiplier(2)->Range(1<<10, 1<<18)->Complexity();
```
The following code will specify asymptotic complexity with a lambda function,
that might be used to customize high-order term calculation.
```c++
BENCHMARK(BM_StringCompare)->RangeMultiplier(2)
->Range(1<<10, 1<<18)->Complexity([](int n)->double{return n; });
```
### Templated benchmarks
Templated benchmarks work the same way: This example produces and consumes
messages of size `sizeof(v)` `range_x` times. It also outputs throughput in the
absence of multiprogramming.
```c++
template <class Q> int BM_Sequential(benchmark::State& state) {
Q q;
typename Q::value_type v;
for (auto _ : state) {
for (int i = state.range(0); i--; )
q.push(v);
for (int e = state.range(0); e--; )
q.Wait(&v);
}
// actually messages, not bytes:
state.SetBytesProcessed(
static_cast<int64_t>(state.iterations())*state.range(0));
}
BENCHMARK_TEMPLATE(BM_Sequential, WaitQueue<int>)->Range(1<<0, 1<<10);
```
Three macros are provided for adding benchmark templates.
```c++
#ifdef BENCHMARK_HAS_CXX11
#define BENCHMARK_TEMPLATE(func, ...) // Takes any number of parameters.
#else // C++ < C++11
#define BENCHMARK_TEMPLATE(func, arg1)
#endif
#define BENCHMARK_TEMPLATE1(func, arg1)
#define BENCHMARK_TEMPLATE2(func, arg1, arg2)
```
### A Faster KeepRunning loop
In C++11 mode, a ranged-based for loop should be used in preference to
the `KeepRunning` loop for running the benchmarks. For example:
```c++
static void BM_Fast(benchmark::State &state) {
for (auto _ : state) {
FastOperation();
}
}
BENCHMARK(BM_Fast);
```
The reason the ranged-for loop is faster than using `KeepRunning`, is
because `KeepRunning` requires a memory load and store of the iteration count
ever iteration, whereas the ranged-for variant is able to keep the iteration count
in a register.
For example, an empty inner loop of using the ranged-based for method looks like:
```asm
# Loop Init
mov rbx, qword ptr [r14 + 104]
call benchmark::State::StartKeepRunning()
test rbx, rbx
je .LoopEnd
.LoopHeader: # =>This Inner Loop Header: Depth=1
add rbx, -1
jne .LoopHeader
.LoopEnd:
```
Compared to an empty `KeepRunning` loop, which looks like:
```asm
.LoopHeader: # in Loop: Header=BB0_3 Depth=1
cmp byte ptr [rbx], 1
jne .LoopInit
.LoopBody: # =>This Inner Loop Header: Depth=1
mov rax, qword ptr [rbx + 8]
lea rcx, [rax + 1]
mov qword ptr [rbx + 8], rcx
cmp rax, qword ptr [rbx + 104]
jb .LoopHeader
jmp .LoopEnd
.LoopInit:
mov rdi, rbx
call benchmark::State::StartKeepRunning()
jmp .LoopBody
.LoopEnd:
```
Unless C++03 compatibility is required, the ranged-for variant of writing
the benchmark loop should be preferred.
## Passing arbitrary arguments to a benchmark
In C++11 it is possible to define a benchmark that takes an arbitrary number
of extra arguments. The `BENCHMARK_CAPTURE(func, test_case_name, ...args)`
macro creates a benchmark that invokes `func` with the `benchmark::State` as
the first argument followed by the specified `args...`.
The `test_case_name` is appended to the name of the benchmark and
should describe the values passed.
```c++
template <class ...ExtraArgs>
void BM_takes_args(benchmark::State& state, ExtraArgs&&... extra_args) {
[...]
}
// Registers a benchmark named "BM_takes_args/int_string_test" that passes
// the specified values to `extra_args`.
BENCHMARK_CAPTURE(BM_takes_args, int_string_test, 42, std::string("abc"));
```
Note that elements of `...args` may refer to global variables. Users should
avoid modifying global state inside of a benchmark.
## Using RegisterBenchmark(name, fn, args...)
The `RegisterBenchmark(name, func, args...)` function provides an alternative
way to create and register benchmarks.
`RegisterBenchmark(name, func, args...)` creates, registers, and returns a
pointer to a new benchmark with the specified `name` that invokes
`func(st, args...)` where `st` is a `benchmark::State` object.
Unlike the `BENCHMARK` registration macros, which can only be used at the global
scope, the `RegisterBenchmark` can be called anywhere. This allows for
benchmark tests to be registered programmatically.
Additionally `RegisterBenchmark` allows any callable object to be registered
as a benchmark. Including capturing lambdas and function objects.
For Example:
```c++
auto BM_test = [](benchmark::State& st, auto Inputs) { /* ... */ };
int main(int argc, char** argv) {
for (auto& test_input : { /* ... */ })
benchmark::RegisterBenchmark(test_input.name(), BM_test, test_input);
benchmark::Initialize(&argc, argv);
benchmark::RunSpecifiedBenchmarks();
}
```
### Multithreaded benchmarks
In a multithreaded test (benchmark invoked by multiple threads simultaneously),
it is guaranteed that none of the threads will start until all have reached
the start of the benchmark loop, and all will have finished before any thread
exits the benchmark loop. (This behavior is also provided by the `KeepRunning()`
API) As such, any global setup or teardown can be wrapped in a check against the thread
index:
```c++
static void BM_MultiThreaded(benchmark::State& state) {
if (state.thread_index == 0) {
// Setup code here.
}
for (auto _ : state) {
// Run the test as normal.
}
if (state.thread_index == 0) {
// Teardown code here.
}
}
BENCHMARK(BM_MultiThreaded)->Threads(2);
```
If the benchmarked code itself uses threads and you want to compare it to
single-threaded code, you may want to use real-time ("wallclock") measurements
for latency comparisons:
```c++
BENCHMARK(BM_test)->Range(8, 8<<10)->UseRealTime();
```
Without `UseRealTime`, CPU time is used by default.
## Manual timing
For benchmarking something for which neither CPU time nor real-time are
correct or accurate enough, completely manual timing is supported using
the `UseManualTime` function.
When `UseManualTime` is used, the benchmarked code must call
`SetIterationTime` once per iteration of the benchmark loop to
report the manually measured time.
An example use case for this is benchmarking GPU execution (e.g. OpenCL
or CUDA kernels, OpenGL or Vulkan or Direct3D draw calls), which cannot
be accurately measured using CPU time or real-time. Instead, they can be
measured accurately using a dedicated API, and these measurement results
can be reported back with `SetIterationTime`.
```c++
static void BM_ManualTiming(benchmark::State& state) {
int microseconds = state.range(0);
std::chrono::duration<double, std::micro> sleep_duration {
static_cast<double>(microseconds)
};
for (auto _ : state) {
auto start = std::chrono::high_resolution_clock::now();
// Simulate some useful workload with a sleep
std::this_thread::sleep_for(sleep_duration);
auto end = std::chrono::high_resolution_clock::now();
auto elapsed_seconds =
std::chrono::duration_cast<std::chrono::duration<double>>(
end - start);
state.SetIterationTime(elapsed_seconds.count());
}
}
BENCHMARK(BM_ManualTiming)->Range(1, 1<<17)->UseManualTime();
```
### Preventing optimisation
To prevent a value or expression from being optimized away by the compiler
the `benchmark::DoNotOptimize(...)` and `benchmark::ClobberMemory()`
functions can be used.
```c++
static void BM_test(benchmark::State& state) {
for (auto _ : state) {
int x = 0;
for (int i=0; i < 64; ++i) {
benchmark::DoNotOptimize(x += i);
}
}
}
```
`DoNotOptimize(<expr>)` forces the *result* of `<expr>` to be stored in either
memory or a register. For GNU based compilers it acts as read/write barrier
for global memory. More specifically it forces the compiler to flush pending
writes to memory and reload any other values as necessary.
Note that `DoNotOptimize(<expr>)` does not prevent optimizations on `<expr>`
in any way. `<expr>` may even be removed entirely when the result is already
known. For example:
```c++
/* Example 1: `<expr>` is removed entirely. */
int foo(int x) { return x + 42; }
while (...) DoNotOptimize(foo(0)); // Optimized to DoNotOptimize(42);
/* Example 2: Result of '<expr>' is only reused */
int bar(int) __attribute__((const));
while (...) DoNotOptimize(bar(0)); // Optimized to:
// int __result__ = bar(0);
// while (...) DoNotOptimize(__result__);
```
The second tool for preventing optimizations is `ClobberMemory()`. In essence
`ClobberMemory()` forces the compiler to perform all pending writes to global
memory. Memory managed by block scope objects must be "escaped" using
`DoNotOptimize(...)` before it can be clobbered. In the below example
`ClobberMemory()` prevents the call to `v.push_back(42)` from being optimized
away.
```c++
static void BM_vector_push_back(benchmark::State& state) {
for (auto _ : state) {
std::vector<int> v;
v.reserve(1);
benchmark::DoNotOptimize(v.data()); // Allow v.data() to be clobbered.
v.push_back(42);
benchmark::ClobberMemory(); // Force 42 to be written to memory.
}
}
```
Note that `ClobberMemory()` is only available for GNU or MSVC based compilers.
### Set time unit manually
If a benchmark runs a few milliseconds it may be hard to visually compare the
measured times, since the output data is given in nanoseconds per default. In
order to manually set the time unit, you can specify it manually:
```c++
BENCHMARK(BM_test)->Unit(benchmark::kMillisecond);
```
## Controlling number of iterations
In all cases, the number of iterations for which the benchmark is run is
governed by the amount of time the benchmark takes. Concretely, the number of
iterations is at least one, not more than 1e9, until CPU time is greater than
the minimum time, or the wallclock time is 5x minimum time. The minimum time is
set as a flag `--benchmark_min_time` or per benchmark by calling `MinTime` on
the registered benchmark object.
## Reporting the mean, median and standard deviation by repeated benchmarks
By default each benchmark is run once and that single result is reported.
However benchmarks are often noisy and a single result may not be representative
of the overall behavior. For this reason it's possible to repeatedly rerun the
benchmark.
The number of runs of each benchmark is specified globally by the
`--benchmark_repetitions` flag or on a per benchmark basis by calling
`Repetitions` on the registered benchmark object. When a benchmark is run more
than once the mean, median and standard deviation of the runs will be reported.
Additionally the `--benchmark_report_aggregates_only={true|false}` flag or
`ReportAggregatesOnly(bool)` function can be used to change how repeated tests
are reported. By default the result of each repeated run is reported. When this
option is `true` only the mean, median and standard deviation of the runs is reported.
Calling `ReportAggregatesOnly(bool)` on a registered benchmark object overrides
the value of the flag for that benchmark.
## User-defined statistics for repeated benchmarks
While having mean, median and standard deviation is nice, this may not be
enough for everyone. For example you may want to know what is the largest
observation, e.g. because you have some real-time constraints. This is easy.
The following code will specify a custom statistic to be calculated, defined
by a lambda function.
```c++
void BM_spin_empty(benchmark::State& state) {
for (auto _ : state) {
for (int x = 0; x < state.range(0); ++x) {
benchmark::DoNotOptimize(x);
}
}
}
BENCHMARK(BM_spin_empty)
->ComputeStatistics("max", [](const std::vector<double>& v) -> double {
return *(std::max_element(std::begin(v), std::end(v)));
})
->Arg(512);
```
## Fixtures
Fixture tests are created by
first defining a type that derives from `::benchmark::Fixture` and then
creating/registering the tests using the following macros:
* `BENCHMARK_F(ClassName, Method)`
* `BENCHMARK_DEFINE_F(ClassName, Method)`
* `BENCHMARK_REGISTER_F(ClassName, Method)`
For Example:
```c++
class MyFixture : public benchmark::Fixture {};
BENCHMARK_F(MyFixture, FooTest)(benchmark::State& st) {
for (auto _ : st) {
...
}
}
BENCHMARK_DEFINE_F(MyFixture, BarTest)(benchmark::State& st) {
for (auto _ : st) {
...
}
}
/* BarTest is NOT registered */
BENCHMARK_REGISTER_F(MyFixture, BarTest)->Threads(2);
/* BarTest is now registered */
```
### Templated fixtures
Also you can create templated fixture by using the following macros:
* `BENCHMARK_TEMPLATE_F(ClassName, Method, ...)`
* `BENCHMARK_TEMPLATE_DEFINE_F(ClassName, Method, ...)`
For example:
```c++
template<typename T>
class MyFixture : public benchmark::Fixture {};
BENCHMARK_TEMPLATE_F(MyFixture, IntTest, int)(benchmark::State& st) {
for (auto _ : st) {
...
}
}
BENCHMARK_TEMPLATE_DEFINE_F(MyFixture, DoubleTest, double)(benchmark::State& st) {
for (auto _ : st) {
...
}
}
BENCHMARK_REGISTER_F(MyFixture, DoubleTest)->Threads(2);
```
## User-defined counters
You can add your own counters with user-defined names. The example below
will add columns "Foo", "Bar" and "Baz" in its output:
```c++
static void UserCountersExample1(benchmark::State& state) {
double numFoos = 0, numBars = 0, numBazs = 0;
for (auto _ : state) {
// ... count Foo,Bar,Baz events
}
state.counters["Foo"] = numFoos;
state.counters["Bar"] = numBars;
state.counters["Baz"] = numBazs;
}
```
The `state.counters` object is a `std::map` with `std::string` keys
and `Counter` values. The latter is a `double`-like class, via an implicit
conversion to `double&`. Thus you can use all of the standard arithmetic
assignment operators (`=,+=,-=,*=,/=`) to change the value of each counter.
In multithreaded benchmarks, each counter is set on the calling thread only.
When the benchmark finishes, the counters from each thread will be summed;
the resulting sum is the value which will be shown for the benchmark.
The `Counter` constructor accepts two parameters: the value as a `double`
and a bit flag which allows you to show counters as rates and/or as
per-thread averages:
```c++
// sets a simple counter
state.counters["Foo"] = numFoos;
// Set the counter as a rate. It will be presented divided
// by the duration of the benchmark.
state.counters["FooRate"] = Counter(numFoos, benchmark::Counter::kIsRate);
// Set the counter as a thread-average quantity. It will
// be presented divided by the number of threads.
state.counters["FooAvg"] = Counter(numFoos, benchmark::Counter::kAvgThreads);
// There's also a combined flag:
state.counters["FooAvgRate"] = Counter(numFoos,benchmark::Counter::kAvgThreadsRate);
```
When you're compiling in C++11 mode or later you can use `insert()` with
`std::initializer_list`:
```c++
// With C++11, this can be done:
state.counters.insert({{"Foo", numFoos}, {"Bar", numBars}, {"Baz", numBazs}});
// ... instead of:
state.counters["Foo"] = numFoos;
state.counters["Bar"] = numBars;
state.counters["Baz"] = numBazs;
```
### Counter reporting
When using the console reporter, by default, user counters are are printed at
the end after the table, the same way as ``bytes_processed`` and
``items_processed``. This is best for cases in which there are few counters,
or where there are only a couple of lines per benchmark. Here's an example of
the default output:
```
------------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters...
------------------------------------------------------------------------------
BM_UserCounter/threads:8 2248 ns 10277 ns 68808 Bar=16 Bat=40 Baz=24 Foo=8
BM_UserCounter/threads:1 9797 ns 9788 ns 71523 Bar=2 Bat=5 Baz=3 Foo=1024m
BM_UserCounter/threads:2 4924 ns 9842 ns 71036 Bar=4 Bat=10 Baz=6 Foo=2
BM_UserCounter/threads:4 2589 ns 10284 ns 68012 Bar=8 Bat=20 Baz=12 Foo=4
BM_UserCounter/threads:8 2212 ns 10287 ns 68040 Bar=16 Bat=40 Baz=24 Foo=8
BM_UserCounter/threads:16 1782 ns 10278 ns 68144 Bar=32 Bat=80 Baz=48 Foo=16
BM_UserCounter/threads:32 1291 ns 10296 ns 68256 Bar=64 Bat=160 Baz=96 Foo=32
BM_UserCounter/threads:4 2615 ns 10307 ns 68040 Bar=8 Bat=20 Baz=12 Foo=4
BM_Factorial 26 ns 26 ns 26608979 40320
BM_Factorial/real_time 26 ns 26 ns 26587936 40320
BM_CalculatePiRange/1 16 ns 16 ns 45704255 0
BM_CalculatePiRange/8 73 ns 73 ns 9520927 3.28374
BM_CalculatePiRange/64 609 ns 609 ns 1140647 3.15746
BM_CalculatePiRange/512 4900 ns 4901 ns 142696 3.14355
```
If this doesn't suit you, you can print each counter as a table column by
passing the flag `--benchmark_counters_tabular=true` to the benchmark
application. This is best for cases in which there are a lot of counters, or
a lot of lines per individual benchmark. Note that this will trigger a
reprinting of the table header any time the counter set changes between
individual benchmarks. Here's an example of corresponding output when
`--benchmark_counters_tabular=true` is passed:
```
---------------------------------------------------------------------------------------
Benchmark Time CPU Iterations Bar Bat Baz Foo
---------------------------------------------------------------------------------------
BM_UserCounter/threads:8 2198 ns 9953 ns 70688 16 40 24 8
BM_UserCounter/threads:1 9504 ns 9504 ns 73787 2 5 3 1
BM_UserCounter/threads:2 4775 ns 9550 ns 72606 4 10 6 2
BM_UserCounter/threads:4 2508 ns 9951 ns 70332 8 20 12 4
BM_UserCounter/threads:8 2055 ns 9933 ns 70344 16 40 24 8
BM_UserCounter/threads:16 1610 ns 9946 ns 70720 32 80 48 16
BM_UserCounter/threads:32 1192 ns 9948 ns 70496 64 160 96 32
BM_UserCounter/threads:4 2506 ns 9949 ns 70332 8 20 12 4
--------------------------------------------------------------
Benchmark Time CPU Iterations
--------------------------------------------------------------
BM_Factorial 26 ns 26 ns 26392245 40320
BM_Factorial/real_time 26 ns 26 ns 26494107 40320
BM_CalculatePiRange/1 15 ns 15 ns 45571597 0
BM_CalculatePiRange/8 74 ns 74 ns 9450212 3.28374
BM_CalculatePiRange/64 595 ns 595 ns 1173901 3.15746
BM_CalculatePiRange/512 4752 ns 4752 ns 147380 3.14355
BM_CalculatePiRange/4k 37970 ns 37972 ns 18453 3.14184
BM_CalculatePiRange/32k 303733 ns 303744 ns 2305 3.14162
BM_CalculatePiRange/256k 2434095 ns 2434186 ns 288 3.1416
BM_CalculatePiRange/1024k 9721140 ns 9721413 ns 71 3.14159
BM_CalculatePi/threads:8 2255 ns 9943 ns 70936
```
Note above the additional header printed when the benchmark changes from
``BM_UserCounter`` to ``BM_Factorial``. This is because ``BM_Factorial`` does
not have the same counter set as ``BM_UserCounter``.
## Exiting Benchmarks in Error
When errors caused by external influences, such as file I/O and network
communication, occur within a benchmark the
`State::SkipWithError(const char* msg)` function can be used to skip that run
of benchmark and report the error. Note that only future iterations of the
`KeepRunning()` are skipped. For the ranged-for version of the benchmark loop
Users must explicitly exit the loop, otherwise all iterations will be performed.
Users may explicitly return to exit the benchmark immediately.
The `SkipWithError(...)` function may be used at any point within the benchmark,
including before and after the benchmark loop.
For example:
```c++
static void BM_test(benchmark::State& state) {
auto resource = GetResource();
if (!resource.good()) {
state.SkipWithError("Resource is not good!");
// KeepRunning() loop will not be entered.
}
for (state.KeepRunning()) {
auto data = resource.read_data();
if (!resource.good()) {
state.SkipWithError("Failed to read data!");
break; // Needed to skip the rest of the iteration.
}
do_stuff(data);
}
}
static void BM_test_ranged_fo(benchmark::State & state) {
state.SkipWithError("test will not be entered");
for (auto _ : state) {
state.SkipWithError("Failed!");
break; // REQUIRED to prevent all further iterations.
}
}
```
## Running a subset of the benchmarks
The `--benchmark_filter=<regex>` option can be used to only run the benchmarks
which match the specified `<regex>`. For example:
```bash
$ ./run_benchmarks.x --benchmark_filter=BM_memcpy/32
Run on (1 X 2300 MHz CPU )
2016-06-25 19:34:24
Benchmark Time CPU Iterations
----------------------------------------------------
BM_memcpy/32 11 ns 11 ns 79545455
BM_memcpy/32k 2181 ns 2185 ns 324074
BM_memcpy/32 12 ns 12 ns 54687500
BM_memcpy/32k 1834 ns 1837 ns 357143
```
## Output Formats
The library supports multiple output formats. Use the
`--benchmark_format=<console|json|csv>` flag to set the format type. `console`
is the default format.
The Console format is intended to be a human readable format. By default
the format generates color output. Context is output on stderr and the
tabular data on stdout. Example tabular output looks like:
```
Benchmark Time(ns) CPU(ns) Iterations
----------------------------------------------------------------------
BM_SetInsert/1024/1 28928 29349 23853 133.097kB/s 33.2742k items/s
BM_SetInsert/1024/8 32065 32913 21375 949.487kB/s 237.372k items/s
BM_SetInsert/1024/10 33157 33648 21431 1.13369MB/s 290.225k items/s
```
The JSON format outputs human readable json split into two top level attributes.
The `context` attribute contains information about the run in general, including
information about the CPU and the date.
The `benchmarks` attribute contains a list of every benchmark run. Example json
output looks like:
```json
{
"context": {
"date": "2015/03/17-18:40:25",
"num_cpus": 40,
"mhz_per_cpu": 2801,
"cpu_scaling_enabled": false,
"build_type": "debug"
},
"benchmarks": [
{
"name": "BM_SetInsert/1024/1",
"iterations": 94877,
"real_time": 29275,
"cpu_time": 29836,
"bytes_per_second": 134066,
"items_per_second": 33516
},
{
"name": "BM_SetInsert/1024/8",
"iterations": 21609,
"real_time": 32317,
"cpu_time": 32429,
"bytes_per_second": 986770,
"items_per_second": 246693
},
{
"name": "BM_SetInsert/1024/10",
"iterations": 21393,
"real_time": 32724,
"cpu_time": 33355,
"bytes_per_second": 1199226,
"items_per_second": 299807
}
]
}
```
The CSV format outputs comma-separated values. The `context` is output on stderr
and the CSV itself on stdout. Example CSV output looks like:
```
name,iterations,real_time,cpu_time,bytes_per_second,items_per_second,label
"BM_SetInsert/1024/1",65465,17890.7,8407.45,475768,118942,
"BM_SetInsert/1024/8",116606,18810.1,9766.64,3.27646e+06,819115,
"BM_SetInsert/1024/10",106365,17238.4,8421.53,4.74973e+06,1.18743e+06,
```
## Output Files
The library supports writing the output of the benchmark to a file specified
by `--benchmark_out=<filename>`. The format of the output can be specified
using `--benchmark_out_format={json|console|csv}`. Specifying
`--benchmark_out` does not suppress the console output.
## Debug vs Release
By default, benchmark builds as a debug library. You will see a warning in the output when this is the case. To build it as a release library instead, use:
```
cmake -DCMAKE_BUILD_TYPE=Release
```
To enable link-time optimisation, use
```
cmake -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_LTO=true
```
If you are using gcc, you might need to set `GCC_AR` and `GCC_RANLIB` cmake cache variables, if autodetection fails.
If you are using clang, you may need to set `LLVMAR_EXECUTABLE`, `LLVMNM_EXECUTABLE` and `LLVMRANLIB_EXECUTABLE` cmake cache variables.
## Linking against the library
When the library is built using GCC it is necessary to link with `-pthread`,
due to how GCC implements `std::thread`.
For GCC 4.x failing to link to pthreads will lead to runtime exceptions, not linker errors.
See [issue #67](https://github.com/google/benchmark/issues/67) for more details.
## Compiler Support
Google Benchmark uses C++11 when building the library. As such we require
a modern C++ toolchain, both compiler and standard library.
The following minimum versions are strongly recommended build the library:
* GCC 4.8
* Clang 3.4
* Visual Studio 2013
* Intel 2015 Update 1
Anything older *may* work.
Note: Using the library and its headers in C++03 is supported. C++11 is only
required to build the library.
## Disable CPU frequency scaling
If you see this error:
```
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
```
you might want to disable the CPU frequency scaling while running the benchmark:
```bash
sudo cpupower frequency-set --governor performance
./mybench
sudo cpupower frequency-set --governor powersave
```
# Known Issues
### Windows with CMake
* Users must manually link `shlwapi.lib`. Failure to do so may result
in unresolved symbols.
### Solaris
* Users must explicitly link with kstat library (-lkstat compilation flag).

7
benchmarks/thirdparty/benchmark/WORKSPACE vendored Executable file
View File

@@ -0,0 +1,7 @@
workspace(name = "com_github_google_benchmark")
http_archive(
name = "com_google_googletest",
urls = ["https://github.com/google/googletest/archive/3f0cf6b62ad1eb50d8736538363d3580dd640c3e.zip"],
strip_prefix = "googletest-3f0cf6b62ad1eb50d8736538363d3580dd640c3e",
)

56
benchmarks/thirdparty/benchmark/appveyor.yml vendored Executable file
View File

@@ -0,0 +1,56 @@
version: '{build}'
image: Visual Studio 2017
configuration:
- Debug
- Release
environment:
matrix:
- compiler: msvc-15-seh
generator: "Visual Studio 15 2017"
- compiler: msvc-15-seh
generator: "Visual Studio 15 2017 Win64"
- compiler: msvc-14-seh
generator: "Visual Studio 14 2015"
- compiler: msvc-14-seh
generator: "Visual Studio 14 2015 Win64"
- compiler: msvc-12-seh
generator: "Visual Studio 12 2013"
- compiler: msvc-12-seh
generator: "Visual Studio 12 2013 Win64"
- compiler: gcc-5.3.0-posix
generator: "MinGW Makefiles"
cxx_path: 'C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
matrix:
fast_finish: true
install:
# git bash conflicts with MinGW makefiles
- if "%generator%"=="MinGW Makefiles" (set "PATH=%PATH:C:\Program Files\Git\usr\bin;=%")
- if not "%cxx_path%"=="" (set "PATH=%PATH%;%cxx_path%")
build_script:
- md _build -Force
- cd _build
- echo %configuration%
- cmake -G "%generator%" "-DCMAKE_BUILD_TYPE=%configuration%" -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON ..
- cmake --build . --config %configuration%
test_script:
- ctest -c %configuration% --timeout 300 --output-on-failure
artifacts:
- path: '_build/CMakeFiles/*.log'
name: logs
- path: '_build/Testing/**/*.xml'
name: test_results

View File

@@ -0,0 +1,74 @@
# - Adds a compiler flag if it is supported by the compiler
#
# This function checks that the supplied compiler flag is supported and then
# adds it to the corresponding compiler flags
#
# add_cxx_compiler_flag(<FLAG> [<VARIANT>])
#
# - Example
#
# include(AddCXXCompilerFlag)
# add_cxx_compiler_flag(-Wall)
# add_cxx_compiler_flag(-no-strict-aliasing RELEASE)
# Requires CMake 2.6+
if(__add_cxx_compiler_flag)
return()
endif()
set(__add_cxx_compiler_flag INCLUDED)
include(CheckCXXCompilerFlag)
function(mangle_compiler_flag FLAG OUTPUT)
string(TOUPPER "HAVE_CXX_FLAG_${FLAG}" SANITIZED_FLAG)
string(REPLACE "+" "X" SANITIZED_FLAG ${SANITIZED_FLAG})
string(REGEX REPLACE "[^A-Za-z_0-9]" "_" SANITIZED_FLAG ${SANITIZED_FLAG})
string(REGEX REPLACE "_+" "_" SANITIZED_FLAG ${SANITIZED_FLAG})
set(${OUTPUT} "${SANITIZED_FLAG}" PARENT_SCOPE)
endfunction(mangle_compiler_flag)
function(add_cxx_compiler_flag FLAG)
mangle_compiler_flag("${FLAG}" MANGLED_FLAG)
set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
check_cxx_compiler_flag("${FLAG}" ${MANGLED_FLAG})
set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
if(${MANGLED_FLAG})
set(VARIANT ${ARGV1})
if(ARGV1)
string(TOUPPER "_${VARIANT}" VARIANT)
endif()
set(CMAKE_CXX_FLAGS${VARIANT} "${CMAKE_CXX_FLAGS${VARIANT}} ${BENCHMARK_CXX_FLAGS${VARIANT}} ${FLAG}" PARENT_SCOPE)
endif()
endfunction()
function(add_required_cxx_compiler_flag FLAG)
mangle_compiler_flag("${FLAG}" MANGLED_FLAG)
set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
check_cxx_compiler_flag("${FLAG}" ${MANGLED_FLAG})
set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
if(${MANGLED_FLAG})
set(VARIANT ${ARGV1})
if(ARGV1)
string(TOUPPER "_${VARIANT}" VARIANT)
endif()
set(CMAKE_CXX_FLAGS${VARIANT} "${CMAKE_CXX_FLAGS${VARIANT}} ${FLAG}" PARENT_SCOPE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}" PARENT_SCOPE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${FLAG}" PARENT_SCOPE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${FLAG}" PARENT_SCOPE)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}" PARENT_SCOPE)
else()
message(FATAL_ERROR "Required flag '${FLAG}' is not supported by the compiler")
endif()
endfunction()
function(check_cxx_warning_flag FLAG)
mangle_compiler_flag("${FLAG}" MANGLED_FLAG)
set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
# Add -Werror to ensure the compiler generates an error if the warning flag
# doesn't exist.
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror ${FLAG}")
check_cxx_compiler_flag("${FLAG}" ${MANGLED_FLAG})
set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
endfunction()

View File

@@ -0,0 +1,64 @@
# - Compile and run code to check for C++ features
#
# This functions compiles a source file under the `cmake` folder
# and adds the corresponding `HAVE_[FILENAME]` flag to the CMake
# environment
#
# cxx_feature_check(<FLAG> [<VARIANT>])
#
# - Example
#
# include(CXXFeatureCheck)
# cxx_feature_check(STD_REGEX)
# Requires CMake 2.8.12+
if(__cxx_feature_check)
return()
endif()
set(__cxx_feature_check INCLUDED)
function(cxx_feature_check FILE)
string(TOLOWER ${FILE} FILE)
string(TOUPPER ${FILE} VAR)
string(TOUPPER "HAVE_${VAR}" FEATURE)
if (DEFINED HAVE_${VAR})
set(HAVE_${VAR} 1 PARENT_SCOPE)
add_definitions(-DHAVE_${VAR})
return()
endif()
if (NOT DEFINED COMPILE_${FEATURE})
message("-- Performing Test ${FEATURE}")
if(CMAKE_CROSSCOMPILING)
try_compile(COMPILE_${FEATURE}
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp
CMAKE_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS}
LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES})
if(COMPILE_${FEATURE})
message(WARNING
"If you see build failures due to cross compilation, try setting HAVE_${VAR} to 0")
set(RUN_${FEATURE} 0)
else()
set(RUN_${FEATURE} 1)
endif()
else()
message("-- Performing Test ${FEATURE}")
try_run(RUN_${FEATURE} COMPILE_${FEATURE}
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp
CMAKE_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS}
LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES})
endif()
endif()
if(RUN_${FEATURE} EQUAL 0)
message("-- Performing Test ${FEATURE} -- success")
set(HAVE_${VAR} 1 PARENT_SCOPE)
add_definitions(-DHAVE_${VAR})
else()
if(NOT COMPILE_${FEATURE})
message("-- Performing Test ${FEATURE} -- failed to compile")
else()
message("-- Performing Test ${FEATURE} -- compiled but failed to run")
endif()
endif()
endfunction()

View File

@@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")

View File

@@ -0,0 +1,54 @@
# - Returns a version string from Git tags
#
# This function inspects the annotated git tags for the project and returns a string
# into a CMake variable
#
# get_git_version(<var>)
#
# - Example
#
# include(GetGitVersion)
# get_git_version(GIT_VERSION)
#
# Requires CMake 2.8.11+
find_package(Git)
if(__get_git_version)
return()
endif()
set(__get_git_version INCLUDED)
function(get_git_version var)
if(GIT_EXECUTABLE)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE status
OUTPUT_VARIABLE GIT_VERSION
ERROR_QUIET)
if(${status})
set(GIT_VERSION "v0.0.0")
else()
string(STRIP ${GIT_VERSION} GIT_VERSION)
string(REGEX REPLACE "-[0-9]+-g" "-" GIT_VERSION ${GIT_VERSION})
endif()
# Work out if the repository is dirty
execute_process(COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_QUIET
ERROR_QUIET)
execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DIFF_INDEX
ERROR_QUIET)
string(COMPARE NOTEQUAL "${GIT_DIFF_INDEX}" "" GIT_DIRTY)
if (${GIT_DIRTY})
set(GIT_VERSION "${GIT_VERSION}-dirty")
endif()
else()
set(GIT_VERSION "v0.0.0")
endif()
message("-- git Version: ${GIT_VERSION}")
set(${var} ${GIT_VERSION} PARENT_SCOPE)
endfunction()

View File

@@ -0,0 +1,113 @@
include(split_list)
macro(build_external_gtest)
include(ExternalProject)
set(GTEST_FLAGS "")
if (BENCHMARK_USE_LIBCXX)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
list(APPEND GTEST_FLAGS -stdlib=libc++)
else()
message(WARNING "Unsupported compiler (${CMAKE_CXX_COMPILER}) when using libc++")
endif()
endif()
if (BENCHMARK_BUILD_32_BITS)
list(APPEND GTEST_FLAGS -m32)
endif()
if (NOT "${CMAKE_CXX_FLAGS}" STREQUAL "")
list(APPEND GTEST_FLAGS ${CMAKE_CXX_FLAGS})
endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" GTEST_BUILD_TYPE)
if ("${GTEST_BUILD_TYPE}" STREQUAL "COVERAGE")
set(GTEST_BUILD_TYPE "DEBUG")
endif()
# FIXME: Since 10/Feb/2017 the googletest trunk has had a bug where
# -Werror=unused-function fires during the build on OS X. This is a temporary
# workaround to keep our travis bots from failing. It should be removed
# once gtest is fixed.
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
list(APPEND GTEST_FLAGS "-Wno-unused-function")
endif()
split_list(GTEST_FLAGS)
set(EXCLUDE_FROM_ALL_OPT "")
set(EXCLUDE_FROM_ALL_VALUE "")
if (${CMAKE_VERSION} VERSION_GREATER "3.0.99")
set(EXCLUDE_FROM_ALL_OPT "EXCLUDE_FROM_ALL")
set(EXCLUDE_FROM_ALL_VALUE "ON")
endif()
ExternalProject_Add(googletest
${EXCLUDE_FROM_ALL_OPT} ${EXCLUDE_FROM_ALL_VALUE}
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG master
PREFIX "${CMAKE_BINARY_DIR}/googletest"
INSTALL_DIR "${CMAKE_BINARY_DIR}/googletest"
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${GTEST_BUILD_TYPE}
-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_INSTALL_LIBDIR:PATH=<INSTALL_DIR>/lib
-DCMAKE_CXX_FLAGS:STRING=${GTEST_FLAGS}
-Dgtest_force_shared_crt:BOOL=ON
)
ExternalProject_Get_Property(googletest install_dir)
set(GTEST_INCLUDE_DIRS ${install_dir}/include)
file(MAKE_DIRECTORY ${GTEST_INCLUDE_DIRS})
set(LIB_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(LIB_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}")
if("${GTEST_BUILD_TYPE}" STREQUAL "DEBUG")
set(LIB_SUFFIX "d${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
# Use gmock_main instead of gtest_main because it initializes gtest as well.
# Note: The libraries are listed in reverse order of their dependancies.
foreach(LIB gtest gmock gmock_main)
add_library(${LIB} UNKNOWN IMPORTED)
set_target_properties(${LIB} PROPERTIES
IMPORTED_LOCATION ${install_dir}/lib/${LIB_PREFIX}${LIB}${LIB_SUFFIX}
INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIRS}
INTERFACE_LINK_LIBRARIES "${GTEST_BOTH_LIBRARIES}"
)
add_dependencies(${LIB} googletest)
list(APPEND GTEST_BOTH_LIBRARIES ${LIB})
endforeach()
endmacro(build_external_gtest)
if (BENCHMARK_ENABLE_GTEST_TESTS)
if (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/googletest)
set(GTEST_ROOT "${CMAKE_SOURCE_DIR}/googletest")
set(INSTALL_GTEST OFF CACHE INTERNAL "")
set(INSTALL_GMOCK OFF CACHE INTERNAL "")
add_subdirectory(${CMAKE_SOURCE_DIR}/googletest)
set(GTEST_BOTH_LIBRARIES gtest gmock gmock_main)
foreach(HEADER test mock)
# CMake 2.8 and older don't respect INTERFACE_INCLUDE_DIRECTORIES, so we
# have to add the paths ourselves.
set(HFILE g${HEADER}/g${HEADER}.h)
set(HPATH ${GTEST_ROOT}/google${HEADER}/include)
find_path(HEADER_PATH_${HEADER} ${HFILE}
NO_DEFAULT_PATHS
HINTS ${HPATH}
)
if (NOT HEADER_PATH_${HEADER})
message(FATAL_ERROR "Failed to find header ${HFILE} in ${HPATH}")
endif()
list(APPEND GTEST_INCLUDE_DIRS ${HEADER_PATH_${HEADER}})
endforeach()
elseif(BENCHMARK_DOWNLOAD_DEPENDENCIES)
build_external_gtest()
else()
find_package(GTest REQUIRED)
find_path(GMOCK_INCLUDE_DIRS gmock/gmock.h
HINTS ${GTEST_INCLUDE_DIRS})
if (NOT GMOCK_INCLUDE_DIRS)
message(FATAL_ERROR "Failed to find header gmock/gmock.h with hint ${GTEST_INCLUDE_DIRS}")
endif()
set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS})
# FIXME: We don't currently require the gmock library to build the tests,
# and it's likely we won't find it, so we don't try. As long as we've
# found the gmock/gmock.h header and gtest_main that should be good enough.
endif()
endif()

View File

@@ -0,0 +1,16 @@
include(FeatureSummary)
find_program(LLVMAR_EXECUTABLE
NAMES llvm-ar
DOC "The llvm-ar executable"
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LLVMAr
DEFAULT_MSG
LLVMAR_EXECUTABLE)
SET_PACKAGE_PROPERTIES(LLVMAr PROPERTIES
URL https://llvm.org/docs/CommandGuide/llvm-ar.html
DESCRIPTION "create, modify, and extract from archives"
)

View File

@@ -0,0 +1,16 @@
include(FeatureSummary)
find_program(LLVMNM_EXECUTABLE
NAMES llvm-nm
DOC "The llvm-nm executable"
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LLVMNm
DEFAULT_MSG
LLVMNM_EXECUTABLE)
SET_PACKAGE_PROPERTIES(LLVMNm PROPERTIES
URL https://llvm.org/docs/CommandGuide/llvm-nm.html
DESCRIPTION "list LLVM bitcode and object files symbol table"
)

View File

@@ -0,0 +1,15 @@
include(FeatureSummary)
find_program(LLVMRANLIB_EXECUTABLE
NAMES llvm-ranlib
DOC "The llvm-ranlib executable"
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LLVMRanLib
DEFAULT_MSG
LLVMRANLIB_EXECUTABLE)
SET_PACKAGE_PROPERTIES(LLVMRanLib PROPERTIES
DESCRIPTION "generate index for LLVM archive"
)

View File

@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: @PROJECT_NAME@
Description: Google microbenchmark framework
Version: @VERSION@
Libs: -L${libdir} -lbenchmark
Cflags: -I${includedir}

View File

@@ -0,0 +1,12 @@
#include <gnuregex.h>
#include <string>
int main() {
std::string str = "test0159";
regex_t re;
int ec = regcomp(&re, "^[a-z]+[0-9]+$", REG_EXTENDED | REG_NOSUB);
if (ec != 0) {
return ec;
}
return regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0;
}

View File

@@ -0,0 +1,8 @@
find_package(LLVMAr REQUIRED)
set(CMAKE_AR "${LLVMAR_EXECUTABLE}" CACHE FILEPATH "" FORCE)
find_package(LLVMNm REQUIRED)
set(CMAKE_NM "${LLVMNM_EXECUTABLE}" CACHE FILEPATH "" FORCE)
find_package(LLVMRanLib REQUIRED)
set(CMAKE_RANLIB "${LLVMRANLIB_EXECUTABLE}" CACHE FILEPATH "" FORCE)

View File

@@ -0,0 +1,14 @@
#include <regex.h>
#include <string>
int main() {
std::string str = "test0159";
regex_t re;
int ec = regcomp(&re, "^[a-z]+[0-9]+$", REG_EXTENDED | REG_NOSUB);
if (ec != 0) {
return ec;
}
int ret = regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0;
regfree(&re);
return ret;
}

View File

@@ -0,0 +1,3 @@
macro(split_list listname)
string(REPLACE ";" " " ${listname} "${${listname}}")
endmacro()

View File

@@ -0,0 +1,10 @@
#include <regex>
#include <string>
int main() {
const std::string str = "test0159";
std::regex re;
re = std::regex("^[a-z]+[0-9]+$",
std::regex_constants::extended | std::regex_constants::nosubs);
return std::regex_search(str, re) ? 0 : -1;
}

View File

@@ -0,0 +1,7 @@
#include <chrono>
int main() {
typedef std::chrono::steady_clock Clock;
Clock::time_point tp = Clock::now();
((void)tp);
}

View File

@@ -0,0 +1,4 @@
#define HAVE_THREAD_SAFETY_ATTRIBUTES
#include "../src/mutex.h"
int main() {}

View File

@@ -0,0 +1,147 @@
# Assembly Tests
The Benchmark library provides a number of functions whose primary
purpose in to affect assembly generation, including `DoNotOptimize`
and `ClobberMemory`. In addition there are other functions,
such as `KeepRunning`, for which generating good assembly is paramount.
For these functions it's important to have tests that verify the
correctness and quality of the implementation. This requires testing
the code generated by the compiler.
This document describes how the Benchmark library tests compiler output,
as well as how to properly write new tests.
## Anatomy of a Test
Writing a test has two steps:
* Write the code you want to generate assembly for.
* Add `// CHECK` lines to match against the verified assembly.
Example:
```c++
// CHECK-LABEL: test_add:
extern "C" int test_add() {
extern int ExternInt;
return ExternInt + 1;
// CHECK: movl ExternInt(%rip), %eax
// CHECK: addl %eax
// CHECK: ret
}
```
#### LLVM Filecheck
[LLVM's Filecheck](https://llvm.org/docs/CommandGuide/FileCheck.html)
is used to test the generated assembly against the `// CHECK` lines
specified in the tests source file. Please see the documentation
linked above for information on how to write `CHECK` directives.
#### Tips and Tricks:
* Tests should match the minimal amount of output required to establish
correctness. `CHECK` directives don't have to match on the exact next line
after the previous match, so tests should omit checks for unimportant
bits of assembly. ([`CHECK-NEXT`](https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-next-directive)
can be used to ensure a match occurs exactly after the previous match).
* The tests are compiled with `-O3 -g0`. So we're only testing the
optimized output.
* The assembly output is further cleaned up using `tools/strip_asm.py`.
This removes comments, assembler directives, and unused labels before
the test is run.
* The generated and stripped assembly file for a test is output under
`<build-directory>/test/<test-name>.s`
* Filecheck supports using [`CHECK` prefixes](https://llvm.org/docs/CommandGuide/FileCheck.html#cmdoption-check-prefixes)
to specify lines that should only match in certain situations.
The Benchmark tests use `CHECK-CLANG` and `CHECK-GNU` for lines that
are only expected to match Clang or GCC's output respectively. Normal
`CHECK` lines match against all compilers. (Note: `CHECK-NOT` and
`CHECK-LABEL` are NOT prefixes. They are versions of non-prefixed
`CHECK` lines)
* Use `extern "C"` to disable name mangling for specific functions. This
makes them easier to name in the `CHECK` lines.
## Problems Writing Portable Tests
Writing tests which check the code generated by a compiler are
inherently non-portable. Different compilers and even different compiler
versions may generate entirely different code. The Benchmark tests
must tolerate this.
LLVM Filecheck provides a number of mechanisms to help write
"more portable" tests; including [matching using regular expressions](https://llvm.org/docs/CommandGuide/FileCheck.html#filecheck-pattern-matching-syntax),
allowing the creation of [named variables](https://llvm.org/docs/CommandGuide/FileCheck.html#filecheck-variables)
for later matching, and [checking non-sequential matches](https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-dag-directive).
#### Capturing Variables
For example, say GCC stores a variable in a register but Clang stores
it in memory. To write a test that tolerates both cases we "capture"
the destination of the store, and then use the captured expression
to write the remainder of the test.
```c++
// CHECK-LABEL: test_div_no_op_into_shr:
extern "C" void test_div_no_op_into_shr(int value) {
int divisor = 2;
benchmark::DoNotOptimize(divisor); // hide the value from the optimizer
return value / divisor;
// CHECK: movl $2, [[DEST:.*]]
// CHECK: idivl [[DEST]]
// CHECK: ret
}
```
#### Using Regular Expressions to Match Differing Output
Often tests require testing assembly lines which may subtly differ
between compilers or compiler versions. A common example of this
is matching stack frame addresses. In this case regular expressions
can be used to match the differing bits of output. For example:
```c++
int ExternInt;
struct Point { int x, y, z; };
// CHECK-LABEL: test_store_point:
extern "C" void test_store_point() {
Point p{ExternInt, ExternInt, ExternInt};
benchmark::DoNotOptimize(p);
// CHECK: movl ExternInt(%rip), %eax
// CHECK: movl %eax, -{{[0-9]+}}(%rsp)
// CHECK: movl %eax, -{{[0-9]+}}(%rsp)
// CHECK: movl %eax, -{{[0-9]+}}(%rsp)
// CHECK: ret
}
```
## Current Requirements and Limitations
The tests require Filecheck to be installed along the `PATH` of the
build machine. Otherwise the tests will be disabled.
Additionally, as mentioned in the previous section, codegen tests are
inherently non-portable. Currently the tests are limited to:
* x86_64 targets.
* Compiled with GCC or Clang
Further work could be done, at least on a limited basis, to extend the
tests to other architectures and compilers (using `CHECK` prefixes).
Furthermore, the tests fail for builds which specify additional flags
that modify code generation, including `--coverage` or `-fsanitize=`.

242
benchmarks/thirdparty/benchmark/docs/tools.md vendored Executable file
View File

@@ -0,0 +1,242 @@
# Benchmark Tools
## compare_bench.py
The `compare_bench.py` utility which can be used to compare the result of benchmarks.
The program is invoked like:
``` bash
$ compare_bench.py <old-benchmark> <new-benchmark> [benchmark options]...
```
Where `<old-benchmark>` and `<new-benchmark>` either specify a benchmark executable file, or a JSON output file. The type of the input file is automatically detected. If a benchmark executable is specified then the benchmark is run to obtain the results. Otherwise the results are simply loaded from the output file.
`[benchmark options]` will be passed to the benchmarks invocations. They can be anything that binary accepts, be it either normal `--benchmark_*` parameters, or some custom parameters your binary takes.
The sample output using the JSON test files under `Inputs/` gives:
``` bash
$ ./compare_bench.py ./gbench/Inputs/test1_run1.json ./gbench/Inputs/test1_run2.json
Comparing ./gbench/Inputs/test1_run1.json to ./gbench/Inputs/test1_run2.json
Benchmark Time CPU Time Old Time New CPU Old CPU New
-------------------------------------------------------------------------------------------------------------
BM_SameTimes +0.0000 +0.0000 10 10 10 10
BM_2xFaster -0.5000 -0.5000 50 25 50 25
BM_2xSlower +1.0000 +1.0000 50 100 50 100
BM_1PercentFaster -0.0100 -0.0100 100 99 100 99
BM_1PercentSlower +0.0100 +0.0100 100 101 100 101
BM_10PercentFaster -0.1000 -0.1000 100 90 100 90
BM_10PercentSlower +0.1000 +0.1000 100 110 100 110
BM_100xSlower +99.0000 +99.0000 100 10000 100 10000
BM_100xFaster -0.9900 -0.9900 10000 100 10000 100
BM_10PercentCPUToTime +0.1000 -0.1000 100 110 100 90
BM_ThirdFaster -0.3333 -0.3334 100 67 100 67
BM_BadTimeUnit -0.9000 +0.2000 0 0 0 1
```
As you can note, the values in `Time` and `CPU` columns are calculated as `(new - old) / |old|`.
When a benchmark executable is run, the raw output from the benchmark is printed in real time to stdout. The sample output using `benchmark/basic_test` for both arguments looks like:
```
./compare_bench.py test/basic_test test/basic_test --benchmark_filter=BM_empty.*
RUNNING: test/basic_test --benchmark_filter=BM_empty.* --benchmark_out=/tmp/tmpN7LF3a
Run on (8 X 4000 MHz CPU s)
2017-11-07 23:28:36
---------------------------------------------------------------------
Benchmark Time CPU Iterations
---------------------------------------------------------------------
BM_empty 4 ns 4 ns 170178757
BM_empty/threads:8 1 ns 7 ns 103868920
BM_empty_stop_start 0 ns 0 ns 1000000000
BM_empty_stop_start/threads:8 0 ns 0 ns 1403031720
RUNNING: /test/basic_test --benchmark_filter=BM_empty.* --benchmark_out=/tmp/tmplvrIp8
Run on (8 X 4000 MHz CPU s)
2017-11-07 23:28:38
---------------------------------------------------------------------
Benchmark Time CPU Iterations
---------------------------------------------------------------------
BM_empty 4 ns 4 ns 169534855
BM_empty/threads:8 1 ns 7 ns 104188776
BM_empty_stop_start 0 ns 0 ns 1000000000
BM_empty_stop_start/threads:8 0 ns 0 ns 1404159424
Comparing ../build/test/basic_test to ../build/test/basic_test
Benchmark Time CPU Time Old Time New CPU Old CPU New
---------------------------------------------------------------------------------------------------------------------
BM_empty -0.0048 -0.0049 4 4 4 4
BM_empty/threads:8 -0.0123 -0.0054 1 1 7 7
BM_empty_stop_start -0.0000 -0.0000 0 0 0 0
BM_empty_stop_start/threads:8 -0.0029 +0.0001 0 0 0 0
```
As you can note, the values in `Time` and `CPU` columns are calculated as `(new - old) / |old|`.
Obviously this example doesn't give any useful output, but it's intended to show the output format when 'compare_bench.py' needs to run benchmarks.
## compare.py
The `compare.py` can be used to compare the result of benchmarks.
There are three modes of operation:
1. Just compare two benchmarks, what `compare_bench.py` did.
The program is invoked like:
``` bash
$ compare.py benchmarks <benchmark_baseline> <benchmark_contender> [benchmark options]...
```
Where `<benchmark_baseline>` and `<benchmark_contender>` either specify a benchmark executable file, or a JSON output file. The type of the input file is automatically detected. If a benchmark executable is specified then the benchmark is run to obtain the results. Otherwise the results are simply loaded from the output file.
`[benchmark options]` will be passed to the benchmarks invocations. They can be anything that binary accepts, be it either normal `--benchmark_*` parameters, or some custom parameters your binary takes.
Example output:
```
$ ./compare.py benchmarks ./a.out ./a.out
RUNNING: ./a.out --benchmark_out=/tmp/tmprBT5nW
Run on (8 X 4000 MHz CPU s)
2017-11-07 21:16:44
------------------------------------------------------
Benchmark Time CPU Iterations
------------------------------------------------------
BM_memcpy/8 36 ns 36 ns 19101577 211.669MB/s
BM_memcpy/64 76 ns 76 ns 9412571 800.199MB/s
BM_memcpy/512 84 ns 84 ns 8249070 5.64771GB/s
BM_memcpy/1024 116 ns 116 ns 6181763 8.19505GB/s
BM_memcpy/8192 643 ns 643 ns 1062855 11.8636GB/s
BM_copy/8 222 ns 222 ns 3137987 34.3772MB/s
BM_copy/64 1608 ns 1608 ns 432758 37.9501MB/s
BM_copy/512 12589 ns 12589 ns 54806 38.7867MB/s
BM_copy/1024 25169 ns 25169 ns 27713 38.8003MB/s
BM_copy/8192 201165 ns 201112 ns 3486 38.8466MB/s
RUNNING: ./a.out --benchmark_out=/tmp/tmpt1wwG_
Run on (8 X 4000 MHz CPU s)
2017-11-07 21:16:53
------------------------------------------------------
Benchmark Time CPU Iterations
------------------------------------------------------
BM_memcpy/8 36 ns 36 ns 19397903 211.255MB/s
BM_memcpy/64 73 ns 73 ns 9691174 839.635MB/s
BM_memcpy/512 85 ns 85 ns 8312329 5.60101GB/s
BM_memcpy/1024 118 ns 118 ns 6438774 8.11608GB/s
BM_memcpy/8192 656 ns 656 ns 1068644 11.6277GB/s
BM_copy/8 223 ns 223 ns 3146977 34.2338MB/s
BM_copy/64 1611 ns 1611 ns 435340 37.8751MB/s
BM_copy/512 12622 ns 12622 ns 54818 38.6844MB/s
BM_copy/1024 25257 ns 25239 ns 27779 38.6927MB/s
BM_copy/8192 205013 ns 205010 ns 3479 38.108MB/s
Comparing ./a.out to ./a.out
Benchmark Time CPU Time Old Time New CPU Old CPU New
------------------------------------------------------------------------------------------------------
BM_memcpy/8 +0.0020 +0.0020 36 36 36 36
BM_memcpy/64 -0.0468 -0.0470 76 73 76 73
BM_memcpy/512 +0.0081 +0.0083 84 85 84 85
BM_memcpy/1024 +0.0098 +0.0097 116 118 116 118
BM_memcpy/8192 +0.0200 +0.0203 643 656 643 656
BM_copy/8 +0.0046 +0.0042 222 223 222 223
BM_copy/64 +0.0020 +0.0020 1608 1611 1608 1611
BM_copy/512 +0.0027 +0.0026 12589 12622 12589 12622
BM_copy/1024 +0.0035 +0.0028 25169 25257 25169 25239
BM_copy/8192 +0.0191 +0.0194 201165 205013 201112 205010
```
What it does is for the every benchmark from the first run it looks for the benchmark with exactly the same name in the second run, and then compares the results. If the names differ, the benchmark is omitted from the diff.
As you can note, the values in `Time` and `CPU` columns are calculated as `(new - old) / |old|`.
2. Compare two different filters of one benchmark
The program is invoked like:
``` bash
$ compare.py filters <benchmark> <filter_baseline> <filter_contender> [benchmark options]...
```
Where `<benchmark>` either specify a benchmark executable file, or a JSON output file. The type of the input file is automatically detected. If a benchmark executable is specified then the benchmark is run to obtain the results. Otherwise the results are simply loaded from the output file.
Where `<filter_baseline>` and `<filter_contender>` are the same regex filters that you would pass to the `[--benchmark_filter=<regex>]` parameter of the benchmark binary.
`[benchmark options]` will be passed to the benchmarks invocations. They can be anything that binary accepts, be it either normal `--benchmark_*` parameters, or some custom parameters your binary takes.
Example output:
```
$ ./compare.py filters ./a.out BM_memcpy BM_copy
RUNNING: ./a.out --benchmark_filter=BM_memcpy --benchmark_out=/tmp/tmpBWKk0k
Run on (8 X 4000 MHz CPU s)
2017-11-07 21:37:28
------------------------------------------------------
Benchmark Time CPU Iterations
------------------------------------------------------
BM_memcpy/8 36 ns 36 ns 17891491 211.215MB/s
BM_memcpy/64 74 ns 74 ns 9400999 825.646MB/s
BM_memcpy/512 87 ns 87 ns 8027453 5.46126GB/s
BM_memcpy/1024 111 ns 111 ns 6116853 8.5648GB/s
BM_memcpy/8192 657 ns 656 ns 1064679 11.6247GB/s
RUNNING: ./a.out --benchmark_filter=BM_copy --benchmark_out=/tmp/tmpAvWcOM
Run on (8 X 4000 MHz CPU s)
2017-11-07 21:37:33
----------------------------------------------------
Benchmark Time CPU Iterations
----------------------------------------------------
BM_copy/8 227 ns 227 ns 3038700 33.6264MB/s
BM_copy/64 1640 ns 1640 ns 426893 37.2154MB/s
BM_copy/512 12804 ns 12801 ns 55417 38.1444MB/s
BM_copy/1024 25409 ns 25407 ns 27516 38.4365MB/s
BM_copy/8192 202986 ns 202990 ns 3454 38.4871MB/s
Comparing BM_memcpy to BM_copy (from ./a.out)
Benchmark Time CPU Time Old Time New CPU Old CPU New
--------------------------------------------------------------------------------------------------------------------
[BM_memcpy vs. BM_copy]/8 +5.2829 +5.2812 36 227 36 227
[BM_memcpy vs. BM_copy]/64 +21.1719 +21.1856 74 1640 74 1640
[BM_memcpy vs. BM_copy]/512 +145.6487 +145.6097 87 12804 87 12801
[BM_memcpy vs. BM_copy]/1024 +227.1860 +227.1776 111 25409 111 25407
[BM_memcpy vs. BM_copy]/8192 +308.1664 +308.2898 657 202986 656 202990
```
As you can see, it applies filter to the benchmarks, both when running the benchmark, and before doing the diff. And to make the diff work, the matches are replaced with some common string. Thus, you can compare two different benchmark families within one benchmark binary.
As you can note, the values in `Time` and `CPU` columns are calculated as `(new - old) / |old|`.
3. Compare filter one from benchmark one to filter two from benchmark two:
The program is invoked like:
``` bash
$ compare.py filters <benchmark_baseline> <filter_baseline> <benchmark_contender> <filter_contender> [benchmark options]...
```
Where `<benchmark_baseline>` and `<benchmark_contender>` either specify a benchmark executable file, or a JSON output file. The type of the input file is automatically detected. If a benchmark executable is specified then the benchmark is run to obtain the results. Otherwise the results are simply loaded from the output file.
Where `<filter_baseline>` and `<filter_contender>` are the same regex filters that you would pass to the `[--benchmark_filter=<regex>]` parameter of the benchmark binary.
`[benchmark options]` will be passed to the benchmarks invocations. They can be anything that binary accepts, be it either normal `--benchmark_*` parameters, or some custom parameters your binary takes.
Example output:
```
$ ./compare.py benchmarksfiltered ./a.out BM_memcpy ./a.out BM_copy
RUNNING: ./a.out --benchmark_filter=BM_memcpy --benchmark_out=/tmp/tmp_FvbYg
Run on (8 X 4000 MHz CPU s)
2017-11-07 21:38:27
------------------------------------------------------
Benchmark Time CPU Iterations
------------------------------------------------------
BM_memcpy/8 37 ns 37 ns 18953482 204.118MB/s
BM_memcpy/64 74 ns 74 ns 9206578 828.245MB/s
BM_memcpy/512 91 ns 91 ns 8086195 5.25476GB/s
BM_memcpy/1024 120 ns 120 ns 5804513 7.95662GB/s
BM_memcpy/8192 664 ns 664 ns 1028363 11.4948GB/s
RUNNING: ./a.out --benchmark_filter=BM_copy --benchmark_out=/tmp/tmpDfL5iE
Run on (8 X 4000 MHz CPU s)
2017-11-07 21:38:32
----------------------------------------------------
Benchmark Time CPU Iterations
----------------------------------------------------
BM_copy/8 230 ns 230 ns 2985909 33.1161MB/s
BM_copy/64 1654 ns 1653 ns 419408 36.9137MB/s
BM_copy/512 13122 ns 13120 ns 53403 37.2156MB/s
BM_copy/1024 26679 ns 26666 ns 26575 36.6218MB/s
BM_copy/8192 215068 ns 215053 ns 3221 36.3283MB/s
Comparing BM_memcpy (from ./a.out) to BM_copy (from ./a.out)
Benchmark Time CPU Time Old Time New CPU Old CPU New
--------------------------------------------------------------------------------------------------------------------
[BM_memcpy vs. BM_copy]/8 +5.1649 +5.1637 37 230 37 230
[BM_memcpy vs. BM_copy]/64 +21.4352 +21.4374 74 1654 74 1653
[BM_memcpy vs. BM_copy]/512 +143.6022 +143.5865 91 13122 91 13120
[BM_memcpy vs. BM_copy]/1024 +221.5903 +221.4790 120 26679 120 26666
[BM_memcpy vs. BM_copy]/8192 +322.9059 +323.0096 664 215068 664 215053
```
This is a mix of the previous two modes, two (potentially different) benchmark binaries are run, and a different filter is applied to each one.
As you can note, the values in `Time` and `CPU` columns are calculated as `(new - old) / |old|`.

File diff suppressed because it is too large Load Diff

320
benchmarks/thirdparty/benchmark/mingw.py vendored Executable file
View File

@@ -0,0 +1,320 @@
#! /usr/bin/env python
# encoding: utf-8
import argparse
import errno
import logging
import os
import platform
import re
import sys
import subprocess
import tempfile
try:
import winreg
except ImportError:
import _winreg as winreg
try:
import urllib.request as request
except ImportError:
import urllib as request
try:
import urllib.parse as parse
except ImportError:
import urlparse as parse
class EmptyLogger(object):
'''
Provides an implementation that performs no logging
'''
def debug(self, *k, **kw):
pass
def info(self, *k, **kw):
pass
def warn(self, *k, **kw):
pass
def error(self, *k, **kw):
pass
def critical(self, *k, **kw):
pass
def setLevel(self, *k, **kw):
pass
urls = (
'http://downloads.sourceforge.net/project/mingw-w64/Toolchains%20'
'targetting%20Win32/Personal%20Builds/mingw-builds/installer/'
'repository.txt',
'http://downloads.sourceforge.net/project/mingwbuilds/host-windows/'
'repository.txt'
)
'''
A list of mingw-build repositories
'''
def repository(urls = urls, log = EmptyLogger()):
'''
Downloads and parse mingw-build repository files and parses them
'''
log.info('getting mingw-builds repository')
versions = {}
re_sourceforge = re.compile(r'http://sourceforge.net/projects/([^/]+)/files')
re_sub = r'http://downloads.sourceforge.net/project/\1'
for url in urls:
log.debug(' - requesting: %s', url)
socket = request.urlopen(url)
repo = socket.read()
if not isinstance(repo, str):
repo = repo.decode();
socket.close()
for entry in repo.split('\n')[:-1]:
value = entry.split('|')
version = tuple([int(n) for n in value[0].strip().split('.')])
version = versions.setdefault(version, {})
arch = value[1].strip()
if arch == 'x32':
arch = 'i686'
elif arch == 'x64':
arch = 'x86_64'
arch = version.setdefault(arch, {})
threading = arch.setdefault(value[2].strip(), {})
exceptions = threading.setdefault(value[3].strip(), {})
revision = exceptions.setdefault(int(value[4].strip()[3:]),
re_sourceforge.sub(re_sub, value[5].strip()))
return versions
def find_in_path(file, path=None):
'''
Attempts to find an executable in the path
'''
if platform.system() == 'Windows':
file += '.exe'
if path is None:
path = os.environ.get('PATH', '')
if type(path) is type(''):
path = path.split(os.pathsep)
return list(filter(os.path.exists,
map(lambda dir, file=file: os.path.join(dir, file), path)))
def find_7zip(log = EmptyLogger()):
'''
Attempts to find 7zip for unpacking the mingw-build archives
'''
log.info('finding 7zip')
path = find_in_path('7z')
if not path:
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\7-Zip')
path, _ = winreg.QueryValueEx(key, 'Path')
path = [os.path.join(path, '7z.exe')]
log.debug('found \'%s\'', path[0])
return path[0]
find_7zip()
def unpack(archive, location, log = EmptyLogger()):
'''
Unpacks a mingw-builds archive
'''
sevenzip = find_7zip(log)
log.info('unpacking %s', os.path.basename(archive))
cmd = [sevenzip, 'x', archive, '-o' + location, '-y']
log.debug(' - %r', cmd)
with open(os.devnull, 'w') as devnull:
subprocess.check_call(cmd, stdout = devnull)
def download(url, location, log = EmptyLogger()):
'''
Downloads and unpacks a mingw-builds archive
'''
log.info('downloading MinGW')
log.debug(' - url: %s', url)
log.debug(' - location: %s', location)
re_content = re.compile(r'attachment;[ \t]*filename=(")?([^"]*)(")?[\r\n]*')
stream = request.urlopen(url)
try:
content = stream.getheader('Content-Disposition') or ''
except AttributeError:
content = stream.headers.getheader('Content-Disposition') or ''
matches = re_content.match(content)
if matches:
filename = matches.group(2)
else:
parsed = parse.urlparse(stream.geturl())
filename = os.path.basename(parsed.path)
try:
os.makedirs(location)
except OSError as e:
if e.errno == errno.EEXIST and os.path.isdir(location):
pass
else:
raise
archive = os.path.join(location, filename)
with open(archive, 'wb') as out:
while True:
buf = stream.read(1024)
if not buf:
break
out.write(buf)
unpack(archive, location, log = log)
os.remove(archive)
possible = os.path.join(location, 'mingw64')
if not os.path.exists(possible):
possible = os.path.join(location, 'mingw32')
if not os.path.exists(possible):
raise ValueError('Failed to find unpacked MinGW: ' + possible)
return possible
def root(location = None, arch = None, version = None, threading = None,
exceptions = None, revision = None, log = EmptyLogger()):
'''
Returns the root folder of a specific version of the mingw-builds variant
of gcc. Will download the compiler if needed
'''
# Get the repository if we don't have all the information
if not (arch and version and threading and exceptions and revision):
versions = repository(log = log)
# Determine some defaults
version = version or max(versions.keys())
if not arch:
arch = platform.machine().lower()
if arch == 'x86':
arch = 'i686'
elif arch == 'amd64':
arch = 'x86_64'
if not threading:
keys = versions[version][arch].keys()
if 'posix' in keys:
threading = 'posix'
elif 'win32' in keys:
threading = 'win32'
else:
threading = keys[0]
if not exceptions:
keys = versions[version][arch][threading].keys()
if 'seh' in keys:
exceptions = 'seh'
elif 'sjlj' in keys:
exceptions = 'sjlj'
else:
exceptions = keys[0]
if revision == None:
revision = max(versions[version][arch][threading][exceptions].keys())
if not location:
location = os.path.join(tempfile.gettempdir(), 'mingw-builds')
# Get the download url
url = versions[version][arch][threading][exceptions][revision]
# Tell the user whatzzup
log.info('finding MinGW %s', '.'.join(str(v) for v in version))
log.debug(' - arch: %s', arch)
log.debug(' - threading: %s', threading)
log.debug(' - exceptions: %s', exceptions)
log.debug(' - revision: %s', revision)
log.debug(' - url: %s', url)
# Store each specific revision differently
slug = '{version}-{arch}-{threading}-{exceptions}-rev{revision}'
slug = slug.format(
version = '.'.join(str(v) for v in version),
arch = arch,
threading = threading,
exceptions = exceptions,
revision = revision
)
if arch == 'x86_64':
root_dir = os.path.join(location, slug, 'mingw64')
elif arch == 'i686':
root_dir = os.path.join(location, slug, 'mingw32')
else:
raise ValueError('Unknown MinGW arch: ' + arch)
# Download if needed
if not os.path.exists(root_dir):
downloaded = download(url, os.path.join(location, slug), log = log)
if downloaded != root_dir:
raise ValueError('The location of mingw did not match\n%s\n%s'
% (downloaded, root_dir))
return root_dir
def str2ver(string):
'''
Converts a version string into a tuple
'''
try:
version = tuple(int(v) for v in string.split('.'))
if len(version) is not 3:
raise ValueError()
except ValueError:
raise argparse.ArgumentTypeError(
'please provide a three digit version string')
return version
def main():
'''
Invoked when the script is run directly by the python interpreter
'''
parser = argparse.ArgumentParser(
description = 'Downloads a specific version of MinGW',
formatter_class = argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument('--location',
help = 'the location to download the compiler to',
default = os.path.join(tempfile.gettempdir(), 'mingw-builds'))
parser.add_argument('--arch', required = True, choices = ['i686', 'x86_64'],
help = 'the target MinGW architecture string')
parser.add_argument('--version', type = str2ver,
help = 'the version of GCC to download')
parser.add_argument('--threading', choices = ['posix', 'win32'],
help = 'the threading type of the compiler')
parser.add_argument('--exceptions', choices = ['sjlj', 'seh', 'dwarf'],
help = 'the method to throw exceptions')
parser.add_argument('--revision', type=int,
help = 'the revision of the MinGW release')
group = parser.add_mutually_exclusive_group()
group.add_argument('-v', '--verbose', action='store_true',
help='increase the script output verbosity')
group.add_argument('-q', '--quiet', action='store_true',
help='only print errors and warning')
args = parser.parse_args()
# Create the logger
logger = logging.getLogger('mingw')
handler = logging.StreamHandler()
formatter = logging.Formatter('%(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.INFO)
if args.quiet:
logger.setLevel(logging.WARN)
if args.verbose:
logger.setLevel(logging.DEBUG)
# Get MinGW
root_dir = root(location = args.location, arch = args.arch,
version = args.version, threading = args.threading,
exceptions = args.exceptions, revision = args.revision,
log = logger)
sys.stdout.write('%s\n' % os.path.join(root_dir, 'bin'))
if __name__ == '__main__':
try:
main()
except IOError as e:
sys.stderr.write('IO error: %s\n' % e)
sys.exit(1)
except OSError as e:
sys.stderr.write('OS error: %s\n' % e)
sys.exit(1)
except KeyboardInterrupt as e:
sys.stderr.write('Killed\n')
sys.exit(1)

16
benchmarks/thirdparty/benchmark/releasing.md vendored Executable file
View File

@@ -0,0 +1,16 @@
# How to release
* Make sure you're on master and synced to HEAD
* Ensure the project builds and tests run (sanity check only, obviously)
* `parallel -j0 exec ::: test/*_test` can help ensure everything at least
passes
* Prepare release notes
* `git log $(git describe --abbrev=0 --tags)..HEAD` gives you the list of
commits between the last annotated tag and HEAD
* Pick the most interesting.
* Create a release through github's interface
* Note this will create a lightweight tag.
* Update this to an annotated tag:
* `git pull --tags`
* `git tag -a -f <tag> <tag>`
* `git push --force origin`

View File

@@ -0,0 +1,105 @@
# Allow the source files to find headers in src/
include_directories(${PROJECT_SOURCE_DIR}/src)
if (DEFINED BENCHMARK_CXX_LINKER_FLAGS)
list(APPEND CMAKE_SHARED_LINKER_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS})
list(APPEND CMAKE_MODULE_LINKER_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS})
endif()
file(GLOB
SOURCE_FILES
*.cc
${PROJECT_SOURCE_DIR}/include/benchmark/*.h
${CMAKE_CURRENT_SOURCE_DIR}/*.h)
list(FILTER SOURCE_FILES EXCLUDE REGEX "benchmark_main\\.cc")
add_library(benchmark ${SOURCE_FILES})
set_target_properties(benchmark PROPERTIES
OUTPUT_NAME "benchmark"
VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_SOVERSION}
)
target_include_directories(benchmark PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
)
# Link threads.
target_link_libraries(benchmark ${BENCHMARK_CXX_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
find_library(LIBRT rt)
if(LIBRT)
target_link_libraries(benchmark ${LIBRT})
endif()
# We need extra libraries on Windows
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
target_link_libraries(benchmark Shlwapi)
endif()
# We need extra libraries on Solaris
if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
target_link_libraries(benchmark kstat)
endif()
# Benchmark main library
add_library(benchmark_main "benchmark_main.cc")
set_target_properties(benchmark_main PROPERTIES
OUTPUT_NAME "benchmark_main"
VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_SOVERSION}
)
target_include_directories(benchmark PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
)
target_link_libraries(benchmark_main benchmark)
set(include_install_dir "include")
set(lib_install_dir "lib/")
set(bin_install_dir "bin/")
set(config_install_dir "lib/cmake/${PROJECT_NAME}")
set(pkgconfig_install_dir "lib/pkgconfig")
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
set(pkg_config "${generated_dir}/${PROJECT_NAME}.pc")
set(targets_export_name "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${version_config}" VERSION ${GIT_VERSION} COMPATIBILITY SameMajorVersion
)
configure_file("${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in" "${project_config}" @ONLY)
configure_file("${PROJECT_SOURCE_DIR}/cmake/benchmark.pc.in" "${pkg_config}" @ONLY)
if (BENCHMARK_ENABLE_INSTALL)
# Install target (will install the library to specified CMAKE_INSTALL_PREFIX variable)
install(
TARGETS benchmark benchmark_main
EXPORT ${targets_export_name}
ARCHIVE DESTINATION ${lib_install_dir}
LIBRARY DESTINATION ${lib_install_dir}
RUNTIME DESTINATION ${bin_install_dir}
INCLUDES DESTINATION ${include_install_dir})
install(
DIRECTORY "${PROJECT_SOURCE_DIR}/include/benchmark"
DESTINATION ${include_install_dir}
FILES_MATCHING PATTERN "*.*h")
install(
FILES "${project_config}" "${version_config}"
DESTINATION "${config_install_dir}")
install(
FILES "${pkg_config}"
DESTINATION "${pkgconfig_install_dir}")
install(
EXPORT "${targets_export_name}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}")
endif()

View File

@@ -0,0 +1,33 @@
#ifndef BENCHMARK_ARRAYSIZE_H_
#define BENCHMARK_ARRAYSIZE_H_
#include "internal_macros.h"
namespace benchmark {
namespace internal {
// The arraysize(arr) macro returns the # of elements in an array arr.
// The expression is a compile-time constant, and therefore can be
// used in defining new arrays, for example. If you use arraysize on
// a pointer by mistake, you will get a compile-time error.
//
// This template function declaration is used in defining arraysize.
// Note that the function doesn't need an implementation, as we only
// use its type.
template <typename T, size_t N>
char (&ArraySizeHelper(T (&array)[N]))[N];
// That gcc wants both of these prototypes seems mysterious. VC, for
// its part, can't decide which to use (another mystery). Matching of
// template overloads: the final frontier.
#ifndef COMPILER_MSVC
template <typename T, size_t N>
char (&ArraySizeHelper(const T (&array)[N]))[N];
#endif
#define arraysize(array) (sizeof(::benchmark::internal::ArraySizeHelper(array)))
} // end namespace internal
} // end namespace benchmark
#endif // BENCHMARK_ARRAYSIZE_H_

View File

@@ -0,0 +1,630 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "benchmark/benchmark.h"
#include "benchmark_api_internal.h"
#include "internal_macros.h"
#ifndef BENCHMARK_OS_WINDOWS
#ifndef BENCHMARK_OS_FUCHSIA
#include <sys/resource.h>
#endif
#include <sys/time.h>
#include <unistd.h>
#endif
#include <algorithm>
#include <atomic>
#include <condition_variable>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include "check.h"
#include "colorprint.h"
#include "commandlineflags.h"
#include "complexity.h"
#include "counter.h"
#include "internal_macros.h"
#include "log.h"
#include "mutex.h"
#include "re.h"
#include "statistics.h"
#include "string_util.h"
#include "thread_manager.h"
#include "thread_timer.h"
DEFINE_bool(benchmark_list_tests, false,
"Print a list of benchmarks. This option overrides all other "
"options.");
DEFINE_string(benchmark_filter, ".",
"A regular expression that specifies the set of benchmarks "
"to execute. If this flag is empty, no benchmarks are run. "
"If this flag is the string \"all\", all benchmarks linked "
"into the process are run.");
DEFINE_double(benchmark_min_time, 0.5,
"Minimum number of seconds we should run benchmark before "
"results are considered significant. For cpu-time based "
"tests, this is the lower bound on the total cpu time "
"used by all threads that make up the test. For real-time "
"based tests, this is the lower bound on the elapsed time "
"of the benchmark execution, regardless of number of "
"threads.");
DEFINE_int32(benchmark_repetitions, 1,
"The number of runs of each benchmark. If greater than 1, the "
"mean and standard deviation of the runs will be reported.");
DEFINE_bool(benchmark_report_aggregates_only, false,
"Report the result of each benchmark repetitions. When 'true' is "
"specified only the mean, standard deviation, and other statistics "
"are reported for repeated benchmarks.");
DEFINE_string(benchmark_format, "console",
"The format to use for console output. Valid values are "
"'console', 'json', or 'csv'.");
DEFINE_string(benchmark_out_format, "json",
"The format to use for file output. Valid values are "
"'console', 'json', or 'csv'.");
DEFINE_string(benchmark_out, "", "The file to write additional output to");
DEFINE_string(benchmark_color, "auto",
"Whether to use colors in the output. Valid values: "
"'true'/'yes'/1, 'false'/'no'/0, and 'auto'. 'auto' means to use "
"colors if the output is being sent to a terminal and the TERM "
"environment variable is set to a terminal type that supports "
"colors.");
DEFINE_bool(benchmark_counters_tabular, false,
"Whether to use tabular format when printing user counters to "
"the console. Valid values: 'true'/'yes'/1, 'false'/'no'/0."
"Defaults to false.");
DEFINE_int32(v, 0, "The level of verbose logging to output");
namespace benchmark {
namespace {
static const size_t kMaxIterations = 1000000000;
} // end namespace
namespace internal {
void UseCharPointer(char const volatile*) {}
namespace {
BenchmarkReporter::Run CreateRunReport(
const benchmark::internal::Benchmark::Instance& b,
const internal::ThreadManager::Result& results,
double seconds) {
// Create report about this benchmark run.
BenchmarkReporter::Run report;
report.benchmark_name = b.name;
report.error_occurred = results.has_error_;
report.error_message = results.error_message_;
report.report_label = results.report_label_;
// This is the total iterations across all threads.
report.iterations = results.iterations;
report.time_unit = b.time_unit;
if (!report.error_occurred) {
double bytes_per_second = 0;
if (results.bytes_processed > 0 && seconds > 0.0) {
bytes_per_second = (results.bytes_processed / seconds);
}
double items_per_second = 0;
if (results.items_processed > 0 && seconds > 0.0) {
items_per_second = (results.items_processed / seconds);
}
if (b.use_manual_time) {
report.real_accumulated_time = results.manual_time_used;
} else {
report.real_accumulated_time = results.real_time_used;
}
report.cpu_accumulated_time = results.cpu_time_used;
report.bytes_per_second = bytes_per_second;
report.items_per_second = items_per_second;
report.complexity_n = results.complexity_n;
report.complexity = b.complexity;
report.complexity_lambda = b.complexity_lambda;
report.statistics = b.statistics;
report.counters = results.counters;
internal::Finish(&report.counters, seconds, b.threads);
}
return report;
}
// Execute one thread of benchmark b for the specified number of iterations.
// Adds the stats collected for the thread into *total.
void RunInThread(const benchmark::internal::Benchmark::Instance* b,
size_t iters, int thread_id,
internal::ThreadManager* manager) {
internal::ThreadTimer timer;
State st(iters, b->arg, thread_id, b->threads, &timer, manager);
b->benchmark->Run(st);
CHECK(st.iterations() >= st.max_iterations)
<< "Benchmark returned before State::KeepRunning() returned false!";
{
MutexLock l(manager->GetBenchmarkMutex());
internal::ThreadManager::Result& results = manager->results;
results.iterations += st.iterations();
results.cpu_time_used += timer.cpu_time_used();
results.real_time_used += timer.real_time_used();
results.manual_time_used += timer.manual_time_used();
results.bytes_processed += st.bytes_processed();
results.items_processed += st.items_processed();
results.complexity_n += st.complexity_length_n();
internal::Increment(&results.counters, st.counters);
}
manager->NotifyThreadComplete();
}
std::vector<BenchmarkReporter::Run> RunBenchmark(
const benchmark::internal::Benchmark::Instance& b,
std::vector<BenchmarkReporter::Run>* complexity_reports) {
std::vector<BenchmarkReporter::Run> reports; // return value
const bool has_explicit_iteration_count = b.iterations != 0;
size_t iters = has_explicit_iteration_count ? b.iterations : 1;
std::unique_ptr<internal::ThreadManager> manager;
std::vector<std::thread> pool(b.threads - 1);
const int repeats =
b.repetitions != 0 ? b.repetitions : FLAGS_benchmark_repetitions;
const bool report_aggregates_only =
repeats != 1 &&
(b.report_mode == internal::RM_Unspecified
? FLAGS_benchmark_report_aggregates_only
: b.report_mode == internal::RM_ReportAggregatesOnly);
for (int repetition_num = 0; repetition_num < repeats; repetition_num++) {
for (;;) {
// Try benchmark
VLOG(2) << "Running " << b.name << " for " << iters << "\n";
manager.reset(new internal::ThreadManager(b.threads));
for (std::size_t ti = 0; ti < pool.size(); ++ti) {
pool[ti] = std::thread(&RunInThread, &b, iters,
static_cast<int>(ti + 1), manager.get());
}
RunInThread(&b, iters, 0, manager.get());
manager->WaitForAllThreads();
for (std::thread& thread : pool) thread.join();
internal::ThreadManager::Result results;
{
MutexLock l(manager->GetBenchmarkMutex());
results = manager->results;
}
manager.reset();
// Adjust real/manual time stats since they were reported per thread.
results.real_time_used /= b.threads;
results.manual_time_used /= b.threads;
VLOG(2) << "Ran in " << results.cpu_time_used << "/"
<< results.real_time_used << "\n";
// Base decisions off of real time if requested by this benchmark.
double seconds = results.cpu_time_used;
if (b.use_manual_time) {
seconds = results.manual_time_used;
} else if (b.use_real_time) {
seconds = results.real_time_used;
}
const double min_time =
!IsZero(b.min_time) ? b.min_time : FLAGS_benchmark_min_time;
// Determine if this run should be reported; Either it has
// run for a sufficient amount of time or because an error was reported.
const bool should_report = repetition_num > 0
|| has_explicit_iteration_count // An exact iteration count was requested
|| results.has_error_
|| iters >= kMaxIterations // No chance to try again, we hit the limit.
|| seconds >= min_time // the elapsed time is large enough
// CPU time is specified but the elapsed real time greatly exceeds the
// minimum time. Note that user provided timers are except from this
// sanity check.
|| ((results.real_time_used >= 5 * min_time) && !b.use_manual_time);
if (should_report) {
BenchmarkReporter::Run report = CreateRunReport(b, results, seconds);
if (!report.error_occurred && b.complexity != oNone)
complexity_reports->push_back(report);
reports.push_back(report);
break;
}
// See how much iterations should be increased by
// Note: Avoid division by zero with max(seconds, 1ns).
double multiplier = min_time * 1.4 / std::max(seconds, 1e-9);
// If our last run was at least 10% of FLAGS_benchmark_min_time then we
// use the multiplier directly. Otherwise we use at most 10 times
// expansion.
// NOTE: When the last run was at least 10% of the min time the max
// expansion should be 14x.
bool is_significant = (seconds / min_time) > 0.1;
multiplier = is_significant ? multiplier : std::min(10.0, multiplier);
if (multiplier <= 1.0) multiplier = 2.0;
double next_iters = std::max(multiplier * iters, iters + 1.0);
if (next_iters > kMaxIterations) {
next_iters = kMaxIterations;
}
VLOG(3) << "Next iters: " << next_iters << ", " << multiplier << "\n";
iters = static_cast<int>(next_iters + 0.5);
}
}
// Calculate additional statistics
auto stat_reports = ComputeStats(reports);
if ((b.complexity != oNone) && b.last_benchmark_instance) {
auto additional_run_stats = ComputeBigO(*complexity_reports);
stat_reports.insert(stat_reports.end(), additional_run_stats.begin(),
additional_run_stats.end());
complexity_reports->clear();
}
if (report_aggregates_only) reports.clear();
reports.insert(reports.end(), stat_reports.begin(), stat_reports.end());
return reports;
}
} // namespace
} // namespace internal
State::State(size_t max_iters, const std::vector<int64_t>& ranges, int thread_i,
int n_threads, internal::ThreadTimer* timer,
internal::ThreadManager* manager)
: total_iterations_(0),
batch_leftover_(0),
max_iterations(max_iters),
started_(false),
finished_(false),
error_occurred_(false),
range_(ranges),
bytes_processed_(0),
items_processed_(0),
complexity_n_(0),
counters(),
thread_index(thread_i),
threads(n_threads),
timer_(timer),
manager_(manager) {
CHECK(max_iterations != 0) << "At least one iteration must be run";
CHECK_LT(thread_index, threads) << "thread_index must be less than threads";
// Note: The use of offsetof below is technically undefined until C++17
// because State is not a standard layout type. However, all compilers
// currently provide well-defined behavior as an extension (which is
// demonstrated since constexpr evaluation must diagnose all undefined
// behavior). However, GCC and Clang also warn about this use of offsetof,
// which must be suppressed.
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif
// Offset tests to ensure commonly accessed data is on the first cache line.
const int cache_line_size = 64;
static_assert(offsetof(State, error_occurred_) <=
(cache_line_size - sizeof(error_occurred_)), "");
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
}
void State::PauseTiming() {
// Add in time accumulated so far
CHECK(started_ && !finished_ && !error_occurred_);
timer_->StopTimer();
}
void State::ResumeTiming() {
CHECK(started_ && !finished_ && !error_occurred_);
timer_->StartTimer();
}
void State::SkipWithError(const char* msg) {
CHECK(msg);
error_occurred_ = true;
{
MutexLock l(manager_->GetBenchmarkMutex());
if (manager_->results.has_error_ == false) {
manager_->results.error_message_ = msg;
manager_->results.has_error_ = true;
}
}
total_iterations_ = 0;
if (timer_->running()) timer_->StopTimer();
}
void State::SetIterationTime(double seconds) {
timer_->SetIterationTime(seconds);
}
void State::SetLabel(const char* label) {
MutexLock l(manager_->GetBenchmarkMutex());
manager_->results.report_label_ = label;
}
void State::StartKeepRunning() {
CHECK(!started_ && !finished_);
started_ = true;
total_iterations_ = error_occurred_ ? 0 : max_iterations;
manager_->StartStopBarrier();
if (!error_occurred_) ResumeTiming();
}
void State::FinishKeepRunning() {
CHECK(started_ && (!finished_ || error_occurred_));
if (!error_occurred_) {
PauseTiming();
}
// Total iterations has now wrapped around past 0. Fix this.
total_iterations_ = 0;
finished_ = true;
manager_->StartStopBarrier();
}
namespace internal {
namespace {
void RunBenchmarks(const std::vector<Benchmark::Instance>& benchmarks,
BenchmarkReporter* console_reporter,
BenchmarkReporter* file_reporter) {
// Note the file_reporter can be null.
CHECK(console_reporter != nullptr);
// Determine the width of the name field using a minimum width of 10.
bool has_repetitions = FLAGS_benchmark_repetitions > 1;
size_t name_field_width = 10;
size_t stat_field_width = 0;
for (const Benchmark::Instance& benchmark : benchmarks) {
name_field_width =
std::max<size_t>(name_field_width, benchmark.name.size());
has_repetitions |= benchmark.repetitions > 1;
for(const auto& Stat : *benchmark.statistics)
stat_field_width = std::max<size_t>(stat_field_width, Stat.name_.size());
}
if (has_repetitions) name_field_width += 1 + stat_field_width;
// Print header here
BenchmarkReporter::Context context;
context.name_field_width = name_field_width;
// Keep track of running times of all instances of current benchmark
std::vector<BenchmarkReporter::Run> complexity_reports;
// We flush streams after invoking reporter methods that write to them. This
// ensures users get timely updates even when streams are not line-buffered.
auto flushStreams = [](BenchmarkReporter* reporter) {
if (!reporter) return;
std::flush(reporter->GetOutputStream());
std::flush(reporter->GetErrorStream());
};
if (console_reporter->ReportContext(context) &&
(!file_reporter || file_reporter->ReportContext(context))) {
flushStreams(console_reporter);
flushStreams(file_reporter);
for (const auto& benchmark : benchmarks) {
std::vector<BenchmarkReporter::Run> reports =
RunBenchmark(benchmark, &complexity_reports);
console_reporter->ReportRuns(reports);
if (file_reporter) file_reporter->ReportRuns(reports);
flushStreams(console_reporter);
flushStreams(file_reporter);
}
}
console_reporter->Finalize();
if (file_reporter) file_reporter->Finalize();
flushStreams(console_reporter);
flushStreams(file_reporter);
}
std::unique_ptr<BenchmarkReporter> CreateReporter(
std::string const& name, ConsoleReporter::OutputOptions output_opts) {
typedef std::unique_ptr<BenchmarkReporter> PtrType;
if (name == "console") {
return PtrType(new ConsoleReporter(output_opts));
} else if (name == "json") {
return PtrType(new JSONReporter);
} else if (name == "csv") {
return PtrType(new CSVReporter);
} else {
std::cerr << "Unexpected format: '" << name << "'\n";
std::exit(1);
}
}
} // end namespace
bool IsZero(double n) {
return std::abs(n) < std::numeric_limits<double>::epsilon();
}
ConsoleReporter::OutputOptions GetOutputOptions(bool force_no_color) {
int output_opts = ConsoleReporter::OO_Defaults;
if ((FLAGS_benchmark_color == "auto" && IsColorTerminal()) ||
IsTruthyFlagValue(FLAGS_benchmark_color)) {
output_opts |= ConsoleReporter::OO_Color;
} else {
output_opts &= ~ConsoleReporter::OO_Color;
}
if(force_no_color) {
output_opts &= ~ConsoleReporter::OO_Color;
}
if(FLAGS_benchmark_counters_tabular) {
output_opts |= ConsoleReporter::OO_Tabular;
} else {
output_opts &= ~ConsoleReporter::OO_Tabular;
}
return static_cast< ConsoleReporter::OutputOptions >(output_opts);
}
} // end namespace internal
size_t RunSpecifiedBenchmarks() {
return RunSpecifiedBenchmarks(nullptr, nullptr);
}
size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter) {
return RunSpecifiedBenchmarks(console_reporter, nullptr);
}
size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter,
BenchmarkReporter* file_reporter) {
std::string spec = FLAGS_benchmark_filter;
if (spec.empty() || spec == "all")
spec = "."; // Regexp that matches all benchmarks
// Setup the reporters
std::ofstream output_file;
std::unique_ptr<BenchmarkReporter> default_console_reporter;
std::unique_ptr<BenchmarkReporter> default_file_reporter;
if (!console_reporter) {
default_console_reporter = internal::CreateReporter(
FLAGS_benchmark_format, internal::GetOutputOptions());
console_reporter = default_console_reporter.get();
}
auto& Out = console_reporter->GetOutputStream();
auto& Err = console_reporter->GetErrorStream();
std::string const& fname = FLAGS_benchmark_out;
if (fname.empty() && file_reporter) {
Err << "A custom file reporter was provided but "
"--benchmark_out=<file> was not specified."
<< std::endl;
std::exit(1);
}
if (!fname.empty()) {
output_file.open(fname);
if (!output_file.is_open()) {
Err << "invalid file name: '" << fname << std::endl;
std::exit(1);
}
if (!file_reporter) {
default_file_reporter = internal::CreateReporter(
FLAGS_benchmark_out_format, ConsoleReporter::OO_None);
file_reporter = default_file_reporter.get();
}
file_reporter->SetOutputStream(&output_file);
file_reporter->SetErrorStream(&output_file);
}
std::vector<internal::Benchmark::Instance> benchmarks;
if (!FindBenchmarksInternal(spec, &benchmarks, &Err)) return 0;
if (benchmarks.empty()) {
Err << "Failed to match any benchmarks against regex: " << spec << "\n";
return 0;
}
if (FLAGS_benchmark_list_tests) {
for (auto const& benchmark : benchmarks) Out << benchmark.name << "\n";
} else {
internal::RunBenchmarks(benchmarks, console_reporter, file_reporter);
}
return benchmarks.size();
}
namespace internal {
void PrintUsageAndExit() {
fprintf(stdout,
"benchmark"
" [--benchmark_list_tests={true|false}]\n"
" [--benchmark_filter=<regex>]\n"
" [--benchmark_min_time=<min_time>]\n"
" [--benchmark_repetitions=<num_repetitions>]\n"
" [--benchmark_report_aggregates_only={true|false}\n"
" [--benchmark_format=<console|json|csv>]\n"
" [--benchmark_out=<filename>]\n"
" [--benchmark_out_format=<json|console|csv>]\n"
" [--benchmark_color={auto|true|false}]\n"
" [--benchmark_counters_tabular={true|false}]\n"
" [--v=<verbosity>]\n");
exit(0);
}
void ParseCommandLineFlags(int* argc, char** argv) {
using namespace benchmark;
BenchmarkReporter::Context::executable_name = argv[0];
for (int i = 1; i < *argc; ++i) {
if (ParseBoolFlag(argv[i], "benchmark_list_tests",
&FLAGS_benchmark_list_tests) ||
ParseStringFlag(argv[i], "benchmark_filter", &FLAGS_benchmark_filter) ||
ParseDoubleFlag(argv[i], "benchmark_min_time",
&FLAGS_benchmark_min_time) ||
ParseInt32Flag(argv[i], "benchmark_repetitions",
&FLAGS_benchmark_repetitions) ||
ParseBoolFlag(argv[i], "benchmark_report_aggregates_only",
&FLAGS_benchmark_report_aggregates_only) ||
ParseStringFlag(argv[i], "benchmark_format", &FLAGS_benchmark_format) ||
ParseStringFlag(argv[i], "benchmark_out", &FLAGS_benchmark_out) ||
ParseStringFlag(argv[i], "benchmark_out_format",
&FLAGS_benchmark_out_format) ||
ParseStringFlag(argv[i], "benchmark_color", &FLAGS_benchmark_color) ||
// "color_print" is the deprecated name for "benchmark_color".
// TODO: Remove this.
ParseStringFlag(argv[i], "color_print", &FLAGS_benchmark_color) ||
ParseBoolFlag(argv[i], "benchmark_counters_tabular",
&FLAGS_benchmark_counters_tabular) ||
ParseInt32Flag(argv[i], "v", &FLAGS_v)) {
for (int j = i; j != *argc - 1; ++j) argv[j] = argv[j + 1];
--(*argc);
--i;
} else if (IsFlag(argv[i], "help")) {
PrintUsageAndExit();
}
}
for (auto const* flag :
{&FLAGS_benchmark_format, &FLAGS_benchmark_out_format})
if (*flag != "console" && *flag != "json" && *flag != "csv") {
PrintUsageAndExit();
}
if (FLAGS_benchmark_color.empty()) {
PrintUsageAndExit();
}
}
int InitializeStreams() {
static std::ios_base::Init init;
return 0;
}
} // end namespace internal
void Initialize(int* argc, char** argv) {
internal::ParseCommandLineFlags(argc, argv);
internal::LogLevel() = FLAGS_v;
}
bool ReportUnrecognizedArguments(int argc, char** argv) {
for (int i = 1; i < argc; ++i) {
fprintf(stderr, "%s: error: unrecognized command-line flag: %s\n", argv[0], argv[i]);
}
return argc > 1;
}
} // end namespace benchmark

View File

@@ -0,0 +1,47 @@
#ifndef BENCHMARK_API_INTERNAL_H
#define BENCHMARK_API_INTERNAL_H
#include "benchmark/benchmark.h"
#include <cmath>
#include <iosfwd>
#include <limits>
#include <string>
#include <vector>
namespace benchmark {
namespace internal {
// Information kept per benchmark we may want to run
struct Benchmark::Instance {
std::string name;
Benchmark* benchmark;
ReportMode report_mode;
std::vector<int64_t> arg;
TimeUnit time_unit;
int range_multiplier;
bool use_real_time;
bool use_manual_time;
BigO complexity;
BigOFunc* complexity_lambda;
UserCounters counters;
const std::vector<Statistics>* statistics;
bool last_benchmark_instance;
int repetitions;
double min_time;
size_t iterations;
int threads; // Number of concurrent threads to us
};
bool FindBenchmarksInternal(const std::string& re,
std::vector<Benchmark::Instance>* benchmarks,
std::ostream* Err);
bool IsZero(double n);
ConsoleReporter::OutputOptions GetOutputOptions(bool force_no_color = false);
} // end namespace internal
} // end namespace benchmark
#endif // BENCHMARK_API_INTERNAL_H

View File

@@ -0,0 +1,17 @@
// Copyright 2018 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "benchmark/benchmark.h"
BENCHMARK_MAIN();

View File

@@ -0,0 +1,461 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "benchmark_register.h"
#ifndef BENCHMARK_OS_WINDOWS
#ifndef BENCHMARK_OS_FUCHSIA
#include <sys/resource.h>
#endif
#include <sys/time.h>
#include <unistd.h>
#endif
#include <algorithm>
#include <atomic>
#include <condition_variable>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <memory>
#include <sstream>
#include <thread>
#include "benchmark/benchmark.h"
#include "benchmark_api_internal.h"
#include "check.h"
#include "commandlineflags.h"
#include "complexity.h"
#include "internal_macros.h"
#include "log.h"
#include "mutex.h"
#include "re.h"
#include "statistics.h"
#include "string_util.h"
#include "timers.h"
namespace benchmark {
namespace {
// For non-dense Range, intermediate values are powers of kRangeMultiplier.
static const int kRangeMultiplier = 8;
// The size of a benchmark family determines is the number of inputs to repeat
// the benchmark on. If this is "large" then warn the user during configuration.
static const size_t kMaxFamilySize = 100;
} // end namespace
namespace internal {
//=============================================================================//
// BenchmarkFamilies
//=============================================================================//
// Class for managing registered benchmarks. Note that each registered
// benchmark identifies a family of related benchmarks to run.
class BenchmarkFamilies {
public:
static BenchmarkFamilies* GetInstance();
// Registers a benchmark family and returns the index assigned to it.
size_t AddBenchmark(std::unique_ptr<Benchmark> family);
// Clear all registered benchmark families.
void ClearBenchmarks();
// Extract the list of benchmark instances that match the specified
// regular expression.
bool FindBenchmarks(std::string re,
std::vector<Benchmark::Instance>* benchmarks,
std::ostream* Err);
private:
BenchmarkFamilies() {}
std::vector<std::unique_ptr<Benchmark>> families_;
Mutex mutex_;
};
BenchmarkFamilies* BenchmarkFamilies::GetInstance() {
static BenchmarkFamilies instance;
return &instance;
}
size_t BenchmarkFamilies::AddBenchmark(std::unique_ptr<Benchmark> family) {
MutexLock l(mutex_);
size_t index = families_.size();
families_.push_back(std::move(family));
return index;
}
void BenchmarkFamilies::ClearBenchmarks() {
MutexLock l(mutex_);
families_.clear();
families_.shrink_to_fit();
}
bool BenchmarkFamilies::FindBenchmarks(
std::string spec, std::vector<Benchmark::Instance>* benchmarks,
std::ostream* ErrStream) {
CHECK(ErrStream);
auto& Err = *ErrStream;
// Make regular expression out of command-line flag
std::string error_msg;
Regex re;
bool isNegativeFilter = false;
if(spec[0] == '-') {
spec.replace(0, 1, "");
isNegativeFilter = true;
}
if (!re.Init(spec, &error_msg)) {
Err << "Could not compile benchmark re: " << error_msg << std::endl;
return false;
}
// Special list of thread counts to use when none are specified
const std::vector<int> one_thread = {1};
MutexLock l(mutex_);
for (std::unique_ptr<Benchmark>& family : families_) {
// Family was deleted or benchmark doesn't match
if (!family) continue;
if (family->ArgsCnt() == -1) {
family->Args({});
}
const std::vector<int>* thread_counts =
(family->thread_counts_.empty()
? &one_thread
: &static_cast<const std::vector<int>&>(family->thread_counts_));
const size_t family_size = family->args_.size() * thread_counts->size();
// The benchmark will be run at least 'family_size' different inputs.
// If 'family_size' is very large warn the user.
if (family_size > kMaxFamilySize) {
Err << "The number of inputs is very large. " << family->name_
<< " will be repeated at least " << family_size << " times.\n";
}
// reserve in the special case the regex ".", since we know the final
// family size.
if (spec == ".") benchmarks->reserve(family_size);
for (auto const& args : family->args_) {
for (int num_threads : *thread_counts) {
Benchmark::Instance instance;
instance.name = family->name_;
instance.benchmark = family.get();
instance.report_mode = family->report_mode_;
instance.arg = args;
instance.time_unit = family->time_unit_;
instance.range_multiplier = family->range_multiplier_;
instance.min_time = family->min_time_;
instance.iterations = family->iterations_;
instance.repetitions = family->repetitions_;
instance.use_real_time = family->use_real_time_;
instance.use_manual_time = family->use_manual_time_;
instance.complexity = family->complexity_;
instance.complexity_lambda = family->complexity_lambda_;
instance.statistics = &family->statistics_;
instance.threads = num_threads;
// Add arguments to instance name
size_t arg_i = 0;
for (auto const& arg : args) {
instance.name += "/";
if (arg_i < family->arg_names_.size()) {
const auto& arg_name = family->arg_names_[arg_i];
if (!arg_name.empty()) {
instance.name +=
StrFormat("%s:", family->arg_names_[arg_i].c_str());
}
}
instance.name += StrFormat("%d", arg);
++arg_i;
}
if (!IsZero(family->min_time_))
instance.name += StrFormat("/min_time:%0.3f", family->min_time_);
if (family->iterations_ != 0)
instance.name += StrFormat("/iterations:%d", family->iterations_);
if (family->repetitions_ != 0)
instance.name += StrFormat("/repeats:%d", family->repetitions_);
if (family->use_manual_time_) {
instance.name += "/manual_time";
} else if (family->use_real_time_) {
instance.name += "/real_time";
}
// Add the number of threads used to the name
if (!family->thread_counts_.empty()) {
instance.name += StrFormat("/threads:%d", instance.threads);
}
if ((re.Match(instance.name) && !isNegativeFilter) ||
(!re.Match(instance.name) && isNegativeFilter)) {
instance.last_benchmark_instance = (&args == &family->args_.back());
benchmarks->push_back(std::move(instance));
}
}
}
}
return true;
}
Benchmark* RegisterBenchmarkInternal(Benchmark* bench) {
std::unique_ptr<Benchmark> bench_ptr(bench);
BenchmarkFamilies* families = BenchmarkFamilies::GetInstance();
families->AddBenchmark(std::move(bench_ptr));
return bench;
}
// FIXME: This function is a hack so that benchmark.cc can access
// `BenchmarkFamilies`
bool FindBenchmarksInternal(const std::string& re,
std::vector<Benchmark::Instance>* benchmarks,
std::ostream* Err) {
return BenchmarkFamilies::GetInstance()->FindBenchmarks(re, benchmarks, Err);
}
//=============================================================================//
// Benchmark
//=============================================================================//
Benchmark::Benchmark(const char* name)
: name_(name),
report_mode_(RM_Unspecified),
time_unit_(kNanosecond),
range_multiplier_(kRangeMultiplier),
min_time_(0),
iterations_(0),
repetitions_(0),
use_real_time_(false),
use_manual_time_(false),
complexity_(oNone),
complexity_lambda_(nullptr) {
ComputeStatistics("mean", StatisticsMean);
ComputeStatistics("median", StatisticsMedian);
ComputeStatistics("stddev", StatisticsStdDev);
}
Benchmark::~Benchmark() {}
Benchmark* Benchmark::Arg(int64_t x) {
CHECK(ArgsCnt() == -1 || ArgsCnt() == 1);
args_.push_back({x});
return this;
}
Benchmark* Benchmark::Unit(TimeUnit unit) {
time_unit_ = unit;
return this;
}
Benchmark* Benchmark::Range(int64_t start, int64_t limit) {
CHECK(ArgsCnt() == -1 || ArgsCnt() == 1);
std::vector<int64_t> arglist;
AddRange(&arglist, start, limit, range_multiplier_);
for (int64_t i : arglist) {
args_.push_back({i});
}
return this;
}
Benchmark* Benchmark::Ranges(
const std::vector<std::pair<int64_t, int64_t>>& ranges) {
CHECK(ArgsCnt() == -1 || ArgsCnt() == static_cast<int>(ranges.size()));
std::vector<std::vector<int64_t>> arglists(ranges.size());
std::size_t total = 1;
for (std::size_t i = 0; i < ranges.size(); i++) {
AddRange(&arglists[i], ranges[i].first, ranges[i].second,
range_multiplier_);
total *= arglists[i].size();
}
std::vector<std::size_t> ctr(arglists.size(), 0);
for (std::size_t i = 0; i < total; i++) {
std::vector<int64_t> tmp;
tmp.reserve(arglists.size());
for (std::size_t j = 0; j < arglists.size(); j++) {
tmp.push_back(arglists[j].at(ctr[j]));
}
args_.push_back(std::move(tmp));
for (std::size_t j = 0; j < arglists.size(); j++) {
if (ctr[j] + 1 < arglists[j].size()) {
++ctr[j];
break;
}
ctr[j] = 0;
}
}
return this;
}
Benchmark* Benchmark::ArgName(const std::string& name) {
CHECK(ArgsCnt() == -1 || ArgsCnt() == 1);
arg_names_ = {name};
return this;
}
Benchmark* Benchmark::ArgNames(const std::vector<std::string>& names) {
CHECK(ArgsCnt() == -1 || ArgsCnt() == static_cast<int>(names.size()));
arg_names_ = names;
return this;
}
Benchmark* Benchmark::DenseRange(int64_t start, int64_t limit, int step) {
CHECK(ArgsCnt() == -1 || ArgsCnt() == 1);
CHECK_GE(start, 0);
CHECK_LE(start, limit);
for (int64_t arg = start; arg <= limit; arg += step) {
args_.push_back({arg});
}
return this;
}
Benchmark* Benchmark::Args(const std::vector<int64_t>& args) {
CHECK(ArgsCnt() == -1 || ArgsCnt() == static_cast<int>(args.size()));
args_.push_back(args);
return this;
}
Benchmark* Benchmark::Apply(void (*custom_arguments)(Benchmark* benchmark)) {
custom_arguments(this);
return this;
}
Benchmark* Benchmark::RangeMultiplier(int multiplier) {
CHECK(multiplier > 1);
range_multiplier_ = multiplier;
return this;
}
Benchmark* Benchmark::MinTime(double t) {
CHECK(t > 0.0);
CHECK(iterations_ == 0);
min_time_ = t;
return this;
}
Benchmark* Benchmark::Iterations(size_t n) {
CHECK(n > 0);
CHECK(IsZero(min_time_));
iterations_ = n;
return this;
}
Benchmark* Benchmark::Repetitions(int n) {
CHECK(n > 0);
repetitions_ = n;
return this;
}
Benchmark* Benchmark::ReportAggregatesOnly(bool value) {
report_mode_ = value ? RM_ReportAggregatesOnly : RM_Default;
return this;
}
Benchmark* Benchmark::UseRealTime() {
CHECK(!use_manual_time_)
<< "Cannot set UseRealTime and UseManualTime simultaneously.";
use_real_time_ = true;
return this;
}
Benchmark* Benchmark::UseManualTime() {
CHECK(!use_real_time_)
<< "Cannot set UseRealTime and UseManualTime simultaneously.";
use_manual_time_ = true;
return this;
}
Benchmark* Benchmark::Complexity(BigO complexity) {
complexity_ = complexity;
return this;
}
Benchmark* Benchmark::Complexity(BigOFunc* complexity) {
complexity_lambda_ = complexity;
complexity_ = oLambda;
return this;
}
Benchmark* Benchmark::ComputeStatistics(std::string name,
StatisticsFunc* statistics) {
statistics_.emplace_back(name, statistics);
return this;
}
Benchmark* Benchmark::Threads(int t) {
CHECK_GT(t, 0);
thread_counts_.push_back(t);
return this;
}
Benchmark* Benchmark::ThreadRange(int min_threads, int max_threads) {
CHECK_GT(min_threads, 0);
CHECK_GE(max_threads, min_threads);
AddRange(&thread_counts_, min_threads, max_threads, 2);
return this;
}
Benchmark* Benchmark::DenseThreadRange(int min_threads, int max_threads,
int stride) {
CHECK_GT(min_threads, 0);
CHECK_GE(max_threads, min_threads);
CHECK_GE(stride, 1);
for (auto i = min_threads; i < max_threads; i += stride) {
thread_counts_.push_back(i);
}
thread_counts_.push_back(max_threads);
return this;
}
Benchmark* Benchmark::ThreadPerCpu() {
thread_counts_.push_back(CPUInfo::Get().num_cpus);
return this;
}
void Benchmark::SetName(const char* name) { name_ = name; }
int Benchmark::ArgsCnt() const {
if (args_.empty()) {
if (arg_names_.empty()) return -1;
return static_cast<int>(arg_names_.size());
}
return static_cast<int>(args_.front().size());
}
//=============================================================================//
// FunctionBenchmark
//=============================================================================//
void FunctionBenchmark::Run(State& st) { func_(st); }
} // end namespace internal
void ClearRegisteredBenchmarks() {
internal::BenchmarkFamilies::GetInstance()->ClearBenchmarks();
}
} // end namespace benchmark

View File

@@ -0,0 +1,33 @@
#ifndef BENCHMARK_REGISTER_H
#define BENCHMARK_REGISTER_H
#include <vector>
#include "check.h"
template <typename T>
void AddRange(std::vector<T>* dst, T lo, T hi, int mult) {
CHECK_GE(lo, 0);
CHECK_GE(hi, lo);
CHECK_GE(mult, 2);
// Add "lo"
dst->push_back(lo);
static const T kmax = std::numeric_limits<T>::max();
// Now space out the benchmarks in multiples of "mult"
for (T i = 1; i < kmax / mult; i *= mult) {
if (i >= hi) break;
if (i > lo) {
dst->push_back(i);
}
}
// Add "hi" (if different from "lo")
if (hi != lo) {
dst->push_back(hi);
}
}
#endif // BENCHMARK_REGISTER_H

79
benchmarks/thirdparty/benchmark/src/check.h vendored Executable file
View File

@@ -0,0 +1,79 @@
#ifndef CHECK_H_
#define CHECK_H_
#include <cstdlib>
#include <ostream>
#include <cmath>
#include "internal_macros.h"
#include "log.h"
namespace benchmark {
namespace internal {
typedef void(AbortHandlerT)();
inline AbortHandlerT*& GetAbortHandler() {
static AbortHandlerT* handler = &std::abort;
return handler;
}
BENCHMARK_NORETURN inline void CallAbortHandler() {
GetAbortHandler()();
std::abort(); // fallback to enforce noreturn
}
// CheckHandler is the class constructed by failing CHECK macros. CheckHandler
// will log information about the failures and abort when it is destructed.
class CheckHandler {
public:
CheckHandler(const char* check, const char* file, const char* func, int line)
: log_(GetErrorLogInstance()) {
log_ << file << ":" << line << ": " << func << ": Check `" << check
<< "' failed. ";
}
LogType& GetLog() { return log_; }
BENCHMARK_NORETURN ~CheckHandler() BENCHMARK_NOEXCEPT_OP(false) {
log_ << std::endl;
CallAbortHandler();
}
CheckHandler& operator=(const CheckHandler&) = delete;
CheckHandler(const CheckHandler&) = delete;
CheckHandler() = delete;
private:
LogType& log_;
};
} // end namespace internal
} // end namespace benchmark
// The CHECK macro returns a std::ostream object that can have extra information
// written to it.
#ifndef NDEBUG
#define CHECK(b) \
(b ? ::benchmark::internal::GetNullLogInstance() \
: ::benchmark::internal::CheckHandler(#b, __FILE__, __func__, __LINE__) \
.GetLog())
#else
#define CHECK(b) ::benchmark::internal::GetNullLogInstance()
#endif
#define CHECK_EQ(a, b) CHECK((a) == (b))
#define CHECK_NE(a, b) CHECK((a) != (b))
#define CHECK_GE(a, b) CHECK((a) >= (b))
#define CHECK_LE(a, b) CHECK((a) <= (b))
#define CHECK_GT(a, b) CHECK((a) > (b))
#define CHECK_LT(a, b) CHECK((a) < (b))
#define CHECK_FLOAT_EQ(a, b, eps) CHECK(std::fabs((a) - (b)) < (eps))
#define CHECK_FLOAT_NE(a, b, eps) CHECK(std::fabs((a) - (b)) >= (eps))
#define CHECK_FLOAT_GE(a, b, eps) CHECK((a) - (b) > -(eps))
#define CHECK_FLOAT_LE(a, b, eps) CHECK((b) - (a) > -(eps))
#define CHECK_FLOAT_GT(a, b, eps) CHECK((a) - (b) > (eps))
#define CHECK_FLOAT_LT(a, b, eps) CHECK((b) - (a) > (eps))
#endif // CHECK_H_

View File

@@ -0,0 +1,188 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "colorprint.h"
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <string>
#include "check.h"
#include "internal_macros.h"
#ifdef BENCHMARK_OS_WINDOWS
#include <Windows.h>
#include <io.h>
#else
#include <unistd.h>
#endif // BENCHMARK_OS_WINDOWS
namespace benchmark {
namespace {
#ifdef BENCHMARK_OS_WINDOWS
typedef WORD PlatformColorCode;
#else
typedef const char* PlatformColorCode;
#endif
PlatformColorCode GetPlatformColorCode(LogColor color) {
#ifdef BENCHMARK_OS_WINDOWS
switch (color) {
case COLOR_RED:
return FOREGROUND_RED;
case COLOR_GREEN:
return FOREGROUND_GREEN;
case COLOR_YELLOW:
return FOREGROUND_RED | FOREGROUND_GREEN;
case COLOR_BLUE:
return FOREGROUND_BLUE;
case COLOR_MAGENTA:
return FOREGROUND_BLUE | FOREGROUND_RED;
case COLOR_CYAN:
return FOREGROUND_BLUE | FOREGROUND_GREEN;
case COLOR_WHITE: // fall through to default
default:
return 0;
}
#else
switch (color) {
case COLOR_RED:
return "1";
case COLOR_GREEN:
return "2";
case COLOR_YELLOW:
return "3";
case COLOR_BLUE:
return "4";
case COLOR_MAGENTA:
return "5";
case COLOR_CYAN:
return "6";
case COLOR_WHITE:
return "7";
default:
return nullptr;
};
#endif
}
} // end namespace
std::string FormatString(const char* msg, va_list args) {
// we might need a second shot at this, so pre-emptivly make a copy
va_list args_cp;
va_copy(args_cp, args);
std::size_t size = 256;
char local_buff[256];
auto ret = vsnprintf(local_buff, size, msg, args_cp);
va_end(args_cp);
// currently there is no error handling for failure, so this is hack.
CHECK(ret >= 0);
if (ret == 0) // handle empty expansion
return {};
else if (static_cast<size_t>(ret) < size)
return local_buff;
else {
// we did not provide a long enough buffer on our first attempt.
size = (size_t)ret + 1; // + 1 for the null byte
std::unique_ptr<char[]> buff(new char[size]);
ret = vsnprintf(buff.get(), size, msg, args);
CHECK(ret > 0 && ((size_t)ret) < size);
return buff.get();
}
}
std::string FormatString(const char* msg, ...) {
va_list args;
va_start(args, msg);
auto tmp = FormatString(msg, args);
va_end(args);
return tmp;
}
void ColorPrintf(std::ostream& out, LogColor color, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
ColorPrintf(out, color, fmt, args);
va_end(args);
}
void ColorPrintf(std::ostream& out, LogColor color, const char* fmt,
va_list args) {
#ifdef BENCHMARK_OS_WINDOWS
((void)out); // suppress unused warning
const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
// Gets the current text color.
CONSOLE_SCREEN_BUFFER_INFO buffer_info;
GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
const WORD old_color_attrs = buffer_info.wAttributes;
// We need to flush the stream buffers into the console before each
// SetConsoleTextAttribute call lest it affect the text that is already
// printed but has not yet reached the console.
fflush(stdout);
SetConsoleTextAttribute(stdout_handle,
GetPlatformColorCode(color) | FOREGROUND_INTENSITY);
vprintf(fmt, args);
fflush(stdout);
// Restores the text color.
SetConsoleTextAttribute(stdout_handle, old_color_attrs);
#else
const char* color_code = GetPlatformColorCode(color);
if (color_code) out << FormatString("\033[0;3%sm", color_code);
out << FormatString(fmt, args) << "\033[m";
#endif
}
bool IsColorTerminal() {
#if BENCHMARK_OS_WINDOWS
// On Windows the TERM variable is usually not set, but the
// console there does support colors.
return 0 != _isatty(_fileno(stdout));
#else
// On non-Windows platforms, we rely on the TERM variable. This list of
// supported TERM values is copied from Google Test:
// <https://github.com/google/googletest/blob/master/googletest/src/gtest.cc#L2925>.
const char* const SUPPORTED_TERM_VALUES[] = {
"xterm", "xterm-color", "xterm-256color",
"screen", "screen-256color", "tmux",
"tmux-256color", "rxvt-unicode", "rxvt-unicode-256color",
"linux", "cygwin",
};
const char* const term = getenv("TERM");
bool term_supports_color = false;
for (const char* candidate : SUPPORTED_TERM_VALUES) {
if (term && 0 == strcmp(term, candidate)) {
term_supports_color = true;
break;
}
}
return 0 != isatty(fileno(stdout)) && term_supports_color;
#endif // BENCHMARK_OS_WINDOWS
}
} // end namespace benchmark

View File

@@ -0,0 +1,33 @@
#ifndef BENCHMARK_COLORPRINT_H_
#define BENCHMARK_COLORPRINT_H_
#include <cstdarg>
#include <iostream>
#include <string>
namespace benchmark {
enum LogColor {
COLOR_DEFAULT,
COLOR_RED,
COLOR_GREEN,
COLOR_YELLOW,
COLOR_BLUE,
COLOR_MAGENTA,
COLOR_CYAN,
COLOR_WHITE
};
std::string FormatString(const char* msg, va_list args);
std::string FormatString(const char* msg, ...);
void ColorPrintf(std::ostream& out, LogColor color, const char* fmt,
va_list args);
void ColorPrintf(std::ostream& out, LogColor color, const char* fmt, ...);
// Returns true if stdout appears to be a terminal that supports colored
// output, false otherwise.
bool IsColorTerminal();
} // end namespace benchmark
#endif // BENCHMARK_COLORPRINT_H_

View File

@@ -0,0 +1,218 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "commandlineflags.h"
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
namespace benchmark {
// Parses 'str' for a 32-bit signed integer. If successful, writes
// the result to *value and returns true; otherwise leaves *value
// unchanged and returns false.
bool ParseInt32(const std::string& src_text, const char* str, int32_t* value) {
// Parses the environment variable as a decimal integer.
char* end = nullptr;
const long long_value = strtol(str, &end, 10); // NOLINT
// Has strtol() consumed all characters in the string?
if (*end != '\0') {
// No - an invalid character was encountered.
std::cerr << src_text << " is expected to be a 32-bit integer, "
<< "but actually has value \"" << str << "\".\n";
return false;
}
// Is the parsed value in the range of an Int32?
const int32_t result = static_cast<int32_t>(long_value);
if (long_value == std::numeric_limits<long>::max() ||
long_value == std::numeric_limits<long>::min() ||
// The parsed value overflows as a long. (strtol() returns
// LONG_MAX or LONG_MIN when the input overflows.)
result != long_value
// The parsed value overflows as an Int32.
) {
std::cerr << src_text << " is expected to be a 32-bit integer, "
<< "but actually has value \"" << str << "\", "
<< "which overflows.\n";
return false;
}
*value = result;
return true;
}
// Parses 'str' for a double. If successful, writes the result to *value and
// returns true; otherwise leaves *value unchanged and returns false.
bool ParseDouble(const std::string& src_text, const char* str, double* value) {
// Parses the environment variable as a decimal integer.
char* end = nullptr;
const double double_value = strtod(str, &end); // NOLINT
// Has strtol() consumed all characters in the string?
if (*end != '\0') {
// No - an invalid character was encountered.
std::cerr << src_text << " is expected to be a double, "
<< "but actually has value \"" << str << "\".\n";
return false;
}
*value = double_value;
return true;
}
// Returns the name of the environment variable corresponding to the
// given flag. For example, FlagToEnvVar("foo") will return
// "BENCHMARK_FOO" in the open-source version.
static std::string FlagToEnvVar(const char* flag) {
const std::string flag_str(flag);
std::string env_var;
for (size_t i = 0; i != flag_str.length(); ++i)
env_var += static_cast<char>(::toupper(flag_str.c_str()[i]));
return "BENCHMARK_" + env_var;
}
// Reads and returns the Boolean environment variable corresponding to
// the given flag; if it's not set, returns default_value.
//
// The value is considered true iff it's not "0".
bool BoolFromEnv(const char* flag, bool default_value) {
const std::string env_var = FlagToEnvVar(flag);
const char* const string_value = getenv(env_var.c_str());
return string_value == nullptr ? default_value
: strcmp(string_value, "0") != 0;
}
// Reads and returns a 32-bit integer stored in the environment
// variable corresponding to the given flag; if it isn't set or
// doesn't represent a valid 32-bit integer, returns default_value.
int32_t Int32FromEnv(const char* flag, int32_t default_value) {
const std::string env_var = FlagToEnvVar(flag);
const char* const string_value = getenv(env_var.c_str());
if (string_value == nullptr) {
// The environment variable is not set.
return default_value;
}
int32_t result = default_value;
if (!ParseInt32(std::string("Environment variable ") + env_var, string_value,
&result)) {
std::cout << "The default value " << default_value << " is used.\n";
return default_value;
}
return result;
}
// Reads and returns the string environment variable corresponding to
// the given flag; if it's not set, returns default_value.
const char* StringFromEnv(const char* flag, const char* default_value) {
const std::string env_var = FlagToEnvVar(flag);
const char* const value = getenv(env_var.c_str());
return value == nullptr ? default_value : value;
}
// Parses a string as a command line flag. The string should have
// the format "--flag=value". When def_optional is true, the "=value"
// part can be omitted.
//
// Returns the value of the flag, or nullptr if the parsing failed.
const char* ParseFlagValue(const char* str, const char* flag,
bool def_optional) {
// str and flag must not be nullptr.
if (str == nullptr || flag == nullptr) return nullptr;
// The flag must start with "--".
const std::string flag_str = std::string("--") + std::string(flag);
const size_t flag_len = flag_str.length();
if (strncmp(str, flag_str.c_str(), flag_len) != 0) return nullptr;
// Skips the flag name.
const char* flag_end = str + flag_len;
// When def_optional is true, it's OK to not have a "=value" part.
if (def_optional && (flag_end[0] == '\0')) return flag_end;
// If def_optional is true and there are more characters after the
// flag name, or if def_optional is false, there must be a '=' after
// the flag name.
if (flag_end[0] != '=') return nullptr;
// Returns the string after "=".
return flag_end + 1;
}
bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
// Gets the value of the flag as a string.
const char* const value_str = ParseFlagValue(str, flag, true);
// Aborts if the parsing failed.
if (value_str == nullptr) return false;
// Converts the string value to a bool.
*value = IsTruthyFlagValue(value_str);
return true;
}
bool ParseInt32Flag(const char* str, const char* flag, int32_t* value) {
// Gets the value of the flag as a string.
const char* const value_str = ParseFlagValue(str, flag, false);
// Aborts if the parsing failed.
if (value_str == nullptr) return false;
// Sets *value to the value of the flag.
return ParseInt32(std::string("The value of flag --") + flag, value_str,
value);
}
bool ParseDoubleFlag(const char* str, const char* flag, double* value) {
// Gets the value of the flag as a string.
const char* const value_str = ParseFlagValue(str, flag, false);
// Aborts if the parsing failed.
if (value_str == nullptr) return false;
// Sets *value to the value of the flag.
return ParseDouble(std::string("The value of flag --") + flag, value_str,
value);
}
bool ParseStringFlag(const char* str, const char* flag, std::string* value) {
// Gets the value of the flag as a string.
const char* const value_str = ParseFlagValue(str, flag, false);
// Aborts if the parsing failed.
if (value_str == nullptr) return false;
*value = value_str;
return true;
}
bool IsFlag(const char* str, const char* flag) {
return (ParseFlagValue(str, flag, true) != nullptr);
}
bool IsTruthyFlagValue(const std::string& value) {
if (value.empty()) return true;
char ch = value[0];
return isalnum(ch) &&
!(ch == '0' || ch == 'f' || ch == 'F' || ch == 'n' || ch == 'N');
}
} // end namespace benchmark

View File

@@ -0,0 +1,79 @@
#ifndef BENCHMARK_COMMANDLINEFLAGS_H_
#define BENCHMARK_COMMANDLINEFLAGS_H_
#include <cstdint>
#include <string>
// Macro for referencing flags.
#define FLAG(name) FLAGS_##name
// Macros for declaring flags.
#define DECLARE_bool(name) extern bool FLAG(name)
#define DECLARE_int32(name) extern int32_t FLAG(name)
#define DECLARE_int64(name) extern int64_t FLAG(name)
#define DECLARE_double(name) extern double FLAG(name)
#define DECLARE_string(name) extern std::string FLAG(name)
// Macros for defining flags.
#define DEFINE_bool(name, default_val, doc) bool FLAG(name) = (default_val)
#define DEFINE_int32(name, default_val, doc) int32_t FLAG(name) = (default_val)
#define DEFINE_int64(name, default_val, doc) int64_t FLAG(name) = (default_val)
#define DEFINE_double(name, default_val, doc) double FLAG(name) = (default_val)
#define DEFINE_string(name, default_val, doc) \
std::string FLAG(name) = (default_val)
namespace benchmark {
// Parses 'str' for a 32-bit signed integer. If successful, writes the result
// to *value and returns true; otherwise leaves *value unchanged and returns
// false.
bool ParseInt32(const std::string& src_text, const char* str, int32_t* value);
// Parses a bool/Int32/string from the environment variable
// corresponding to the given Google Test flag.
bool BoolFromEnv(const char* flag, bool default_val);
int32_t Int32FromEnv(const char* flag, int32_t default_val);
double DoubleFromEnv(const char* flag, double default_val);
const char* StringFromEnv(const char* flag, const char* default_val);
// Parses a string for a bool flag, in the form of either
// "--flag=value" or "--flag".
//
// In the former case, the value is taken as true if it passes IsTruthyValue().
//
// In the latter case, the value is taken as true.
//
// On success, stores the value of the flag in *value, and returns
// true. On failure, returns false without changing *value.
bool ParseBoolFlag(const char* str, const char* flag, bool* value);
// Parses a string for an Int32 flag, in the form of
// "--flag=value".
//
// On success, stores the value of the flag in *value, and returns
// true. On failure, returns false without changing *value.
bool ParseInt32Flag(const char* str, const char* flag, int32_t* value);
// Parses a string for a Double flag, in the form of
// "--flag=value".
//
// On success, stores the value of the flag in *value, and returns
// true. On failure, returns false without changing *value.
bool ParseDoubleFlag(const char* str, const char* flag, double* value);
// Parses a string for a string flag, in the form of
// "--flag=value".
//
// On success, stores the value of the flag in *value, and returns
// true. On failure, returns false without changing *value.
bool ParseStringFlag(const char* str, const char* flag, std::string* value);
// Returns true if the string matches the flag.
bool IsFlag(const char* str, const char* flag);
// Returns true unless value starts with one of: '0', 'f', 'F', 'n' or 'N', or
// some non-alphanumeric character. As a special case, also returns true if
// value is the empty string.
bool IsTruthyFlagValue(const std::string& value);
} // end namespace benchmark
#endif // BENCHMARK_COMMANDLINEFLAGS_H_

View File

@@ -0,0 +1,220 @@
// Copyright 2016 Ismael Jimenez Martinez. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Source project : https://github.com/ismaelJimenez/cpp.leastsq
// Adapted to be used with google benchmark
#include "benchmark/benchmark.h"
#include <algorithm>
#include <cmath>
#include "check.h"
#include "complexity.h"
namespace benchmark {
// Internal function to calculate the different scalability forms
BigOFunc* FittingCurve(BigO complexity) {
switch (complexity) {
case oN:
return [](int64_t n) -> double { return static_cast<double>(n); };
case oNSquared:
return [](int64_t n) -> double { return std::pow(n, 2); };
case oNCubed:
return [](int64_t n) -> double { return std::pow(n, 3); };
case oLogN:
return [](int64_t n) { return log2(n); };
case oNLogN:
return [](int64_t n) { return n * log2(n); };
case o1:
default:
return [](int64_t) { return 1.0; };
}
}
// Function to return an string for the calculated complexity
std::string GetBigOString(BigO complexity) {
switch (complexity) {
case oN:
return "N";
case oNSquared:
return "N^2";
case oNCubed:
return "N^3";
case oLogN:
return "lgN";
case oNLogN:
return "NlgN";
case o1:
return "(1)";
default:
return "f(N)";
}
}
// Find the coefficient for the high-order term in the running time, by
// minimizing the sum of squares of relative error, for the fitting curve
// given by the lambda expression.
// - n : Vector containing the size of the benchmark tests.
// - time : Vector containing the times for the benchmark tests.
// - fitting_curve : lambda expression (e.g. [](int64_t n) {return n; };).
// For a deeper explanation on the algorithm logic, look the README file at
// http://github.com/ismaelJimenez/Minimal-Cpp-Least-Squared-Fit
LeastSq MinimalLeastSq(const std::vector<int64_t>& n,
const std::vector<double>& time,
BigOFunc* fitting_curve) {
double sigma_gn = 0.0;
double sigma_gn_squared = 0.0;
double sigma_time = 0.0;
double sigma_time_gn = 0.0;
// Calculate least square fitting parameter
for (size_t i = 0; i < n.size(); ++i) {
double gn_i = fitting_curve(n[i]);
sigma_gn += gn_i;
sigma_gn_squared += gn_i * gn_i;
sigma_time += time[i];
sigma_time_gn += time[i] * gn_i;
}
LeastSq result;
result.complexity = oLambda;
// Calculate complexity.
result.coef = sigma_time_gn / sigma_gn_squared;
// Calculate RMS
double rms = 0.0;
for (size_t i = 0; i < n.size(); ++i) {
double fit = result.coef * fitting_curve(n[i]);
rms += pow((time[i] - fit), 2);
}
// Normalized RMS by the mean of the observed values
double mean = sigma_time / n.size();
result.rms = sqrt(rms / n.size()) / mean;
return result;
}
// Find the coefficient for the high-order term in the running time, by
// minimizing the sum of squares of relative error.
// - n : Vector containing the size of the benchmark tests.
// - time : Vector containing the times for the benchmark tests.
// - complexity : If different than oAuto, the fitting curve will stick to
// this one. If it is oAuto, it will be calculated the best
// fitting curve.
LeastSq MinimalLeastSq(const std::vector<int64_t>& n,
const std::vector<double>& time, const BigO complexity) {
CHECK_EQ(n.size(), time.size());
CHECK_GE(n.size(), 2); // Do not compute fitting curve is less than two
// benchmark runs are given
CHECK_NE(complexity, oNone);
LeastSq best_fit;
if (complexity == oAuto) {
std::vector<BigO> fit_curves = {oLogN, oN, oNLogN, oNSquared, oNCubed};
// Take o1 as default best fitting curve
best_fit = MinimalLeastSq(n, time, FittingCurve(o1));
best_fit.complexity = o1;
// Compute all possible fitting curves and stick to the best one
for (const auto& fit : fit_curves) {
LeastSq current_fit = MinimalLeastSq(n, time, FittingCurve(fit));
if (current_fit.rms < best_fit.rms) {
best_fit = current_fit;
best_fit.complexity = fit;
}
}
} else {
best_fit = MinimalLeastSq(n, time, FittingCurve(complexity));
best_fit.complexity = complexity;
}
return best_fit;
}
std::vector<BenchmarkReporter::Run> ComputeBigO(
const std::vector<BenchmarkReporter::Run>& reports) {
typedef BenchmarkReporter::Run Run;
std::vector<Run> results;
if (reports.size() < 2) return results;
// Accumulators.
std::vector<int64_t> n;
std::vector<double> real_time;
std::vector<double> cpu_time;
// Populate the accumulators.
for (const Run& run : reports) {
CHECK_GT(run.complexity_n, 0) << "Did you forget to call SetComplexityN?";
n.push_back(run.complexity_n);
real_time.push_back(run.real_accumulated_time / run.iterations);
cpu_time.push_back(run.cpu_accumulated_time / run.iterations);
}
LeastSq result_cpu;
LeastSq result_real;
if (reports[0].complexity == oLambda) {
result_cpu = MinimalLeastSq(n, cpu_time, reports[0].complexity_lambda);
result_real = MinimalLeastSq(n, real_time, reports[0].complexity_lambda);
} else {
result_cpu = MinimalLeastSq(n, cpu_time, reports[0].complexity);
result_real = MinimalLeastSq(n, real_time, result_cpu.complexity);
}
std::string benchmark_name =
reports[0].benchmark_name.substr(0, reports[0].benchmark_name.find('/'));
// Get the data from the accumulator to BenchmarkReporter::Run's.
Run big_o;
big_o.benchmark_name = benchmark_name + "_BigO";
big_o.iterations = 0;
big_o.real_accumulated_time = result_real.coef;
big_o.cpu_accumulated_time = result_cpu.coef;
big_o.report_big_o = true;
big_o.complexity = result_cpu.complexity;
// All the time results are reported after being multiplied by the
// time unit multiplier. But since RMS is a relative quantity it
// should not be multiplied at all. So, here, we _divide_ it by the
// multiplier so that when it is multiplied later the result is the
// correct one.
double multiplier = GetTimeUnitMultiplier(reports[0].time_unit);
// Only add label to mean/stddev if it is same for all runs
Run rms;
big_o.report_label = reports[0].report_label;
rms.benchmark_name = benchmark_name + "_RMS";
rms.report_label = big_o.report_label;
rms.iterations = 0;
rms.real_accumulated_time = result_real.rms / multiplier;
rms.cpu_accumulated_time = result_cpu.rms / multiplier;
rms.report_rms = true;
rms.complexity = result_cpu.complexity;
// don't forget to keep the time unit, or we won't be able to
// recover the correct value.
rms.time_unit = reports[0].time_unit;
results.push_back(big_o);
results.push_back(rms);
return results;
}
} // end namespace benchmark

View File

@@ -0,0 +1,55 @@
// Copyright 2016 Ismael Jimenez Martinez. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Source project : https://github.com/ismaelJimenez/cpp.leastsq
// Adapted to be used with google benchmark
#ifndef COMPLEXITY_H_
#define COMPLEXITY_H_
#include <string>
#include <vector>
#include "benchmark/benchmark.h"
namespace benchmark {
// Return a vector containing the bigO and RMS information for the specified
// list of reports. If 'reports.size() < 2' an empty vector is returned.
std::vector<BenchmarkReporter::Run> ComputeBigO(
const std::vector<BenchmarkReporter::Run>& reports);
// This data structure will contain the result returned by MinimalLeastSq
// - coef : Estimated coeficient for the high-order term as
// interpolated from data.
// - rms : Normalized Root Mean Squared Error.
// - complexity : Scalability form (e.g. oN, oNLogN). In case a scalability
// form has been provided to MinimalLeastSq this will return
// the same value. In case BigO::oAuto has been selected, this
// parameter will return the best fitting curve detected.
struct LeastSq {
LeastSq() : coef(0.0), rms(0.0), complexity(oNone) {}
double coef;
double rms;
BigO complexity;
};
// Function to return an string for the calculated complexity
std::string GetBigOString(BigO complexity);
} // end namespace benchmark
#endif // COMPLEXITY_H_

View File

@@ -0,0 +1,182 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "benchmark/benchmark.h"
#include "complexity.h"
#include "counter.h"
#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
#include "check.h"
#include "colorprint.h"
#include "commandlineflags.h"
#include "internal_macros.h"
#include "string_util.h"
#include "timers.h"
namespace benchmark {
bool ConsoleReporter::ReportContext(const Context& context) {
name_field_width_ = context.name_field_width;
printed_header_ = false;
prev_counters_.clear();
PrintBasicContext(&GetErrorStream(), context);
#ifdef BENCHMARK_OS_WINDOWS
if ((output_options_ & OO_Color) && &std::cout != &GetOutputStream()) {
GetErrorStream()
<< "Color printing is only supported for stdout on windows."
" Disabling color printing\n";
output_options_ = static_cast< OutputOptions >(output_options_ & ~OO_Color);
}
#endif
return true;
}
void ConsoleReporter::PrintHeader(const Run& run) {
std::string str = FormatString("%-*s %13s %13s %10s", static_cast<int>(name_field_width_),
"Benchmark", "Time", "CPU", "Iterations");
if(!run.counters.empty()) {
if(output_options_ & OO_Tabular) {
for(auto const& c : run.counters) {
str += FormatString(" %10s", c.first.c_str());
}
} else {
str += " UserCounters...";
}
}
str += "\n";
std::string line = std::string(str.length(), '-');
GetOutputStream() << line << "\n" << str << line << "\n";
}
void ConsoleReporter::ReportRuns(const std::vector<Run>& reports) {
for (const auto& run : reports) {
// print the header:
// --- if none was printed yet
bool print_header = !printed_header_;
// --- or if the format is tabular and this run
// has different fields from the prev header
print_header |= (output_options_ & OO_Tabular) &&
(!internal::SameNames(run.counters, prev_counters_));
if (print_header) {
printed_header_ = true;
prev_counters_ = run.counters;
PrintHeader(run);
}
// As an alternative to printing the headers like this, we could sort
// the benchmarks by header and then print. But this would require
// waiting for the full results before printing, or printing twice.
PrintRunData(run);
}
}
static void IgnoreColorPrint(std::ostream& out, LogColor, const char* fmt,
...) {
va_list args;
va_start(args, fmt);
out << FormatString(fmt, args);
va_end(args);
}
void ConsoleReporter::PrintRunData(const Run& result) {
typedef void(PrinterFn)(std::ostream&, LogColor, const char*, ...);
auto& Out = GetOutputStream();
PrinterFn* printer = (output_options_ & OO_Color) ?
(PrinterFn*)ColorPrintf : IgnoreColorPrint;
auto name_color =
(result.report_big_o || result.report_rms) ? COLOR_BLUE : COLOR_GREEN;
printer(Out, name_color, "%-*s ", name_field_width_,
result.benchmark_name.c_str());
if (result.error_occurred) {
printer(Out, COLOR_RED, "ERROR OCCURRED: \'%s\'",
result.error_message.c_str());
printer(Out, COLOR_DEFAULT, "\n");
return;
}
// Format bytes per second
std::string rate;
if (result.bytes_per_second > 0) {
rate = StrCat(" ", HumanReadableNumber(result.bytes_per_second), "B/s");
}
// Format items per second
std::string items;
if (result.items_per_second > 0) {
items =
StrCat(" ", HumanReadableNumber(result.items_per_second), " items/s");
}
const double real_time = result.GetAdjustedRealTime();
const double cpu_time = result.GetAdjustedCPUTime();
if (result.report_big_o) {
std::string big_o = GetBigOString(result.complexity);
printer(Out, COLOR_YELLOW, "%10.2f %s %10.2f %s ", real_time, big_o.c_str(),
cpu_time, big_o.c_str());
} else if (result.report_rms) {
printer(Out, COLOR_YELLOW, "%10.0f %% %10.0f %% ", real_time * 100,
cpu_time * 100);
} else {
const char* timeLabel = GetTimeUnitString(result.time_unit);
printer(Out, COLOR_YELLOW, "%10.0f %s %10.0f %s ", real_time, timeLabel,
cpu_time, timeLabel);
}
if (!result.report_big_o && !result.report_rms) {
printer(Out, COLOR_CYAN, "%10lld", result.iterations);
}
for (auto& c : result.counters) {
const std::size_t cNameLen = std::max(std::string::size_type(10),
c.first.length());
auto const& s = HumanReadableNumber(c.second.value, 1000);
if (output_options_ & OO_Tabular) {
if (c.second.flags & Counter::kIsRate) {
printer(Out, COLOR_DEFAULT, " %*s/s", cNameLen - 2, s.c_str());
} else {
printer(Out, COLOR_DEFAULT, " %*s", cNameLen, s.c_str());
}
} else {
const char* unit = (c.second.flags & Counter::kIsRate) ? "/s" : "";
printer(Out, COLOR_DEFAULT, " %s=%s%s", c.first.c_str(), s.c_str(),
unit);
}
}
if (!rate.empty()) {
printer(Out, COLOR_DEFAULT, " %*s", 13, rate.c_str());
}
if (!items.empty()) {
printer(Out, COLOR_DEFAULT, " %*s", 18, items.c_str());
}
if (!result.report_label.empty()) {
printer(Out, COLOR_DEFAULT, " %s", result.report_label.c_str());
}
printer(Out, COLOR_DEFAULT, "\n");
}
} // end namespace benchmark

View File

@@ -0,0 +1,68 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "counter.h"
namespace benchmark {
namespace internal {
double Finish(Counter const& c, double cpu_time, double num_threads) {
double v = c.value;
if (c.flags & Counter::kIsRate) {
v /= cpu_time;
}
if (c.flags & Counter::kAvgThreads) {
v /= num_threads;
}
return v;
}
void Finish(UserCounters *l, double cpu_time, double num_threads) {
for (auto &c : *l) {
c.second.value = Finish(c.second, cpu_time, num_threads);
}
}
void Increment(UserCounters *l, UserCounters const& r) {
// add counters present in both or just in *l
for (auto &c : *l) {
auto it = r.find(c.first);
if (it != r.end()) {
c.second.value = c.second + it->second;
}
}
// add counters present in r, but not in *l
for (auto const &tc : r) {
auto it = l->find(tc.first);
if (it == l->end()) {
(*l)[tc.first] = tc.second;
}
}
}
bool SameNames(UserCounters const& l, UserCounters const& r) {
if (&l == &r) return true;
if (l.size() != r.size()) {
return false;
}
for (auto const& c : l) {
if (r.find(c.first) == r.end()) {
return false;
}
}
return true;
}
} // end namespace internal
} // end namespace benchmark

26
benchmarks/thirdparty/benchmark/src/counter.h vendored Executable file
View File

@@ -0,0 +1,26 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "benchmark/benchmark.h"
namespace benchmark {
// these counter-related functions are hidden to reduce API surface.
namespace internal {
void Finish(UserCounters *l, double time, double num_threads);
void Increment(UserCounters *l, UserCounters const& r);
bool SameNames(UserCounters const& l, UserCounters const& r);
} // end namespace internal
} //end namespace benchmark

View File

@@ -0,0 +1,149 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "benchmark/benchmark.h"
#include "complexity.h"
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
#include "string_util.h"
#include "timers.h"
#include "check.h"
// File format reference: http://edoceo.com/utilitas/csv-file-format.
namespace benchmark {
namespace {
std::vector<std::string> elements = {
"name", "iterations", "real_time", "cpu_time",
"time_unit", "bytes_per_second", "items_per_second", "label",
"error_occurred", "error_message"};
} // namespace
bool CSVReporter::ReportContext(const Context& context) {
PrintBasicContext(&GetErrorStream(), context);
return true;
}
void CSVReporter::ReportRuns(const std::vector<Run> & reports) {
std::ostream& Out = GetOutputStream();
if (!printed_header_) {
// save the names of all the user counters
for (const auto& run : reports) {
for (const auto& cnt : run.counters) {
user_counter_names_.insert(cnt.first);
}
}
// print the header
for (auto B = elements.begin(); B != elements.end();) {
Out << *B++;
if (B != elements.end()) Out << ",";
}
for (auto B = user_counter_names_.begin(); B != user_counter_names_.end();) {
Out << ",\"" << *B++ << "\"";
}
Out << "\n";
printed_header_ = true;
} else {
// check that all the current counters are saved in the name set
for (const auto& run : reports) {
for (const auto& cnt : run.counters) {
CHECK(user_counter_names_.find(cnt.first) != user_counter_names_.end())
<< "All counters must be present in each run. "
<< "Counter named \"" << cnt.first
<< "\" was not in a run after being added to the header";
}
}
}
// print results for each run
for (const auto& run : reports) {
PrintRunData(run);
}
}
void CSVReporter::PrintRunData(const Run & run) {
std::ostream& Out = GetOutputStream();
// Field with embedded double-quote characters must be doubled and the field
// delimited with double-quotes.
std::string name = run.benchmark_name;
ReplaceAll(&name, "\"", "\"\"");
Out << '"' << name << "\",";
if (run.error_occurred) {
Out << std::string(elements.size() - 3, ',');
Out << "true,";
std::string msg = run.error_message;
ReplaceAll(&msg, "\"", "\"\"");
Out << '"' << msg << "\"\n";
return;
}
// Do not print iteration on bigO and RMS report
if (!run.report_big_o && !run.report_rms) {
Out << run.iterations;
}
Out << ",";
Out << run.GetAdjustedRealTime() << ",";
Out << run.GetAdjustedCPUTime() << ",";
// Do not print timeLabel on bigO and RMS report
if (run.report_big_o) {
Out << GetBigOString(run.complexity);
} else if (!run.report_rms) {
Out << GetTimeUnitString(run.time_unit);
}
Out << ",";
if (run.bytes_per_second > 0.0) {
Out << run.bytes_per_second;
}
Out << ",";
if (run.items_per_second > 0.0) {
Out << run.items_per_second;
}
Out << ",";
if (!run.report_label.empty()) {
// Field with embedded double-quote characters must be doubled and the field
// delimited with double-quotes.
std::string label = run.report_label;
ReplaceAll(&label, "\"", "\"\"");
Out << "\"" << label << "\"";
}
Out << ",,"; // for error_occurred and error_message
// Print user counters
for (const auto &ucn : user_counter_names_) {
auto it = run.counters.find(ucn);
if(it == run.counters.end()) {
Out << ",";
} else {
Out << "," << it->second;
}
}
Out << '\n';
}
} // end namespace benchmark

View File

@@ -0,0 +1,177 @@
// ----------------------------------------------------------------------
// CycleClock
// A CycleClock tells you the current time in Cycles. The "time"
// is actually time since power-on. This is like time() but doesn't
// involve a system call and is much more precise.
//
// NOTE: Not all cpu/platform/kernel combinations guarantee that this
// clock increments at a constant rate or is synchronized across all logical
// cpus in a system.
//
// If you need the above guarantees, please consider using a different
// API. There are efforts to provide an interface which provides a millisecond
// granularity and implemented as a memory read. A memory read is generally
// cheaper than the CycleClock for many architectures.
//
// Also, in some out of order CPU implementations, the CycleClock is not
// serializing. So if you're trying to count at cycles granularity, your
// data might be inaccurate due to out of order instruction execution.
// ----------------------------------------------------------------------
#ifndef BENCHMARK_CYCLECLOCK_H_
#define BENCHMARK_CYCLECLOCK_H_
#include <cstdint>
#include "benchmark/benchmark.h"
#include "internal_macros.h"
#if defined(BENCHMARK_OS_MACOSX)
#include <mach/mach_time.h>
#endif
// For MSVC, we want to use '_asm rdtsc' when possible (since it works
// with even ancient MSVC compilers), and when not possible the
// __rdtsc intrinsic, declared in <intrin.h>. Unfortunately, in some
// environments, <windows.h> and <intrin.h> have conflicting
// declarations of some other intrinsics, breaking compilation.
// Therefore, we simply declare __rdtsc ourselves. See also
// http://connect.microsoft.com/VisualStudio/feedback/details/262047
#if defined(COMPILER_MSVC) && !defined(_M_IX86)
extern "C" uint64_t __rdtsc();
#pragma intrinsic(__rdtsc)
#endif
#ifndef BENCHMARK_OS_WINDOWS
#include <sys/time.h>
#include <time.h>
#endif
#ifdef BENCHMARK_OS_EMSCRIPTEN
#include <emscripten.h>
#endif
namespace benchmark {
// NOTE: only i386 and x86_64 have been well tested.
// PPC, sparc, alpha, and ia64 are based on
// http://peter.kuscsik.com/wordpress/?p=14
// with modifications by m3b. See also
// https://setisvn.ssl.berkeley.edu/svn/lib/fftw-3.0.1/kernel/cycle.h
namespace cycleclock {
// This should return the number of cycles since power-on. Thread-safe.
inline BENCHMARK_ALWAYS_INLINE int64_t Now() {
#if defined(BENCHMARK_OS_MACOSX)
// this goes at the top because we need ALL Macs, regardless of
// architecture, to return the number of "mach time units" that
// have passed since startup. See sysinfo.cc where
// InitializeSystemInfo() sets the supposed cpu clock frequency of
// macs to the number of mach time units per second, not actual
// CPU clock frequency (which can change in the face of CPU
// frequency scaling). Also note that when the Mac sleeps, this
// counter pauses; it does not continue counting, nor does it
// reset to zero.
return mach_absolute_time();
#elif defined(BENCHMARK_OS_EMSCRIPTEN)
// this goes above x86-specific code because old versions of Emscripten
// define __x86_64__, although they have nothing to do with it.
return static_cast<int64_t>(emscripten_get_now() * 1e+6);
#elif defined(__i386__)
int64_t ret;
__asm__ volatile("rdtsc" : "=A"(ret));
return ret;
#elif defined(__x86_64__) || defined(__amd64__)
uint64_t low, high;
__asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
return (high << 32) | low;
#elif defined(__powerpc__) || defined(__ppc__)
// This returns a time-base, which is not always precisely a cycle-count.
int64_t tbl, tbu0, tbu1;
asm("mftbu %0" : "=r"(tbu0));
asm("mftb %0" : "=r"(tbl));
asm("mftbu %0" : "=r"(tbu1));
tbl &= -static_cast<int64_t>(tbu0 == tbu1);
// high 32 bits in tbu1; low 32 bits in tbl (tbu0 is garbage)
return (tbu1 << 32) | tbl;
#elif defined(__sparc__)
int64_t tick;
asm(".byte 0x83, 0x41, 0x00, 0x00");
asm("mov %%g1, %0" : "=r"(tick));
return tick;
#elif defined(__ia64__)
int64_t itc;
asm("mov %0 = ar.itc" : "=r"(itc));
return itc;
#elif defined(COMPILER_MSVC) && defined(_M_IX86)
// Older MSVC compilers (like 7.x) don't seem to support the
// __rdtsc intrinsic properly, so I prefer to use _asm instead
// when I know it will work. Otherwise, I'll use __rdtsc and hope
// the code is being compiled with a non-ancient compiler.
_asm rdtsc
#elif defined(COMPILER_MSVC)
return __rdtsc();
#elif defined(BENCHMARK_OS_NACL)
// Native Client validator on x86/x86-64 allows RDTSC instructions,
// and this case is handled above. Native Client validator on ARM
// rejects MRC instructions (used in the ARM-specific sequence below),
// so we handle it here. Portable Native Client compiles to
// architecture-agnostic bytecode, which doesn't provide any
// cycle counter access mnemonics.
// Native Client does not provide any API to access cycle counter.
// Use clock_gettime(CLOCK_MONOTONIC, ...) instead of gettimeofday
// because is provides nanosecond resolution (which is noticable at
// least for PNaCl modules running on x86 Mac & Linux).
// Initialize to always return 0 if clock_gettime fails.
struct timespec ts = { 0, 0 };
clock_gettime(CLOCK_MONOTONIC, &ts);
return static_cast<int64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec;
#elif defined(__aarch64__)
// System timer of ARMv8 runs at a different frequency than the CPU's.
// The frequency is fixed, typically in the range 1-50MHz. It can be
// read at CNTFRQ special register. We assume the OS has set up
// the virtual timer properly.
int64_t virtual_timer_value;
asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
return virtual_timer_value;
#elif defined(__ARM_ARCH)
// V6 is the earliest arch that has a standard cyclecount
// Native Client validator doesn't allow MRC instructions.
#if (__ARM_ARCH >= 6)
uint32_t pmccntr;
uint32_t pmuseren;
uint32_t pmcntenset;
// Read the user mode perf monitor counter access permissions.
asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r"(pmuseren));
if (pmuseren & 1) { // Allows reading perfmon counters for user mode code.
asm volatile("mrc p15, 0, %0, c9, c12, 1" : "=r"(pmcntenset));
if (pmcntenset & 0x80000000ul) { // Is it counting?
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(pmccntr));
// The counter is set up to count every 64th cycle
return static_cast<int64_t>(pmccntr) * 64; // Should optimize to << 6
}
}
#endif
struct timeval tv;
gettimeofday(&tv, nullptr);
return static_cast<int64_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
#elif defined(__mips__)
// mips apparently only allows rdtsc for superusers, so we fall
// back to gettimeofday. It's possible clock_gettime would be better.
struct timeval tv;
gettimeofday(&tv, nullptr);
return static_cast<int64_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
#elif defined(__s390__) // Covers both s390 and s390x.
// Return the CPU clock.
uint64_t tsc;
asm("stck %0" : "=Q" (tsc) : : "cc");
return tsc;
#else
// The soft failover to a generic implementation is automatic only for ARM.
// For other platforms the developer is expected to make an attempt to create
// a fast implementation and use generic version if nothing better is available.
#error You need to define CycleTimer for your OS and CPU
#endif
}
} // end namespace cycleclock
} // end namespace benchmark
#endif // BENCHMARK_CYCLECLOCK_H_

View File

@@ -0,0 +1,89 @@
#ifndef BENCHMARK_INTERNAL_MACROS_H_
#define BENCHMARK_INTERNAL_MACROS_H_
#include "benchmark/benchmark.h"
#ifndef __has_feature
#define __has_feature(x) 0
#endif
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
#if defined(__clang__)
#if !defined(COMPILER_CLANG)
#define COMPILER_CLANG
#endif
#elif defined(_MSC_VER)
#if !defined(COMPILER_MSVC)
#define COMPILER_MSVC
#endif
#elif defined(__GNUC__)
#if !defined(COMPILER_GCC)
#define COMPILER_GCC
#endif
#endif
#if __has_feature(cxx_attributes)
#define BENCHMARK_NORETURN [[noreturn]]
#elif defined(__GNUC__)
#define BENCHMARK_NORETURN __attribute__((noreturn))
#elif defined(COMPILER_MSVC)
#define BENCHMARK_NORETURN __declspec(noreturn)
#else
#define BENCHMARK_NORETURN
#endif
#if defined(__CYGWIN__)
#define BENCHMARK_OS_CYGWIN 1
#elif defined(_WIN32)
#define BENCHMARK_OS_WINDOWS 1
#elif defined(__APPLE__)
#define BENCHMARK_OS_APPLE 1
#include "TargetConditionals.h"
#if defined(TARGET_OS_MAC)
#define BENCHMARK_OS_MACOSX 1
#if defined(TARGET_OS_IPHONE)
#define BENCHMARK_OS_IOS 1
#endif
#endif
#elif defined(__FreeBSD__)
#define BENCHMARK_OS_FREEBSD 1
#elif defined(__NetBSD__)
#define BENCHMARK_OS_NETBSD 1
#elif defined(__OpenBSD__)
#define BENCHMARK_OS_OPENBSD 1
#elif defined(__linux__)
#define BENCHMARK_OS_LINUX 1
#elif defined(__native_client__)
#define BENCHMARK_OS_NACL 1
#elif defined(__EMSCRIPTEN__)
#define BENCHMARK_OS_EMSCRIPTEN 1
#elif defined(__rtems__)
#define BENCHMARK_OS_RTEMS 1
#elif defined(__Fuchsia__)
#define BENCHMARK_OS_FUCHSIA 1
#elif defined (__SVR4) && defined (__sun)
#define BENCHMARK_OS_SOLARIS 1
#endif
#if !__has_feature(cxx_exceptions) && !defined(__cpp_exceptions) \
&& !defined(__EXCEPTIONS)
#define BENCHMARK_HAS_NO_EXCEPTIONS
#endif
#if defined(COMPILER_CLANG) || defined(COMPILER_GCC)
#define BENCHMARK_MAYBE_UNUSED __attribute__((unused))
#else
#define BENCHMARK_MAYBE_UNUSED
#endif
#if defined(COMPILER_GCC) || __has_builtin(__builtin_unreachable)
#define BENCHMARK_UNREACHABLE() __builtin_unreachable()
#elif defined(COMPILER_MSVC)
#define BENCHMARK_UNREACHABLE() __assume(false)
#else
#define BENCHMARK_UNREACHABLE() ((void)0)
#endif
#endif // BENCHMARK_INTERNAL_MACROS_H_

View File

@@ -0,0 +1,205 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "benchmark/benchmark.h"
#include "complexity.h"
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
#include <iomanip> // for setprecision
#include <limits>
#include "string_util.h"
#include "timers.h"
namespace benchmark {
namespace {
std::string FormatKV(std::string const& key, std::string const& value) {
return StrFormat("\"%s\": \"%s\"", key.c_str(), value.c_str());
}
std::string FormatKV(std::string const& key, const char* value) {
return StrFormat("\"%s\": \"%s\"", key.c_str(), value);
}
std::string FormatKV(std::string const& key, bool value) {
return StrFormat("\"%s\": %s", key.c_str(), value ? "true" : "false");
}
std::string FormatKV(std::string const& key, int64_t value) {
std::stringstream ss;
ss << '"' << key << "\": " << value;
return ss.str();
}
std::string FormatKV(std::string const& key, double value) {
std::stringstream ss;
ss << '"' << key << "\": ";
const auto max_digits10 = std::numeric_limits<decltype (value)>::max_digits10;
const auto max_fractional_digits10 = max_digits10 - 1;
ss << std::scientific << std::setprecision(max_fractional_digits10) << value;
return ss.str();
}
int64_t RoundDouble(double v) { return static_cast<int64_t>(v + 0.5); }
} // end namespace
bool JSONReporter::ReportContext(const Context& context) {
std::ostream& out = GetOutputStream();
out << "{\n";
std::string inner_indent(2, ' ');
// Open context block and print context information.
out << inner_indent << "\"context\": {\n";
std::string indent(4, ' ');
std::string walltime_value = LocalDateTimeString();
out << indent << FormatKV("date", walltime_value) << ",\n";
if (Context::executable_name) {
out << indent << FormatKV("executable", Context::executable_name) << ",\n";
}
CPUInfo const& info = context.cpu_info;
out << indent << FormatKV("num_cpus", static_cast<int64_t>(info.num_cpus))
<< ",\n";
out << indent
<< FormatKV("mhz_per_cpu",
RoundDouble(info.cycles_per_second / 1000000.0))
<< ",\n";
out << indent << FormatKV("cpu_scaling_enabled", info.scaling_enabled)
<< ",\n";
out << indent << "\"caches\": [\n";
indent = std::string(6, ' ');
std::string cache_indent(8, ' ');
for (size_t i = 0; i < info.caches.size(); ++i) {
auto& CI = info.caches[i];
out << indent << "{\n";
out << cache_indent << FormatKV("type", CI.type) << ",\n";
out << cache_indent << FormatKV("level", static_cast<int64_t>(CI.level))
<< ",\n";
out << cache_indent
<< FormatKV("size", static_cast<int64_t>(CI.size) * 1000u) << ",\n";
out << cache_indent
<< FormatKV("num_sharing", static_cast<int64_t>(CI.num_sharing))
<< "\n";
out << indent << "}";
if (i != info.caches.size() - 1) out << ",";
out << "\n";
}
indent = std::string(4, ' ');
out << indent << "],\n";
#if defined(NDEBUG)
const char build_type[] = "release";
#else
const char build_type[] = "debug";
#endif
out << indent << FormatKV("library_build_type", build_type) << "\n";
// Close context block and open the list of benchmarks.
out << inner_indent << "},\n";
out << inner_indent << "\"benchmarks\": [\n";
return true;
}
void JSONReporter::ReportRuns(std::vector<Run> const& reports) {
if (reports.empty()) {
return;
}
std::string indent(4, ' ');
std::ostream& out = GetOutputStream();
if (!first_report_) {
out << ",\n";
}
first_report_ = false;
for (auto it = reports.begin(); it != reports.end(); ++it) {
out << indent << "{\n";
PrintRunData(*it);
out << indent << '}';
auto it_cp = it;
if (++it_cp != reports.end()) {
out << ",\n";
}
}
}
void JSONReporter::Finalize() {
// Close the list of benchmarks and the top level object.
GetOutputStream() << "\n ]\n}\n";
}
void JSONReporter::PrintRunData(Run const& run) {
std::string indent(6, ' ');
std::ostream& out = GetOutputStream();
out << indent << FormatKV("name", run.benchmark_name) << ",\n";
if (run.error_occurred) {
out << indent << FormatKV("error_occurred", run.error_occurred) << ",\n";
out << indent << FormatKV("error_message", run.error_message) << ",\n";
}
if (!run.report_big_o && !run.report_rms) {
out << indent << FormatKV("iterations", run.iterations) << ",\n";
out << indent
<< FormatKV("real_time", run.GetAdjustedRealTime())
<< ",\n";
out << indent
<< FormatKV("cpu_time", run.GetAdjustedCPUTime());
out << ",\n"
<< indent << FormatKV("time_unit", GetTimeUnitString(run.time_unit));
} else if (run.report_big_o) {
out << indent
<< FormatKV("cpu_coefficient", run.GetAdjustedCPUTime())
<< ",\n";
out << indent
<< FormatKV("real_coefficient", run.GetAdjustedRealTime())
<< ",\n";
out << indent << FormatKV("big_o", GetBigOString(run.complexity)) << ",\n";
out << indent << FormatKV("time_unit", GetTimeUnitString(run.time_unit));
} else if (run.report_rms) {
out << indent
<< FormatKV("rms", run.GetAdjustedCPUTime());
}
if (run.bytes_per_second > 0.0) {
out << ",\n"
<< indent
<< FormatKV("bytes_per_second", run.bytes_per_second);
}
if (run.items_per_second > 0.0) {
out << ",\n"
<< indent
<< FormatKV("items_per_second", run.items_per_second);
}
for(auto &c : run.counters) {
out << ",\n"
<< indent
<< FormatKV(c.first, c.second);
}
if (!run.report_label.empty()) {
out << ",\n" << indent << FormatKV("label", run.report_label);
}
out << '\n';
}
} // end namespace benchmark

73
benchmarks/thirdparty/benchmark/src/log.h vendored Executable file
View File

@@ -0,0 +1,73 @@
#ifndef BENCHMARK_LOG_H_
#define BENCHMARK_LOG_H_
#include <iostream>
#include <ostream>
#include "benchmark/benchmark.h"
namespace benchmark {
namespace internal {
typedef std::basic_ostream<char>&(EndLType)(std::basic_ostream<char>&);
class LogType {
friend LogType& GetNullLogInstance();
friend LogType& GetErrorLogInstance();
// FIXME: Add locking to output.
template <class Tp>
friend LogType& operator<<(LogType&, Tp const&);
friend LogType& operator<<(LogType&, EndLType*);
private:
LogType(std::ostream* out) : out_(out) {}
std::ostream* out_;
BENCHMARK_DISALLOW_COPY_AND_ASSIGN(LogType);
};
template <class Tp>
LogType& operator<<(LogType& log, Tp const& value) {
if (log.out_) {
*log.out_ << value;
}
return log;
}
inline LogType& operator<<(LogType& log, EndLType* m) {
if (log.out_) {
*log.out_ << m;
}
return log;
}
inline int& LogLevel() {
static int log_level = 0;
return log_level;
}
inline LogType& GetNullLogInstance() {
static LogType log(nullptr);
return log;
}
inline LogType& GetErrorLogInstance() {
static LogType log(&std::clog);
return log;
}
inline LogType& GetLogInstanceForLevel(int level) {
if (level <= LogLevel()) {
return GetErrorLogInstance();
}
return GetNullLogInstance();
}
} // end namespace internal
} // end namespace benchmark
#define VLOG(x) \
(::benchmark::internal::GetLogInstanceForLevel(x) << "-- LOG(" << x << "):" \
" ")
#endif

155
benchmarks/thirdparty/benchmark/src/mutex.h vendored Executable file
View File

@@ -0,0 +1,155 @@
#ifndef BENCHMARK_MUTEX_H_
#define BENCHMARK_MUTEX_H_
#include <condition_variable>
#include <mutex>
#include "check.h"
// Enable thread safety attributes only with clang.
// The attributes can be safely erased when compiling with other compilers.
#if defined(HAVE_THREAD_SAFETY_ATTRIBUTES)
#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
#else
#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
#endif
#define CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
#define SCOPED_CAPABILITY THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
#define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
#define ACQUIRED_BEFORE(...) \
THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
#define ACQUIRED_AFTER(...) \
THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
#define REQUIRES(...) \
THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
#define REQUIRES_SHARED(...) \
THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
#define ACQUIRE(...) \
THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
#define ACQUIRE_SHARED(...) \
THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
#define RELEASE(...) \
THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
#define RELEASE_SHARED(...) \
THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
#define TRY_ACQUIRE(...) \
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
#define TRY_ACQUIRE_SHARED(...) \
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
#define EXCLUDES(...) THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
#define ASSERT_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
#define ASSERT_SHARED_CAPABILITY(x) \
THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
#define RETURN_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
#define NO_THREAD_SAFETY_ANALYSIS \
THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
namespace benchmark {
typedef std::condition_variable Condition;
// NOTE: Wrappers for std::mutex and std::unique_lock are provided so that
// we can annotate them with thread safety attributes and use the
// -Wthread-safety warning with clang. The standard library types cannot be
// used directly because they do not provided the required annotations.
class CAPABILITY("mutex") Mutex {
public:
Mutex() {}
void lock() ACQUIRE() { mut_.lock(); }
void unlock() RELEASE() { mut_.unlock(); }
std::mutex& native_handle() { return mut_; }
private:
std::mutex mut_;
};
class SCOPED_CAPABILITY MutexLock {
typedef std::unique_lock<std::mutex> MutexLockImp;
public:
MutexLock(Mutex& m) ACQUIRE(m) : ml_(m.native_handle()) {}
~MutexLock() RELEASE() {}
MutexLockImp& native_handle() { return ml_; }
private:
MutexLockImp ml_;
};
class Barrier {
public:
Barrier(int num_threads) : running_threads_(num_threads) {}
// Called by each thread
bool wait() EXCLUDES(lock_) {
bool last_thread = false;
{
MutexLock ml(lock_);
last_thread = createBarrier(ml);
}
if (last_thread) phase_condition_.notify_all();
return last_thread;
}
void removeThread() EXCLUDES(lock_) {
MutexLock ml(lock_);
--running_threads_;
if (entered_ != 0) phase_condition_.notify_all();
}
private:
Mutex lock_;
Condition phase_condition_;
int running_threads_;
// State for barrier management
int phase_number_ = 0;
int entered_ = 0; // Number of threads that have entered this barrier
// Enter the barrier and wait until all other threads have also
// entered the barrier. Returns iff this is the last thread to
// enter the barrier.
bool createBarrier(MutexLock& ml) REQUIRES(lock_) {
CHECK_LT(entered_, running_threads_);
entered_++;
if (entered_ < running_threads_) {
// Wait for all threads to enter
int phase_number_cp = phase_number_;
auto cb = [this, phase_number_cp]() {
return this->phase_number_ > phase_number_cp ||
entered_ == running_threads_; // A thread has aborted in error
};
phase_condition_.wait(ml.native_handle(), cb);
if (phase_number_ > phase_number_cp) return false;
// else (running_threads_ == entered_) and we are the last thread.
}
// Last thread has reached the barrier
phase_number_++;
entered_ = 0;
return true;
}
};
} // end namespace benchmark
#endif // BENCHMARK_MUTEX_H_

152
benchmarks/thirdparty/benchmark/src/re.h vendored Executable file
View File

@@ -0,0 +1,152 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef BENCHMARK_RE_H_
#define BENCHMARK_RE_H_
#include "internal_macros.h"
#if !defined(HAVE_STD_REGEX) && \
!defined(HAVE_GNU_POSIX_REGEX) && \
!defined(HAVE_POSIX_REGEX)
// No explicit regex selection; detect based on builtin hints.
#if defined(BENCHMARK_OS_LINUX) || defined(BENCHMARK_OS_APPLE)
#define HAVE_POSIX_REGEX 1
#elif __cplusplus >= 199711L
#define HAVE_STD_REGEX 1
#endif
#endif
// Prefer C regex libraries when compiling w/o exceptions so that we can
// correctly report errors.
#if defined(BENCHMARK_HAS_NO_EXCEPTIONS) && \
defined(BENCHMARK_HAVE_STD_REGEX) && \
(defined(HAVE_GNU_POSIX_REGEX) || defined(HAVE_POSIX_REGEX))
#undef HAVE_STD_REGEX
#endif
#if defined(HAVE_STD_REGEX)
#include <regex>
#elif defined(HAVE_GNU_POSIX_REGEX)
#include <gnuregex.h>
#elif defined(HAVE_POSIX_REGEX)
#include <regex.h>
#else
#error No regular expression backend was found!
#endif
#include <string>
#include "check.h"
namespace benchmark {
// A wrapper around the POSIX regular expression API that provides automatic
// cleanup
class Regex {
public:
Regex() : init_(false) {}
~Regex();
// Compile a regular expression matcher from spec. Returns true on success.
//
// On failure (and if error is not nullptr), error is populated with a human
// readable error message if an error occurs.
bool Init(const std::string& spec, std::string* error);
// Returns whether str matches the compiled regular expression.
bool Match(const std::string& str);
private:
bool init_;
// Underlying regular expression object
#if defined(HAVE_STD_REGEX)
std::regex re_;
#elif defined(HAVE_POSIX_REGEX) || defined(HAVE_GNU_POSIX_REGEX)
regex_t re_;
#else
#error No regular expression backend implementation available
#endif
};
#if defined(HAVE_STD_REGEX)
inline bool Regex::Init(const std::string& spec, std::string* error) {
#ifdef BENCHMARK_HAS_NO_EXCEPTIONS
((void)error); // suppress unused warning
#else
try {
#endif
re_ = std::regex(spec, std::regex_constants::extended);
init_ = true;
#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
} catch (const std::regex_error& e) {
if (error) {
*error = e.what();
}
}
#endif
return init_;
}
inline Regex::~Regex() {}
inline bool Regex::Match(const std::string& str) {
if (!init_) {
return false;
}
return std::regex_search(str, re_);
}
#else
inline bool Regex::Init(const std::string& spec, std::string* error) {
int ec = regcomp(&re_, spec.c_str(), REG_EXTENDED | REG_NOSUB);
if (ec != 0) {
if (error) {
size_t needed = regerror(ec, &re_, nullptr, 0);
char* errbuf = new char[needed];
regerror(ec, &re_, errbuf, needed);
// regerror returns the number of bytes necessary to null terminate
// the string, so we move that when assigning to error.
CHECK_NE(needed, 0);
error->assign(errbuf, needed - 1);
delete[] errbuf;
}
return false;
}
init_ = true;
return true;
}
inline Regex::~Regex() {
if (init_) {
regfree(&re_);
}
}
inline bool Regex::Match(const std::string& str) {
if (!init_) {
return false;
}
return regexec(&re_, str.c_str(), 0, nullptr, 0) == 0;
}
#endif
} // end namespace benchmark
#endif // BENCHMARK_RE_H_

View File

@@ -0,0 +1,87 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "benchmark/benchmark.h"
#include "timers.h"
#include <cstdlib>
#include <iostream>
#include <tuple>
#include <vector>
#include "check.h"
namespace benchmark {
BenchmarkReporter::BenchmarkReporter()
: output_stream_(&std::cout), error_stream_(&std::cerr) {}
BenchmarkReporter::~BenchmarkReporter() {}
void BenchmarkReporter::PrintBasicContext(std::ostream *out,
Context const &context) {
CHECK(out) << "cannot be null";
auto &Out = *out;
Out << LocalDateTimeString() << "\n";
if (context.executable_name)
Out << "Running " << context.executable_name << "\n";
const CPUInfo &info = context.cpu_info;
Out << "Run on (" << info.num_cpus << " X "
<< (info.cycles_per_second / 1000000.0) << " MHz CPU "
<< ((info.num_cpus > 1) ? "s" : "") << ")\n";
if (info.caches.size() != 0) {
Out << "CPU Caches:\n";
for (auto &CInfo : info.caches) {
Out << " L" << CInfo.level << " " << CInfo.type << " "
<< (CInfo.size / 1000) << "K";
if (CInfo.num_sharing != 0)
Out << " (x" << (info.num_cpus / CInfo.num_sharing) << ")";
Out << "\n";
}
}
if (info.scaling_enabled) {
Out << "***WARNING*** CPU scaling is enabled, the benchmark "
"real time measurements may be noisy and will incur extra "
"overhead.\n";
}
#ifndef NDEBUG
Out << "***WARNING*** Library was built as DEBUG. Timings may be "
"affected.\n";
#endif
}
// No initializer because it's already initialized to NULL.
const char* BenchmarkReporter::Context::executable_name;
BenchmarkReporter::Context::Context() : cpu_info(CPUInfo::Get()) {}
double BenchmarkReporter::Run::GetAdjustedRealTime() const {
double new_time = real_accumulated_time * GetTimeUnitMultiplier(time_unit);
if (iterations != 0) new_time /= static_cast<double>(iterations);
return new_time;
}
double BenchmarkReporter::Run::GetAdjustedCPUTime() const {
double new_time = cpu_accumulated_time * GetTimeUnitMultiplier(time_unit);
if (iterations != 0) new_time /= static_cast<double>(iterations);
return new_time;
}
} // end namespace benchmark

51
benchmarks/thirdparty/benchmark/src/sleep.cc vendored Executable file
View File

@@ -0,0 +1,51 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "sleep.h"
#include <cerrno>
#include <cstdlib>
#include <ctime>
#include "internal_macros.h"
#ifdef BENCHMARK_OS_WINDOWS
#include <Windows.h>
#endif
namespace benchmark {
#ifdef BENCHMARK_OS_WINDOWS
// Window's Sleep takes milliseconds argument.
void SleepForMilliseconds(int milliseconds) { Sleep(milliseconds); }
void SleepForSeconds(double seconds) {
SleepForMilliseconds(static_cast<int>(kNumMillisPerSecond * seconds));
}
#else // BENCHMARK_OS_WINDOWS
void SleepForMicroseconds(int microseconds) {
struct timespec sleep_time;
sleep_time.tv_sec = microseconds / kNumMicrosPerSecond;
sleep_time.tv_nsec = (microseconds % kNumMicrosPerSecond) * kNumNanosPerMicro;
while (nanosleep(&sleep_time, &sleep_time) != 0 && errno == EINTR)
; // Ignore signals and wait for the full interval to elapse.
}
void SleepForMilliseconds(int milliseconds) {
SleepForMicroseconds(milliseconds * kNumMicrosPerMilli);
}
void SleepForSeconds(double seconds) {
SleepForMicroseconds(static_cast<int>(seconds * kNumMicrosPerSecond));
}
#endif // BENCHMARK_OS_WINDOWS
} // end namespace benchmark

15
benchmarks/thirdparty/benchmark/src/sleep.h vendored Executable file
View File

@@ -0,0 +1,15 @@
#ifndef BENCHMARK_SLEEP_H_
#define BENCHMARK_SLEEP_H_
namespace benchmark {
const int kNumMillisPerSecond = 1000;
const int kNumMicrosPerMilli = 1000;
const int kNumMicrosPerSecond = kNumMillisPerSecond * 1000;
const int kNumNanosPerMicro = 1000;
const int kNumNanosPerSecond = kNumNanosPerMicro * kNumMicrosPerSecond;
void SleepForMilliseconds(int milliseconds);
void SleepForSeconds(double seconds);
} // end namespace benchmark
#endif // BENCHMARK_SLEEP_H_

View File

@@ -0,0 +1,178 @@
// Copyright 2016 Ismael Jimenez Martinez. All rights reserved.
// Copyright 2017 Roman Lebedev. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "benchmark/benchmark.h"
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <numeric>
#include "check.h"
#include "statistics.h"
namespace benchmark {
auto StatisticsSum = [](const std::vector<double>& v) {
return std::accumulate(v.begin(), v.end(), 0.0);
};
double StatisticsMean(const std::vector<double>& v) {
if (v.empty()) return 0.0;
return StatisticsSum(v) * (1.0 / v.size());
}
double StatisticsMedian(const std::vector<double>& v) {
if (v.size() < 3) return StatisticsMean(v);
std::vector<double> copy(v);
auto center = copy.begin() + v.size() / 2;
std::nth_element(copy.begin(), center, copy.end());
// did we have an odd number of samples?
// if yes, then center is the median
// it no, then we are looking for the average between center and the value before
if(v.size() % 2 == 1)
return *center;
auto center2 = copy.begin() + v.size() / 2 - 1;
std::nth_element(copy.begin(), center2, copy.end());
return (*center + *center2) / 2.0;
}
// Return the sum of the squares of this sample set
auto SumSquares = [](const std::vector<double>& v) {
return std::inner_product(v.begin(), v.end(), v.begin(), 0.0);
};
auto Sqr = [](const double dat) { return dat * dat; };
auto Sqrt = [](const double dat) {
// Avoid NaN due to imprecision in the calculations
if (dat < 0.0) return 0.0;
return std::sqrt(dat);
};
double StatisticsStdDev(const std::vector<double>& v) {
const auto mean = StatisticsMean(v);
if (v.empty()) return mean;
// Sample standard deviation is undefined for n = 1
if (v.size() == 1)
return 0.0;
const double avg_squares = SumSquares(v) * (1.0 / v.size());
return Sqrt(v.size() / (v.size() - 1.0) * (avg_squares - Sqr(mean)));
}
std::vector<BenchmarkReporter::Run> ComputeStats(
const std::vector<BenchmarkReporter::Run>& reports) {
typedef BenchmarkReporter::Run Run;
std::vector<Run> results;
auto error_count =
std::count_if(reports.begin(), reports.end(),
[](Run const& run) { return run.error_occurred; });
if (reports.size() - error_count < 2) {
// We don't report aggregated data if there was a single run.
return results;
}
// Accumulators.
std::vector<double> real_accumulated_time_stat;
std::vector<double> cpu_accumulated_time_stat;
std::vector<double> bytes_per_second_stat;
std::vector<double> items_per_second_stat;
real_accumulated_time_stat.reserve(reports.size());
cpu_accumulated_time_stat.reserve(reports.size());
bytes_per_second_stat.reserve(reports.size());
items_per_second_stat.reserve(reports.size());
// All repetitions should be run with the same number of iterations so we
// can take this information from the first benchmark.
int64_t const run_iterations = reports.front().iterations;
// create stats for user counters
struct CounterStat {
Counter c;
std::vector<double> s;
};
std::map< std::string, CounterStat > counter_stats;
for(Run const& r : reports) {
for(auto const& cnt : r.counters) {
auto it = counter_stats.find(cnt.first);
if(it == counter_stats.end()) {
counter_stats.insert({cnt.first, {cnt.second, std::vector<double>{}}});
it = counter_stats.find(cnt.first);
it->second.s.reserve(reports.size());
} else {
CHECK_EQ(counter_stats[cnt.first].c.flags, cnt.second.flags);
}
}
}
// Populate the accumulators.
for (Run const& run : reports) {
CHECK_EQ(reports[0].benchmark_name, run.benchmark_name);
CHECK_EQ(run_iterations, run.iterations);
if (run.error_occurred) continue;
real_accumulated_time_stat.emplace_back(run.real_accumulated_time);
cpu_accumulated_time_stat.emplace_back(run.cpu_accumulated_time);
items_per_second_stat.emplace_back(run.items_per_second);
bytes_per_second_stat.emplace_back(run.bytes_per_second);
// user counters
for(auto const& cnt : run.counters) {
auto it = counter_stats.find(cnt.first);
CHECK_NE(it, counter_stats.end());
it->second.s.emplace_back(cnt.second);
}
}
// Only add label if it is same for all runs
std::string report_label = reports[0].report_label;
for (std::size_t i = 1; i < reports.size(); i++) {
if (reports[i].report_label != report_label) {
report_label = "";
break;
}
}
for(const auto& Stat : *reports[0].statistics) {
// Get the data from the accumulator to BenchmarkReporter::Run's.
Run data;
data.benchmark_name = reports[0].benchmark_name + "_" + Stat.name_;
data.report_label = report_label;
data.iterations = run_iterations;
data.real_accumulated_time = Stat.compute_(real_accumulated_time_stat);
data.cpu_accumulated_time = Stat.compute_(cpu_accumulated_time_stat);
data.bytes_per_second = Stat.compute_(bytes_per_second_stat);
data.items_per_second = Stat.compute_(items_per_second_stat);
data.time_unit = reports[0].time_unit;
// user counters
for(auto const& kv : counter_stats) {
const auto uc_stat = Stat.compute_(kv.second.s);
auto c = Counter(uc_stat, counter_stats[kv.first].c.flags);
data.counters[kv.first] = c;
}
results.push_back(data);
}
return results;
}
} // end namespace benchmark

View File

@@ -0,0 +1,37 @@
// Copyright 2016 Ismael Jimenez Martinez. All rights reserved.
// Copyright 2017 Roman Lebedev. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef STATISTICS_H_
#define STATISTICS_H_
#include <vector>
#include "benchmark/benchmark.h"
namespace benchmark {
// Return a vector containing the mean, median and standard devation information
// (and any user-specified info) for the specified list of reports. If 'reports'
// contains less than two non-errored runs an empty vector is returned
std::vector<BenchmarkReporter::Run> ComputeStats(
const std::vector<BenchmarkReporter::Run>& reports);
double StatisticsMean(const std::vector<double>& v);
double StatisticsMedian(const std::vector<double>& v);
double StatisticsStdDev(const std::vector<double>& v);
} // end namespace benchmark
#endif // STATISTICS_H_

View File

@@ -0,0 +1,172 @@
#include "string_util.h"
#include <array>
#include <cmath>
#include <cstdarg>
#include <cstdio>
#include <memory>
#include <sstream>
#include "arraysize.h"
namespace benchmark {
namespace {
// kilo, Mega, Giga, Tera, Peta, Exa, Zetta, Yotta.
const char kBigSIUnits[] = "kMGTPEZY";
// Kibi, Mebi, Gibi, Tebi, Pebi, Exbi, Zebi, Yobi.
const char kBigIECUnits[] = "KMGTPEZY";
// milli, micro, nano, pico, femto, atto, zepto, yocto.
const char kSmallSIUnits[] = "munpfazy";
// We require that all three arrays have the same size.
static_assert(arraysize(kBigSIUnits) == arraysize(kBigIECUnits),
"SI and IEC unit arrays must be the same size");
static_assert(arraysize(kSmallSIUnits) == arraysize(kBigSIUnits),
"Small SI and Big SI unit arrays must be the same size");
static const int64_t kUnitsSize = arraysize(kBigSIUnits);
void ToExponentAndMantissa(double val, double thresh, int precision,
double one_k, std::string* mantissa,
int64_t* exponent) {
std::stringstream mantissa_stream;
if (val < 0) {
mantissa_stream << "-";
val = -val;
}
// Adjust threshold so that it never excludes things which can't be rendered
// in 'precision' digits.
const double adjusted_threshold =
std::max(thresh, 1.0 / std::pow(10.0, precision));
const double big_threshold = adjusted_threshold * one_k;
const double small_threshold = adjusted_threshold;
// Values in ]simple_threshold,small_threshold[ will be printed as-is
const double simple_threshold = 0.01;
if (val > big_threshold) {
// Positive powers
double scaled = val;
for (size_t i = 0; i < arraysize(kBigSIUnits); ++i) {
scaled /= one_k;
if (scaled <= big_threshold) {
mantissa_stream << scaled;
*exponent = i + 1;
*mantissa = mantissa_stream.str();
return;
}
}
mantissa_stream << val;
*exponent = 0;
} else if (val < small_threshold) {
// Negative powers
if (val < simple_threshold) {
double scaled = val;
for (size_t i = 0; i < arraysize(kSmallSIUnits); ++i) {
scaled *= one_k;
if (scaled >= small_threshold) {
mantissa_stream << scaled;
*exponent = -static_cast<int64_t>(i + 1);
*mantissa = mantissa_stream.str();
return;
}
}
}
mantissa_stream << val;
*exponent = 0;
} else {
mantissa_stream << val;
*exponent = 0;
}
*mantissa = mantissa_stream.str();
}
std::string ExponentToPrefix(int64_t exponent, bool iec) {
if (exponent == 0) return "";
const int64_t index = (exponent > 0 ? exponent - 1 : -exponent - 1);
if (index >= kUnitsSize) return "";
const char* array =
(exponent > 0 ? (iec ? kBigIECUnits : kBigSIUnits) : kSmallSIUnits);
if (iec)
return array[index] + std::string("i");
else
return std::string(1, array[index]);
}
std::string ToBinaryStringFullySpecified(double value, double threshold,
int precision, double one_k = 1024.0) {
std::string mantissa;
int64_t exponent;
ToExponentAndMantissa(value, threshold, precision, one_k, &mantissa,
&exponent);
return mantissa + ExponentToPrefix(exponent, false);
}
} // end namespace
void AppendHumanReadable(int n, std::string* str) {
std::stringstream ss;
// Round down to the nearest SI prefix.
ss << ToBinaryStringFullySpecified(n, 1.0, 0);
*str += ss.str();
}
std::string HumanReadableNumber(double n, double one_k) {
// 1.1 means that figures up to 1.1k should be shown with the next unit down;
// this softens edge effects.
// 1 means that we should show one decimal place of precision.
return ToBinaryStringFullySpecified(n, 1.1, 1, one_k);
}
std::string StrFormatImp(const char* msg, va_list args) {
// we might need a second shot at this, so pre-emptivly make a copy
va_list args_cp;
va_copy(args_cp, args);
// TODO(ericwf): use std::array for first attempt to avoid one memory
// allocation guess what the size might be
std::array<char, 256> local_buff;
std::size_t size = local_buff.size();
// 2015-10-08: vsnprintf is used instead of snd::vsnprintf due to a limitation
// in the android-ndk
auto ret = vsnprintf(local_buff.data(), size, msg, args_cp);
va_end(args_cp);
// handle empty expansion
if (ret == 0) return std::string{};
if (static_cast<std::size_t>(ret) < size)
return std::string(local_buff.data());
// we did not provide a long enough buffer on our first attempt.
// add 1 to size to account for null-byte in size cast to prevent overflow
size = static_cast<std::size_t>(ret) + 1;
auto buff_ptr = std::unique_ptr<char[]>(new char[size]);
// 2015-10-08: vsnprintf is used instead of snd::vsnprintf due to a limitation
// in the android-ndk
ret = vsnprintf(buff_ptr.get(), size, msg, args);
return std::string(buff_ptr.get());
}
std::string StrFormat(const char* format, ...) {
va_list args;
va_start(args, format);
std::string tmp = StrFormatImp(format, args);
va_end(args);
return tmp;
}
void ReplaceAll(std::string* str, const std::string& from,
const std::string& to) {
std::size_t start = 0;
while ((start = str->find(from, start)) != std::string::npos) {
str->replace(start, from.length(), to);
start += to.length();
}
}
} // end namespace benchmark

View File

@@ -0,0 +1,40 @@
#ifndef BENCHMARK_STRING_UTIL_H_
#define BENCHMARK_STRING_UTIL_H_
#include <sstream>
#include <string>
#include <utility>
#include "internal_macros.h"
namespace benchmark {
void AppendHumanReadable(int n, std::string* str);
std::string HumanReadableNumber(double n, double one_k = 1024.0);
std::string StrFormat(const char* format, ...);
inline std::ostream& StrCatImp(std::ostream& out) BENCHMARK_NOEXCEPT {
return out;
}
template <class First, class... Rest>
inline std::ostream& StrCatImp(std::ostream& out, First&& f,
Rest&&... rest) {
out << std::forward<First>(f);
return StrCatImp(out, std::forward<Rest>(rest)...);
}
template <class... Args>
inline std::string StrCat(Args&&... args) {
std::ostringstream ss;
StrCatImp(ss, std::forward<Args>(args)...);
return ss.str();
}
void ReplaceAll(std::string* str, const std::string& from,
const std::string& to);
} // end namespace benchmark
#endif // BENCHMARK_STRING_UTIL_H_

587
benchmarks/thirdparty/benchmark/src/sysinfo.cc vendored Executable file
View File

@@ -0,0 +1,587 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "internal_macros.h"
#ifdef BENCHMARK_OS_WINDOWS
#include <Shlwapi.h>
#undef StrCat // Don't let StrCat in string_util.h be renamed to lstrcatA
#include <VersionHelpers.h>
#include <Windows.h>
#else
#include <fcntl.h>
#ifndef BENCHMARK_OS_FUCHSIA
#include <sys/resource.h>
#endif
#include <sys/time.h>
#include <sys/types.h> // this header must be included before 'sys/sysctl.h' to avoid compilation error on FreeBSD
#include <unistd.h>
#if defined BENCHMARK_OS_FREEBSD || defined BENCHMARK_OS_MACOSX || \
defined BENCHMARK_OS_NETBSD || defined BENCHMARK_OS_OPENBSD
#define BENCHMARK_HAS_SYSCTL
#include <sys/sysctl.h>
#endif
#endif
#if defined(BENCHMARK_OS_SOLARIS)
#include <kstat.h>
#endif
#include <algorithm>
#include <array>
#include <bitset>
#include <cerrno>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iterator>
#include <limits>
#include <memory>
#include <sstream>
#include "check.h"
#include "cycleclock.h"
#include "internal_macros.h"
#include "log.h"
#include "sleep.h"
#include "string_util.h"
namespace benchmark {
namespace {
void PrintImp(std::ostream& out) { out << std::endl; }
template <class First, class... Rest>
void PrintImp(std::ostream& out, First&& f, Rest&&... rest) {
out << std::forward<First>(f);
PrintImp(out, std::forward<Rest>(rest)...);
}
template <class... Args>
BENCHMARK_NORETURN void PrintErrorAndDie(Args&&... args) {
PrintImp(std::cerr, std::forward<Args>(args)...);
std::exit(EXIT_FAILURE);
}
#ifdef BENCHMARK_HAS_SYSCTL
/// ValueUnion - A type used to correctly alias the byte-for-byte output of
/// `sysctl` with the result type it's to be interpreted as.
struct ValueUnion {
union DataT {
uint32_t uint32_value;
uint64_t uint64_value;
// For correct aliasing of union members from bytes.
char bytes[8];
};
using DataPtr = std::unique_ptr<DataT, decltype(&std::free)>;
// The size of the data union member + its trailing array size.
size_t Size;
DataPtr Buff;
public:
ValueUnion() : Size(0), Buff(nullptr, &std::free) {}
explicit ValueUnion(size_t BuffSize)
: Size(sizeof(DataT) + BuffSize),
Buff(::new (std::malloc(Size)) DataT(), &std::free) {}
ValueUnion(ValueUnion&& other) = default;
explicit operator bool() const { return bool(Buff); }
char* data() const { return Buff->bytes; }
std::string GetAsString() const { return std::string(data()); }
int64_t GetAsInteger() const {
if (Size == sizeof(Buff->uint32_value))
return static_cast<int32_t>(Buff->uint32_value);
else if (Size == sizeof(Buff->uint64_value))
return static_cast<int64_t>(Buff->uint64_value);
BENCHMARK_UNREACHABLE();
}
uint64_t GetAsUnsigned() const {
if (Size == sizeof(Buff->uint32_value))
return Buff->uint32_value;
else if (Size == sizeof(Buff->uint64_value))
return Buff->uint64_value;
BENCHMARK_UNREACHABLE();
}
template <class T, int N>
std::array<T, N> GetAsArray() {
const int ArrSize = sizeof(T) * N;
CHECK_LE(ArrSize, Size);
std::array<T, N> Arr;
std::memcpy(Arr.data(), data(), ArrSize);
return Arr;
}
};
ValueUnion GetSysctlImp(std::string const& Name) {
#if defined BENCHMARK_OS_OPENBSD
int mib[2];
mib[0] = CTL_HW;
if ((Name == "hw.ncpu") || (Name == "hw.cpuspeed")){
ValueUnion buff(sizeof(int));
if (Name == "hw.ncpu") {
mib[1] = HW_NCPU;
} else {
mib[1] = HW_CPUSPEED;
}
if (sysctl(mib, 2, buff.data(), &buff.Size, nullptr, 0) == -1) {
return ValueUnion();
}
return buff;
}
return ValueUnion();
#else
size_t CurBuffSize = 0;
if (sysctlbyname(Name.c_str(), nullptr, &CurBuffSize, nullptr, 0) == -1)
return ValueUnion();
ValueUnion buff(CurBuffSize);
if (sysctlbyname(Name.c_str(), buff.data(), &buff.Size, nullptr, 0) == 0)
return buff;
return ValueUnion();
#endif
}
BENCHMARK_MAYBE_UNUSED
bool GetSysctl(std::string const& Name, std::string* Out) {
Out->clear();
auto Buff = GetSysctlImp(Name);
if (!Buff) return false;
Out->assign(Buff.data());
return true;
}
template <class Tp,
class = typename std::enable_if<std::is_integral<Tp>::value>::type>
bool GetSysctl(std::string const& Name, Tp* Out) {
*Out = 0;
auto Buff = GetSysctlImp(Name);
if (!Buff) return false;
*Out = static_cast<Tp>(Buff.GetAsUnsigned());
return true;
}
template <class Tp, size_t N>
bool GetSysctl(std::string const& Name, std::array<Tp, N>* Out) {
auto Buff = GetSysctlImp(Name);
if (!Buff) return false;
*Out = Buff.GetAsArray<Tp, N>();
return true;
}
#endif
template <class ArgT>
bool ReadFromFile(std::string const& fname, ArgT* arg) {
*arg = ArgT();
std::ifstream f(fname.c_str());
if (!f.is_open()) return false;
f >> *arg;
return f.good();
}
bool CpuScalingEnabled(int num_cpus) {
// We don't have a valid CPU count, so don't even bother.
if (num_cpus <= 0) return false;
#ifndef BENCHMARK_OS_WINDOWS
// On Linux, the CPUfreq subsystem exposes CPU information as files on the
// local file system. If reading the exported files fails, then we may not be
// running on Linux, so we silently ignore all the read errors.
std::string res;
for (int cpu = 0; cpu < num_cpus; ++cpu) {
std::string governor_file =
StrCat("/sys/devices/system/cpu/cpu", cpu, "/cpufreq/scaling_governor");
if (ReadFromFile(governor_file, &res) && res != "performance") return true;
}
#endif
return false;
}
int CountSetBitsInCPUMap(std::string Val) {
auto CountBits = [](std::string Part) {
using CPUMask = std::bitset<sizeof(std::uintptr_t) * CHAR_BIT>;
Part = "0x" + Part;
CPUMask Mask(std::stoul(Part, nullptr, 16));
return static_cast<int>(Mask.count());
};
size_t Pos;
int total = 0;
while ((Pos = Val.find(',')) != std::string::npos) {
total += CountBits(Val.substr(0, Pos));
Val = Val.substr(Pos + 1);
}
if (!Val.empty()) {
total += CountBits(Val);
}
return total;
}
BENCHMARK_MAYBE_UNUSED
std::vector<CPUInfo::CacheInfo> GetCacheSizesFromKVFS() {
std::vector<CPUInfo::CacheInfo> res;
std::string dir = "/sys/devices/system/cpu/cpu0/cache/";
int Idx = 0;
while (true) {
CPUInfo::CacheInfo info;
std::string FPath = StrCat(dir, "index", Idx++, "/");
std::ifstream f(StrCat(FPath, "size").c_str());
if (!f.is_open()) break;
std::string suffix;
f >> info.size;
if (f.fail())
PrintErrorAndDie("Failed while reading file '", FPath, "size'");
if (f.good()) {
f >> suffix;
if (f.bad())
PrintErrorAndDie(
"Invalid cache size format: failed to read size suffix");
else if (f && suffix != "K")
PrintErrorAndDie("Invalid cache size format: Expected bytes ", suffix);
else if (suffix == "K")
info.size *= 1000;
}
if (!ReadFromFile(StrCat(FPath, "type"), &info.type))
PrintErrorAndDie("Failed to read from file ", FPath, "type");
if (!ReadFromFile(StrCat(FPath, "level"), &info.level))
PrintErrorAndDie("Failed to read from file ", FPath, "level");
std::string map_str;
if (!ReadFromFile(StrCat(FPath, "shared_cpu_map"), &map_str))
PrintErrorAndDie("Failed to read from file ", FPath, "shared_cpu_map");
info.num_sharing = CountSetBitsInCPUMap(map_str);
res.push_back(info);
}
return res;
}
#ifdef BENCHMARK_OS_MACOSX
std::vector<CPUInfo::CacheInfo> GetCacheSizesMacOSX() {
std::vector<CPUInfo::CacheInfo> res;
std::array<uint64_t, 4> CacheCounts{{0, 0, 0, 0}};
GetSysctl("hw.cacheconfig", &CacheCounts);
struct {
std::string name;
std::string type;
int level;
size_t num_sharing;
} Cases[] = {{"hw.l1dcachesize", "Data", 1, CacheCounts[1]},
{"hw.l1icachesize", "Instruction", 1, CacheCounts[1]},
{"hw.l2cachesize", "Unified", 2, CacheCounts[2]},
{"hw.l3cachesize", "Unified", 3, CacheCounts[3]}};
for (auto& C : Cases) {
int val;
if (!GetSysctl(C.name, &val)) continue;
CPUInfo::CacheInfo info;
info.type = C.type;
info.level = C.level;
info.size = val;
info.num_sharing = static_cast<int>(C.num_sharing);
res.push_back(std::move(info));
}
return res;
}
#elif defined(BENCHMARK_OS_WINDOWS)
std::vector<CPUInfo::CacheInfo> GetCacheSizesWindows() {
std::vector<CPUInfo::CacheInfo> res;
DWORD buffer_size = 0;
using PInfo = SYSTEM_LOGICAL_PROCESSOR_INFORMATION;
using CInfo = CACHE_DESCRIPTOR;
using UPtr = std::unique_ptr<PInfo, decltype(&std::free)>;
GetLogicalProcessorInformation(nullptr, &buffer_size);
UPtr buff((PInfo*)malloc(buffer_size), &std::free);
if (!GetLogicalProcessorInformation(buff.get(), &buffer_size))
PrintErrorAndDie("Failed during call to GetLogicalProcessorInformation: ",
GetLastError());
PInfo* it = buff.get();
PInfo* end = buff.get() + (buffer_size / sizeof(PInfo));
for (; it != end; ++it) {
if (it->Relationship != RelationCache) continue;
using BitSet = std::bitset<sizeof(ULONG_PTR) * CHAR_BIT>;
BitSet B(it->ProcessorMask);
// To prevent duplicates, only consider caches where CPU 0 is specified
if (!B.test(0)) continue;
CInfo* Cache = &it->Cache;
CPUInfo::CacheInfo C;
C.num_sharing = static_cast<int>(B.count());
C.level = Cache->Level;
C.size = Cache->Size;
switch (Cache->Type) {
case CacheUnified:
C.type = "Unified";
break;
case CacheInstruction:
C.type = "Instruction";
break;
case CacheData:
C.type = "Data";
break;
case CacheTrace:
C.type = "Trace";
break;
default:
C.type = "Unknown";
break;
}
res.push_back(C);
}
return res;
}
#endif
std::vector<CPUInfo::CacheInfo> GetCacheSizes() {
#ifdef BENCHMARK_OS_MACOSX
return GetCacheSizesMacOSX();
#elif defined(BENCHMARK_OS_WINDOWS)
return GetCacheSizesWindows();
#else
return GetCacheSizesFromKVFS();
#endif
}
int GetNumCPUs() {
#ifdef BENCHMARK_HAS_SYSCTL
int NumCPU = -1;
if (GetSysctl("hw.ncpu", &NumCPU)) return NumCPU;
fprintf(stderr, "Err: %s\n", strerror(errno));
std::exit(EXIT_FAILURE);
#elif defined(BENCHMARK_OS_WINDOWS)
SYSTEM_INFO sysinfo;
// Use memset as opposed to = {} to avoid GCC missing initializer false
// positives.
std::memset(&sysinfo, 0, sizeof(SYSTEM_INFO));
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors; // number of logical
// processors in the current
// group
#elif defined(BENCHMARK_OS_SOLARIS)
// Returns -1 in case of a failure.
int NumCPU = sysconf(_SC_NPROCESSORS_ONLN);
if (NumCPU < 0) {
fprintf(stderr,
"sysconf(_SC_NPROCESSORS_ONLN) failed with error: %s\n",
strerror(errno));
}
return NumCPU;
#else
int NumCPUs = 0;
int MaxID = -1;
std::ifstream f("/proc/cpuinfo");
if (!f.is_open()) {
std::cerr << "failed to open /proc/cpuinfo\n";
return -1;
}
const std::string Key = "processor";
std::string ln;
while (std::getline(f, ln)) {
if (ln.empty()) continue;
size_t SplitIdx = ln.find(':');
std::string value;
if (SplitIdx != std::string::npos) value = ln.substr(SplitIdx + 1);
if (ln.size() >= Key.size() && ln.compare(0, Key.size(), Key) == 0) {
NumCPUs++;
if (!value.empty()) {
int CurID = std::stoi(value);
MaxID = std::max(CurID, MaxID);
}
}
}
if (f.bad()) {
std::cerr << "Failure reading /proc/cpuinfo\n";
return -1;
}
if (!f.eof()) {
std::cerr << "Failed to read to end of /proc/cpuinfo\n";
return -1;
}
f.close();
if ((MaxID + 1) != NumCPUs) {
fprintf(stderr,
"CPU ID assignments in /proc/cpuinfo seem messed up."
" This is usually caused by a bad BIOS.\n");
}
return NumCPUs;
#endif
BENCHMARK_UNREACHABLE();
}
double GetCPUCyclesPerSecond() {
#if defined BENCHMARK_OS_LINUX || defined BENCHMARK_OS_CYGWIN
long freq;
// If the kernel is exporting the tsc frequency use that. There are issues
// where cpuinfo_max_freq cannot be relied on because the BIOS may be
// exporintg an invalid p-state (on x86) or p-states may be used to put the
// processor in a new mode (turbo mode). Essentially, those frequencies
// cannot always be relied upon. The same reasons apply to /proc/cpuinfo as
// well.
if (ReadFromFile("/sys/devices/system/cpu/cpu0/tsc_freq_khz", &freq)
// If CPU scaling is in effect, we want to use the *maximum* frequency,
// not whatever CPU speed some random processor happens to be using now.
|| ReadFromFile("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq",
&freq)) {
// The value is in kHz (as the file name suggests). For example, on a
// 2GHz warpstation, the file contains the value "2000000".
return freq * 1000.0;
}
const double error_value = -1;
double bogo_clock = error_value;
std::ifstream f("/proc/cpuinfo");
if (!f.is_open()) {
std::cerr << "failed to open /proc/cpuinfo\n";
return error_value;
}
auto startsWithKey = [](std::string const& Value, std::string const& Key) {
if (Key.size() > Value.size()) return false;
auto Cmp = [&](char X, char Y) {
return std::tolower(X) == std::tolower(Y);
};
return std::equal(Key.begin(), Key.end(), Value.begin(), Cmp);
};
std::string ln;
while (std::getline(f, ln)) {
if (ln.empty()) continue;
size_t SplitIdx = ln.find(':');
std::string value;
if (SplitIdx != std::string::npos) value = ln.substr(SplitIdx + 1);
// When parsing the "cpu MHz" and "bogomips" (fallback) entries, we only
// accept positive values. Some environments (virtual machines) report zero,
// which would cause infinite looping in WallTime_Init.
if (startsWithKey(ln, "cpu MHz")) {
if (!value.empty()) {
double cycles_per_second = std::stod(value) * 1000000.0;
if (cycles_per_second > 0) return cycles_per_second;
}
} else if (startsWithKey(ln, "bogomips")) {
if (!value.empty()) {
bogo_clock = std::stod(value) * 1000000.0;
if (bogo_clock < 0.0) bogo_clock = error_value;
}
}
}
if (f.bad()) {
std::cerr << "Failure reading /proc/cpuinfo\n";
return error_value;
}
if (!f.eof()) {
std::cerr << "Failed to read to end of /proc/cpuinfo\n";
return error_value;
}
f.close();
// If we found the bogomips clock, but nothing better, we'll use it (but
// we're not happy about it); otherwise, fallback to the rough estimation
// below.
if (bogo_clock >= 0.0) return bogo_clock;
#elif defined BENCHMARK_HAS_SYSCTL
constexpr auto* FreqStr =
#if defined(BENCHMARK_OS_FREEBSD) || defined(BENCHMARK_OS_NETBSD)
"machdep.tsc_freq";
#elif defined BENCHMARK_OS_OPENBSD
"hw.cpuspeed";
#else
"hw.cpufrequency";
#endif
unsigned long long hz = 0;
#if defined BENCHMARK_OS_OPENBSD
if (GetSysctl(FreqStr, &hz)) return hz * 1000000;
#else
if (GetSysctl(FreqStr, &hz)) return hz;
#endif
fprintf(stderr, "Unable to determine clock rate from sysctl: %s: %s\n",
FreqStr, strerror(errno));
#elif defined BENCHMARK_OS_WINDOWS
// In NT, read MHz from the registry. If we fail to do so or we're in win9x
// then make a crude estimate.
DWORD data, data_size = sizeof(data);
if (IsWindowsXPOrGreater() &&
SUCCEEDED(
SHGetValueA(HKEY_LOCAL_MACHINE,
"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",
"~MHz", nullptr, &data, &data_size)))
return static_cast<double>((int64_t)data *
(int64_t)(1000 * 1000)); // was mhz
#elif defined (BENCHMARK_OS_SOLARIS)
kstat_ctl_t *kc = kstat_open();
if (!kc) {
std::cerr << "failed to open /dev/kstat\n";
return -1;
}
kstat_t *ksp = kstat_lookup(kc, (char*)"cpu_info", -1, (char*)"cpu_info0");
if (!ksp) {
std::cerr << "failed to lookup in /dev/kstat\n";
return -1;
}
if (kstat_read(kc, ksp, NULL) < 0) {
std::cerr << "failed to read from /dev/kstat\n";
return -1;
}
kstat_named_t *knp =
(kstat_named_t*)kstat_data_lookup(ksp, (char*)"current_clock_Hz");
if (!knp) {
std::cerr << "failed to lookup data in /dev/kstat\n";
return -1;
}
if (knp->data_type != KSTAT_DATA_UINT64) {
std::cerr << "current_clock_Hz is of unexpected data type: "
<< knp->data_type << "\n";
return -1;
}
double clock_hz = knp->value.ui64;
kstat_close(kc);
return clock_hz;
#endif
// If we've fallen through, attempt to roughly estimate the CPU clock rate.
const int estimate_time_ms = 1000;
const auto start_ticks = cycleclock::Now();
SleepForMilliseconds(estimate_time_ms);
return static_cast<double>(cycleclock::Now() - start_ticks);
}
} // end namespace
const CPUInfo& CPUInfo::Get() {
static const CPUInfo* info = new CPUInfo();
return *info;
}
CPUInfo::CPUInfo()
: num_cpus(GetNumCPUs()),
cycles_per_second(GetCPUCyclesPerSecond()),
caches(GetCacheSizes()),
scaling_enabled(CpuScalingEnabled(num_cpus)) {}
} // end namespace benchmark

View File

@@ -0,0 +1,66 @@
#ifndef BENCHMARK_THREAD_MANAGER_H
#define BENCHMARK_THREAD_MANAGER_H
#include <atomic>
#include "benchmark/benchmark.h"
#include "mutex.h"
namespace benchmark {
namespace internal {
class ThreadManager {
public:
ThreadManager(int num_threads)
: alive_threads_(num_threads), start_stop_barrier_(num_threads) {}
Mutex& GetBenchmarkMutex() const RETURN_CAPABILITY(benchmark_mutex_) {
return benchmark_mutex_;
}
bool StartStopBarrier() EXCLUDES(end_cond_mutex_) {
return start_stop_barrier_.wait();
}
void NotifyThreadComplete() EXCLUDES(end_cond_mutex_) {
start_stop_barrier_.removeThread();
if (--alive_threads_ == 0) {
MutexLock lock(end_cond_mutex_);
end_condition_.notify_all();
}
}
void WaitForAllThreads() EXCLUDES(end_cond_mutex_) {
MutexLock lock(end_cond_mutex_);
end_condition_.wait(lock.native_handle(),
[this]() { return alive_threads_ == 0; });
}
public:
struct Result {
int64_t iterations = 0;
double real_time_used = 0;
double cpu_time_used = 0;
double manual_time_used = 0;
int64_t bytes_processed = 0;
int64_t items_processed = 0;
int64_t complexity_n = 0;
std::string report_label_;
std::string error_message_;
bool has_error_ = false;
UserCounters counters;
};
GUARDED_BY(GetBenchmarkMutex()) Result results;
private:
mutable Mutex benchmark_mutex_;
std::atomic<int> alive_threads_;
Barrier start_stop_barrier_;
Mutex end_cond_mutex_;
Condition end_condition_;
};
} // namespace internal
} // namespace benchmark
#endif // BENCHMARK_THREAD_MANAGER_H

View File

@@ -0,0 +1,69 @@
#ifndef BENCHMARK_THREAD_TIMER_H
#define BENCHMARK_THREAD_TIMER_H
#include "check.h"
#include "timers.h"
namespace benchmark {
namespace internal {
class ThreadTimer {
public:
ThreadTimer() = default;
// Called by each thread
void StartTimer() {
running_ = true;
start_real_time_ = ChronoClockNow();
start_cpu_time_ = ThreadCPUUsage();
}
// Called by each thread
void StopTimer() {
CHECK(running_);
running_ = false;
real_time_used_ += ChronoClockNow() - start_real_time_;
// Floating point error can result in the subtraction producing a negative
// time. Guard against that.
cpu_time_used_ += std::max<double>(ThreadCPUUsage() - start_cpu_time_, 0);
}
// Called by each thread
void SetIterationTime(double seconds) { manual_time_used_ += seconds; }
bool running() const { return running_; }
// REQUIRES: timer is not running
double real_time_used() {
CHECK(!running_);
return real_time_used_;
}
// REQUIRES: timer is not running
double cpu_time_used() {
CHECK(!running_);
return cpu_time_used_;
}
// REQUIRES: timer is not running
double manual_time_used() {
CHECK(!running_);
return manual_time_used_;
}
private:
bool running_ = false; // Is the timer running
double start_real_time_ = 0; // If running_
double start_cpu_time_ = 0; // If running_
// Accumulated time so far (does not contain current slice if running_)
double real_time_used_ = 0;
double cpu_time_used_ = 0;
// Manually set iteration time. User sets this with SetIterationTime(seconds).
double manual_time_used_ = 0;
};
} // namespace internal
} // namespace benchmark
#endif // BENCHMARK_THREAD_TIMER_H

217
benchmarks/thirdparty/benchmark/src/timers.cc vendored Executable file
View File

@@ -0,0 +1,217 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "timers.h"
#include "internal_macros.h"
#ifdef BENCHMARK_OS_WINDOWS
#include <Shlwapi.h>
#undef StrCat // Don't let StrCat in string_util.h be renamed to lstrcatA
#include <VersionHelpers.h>
#include <Windows.h>
#else
#include <fcntl.h>
#ifndef BENCHMARK_OS_FUCHSIA
#include <sys/resource.h>
#endif
#include <sys/time.h>
#include <sys/types.h> // this header must be included before 'sys/sysctl.h' to avoid compilation error on FreeBSD
#include <unistd.h>
#if defined BENCHMARK_OS_FREEBSD || defined BENCHMARK_OS_MACOSX
#include <sys/sysctl.h>
#endif
#if defined(BENCHMARK_OS_MACOSX)
#include <mach/mach_init.h>
#include <mach/mach_port.h>
#include <mach/thread_act.h>
#endif
#endif
#ifdef BENCHMARK_OS_EMSCRIPTEN
#include <emscripten.h>
#endif
#include <cerrno>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <limits>
#include <mutex>
#include "check.h"
#include "log.h"
#include "sleep.h"
#include "string_util.h"
namespace benchmark {
// Suppress unused warnings on helper functions.
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
namespace {
#if defined(BENCHMARK_OS_WINDOWS)
double MakeTime(FILETIME const& kernel_time, FILETIME const& user_time) {
ULARGE_INTEGER kernel;
ULARGE_INTEGER user;
kernel.HighPart = kernel_time.dwHighDateTime;
kernel.LowPart = kernel_time.dwLowDateTime;
user.HighPart = user_time.dwHighDateTime;
user.LowPart = user_time.dwLowDateTime;
return (static_cast<double>(kernel.QuadPart) +
static_cast<double>(user.QuadPart)) *
1e-7;
}
#elif !defined(BENCHMARK_OS_FUCHSIA)
double MakeTime(struct rusage const& ru) {
return (static_cast<double>(ru.ru_utime.tv_sec) +
static_cast<double>(ru.ru_utime.tv_usec) * 1e-6 +
static_cast<double>(ru.ru_stime.tv_sec) +
static_cast<double>(ru.ru_stime.tv_usec) * 1e-6);
}
#endif
#if defined(BENCHMARK_OS_MACOSX)
double MakeTime(thread_basic_info_data_t const& info) {
return (static_cast<double>(info.user_time.seconds) +
static_cast<double>(info.user_time.microseconds) * 1e-6 +
static_cast<double>(info.system_time.seconds) +
static_cast<double>(info.system_time.microseconds) * 1e-6);
}
#endif
#if defined(CLOCK_PROCESS_CPUTIME_ID) || defined(CLOCK_THREAD_CPUTIME_ID)
double MakeTime(struct timespec const& ts) {
return ts.tv_sec + (static_cast<double>(ts.tv_nsec) * 1e-9);
}
#endif
BENCHMARK_NORETURN static void DiagnoseAndExit(const char* msg) {
std::cerr << "ERROR: " << msg << std::endl;
std::exit(EXIT_FAILURE);
}
} // end namespace
double ProcessCPUUsage() {
#if defined(BENCHMARK_OS_WINDOWS)
HANDLE proc = GetCurrentProcess();
FILETIME creation_time;
FILETIME exit_time;
FILETIME kernel_time;
FILETIME user_time;
if (GetProcessTimes(proc, &creation_time, &exit_time, &kernel_time,
&user_time))
return MakeTime(kernel_time, user_time);
DiagnoseAndExit("GetProccessTimes() failed");
#elif defined(BENCHMARK_OS_EMSCRIPTEN)
// clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ...) returns 0 on Emscripten.
// Use Emscripten-specific API. Reported CPU time would be exactly the
// same as total time, but this is ok because there aren't long-latency
// syncronous system calls in Emscripten.
return emscripten_get_now() * 1e-3;
#elif defined(CLOCK_PROCESS_CPUTIME_ID) && !defined(BENCHMARK_OS_MACOSX)
// FIXME We want to use clock_gettime, but its not available in MacOS 10.11. See
// https://github.com/google/benchmark/pull/292
struct timespec spec;
if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &spec) == 0)
return MakeTime(spec);
DiagnoseAndExit("clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ...) failed");
#else
struct rusage ru;
if (getrusage(RUSAGE_SELF, &ru) == 0) return MakeTime(ru);
DiagnoseAndExit("getrusage(RUSAGE_SELF, ...) failed");
#endif
}
double ThreadCPUUsage() {
#if defined(BENCHMARK_OS_WINDOWS)
HANDLE this_thread = GetCurrentThread();
FILETIME creation_time;
FILETIME exit_time;
FILETIME kernel_time;
FILETIME user_time;
GetThreadTimes(this_thread, &creation_time, &exit_time, &kernel_time,
&user_time);
return MakeTime(kernel_time, user_time);
#elif defined(BENCHMARK_OS_MACOSX)
// FIXME We want to use clock_gettime, but its not available in MacOS 10.11. See
// https://github.com/google/benchmark/pull/292
mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
thread_basic_info_data_t info;
mach_port_t thread = pthread_mach_thread_np(pthread_self());
if (thread_info(thread, THREAD_BASIC_INFO, (thread_info_t)&info, &count) ==
KERN_SUCCESS) {
return MakeTime(info);
}
DiagnoseAndExit("ThreadCPUUsage() failed when evaluating thread_info");
#elif defined(BENCHMARK_OS_EMSCRIPTEN)
// Emscripten doesn't support traditional threads
return ProcessCPUUsage();
#elif defined(BENCHMARK_OS_RTEMS)
// RTEMS doesn't support CLOCK_THREAD_CPUTIME_ID. See
// https://github.com/RTEMS/rtems/blob/master/cpukit/posix/src/clockgettime.c
return ProcessCPUUsage();
#elif defined(BENCHMARK_OS_SOLARIS)
struct rusage ru;
if (getrusage(RUSAGE_LWP, &ru) == 0) return MakeTime(ru);
DiagnoseAndExit("getrusage(RUSAGE_LWP, ...) failed");
#elif defined(CLOCK_THREAD_CPUTIME_ID)
struct timespec ts;
if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) == 0) return MakeTime(ts);
DiagnoseAndExit("clock_gettime(CLOCK_THREAD_CPUTIME_ID, ...) failed");
#else
#error Per-thread timing is not available on your system.
#endif
}
namespace {
std::string DateTimeString(bool local) {
typedef std::chrono::system_clock Clock;
std::time_t now = Clock::to_time_t(Clock::now());
const std::size_t kStorageSize = 128;
char storage[kStorageSize];
std::size_t written;
if (local) {
#if defined(BENCHMARK_OS_WINDOWS)
written =
std::strftime(storage, sizeof(storage), "%x %X", ::localtime(&now));
#else
std::tm timeinfo;
::localtime_r(&now, &timeinfo);
written = std::strftime(storage, sizeof(storage), "%F %T", &timeinfo);
#endif
} else {
#if defined(BENCHMARK_OS_WINDOWS)
written = std::strftime(storage, sizeof(storage), "%x %X", ::gmtime(&now));
#else
std::tm timeinfo;
::gmtime_r(&now, &timeinfo);
written = std::strftime(storage, sizeof(storage), "%F %T", &timeinfo);
#endif
}
CHECK(written < kStorageSize);
((void)written); // prevent unused variable in optimized mode.
return std::string(storage);
}
} // end namespace
std::string LocalDateTimeString() { return DateTimeString(true); }
} // end namespace benchmark

Some files were not shown because too many files have changed in this diff Show More