689 Commits

Author SHA1 Message Date
Frank Richter
c5cb313ca0 Do not allow tokenError tokens after input if failIfExtra is set. (#1014)
Currently when failIfExtra is set and strictRoot is not set,
OurReader::parse() will accept trailing non-whitespace after the JSON value
as long as the first token is not a valid JSON token. This commit changes
this to disallow any non-whitespace after the JSON value.

This commit also suppresses the "Extra non-whitespace after JSON value."
error message if parsing was aborted after another error.
2019-09-16 10:41:50 -07:00
dota17
d622250c3e Check the comments array boundry. (#993)
* check the comments array boundry

* remove empty line
2019-09-16 10:40:09 -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
dota17
3550a0a939 add some testcases: WriteTest, StreamWriterTest (#1015) 2019-09-16 10:32:46 -07:00
Google AutoFuzz Team
21ab82916b Add dictionary for fuzzing (#1020) 2019-09-16 10:30:59 -07:00
dota17
fd940255ce change the returned value (#1003) 2019-08-26 12:47:54 -07:00
dota17
c92c87b47d Add some test cases in ValueTest (#1010)
* add some test cases in ValueTest

* add some test cases in ValueTest
2019-08-26 12:36:51 -07:00
Frank Richter
b941149a37 tests: Improve CharReaderFailIfExtraTest (#1011)
* There was a nonsensical change of 'failIfExtra' before calling strictMode():
  the latter resets the former.
  Dealt with by having one test with pure strictMode and one with strictMode
  but failIfExtra=false.
* The JSONTEST_ASSERT_STRING_EQUAL tests for the error strings swapped
  the 'expected' and 'actual' values.
2019-08-26 12:36:27 -07:00
dota17
2cf939e8c3 change Value::null to Value::nullSingleton() (#1000) 2019-08-13 22:42:10 -07:00
Jordan Bayles
7b28698c5c
Cleanup versioning strategy relanding (#989) (#997)
* Cleanup versioning strategy

Currently, versioning is a mess. CMake and Meson have seperate build
version number storage locations, with no way of knowing you need to
have both. Plus, due to recent revisions the amalgamate script is broken
unless you build first, and may still be broken afterwards.

This PR fixes some issues with versioning, and adds comments clarifying
what has to be done when doing a release.

* Run clang format

* Update SOVERSION....
2019-08-13 22:41:43 -07:00
Jordan Bayles
0d27381acf
Revert "Cleanup versioning strategy (#989)" (#996)
This reverts commit 12325b814f00cc31c6ccdb7a17d058c4dbc55aed.
2019-07-31 11:26:48 -07:00
Jordan Bayles
12325b814f
Cleanup versioning strategy (#989)
* Cleanup versioning strategy

Currently, versioning is a mess. CMake and Meson have seperate build
version number storage locations, with no way of knowing you need to
have both. Plus, due to recent revisions the amalgamate script is broken
unless you build first, and may still be broken afterwards.

This PR fixes some issues with versioning, and adds comments clarifying
what has to be done when doing a release.

* Run clang format

* Update SOVERSION....
2019-07-22 15:25:23 -07:00
dota17
b27c83f691 Delete JSONCPP_DEPRECATED, use [[deprecated]] instead. (#978)
* delete JSONCPP_DEPRECATED, use [[deprecated]]

* add pragma warning(disable:4996)

* add error C2416

* update

* update

* update
2019-07-17 13:35:33 -07:00
Billy Donahue
483eba84a7 Improve code comment formatting (Issue #985) 2019-07-17 13:04:53 -07:00
Jordan Bayles
25c57812e2 Add new JSON_USE_NULLREF flag
This patch adds a new flag, JSON_USE_NULLREF, which removes
the legacy singletons null, nullRef for consumers that require not
having static initialized globals, like Chromium.
2019-07-11 14:34:51 -07:00
Jordan Bayles
9ef812a097 \#964 Delete JSONCPP_NORETURN for [[noreturn]]
This patch removes the custom JSONCPP_NORETURN macro in favor of the
C++11 standard [[noreturn]] attribute.
2019-07-10 18:57:47 -07:00
lilinchao
60ba071aac pop the root node after readValue() 2019-07-09 16:16:00 -07:00
lilinchao
3c32dca892 adjust some codes position 2019-07-02 13:39:32 -07:00
Jordan Bayles
7924d3ff97 Update version.h.in header comments
Currently, the comments in the version.h.in header file are
incorrect. This tiny patch just updates them.
2019-07-01 13:23:53 -07:00
Jordan Bayles
95b3092ce4 Fix comments on Json Reader
There have been multiple discussions of the inaccurate comments in the
Json Reader class. This patch just updates those comments.
2019-06-28 10:25:13 -07:00
Jordan Bayles
44bc38f0a1 Issue #633: Fix issue with maxInt
This patch is a minor fix to Json::OurReader to properly check against
maxLargestInt, not maxInt. Some cleanup in the decodeNumber method is
included.
2019-06-28 09:43:32 -07:00
Jordan Bayles
ddc9e0fcd7 Run clang-format on the repository
We currently don't have any checks for clang formatting as part of our
check-in process, this is an incremental patch to get things compliant.
2019-06-27 12:25:42 -07:00
Google AutoFuzz Team
dc170e30e2 Update main.cpp 2019-06-27 11:58:42 -07:00
Google-Autofuzz
d148e28b9b added fuzz.cpp to macro in main.cpp 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
bcc0472621 Update jsontest.cpp 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
c4d1cb1cd1 Update jsontest.cpp 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
336c300ca4 Update jsontest.cpp 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
400ec89811 Update CMakeLists.txt 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
181f9eb129 Update CMakeLists.txt 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
13afd0e455 Update main.cpp 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
caa2f3bf42 Update main.cpp 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
fdcd2fc232 Update main.cpp 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
92cc77392e Added include fuzz.cpp 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
7e69f15a64 added llvm 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
8e01024ce3 fix llvm 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
6d236e1948 Update fuzz.cpp 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
d81a3caece Update fuzz.h 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
2939d85b84 Update fuzz.cpp 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
9725530a4f Update fuzz.h 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
576b271a04 Update fuzz.cpp 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
9d6db96f36 Update fuzz.h 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
46d35659ef Update fuzz.h 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
29434414d7 Update fuzz.cpp 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
3247202676 Updated fuzz.h 2019-06-27 11:58:42 -07:00
Google AutoFuzz Team
0e3b22dd3a Updated header and fixed the bug 2019-06-27 11:58:42 -07:00
Autofuzz team
786851819e Add a simple fuzz test for jsoncpp. 2019-06-27 11:58:42 -07:00
Olivier LIESS
629a727b5f version.h : wrong file was deployed, added required include path and 2019-06-26 09:05:34 -07:00
cmlchen
c51d718ead extract variable 2019-06-26 09:03:12 -07:00
cmlchen
7c7ccbf934 fix compile problem 2019-06-26 09:03:12 -07:00
cmlchen
b7feb2d493 use fpclassify to test a float number is zero or nan 2019-06-26 09:03:12 -07:00
chenguoping
5510f14a71 repair a typo error 2019-06-25 15:16:16 -07:00
Jordan Bayles
d34479ec34 Issue 920: Fix android build with casting fix
This patch removes an unchecked conversion from a 64bit wide type
to a 32bit wide type, fixing a compile error on some platforms.

Issue:920
2019-06-25 15:14:53 -07:00
Billy Donahue
dd6921f479 Add WideString test for Issue #756 2019-06-25 15:14:01 -07:00
Jordan Bayles
2a3ae0e79f
Merge pull request #932 from oleurodecision/cmake_clean
cmake cleanup
2019-06-25 13:59:46 -07:00
Jordan Bayles
d5bd1a7716 Run clang format
Clang format hasn't been run on some recent checkins. This patch updates
the repository with clang format properly run on all files.
2019-06-24 14:06:45 -07:00
Jordan Bayles
83cc92161b Fix JSON_USE_EXCEPTION=0 use case
This patch fixes the JSON_USE_EXCEPTION flag. Currently, due to the
throwRuntimeError and throwLogicError methods implemented in json_value,
even if JSON_USE_EXCEPTION is set to 0 jsoncpp will still throw. This
breaks integration into projects with -fno-exceptions set, such as
Chromium.
2019-06-21 18:16:52 -05:00
Olivier LIESS
85f5b1c8f9 fixed typos 2019-06-03 16:31:07 +02:00
Olivier LIESS
8d2095af3c cmake fixes 2019-06-03 12:45:24 +02:00
Frank Richter
9a629bc5e1 tests: Add a comment 2019-03-23 14:39:59 +01:00
Frank Richter
d76fe5687d Implement Value::demand() 2019-03-23 14:32:13 +01:00
Frank Richter
eb7bd9546e Value::find(): Fix assert message 2019-03-23 14:32:13 +01:00
Frank Richter
0adb053294 tests: Add small checks for find() 2019-03-23 14:16:13 +01:00
Billy Donahue
9a55d22d3d remove JSON_HAS_RVALUE_REFERENCES 2019-03-01 06:32:18 -06:00
Billy Donahue
00558b38db VS2013 doesn't allow move ops to be =default 2019-03-01 06:31:58 -06:00
Billy Donahue
433107f1d9 refactor comments_ into a class 2019-03-01 06:31:58 -06:00
Billy Donahue
0c1cc6e1a3
pack the {type,allocated} bitfield (#876)
* pack the {type,allocated} bitfield (Issue#873)
This allows special functions to be implemented more easily.
2019-01-20 23:59:16 -05:00
Billy Donahue
2b593a9da8 apply the C++11 style change in .clang-format 2019-01-18 07:02:16 -06:00
Billy Donahue
1c2ed7a10f convert JSONCPP_STRING etc from macros to typedefs 2019-01-17 23:14:18 -05:00
Billy Donahue
dc4a7f9b61 Reapply clang-format.
$ clang-format -i -style=file \
        $(find  . | egrep '.*\.(h|cpp|inl)$')
2019-01-17 11:11:55 -05:00
Hans Johnson
21a4185634 STYLE: Avoid unnecessary conversions from size_t to unsigned int
Make the index values consistent with size_t.
2019-01-15 18:30:49 -06:00
Hans Johnson
d11732043a STYLE: Pefer = delete to explicitly trivial implementations
This check replaces undefined special member functions with
= delete;. The explicitly deleted function declarations enable more
opportunities in optimization, because the compiler might treat
explicitly delted functions as noops.

Additionally, the C++11 use of = delete more clearly expreses the
intent for the special member functions.

SRCDIR=/Users/johnsonhj/src/jsoncpp/ #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-equals-delete  -header-filter=.* -fix
2019-01-15 18:30:49 -06:00
Hans Johnson
e3e05c7085 STYLE: Pefer = default to explicitly trivial implementations
This check replaces default bodies of special member functions with
= default;. The explicitly defaulted function declarations enable more
opportunities in optimization, because the compiler might treat
explicitly defaulted functions as trivial.

Additionally, the C++11 use of = default more clearly expreses the
intent for the special member functions.

SRCDIR=/Users/johnsonhj/src/jsoncpp/ #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-equals-default  -header-filter=.* -fix
2019-01-15 18:30:49 -06:00
Hans Johnson
e817e4fc25 STYLE: Use default member initialization
Converts a default constructor’s member initializers into the new
default member initializers in C++11. Other member initializers that match the
default member initializer are removed. This can reduce repeated code or allow
use of ‘= default’.

SRCDIR=/Users/johnsonhj/src/jsoncpp/ #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-default-member-init  -header-filter=.* -fix
2019-01-15 18:30:49 -06:00
Hans Johnson
b5093e8122 PERF: Allow compiler to choose best way to construct a copy
With move semantics added to the language and the standard library updated with
move constructors added for many types it is now interesting to take an
argument directly by value, instead of by const-reference, and then copy. This
check allows the compiler to take care of choosing the best way to construct
the copy.

The transformation is usually beneficial when the calling code passes an rvalue
and assumes the move construction is a cheap operation. This short example
illustrates how the construction of the value happens:

SRCDIR=/Users/johnsonhj/src/jsoncpp/ #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-pass-by-value  -header-filter=.* -fix
2019-01-15 18:30:49 -06:00
Hans Johnson
1fc3de7ca1 STYLE: Use auto for variable type matches the type of the initializer expression
This check is responsible for using the auto type specifier for variable
declarations to improve code readability and maintainability.

The auto type specifier will only be introduced in situations where the
variable type matches the type of the initializer expression. In other words
auto should deduce the same type that was originally spelled in the source

SRCDIR=/Users/johnsonhj/src/jsoncpp/ #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-auto -header-filter = .* -fix
2019-01-15 18:30:49 -06:00
Hans Johnson
cbeed7b076 STYLE: Use range-based loops from C++11
C++11 Range based for loops can be used in

Used as a more readable equivalent to the traditional for loop operating over a
range of values, such as all elements in a container, in the forward direction..

Range based loopes are more explicit for only computing the
end location once for containers.

SRCDIR=/Users/johnsonhj/src/jsoncpp/ #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-loop-convert  -header-filter=.* -fix
2019-01-15 18:30:49 -06:00
Hans Johnson
3beadff472 PERF: readability container size empty
The emptiness of a container should be checked using the empty() method
instead of the size() method. It is not guaranteed that size() is a
constant-time function, and it is generally more efficient and also
shows clearer intent to use empty(). Furthermore some containers may
implement the empty() method but not implement the size() method. Using
empty() whenever possible makes it easier to switch to another container
in the future.

SRCDIR=/Users/johnsonhj/src/jsoncpp/ #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,readability-container-size-empty  -header-filter=.* -fix
2019-01-15 18:30:49 -06:00
Hans Johnson
31d65711d6 ENH: Remove conditionals for unsupported VS compilers
Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported
compiler with sufficient C++11 capabilities

See:
https://blogs.msdn.microsoft.com/vcblog/2013/12/02/c1114-core-language-features-in-vs-2013-and-the-nov-2013-ctp/
for details related to language features supported.
2019-01-14 16:27:52 -06:00
Hans Johnson
2853b1cdac COMP: Use C++11 override directly
The override support in C++11 is required so avoid aliasing
this feature.  Compilers that do not support the override keyword
are no longer supported.
2019-01-14 16:14:12 -06:00
terrycz126
8b31c6f0fd Fix redefined(_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES) warning 2019-01-14 16:13:21 -06:00
Hans Johnson
a3c8e86c0b ENH: Refactor and enhance the CI testing infrastructure
1) Improve travis build script for use outside travis.
   Allow the script used for CI builds to also be used
   locally in a similar manner to the CI use of the scrips

2) Add ctest compatible testing and CDASH support
   Report testing and building results to
   https://my.cdash.org/index.php?project=jsoncpp

   NOTE: The new ctest infrastructure is not yet robust on winodws
         Do no yet enable the new features for running test with ctest
         on windows platform.  The previous behaviors are maintainted,
         but enhance test reporting from windows is not yet supported.

3) Add a cmake coverage testing option
   Ensure that cmake builds on linux are tested.
   Ensure that code coverage is reported.

4) Move conditional environment checking into the matrix
   Avoid multiple places where conditional logic is used to
   change compiler behavior.  As more test environments are
   created fromt the travis.yml matrix, all settings should be
   obvious from that one location.

5) Tests with known regressions from the jsonchecker are suppressed
    Tests that are known to pass with jsoncpp more lenient
    syntax enforcement are exluded from tests in test/runjsontests.py
2019-01-14 16:12:43 -06:00
Brad King
056850c44b reader: fix signed overflow when parsing negative value
Clang's ubsan (-fsanitize=undefined) reports:

    runtime error: negation of -9223372036854775808 cannot be represented in
    type 'Json::Value::LargestInt' (aka 'long'); cast to an unsigned type to
    negate this value to itself

Follow its advice and update the code to remove the explicit negation.
2019-01-11 14:04:41 -06:00
Stefano Fiorentino
009a3ad24c issue_836: Check if `removed' is a valid pointer before copy data to it
functions involved:
	- bool Value::removeMember(const char* key, const char* cend, Value* removed)

Signed-off-by: Stefano Fiorentino <stefano.fiore84@gmail.com>
2019-01-11 11:27:59 -06:00
fangguo
7d16e10113 fiexd “Cannot take the address of a bit field.”
```c++
 #include <iostream>

class TestBool
{
public:
    TestBool():addChildValues_(){}
    TestBool(int):addChildValues_(false){}
    bool addChildValues_ : 1;
    bool indented_ : 1;
};


int main()
{
    std::cout << "\n TestBool () addChildValues_ = " << TestBool().addChildValues_;
    std::cout << "\n TestBool false addChildValues_ = " << TestBool(3).addChildValues_;
    return 0;
}
```

```text
root@osssvr-1 # /opt/SUNWspro/prod/bin/CC  testbool.cpp -o testbool   
Error: Cannot take the address of a bit field.
1 Error(s) detected.
```
2018-12-31 07:39:04 +07:00
Hans Johnson
97e05c41f2 COMP: Provide C++11 feature testing during config
Test compiler feature sets early so that required features
are validated before long compilation process is started.
2018-12-30 15:32:57 -06:00
Hans Johnson
0417e626c0 STYLE: Convert CMake-language commands to lower case
Ancient CMake versions required upper-case commands.  Later command names
became case-insensitive.  Now the preferred style is lower-case.
2018-12-30 15:32:57 -06:00
Hans Johnson
2cb1ad5d0c STYLE: Replace integer literals which are cast to bool.
Finds and replaces integer literals which are cast to bool.

SRCDIR=/Users/johnsonhj/src/jsoncpp #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-bool-literals  -header-filter=.* -fix
2018-12-30 15:31:12 -06:00
Hans Johnson
e50bfefef1 COMP: Prefer the C++ headers over the C99 headers
Using the C++11 headers keeps the library cleaner and more
rigorously scoped use of namespaces.
2018-12-30 15:29:22 -06:00
Hans Johnson
5c8e539af4 ENH: MSVS 2013 snprintf compatible substitute
Simplify the backwards compatible snprintf configuration for pre
1900 version of MSVC.  Otherwise prefer C++11 syntax using std::snprintf.
2018-12-30 15:29:22 -06:00
Radoslav Atanasov
ccd077ffce Fix MSVC 15.9 (2017) warning C4866
by changing operator[] param type from JSONCPP_STRING to const JSONCPP_STRING& for CharReaderBuilder and StreamWriterBuilder (as it is already in Value).

https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c4866?view=vs-2017
2018-12-30 15:28:09 -06:00
Hans Johnson
4abf4ec208 PERF: Replace explicit return calls of constructor
Replaces explicit calls to the constructor in a return with a braced
initializer list. This way the return type is not needlessly duplicated in the
function definition and the return statement.

SRCDIR=/Users/johnsonhj/src/jsoncpp #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-return-braced-init-list  -header-filter=.* -fix
2018-12-30 15:26:29 -06:00
Hans Johnson
f64244ed3f COMP: Use nullptr instead of 0 or NULL
The check converts the usage of null pointer constants (eg. NULL, 0) to
use the new C++11 nullptr keyword.

SRCDIR=/Users/johnsonhj/src/jsoncpp #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-nullptr  -header-filter=.* -fix
2018-12-12 13:41:06 -06:00
manang
b955e0f699
Update json_writer.cpp 2018-12-03 10:26:27 +01:00
Julien Schueller
ec4251b728 Use CMAKE_CROSSCOMPILING_EMULATOR to run tests
Needed when cross-compiling
2018-12-02 18:37:11 -06:00
Julien Schueller
010a2d04d3 Unique lib target name 2018-12-02 18:37:11 -06:00
YantaoZhao
e32ee4717c allow nullptr when not care the removed array value 2018-07-03 21:29:18 +08:00
pavel.pimenov
745287275c "\n" -> '\n' 2018-06-24 18:51:10 -05:00
Kamel CHAOUCHE
ee34ac1fbb Add position independent code feature to CMakeList.txt
Enable Position Independent Code for shared lib
2018-06-22 11:37:18 -05:00
pavel.pimenov
86789e7c2f Fix #782 2018-06-05 10:17:36 +03:00
Marian Klymov
a5d7c714b1 Fix typo in previous fix. 2018-06-02 21:52:45 +03:00
Marian Klymov
84ca7d6f0b Apply the formatting specified in .clang-format file. 2018-06-02 20:27:31 +03:00
Marian Klymov
fc20134c92 Fix different names for parameters in declaration and definition 2018-06-02 20:15:26 +03:00
Marian Klymov
091e03979d Reduce scope of variable. 2018-06-02 19:48:10 +03:00
Marian Klymov
a7d0ffc717 Remove unused private function in TestResult class 2018-06-02 19:46:16 +03:00
Marian Klymov
c8bb600d27 Pass string as a const reference. 2018-06-02 19:41:57 +03:00
Marian Klymov
85a263e89f Fix improper format specifier in printf
%d in format string requires 'int' but the argument type is 'unsigned int'.
2018-06-02 19:38:12 +03:00
Billy Donahue
b5e1fe89aa Apply the formatting specified in .clang-format file.
$ clang-format --version
  clang-format version 7.0.0 (tags/google/stable/2018-01-11)
  $ clang-format -i --style=file $(find . -name '*.cpp' -o -name '*.h')
2018-05-20 18:38:42 -04:00
Billy Donahue
abd39e791b json_tool missing include 2018-05-20 18:38:42 -04:00
Billy Donahue
aa1b383666 fix string construction 2018-05-13 18:28:05 -04:00
Billy Donahue
0ba5c435f4 Improvements in writing precision and json_tool.h helpers 2018-05-11 14:31:12 -04:00
fo40225
cf73619e28 refactoring cross compiler macro 2018-05-09 02:06:19 -05:00
binyangl
0a62267fe4 Disable warning "C4702" when compiling json cpp using vs2013 and above 2018-05-08 20:55:30 +08:00
fo40225
6e5e9be736 corss compiler isnan 2018-05-08 12:35:08 +08:00
fo40225
4050143288 fix ValueTest/integers, CharReaderAllowSpecialFloatsTest/issue209 test failure when fp:fast on msvc 2018-05-05 15:05:22 +08:00
fo40225
3f0d91f08a fix ValueTest/specialFloats test failure when fp:fast on msvc 2018-05-05 14:38:53 +08:00
Mike R
a07fc53287 Add setting precision for json writers and also add decimal places precision type. (#752)
* Added setting precision for writers.
* Added special case for precise precision and global precision.
* Added good setting of type of precision and also added this type to BuiltStreamWriter and for its settings.
* Added some tests.
2018-03-13 15:35:31 -05:00
Christopher Dunn
3e2b8ea9cc
Minor changes for static analysis (#749)
re: #747
2018-03-03 12:51:17 -06:00
Thomas Jandecka
592d942b3b fix: byte shift when interpreting 32-bit utf-8 codepoints 2018-02-14 14:23:58 +01:00
luzpaz
5b45aa55ca Misc-typos (#741)
Found in downstream CMake repo via `codespell -q 3`
2018-02-08 19:05:50 -06:00
Maxim Ky
1ec85c76a4 Value::removeMember arg "removed" is optional now (could be nullptr) 2018-01-29 16:59:24 +03:00
Maxim Ky
c27936e0aa Value::removeMember moves the existing value to "removed" now 2018-01-29 16:58:45 +03:00
Andrey Okoshkin
9b569c8ce3 Make Value copy constructor simplier
Helper private methods Value::dupPayload() and Value::dupMeta() are added.
Value copy constructor doesn't attempt to delete its data first.
* Value::dupPayload() duplicates a payload.
* Value::dupMeta() duplicates comments and an offset position with a limit.
2018-01-12 15:59:20 +03:00
Andrey Okoshkin
392e3a5b49 Add basic test for Value::copy() (#704) 2018-01-12 14:36:01 +03:00
Andrey Okoshkin
c69148c946 Fix Value::copyPayload() and Value::copy() (#704)
Value copy constructor shares the same code with Value::copy() and Value::copyPayload().
New Value::releasePayload() is used to free payload memory.
Fixes: #704
2018-01-12 14:33:47 +03:00
Christopher Dunn
63ab03ca28
replace code point in range(0xD800, 0xDFFF) to replacement mark (#714)
closes #712
2017-12-20 14:43:55 -06:00
Wolfram Rösler
9079422ac1 Allow Json::Value to be used in a boolean context (#695)
Must bump soversion too.
2017-12-05 11:18:55 -06:00
Remy Jette
42ca02b833
Fix sign mismatch in valueToString
`valueToString` takes an argument `unsigned int precision`, but it is used with `%d` rather than `%u` in the `snprintf` format string. Make the format string look for an unsigned value instead.
2017-12-04 17:49:36 -08:00
Josh Soref
e6a588a246 Spelling (#703) 2017-12-03 10:54:29 -06:00
Sascha Zelzer
7c979e8661 Suppress implicit-fallthrough warnings from GCC 7 (#697)
GCC 7, when compiling with -Wimplicit-fallthrough=1 or higher, issues a warning which can be suppressed using a comment that matches certain regular expressions. The comment change does just that: signal to GCC that the fall through is intentional.

Fixes #676
2017-11-16 13:13:55 -06:00
Marcel Raad
240c85a10c
MSVC warning fixes in tests
- only use "#pragma GCC" on GCC-compatible compilers
- suppress deprecation warnings also on MSVC
2017-11-10 11:00:40 +01:00
Christopher Dunn
d61cddedac rm unused func 2017-10-29 23:45:01 -05:00
Wolfram Rösler
a06b390187 Un-deprecate removeMember overloads, return void (#693)
* Un-deprecate removeMember overloads, return void

Sometimes we just want to remove something we don't need anymore. Having
to supply a return buffer for the removeMember function to return something
we don't care about is a nuisance. There are removeMember overloads that
don't need a return buffer but they are deprecated. This commit un-deprecates
these overloads and modifies them to return nothing (void) instead of the
object that was removed.

Further discussion: https://github.com/open-source-parsers/jsoncpp/pull/689

WARNING: Changes the return type of the formerly deprecated removeMember
overloads from Value to void. May break existing client code.

* Minor stylistic fixes

Don't explicitly return a void value from a void function. Also, convert
size_t to unsigned in the CZString ctor to avoid a compiler warning.
2017-10-18 00:19:27 -05:00
Paweł Kierski
42a161fc80 Serialize UTF-8 string with Unicode escapes (#687)
Squashed and merged.
2017-10-03 18:19:20 -07:00
Christopher Dunn
a3a4059367 Use non-deprecated removeMember()
closes #683
2017-09-30 00:46:15 -05:00
Christopher Dunn
17c14e73a9 Use move ctor in append() 2017-09-15 18:55:50 -05:00
Christopher Dunn
c89f0282d1 Do not write to stderr
fixes #665
closes #666
2017-09-09 14:49:55 -05:00
Christopher Dunn
d830c0ab94 Fix writeCommentBeforeValue() iter deref
fixes #649
2017-08-28 08:43:05 -05:00
Christopher Dunn
90591c70cd Suppress GCC deprecated-declarations warning for tests 2017-08-28 08:42:43 -05:00
Christopher Dunn
6d31cec7cf Drop scons support 2017-08-27 15:02:01 -05:00
Christopher Dunn
004270db37 Avoid memory error
But simply use `.assign()` instead of the extra copy. (See comment from
@BillyDonhue at #580.)

fixes #578
closes #580
2017-08-27 14:16:01 -05:00
Gaurav
9006194139 Fix uninitialized value detected by valgrind
Fix issue reported in https://github.com/open-source-parsers/jsoncpp/issues/578
For std::string variable, length() is more readable than size().
2017-08-27 14:16:01 -05:00
damiram
ef16a35328 Fixing warnings. Added JSONCPP_DEPRECATED definition for clang. Also updating .gitignore to ignore .DS_Store files (Mac OS Finder generated) 2017-08-02 22:44:42 -07:00
Александр Малинин
6a15ca6442 Fix non-rvalue Json::Value assignment operator (should copy, not move) 2017-07-31 15:29:02 +03:00
Devin Jeanpierre
59e4d35339 Restore BL's authorship attribution, and add "The Jsoncpp Authors" where it was missing.
Requested/noticed in https://github.com/open-source-parsers/jsoncpp/pull/610, and a
followup to https://github.com/open-source-parsers/jsoncpp/pull/607 .
2017-07-21 03:44:36 -07:00
Christopher Dunn
f26edb05e5 Merge pull request #630 from jschueller/appveyor
Fix shared/static lib build conflict

resolves #631
2017-07-16 17:18:24 -05:00
pavel.pimenov
ea9f0cec30 strstr -> strchr
https://www.viva64.com/en/w/V817/print/
2017-07-13 14:21:53 +03:00
Julien Schueller
ffdcc9355d Avoid import/static libs name clash 2017-07-13 09:03:35 +02:00
Dhruv Paranjape
0ba8bd73f5 add move assignment operator for CZString and change copy assignment to const reference. 2017-07-08 17:47:13 +05:30
Dhruv Paranjape
23c44d9f9e overload append function for R value references. 2017-07-08 17:30:47 +05:30