Commit Graph

338 Commits

Author SHA1 Message Date
Jacek Galowicz
8214f717e7
Fix typo in JSONCPP_USE_SECURE_MEMORY vs JSONCPP_USING_SECURE_MEMORY (#1567) 2024-09-12 10:58:39 -07:00
Pavel Tsynk
07e3d1b076
Fix deallocate for working on old compiers (#1478)
Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
2024-09-11 17:43:25 -07:00
Jordan Bayles
871f0cc43b
Release 1.9.6 and move versions to 1.9.7 (#1566)
* Release 1.9.6 and move versions to 1.9.7

This patch updates versions to be for version 1.9.7.

* remove log.txt
2024-09-11 17:01:27 -07:00
Timofey
7f36cdb3ea
Added Value::find with String key (#1467)
* Added Value::find with String key

* Fix codestyle

---------

Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
Co-authored-by: Petukhov Timofey <Timofey.Petukhov@infotecs.ru>
2024-09-09 20:14:36 -07:00
Alex Beregszaszi
3aa1192a00
Introduce CharReaderBuilder::ecma404Mode (#1333)
* Introduce CharReaderBuilder::ecma404Mode

* Bump micro version

---------

Co-authored-by: Jordan Bayles <jophba@chromium.org>
Co-authored-by: Billy Donahue <BillyDonahue@users.noreply.github.com>
Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
2024-09-09 20:11:44 -07:00
Kerem TAN
162ead383d
include/json/value.h is changed (#1462)
Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
2024-09-09 20:08:55 -07:00
Lars Müller
2072e2b4e3
Use current source / binary dir when assuring out of source builds (#1527)
Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
2024-09-09 19:56:37 -07:00
Pavel Tsynk
31754ce2e2
Fixed setting JSONCPP_USE_SECURE_MEMORY definition (#1479)
* Fixed setting JSONCPP_USE_SECURE_MEMORY definition

* fix indent

* Fix passing from command line

* simplified definition

---------

Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
2024-09-09 18:51:11 -07:00
martinduffy1
c04c0c2131
CharReader: Add StructuredError (#1409)
* CharReader: Add Structured Error

Add getStructuredError to CharReader

* run clang format

---------

Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
Co-authored-by: Jordan Bayles <jophba@chromium.org>
2024-09-09 18:48:54 -07:00
Philip Top
034976a19d
add a valueToQuotedString overload (#1397)
* add a valueToQuotedString overload to take a string length to support things like a string_view more directly.

* Apply suggestions from code review

Co-authored-by: Billy Donahue <BillyDonahue@users.noreply.github.com>

---------

Co-authored-by: Billy Donahue <BillyDonahue@users.noreply.github.com>
Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
2024-09-09 17:38:22 -07:00
vslashg
0a9b9d9c6e
Fix a parser bug where tokens are misidentified as commas. (#1502)
* Fix a parser bug where tokens are misidentified as commas.

In the old and new readers, when parsing an object, a comment
followed by any non-`}` token is treated as a comma.

The new unit test required changing the runjsontests.py
flag regime so that failure tests could be run with default settings.

* Honor allowComments==false mode.

Much of the comment handling in the parsers is bespoke, and does not
honor this flag.  By unfiying it under a common API, the parser is
simplified and strict mode is now more correctly strict.

Note that allowComments mode does not allow for comments in
arbitrary locations; they are allowed only in certain positions.
Rectifying this is a bigger effort, since collectComments mode requires
storing the comments somewhere, and it's not immediately clear
where in the DOM all such comments should live.

---------

Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
2024-09-09 17:30:16 -07:00
Jordan Bayles
5c003ecacc
Fix clang format issues (#1555) 2024-09-09 15:48:18 -07:00
Jakob Widauer
3d9bf8ee54
feat: adds front and back methods to Value type (#1458)
Value::front and Value::back
2023-06-07 12:11:01 -04:00
mwestphal
8190e061bc
Fix wrong usage of doxygen groups (#1417) 2022-07-14 17:57:37 -04:00
Jessica Clarke
42e892d96e
Use default rather than hard-coded 8 for maximum aggregate member alignment (#1378)
On CHERI, and thus Arm's Morello prototype, pointers are represented as
hardware capabilities. These capabilities are comprised of not just an
integer address, as is the representation for traditional pointers, but
also bounds, permissions and other metadata, plus a tag bit used as the
validity bit, which provides fine-grained spatial and referential safety
for C and C++ in hardware. This tag bit is not part of the data itself
and is instead kept on the side, flowing with the capability between
registers and the memory subsystem, and any attempt to amplify the
privilege of or corrupt a capability clears this tag (or, in some cases,
traps), rendering them impossible to forge; you can only create
capabilities that are (possibly trivial) subsets of existing ones.

When the capability is stored in memory, this tag bit needs to be
preserved, which is done through the use of tagged memory. Every
capability-sized word gains an additional non-addressable (from the
CPU's perspective; depending on the implementation the tag bits may be
stored in a small block of memory carved out of normal DRAM that the CPU
is blocked from accessing) bit. This means that capabilities can only be
stored to aligned locations; attempting to store them to unaligned
locations will trap with an alignment fault or, if you end up using a
memcpy call, will copy the raw bytes of the capability's representation
but lose the tag, so when it is eventually loaded back as a capability
and dereferenced it will fault.

Since, on 64-bit architectures, our capabilities, used to implement C
language pointers, are 128-bit quantities, this means they need 16-byte
alignment. Currently the various #pragma pack directives, used to work
around (extremely broken and bogus) code that includes jsoncpp in a
context where the maximum alignment has been overridden, hard-code 8 as
the maximum alignment to use, and so do not sufficiently align CHERI /
Morello capabilities on 64-bit architectures. On Windows x64, the
default is also not 8 but 16 (ARM64 is supposedly 8), so this is
slightly dodgy to do there too, but in practice likely not an issue so
long as you don't use any 128-bit types there.

Instead of hard-coding a width, use a directive that resets the packing
back to the default. Unfortunately, whilst GCC and Clang both accept
using #pragma pack(push, 0) as shorthand like for any non-zero value,
MSVC does not, so this needs to be two directives.
2022-01-12 16:27:16 -05:00
luzpaz
a1f1613bdd
Fix various typos (#1350)
Found via `codespell -q 3 -L alue,alse`

Co-authored-by: Christopher Dunn <cdunn2001@gmail.com>
Co-authored-by: Jordan Bayles <jophba@chromium.org>
2021-12-14 18:04:47 -08:00
Christopher Dunn
c4904b2c0d Bump micro version 2021-11-03 11:39:54 -05:00
Christopher Dunn
54a5432c01 Drop compile-time deprecation warning 2021-11-03 11:35:15 -05:00
Alex Beregszaszi
94a6220f7c
Document skipBom in CharReaderBuilder (#1332) 2021-09-21 01:55:25 -04:00
PinkD
1ee39a6752 add comment for emitUTF8 in header 2021-03-06 01:33:15 -06:00
Riccardo Corsi
eab8ebe644 Disable also Visual Studio warning C4275 (std::exception used as base class in dll-interface class) when building as DLL and JSONCPP_DISABLE_DLL_INTERFACE_WARNING is defined. 2021-01-10 00:50:48 -06:00
Billy Donahue
fe9663e7ed Json::ValueIterator operators * and -> need to be const
Fixes #1249.
2021-01-10 00:40:21 -06:00
Hans Johnson
8954092f0a
ENH: Prevent cmake in source builds (#1091)
* ENH: Prevent cmake in source builds

Building directly inside the root of the source tree
can cause problems where the build intermediate files
overwrite or conflict with the intended source code
files.

This modification identifies this problem and
issues failure messages and suggestions to over
come the problem with more robust build suggestion.

Co-authored-by: Jordan Bayles <jophba@chromium.org>
2020-11-06 13:35:51 -08:00
Marcel Opprecht
ceae0e3867
Fix clang-tidy warnings (#1231)
* Fix clang-tidy warnings

Signed-off-by: Marcel Opprecht <marcel.opprecht@scandit.com>

* Fixup/clang-format

Co-authored-by: Marcel Opprecht <marcel.opprecht@scandit.com>
Co-authored-by: Jordan Bayles <jophba@chromium.org>
2020-11-06 13:22:26 -08:00
Christian Ledergerber
30170d651c Fix c++20 compilation problem for clang10 and fix potential bug due to compiler optimization 2020-11-02 10:51:39 -05:00
Ben Boeckel
72db276986 version.h: fix the version number in the header
Fixes: #1224
2020-10-03 23:09:25 -05:00
Jordan Bayles
9059f5cad0
Roll version numbers for 1.9.4 release (#1223) 2020-09-25 19:19:16 -07:00
nathanruiz
c8453d39d1
Delete nullptr Json::Value constructor (#1194)
This patch adds an explicit ctor with a std::nullptr_t argument, that is `delete`-d. This keeps Json::Value from exposing a coding error when automatically promoted to a const char* type.
2020-06-23 14:52:28 -07:00
Rosen Penev
90ca694e46
clang-tidy fixes again (#1155)
* [clang-tidy] remove redundant string initialization

Found with readability-redundant-string-init

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* [clang-tidy] switch to raw strings

Easier to read.

Found with modernize-raw-string-literal

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* [clang-tidy] fix performance issues

Found with performance*

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* fix extra comma warnings

Found with clang's -Wextra-semi-stmt

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* remove JSONCPP_OP_EXPLICIT

This codebase in C++11. No need for compatibility with C++98.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* remove JSONCPP_NOEXCEPT

This codebase is C++11 now. No need for this macro.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-12 01:26:04 -04:00
Chen
3beb37ea14
revert trailing comma in old Reader (#1126) 2020-02-13 13:25:08 -08:00
David Gobbi
dc180eb25e
Remove '=delete' from template methods for Xcode 8 (#1133)
For Apple clang-800.0.42.1, which was released with Xcode 8 in
September 2016, the '=delete' on the 'is' and 'as' methods causes
the following errors for value.h:

  inline declaration of 'as<bool>' follows non-inline definition
  inline declaration of 'is<bool>' follows non-inline definition

etcetera for the other specializations of 'is' and 'as'.  The same
problem also occurs for clang-3.8 but not clang-3.9 or later.
2020-02-13 13:22:49 -08:00
David Seifert
6bc55ec35d Meson updates (#1124)
* Modernize meson.build

* Make tests optional
* Use `files()` for quick sanity checks

* Bump version to 1.9.3

* Bump SOVERSION, as some functions were removed
  and structs were changed, as determined by
  libabigail.
2020-01-07 09:23:50 +08:00
Chen
2983f5a89a
Run Clang-tidy with modernize-use-auto (#1077)
* Run clang-tidy modify with modernize-use-auto
* Use using instead of typedef
2019-12-04 09:08:45 +08:00
Chen
a0bd9adfef
Add an insert overload function (#1110) 2019-12-03 09:13:42 +08:00
Jordan Bayles
a481201af1 Readd some overzealously removed code 2019-11-14 10:21:15 -08:00
Jordan Bayles
9704cedb20 Issue 1100: Drop CPPTL support
CPPTL support is no longer relevant to JsonCpp, and can be removed from
the library. This patch removes all mentions of CPPTL, by removing all
definitions and code sections conditionally compiled only when JsonCpp
is used with CPPTL. Include guards are also renamed to not refer to
CPPTL where appropriate.
2019-11-14 09:38:11 -08:00
Jacob Bundgaard
1c8f7d8ae5 Run clang-format 2019-11-14 00:05:24 -06:00
Jacob Bundgaard
01db7b7430 Allow trailing comma in objects 2019-11-14 00:05:24 -06:00
Billy Donahue
53c8e2cb3b
Issue 1066 (#1080)
Implemented `as<T>()` and `is<T>()` with accompanying tests
2019-11-11 22:43:52 -05:00
Hans Johnson
b082693b9e COMP: Improve const correctness for ValueIterators (#1056)
The protected deref method had inconsistent interface
of being a const function that returned a non-const
reference.  Resolves #914.
2019-10-17 10:52:13 -07:00
dota17
bdacfd7bc0
add a new method to insert a new value in an array at specific index. (#949)
* add a new method to insert a new value in an array at specific index.

* update: index > length, return false;

* fix clang-format
2019-10-16 14:33:53 +08:00
Rosen Penev
bcad4e4de2 clang-tidy cleanups 2 (#1048)
* [clang-tidy] Add explicit to single argument constructor

Found with hicpp-explicit-conversions

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* [clang-tidy] Fix mismatching declaration

Found with readability-inconsistent-declaration-parameter-name

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* [clang-tidy] Replace {} with = default

Found with modernize-use-equals-default

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* [clang-tidy] Remove redundant .c_Str

Found with readability-redundant-string-cstr

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* [clang-tidy] Simplify boolean expressions

Found with readability-simplify-boolean-expr

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* [clang-tidy] Use std::move

Found with modernize-pass-by-value

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* [clang-tidy] Uppercase literal suffixes

Found with hicpp-uppercase-literal-suffix

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-10-15 15:27:23 +08:00
es1x
2ee3b1dbb1 Re-add JSONCPP_NORETURN (#1041)
Fixes Visual Studio 2013 compatibility.
2019-10-11 11:33:36 -07:00
Jordan Bayles
f34bf24bbd
Issue #958: Travis CI should enforce clang-format standards (#1026)
* Issue #958: Travis CI should enfore clang-format standards

This patch adds clang format support to the travis bots.

* Update path

* Roll back to version 8 since 9 is in test

* Cleanup clang

* Revert "Delete JSONCPP_DEPRECATED, use [[deprecated]] instead. (#978)" (#1029)

This reverts commit b27c83f691.
2019-10-11 11:19:00 -07:00
Jordan Bayles
00b979f086
Issue #970: Rename features.h to json_features.h (#1024)
This patch fixes a build issue on CMake, presumably due to the new glibc
having a features.h include file. This patch renames our features.h file
to avoid a name collision.
2019-09-25 14:04:53 -07:00
Jordan Bayles
81ae1d55f7
Just run clang format (#1025) 2019-09-16 12:37:14 -07:00
m-gupta
3013ed48b3 jsoncpp: Define JSON_USE_INT64_DOUBLE_CONVERSION for clang as well. (#1002)
The current check to define JSON_USE_INT64_DOUBLE_CONVERSION
works for GCC but not clang.

Clang does define __GNUC__ but with a value 4 which misses
the check for >= 6.

This avoids the -Wimplicit-int-float-conversion warning
when jsoncpp is built with a recent version of clang.

Signed-off-by: Manoj Gupta <manojgupta@google.com>
2019-09-16 12:24:13 -07:00
dota17
abcd3f7b1f Modify code comments in write.h (#987)
* modify code comments in write.h

* update
2019-09-16 10:40:35 -07:00
dota17
db61dba885 Improving Code Readability (#1004) 2019-09-16 10:35:48 -07:00
dota17
7ef0f9fa5b [Language Conformance] Use constexpr restriction in jsoncpp (#1005)
* use constexpr restriction in jsoncpp

* remove TODO comment
2019-09-16 10:33:47 -07:00