Commit Graph

1182 Commits

Author SHA1 Message Date
Billy Donahue
d85d75045c Issue #872: add json/allocator.h in the amalgamated header.
I don't know why we didn't include this before.
It seems to work fine.
2019-01-20 22:13:38 -05:00
Billy Donahue
2b593a9da8 apply the C++11 style change in .clang-format 2019-01-18 07:02:16 -06:00
Billy Donahue
756a08fbbd switch .clang-format to C++11 2019-01-18 07:02:16 -06:00
Hans Johnson
2c257590a1 BUG: VERSION_LESS_EQUAL introduced in cmake 3.7
Older versions of cmake, according to documentation:
https://cmake.org/cmake/help/v3.5/command/if.html , do not know
VERSION_LESS_EQUAL, just VERSION_LESS.

This leads to errors:

CMake Error at somewhere/jsoncpp/CMakeLists.txt:18 (if):
  if given arguments:

    "3.5.1" "VERSION_LESS_EQUAL" "3.13.1"

  Unknown arguments specified

Resolves: #866
2019-01-18 07:00:39 -06:00
Hans Johnson
deb6cca214 STYLE: FATAL_ERROR ignored in cmake_required_minimum since 2.6.0 2019-01-18 07:00:39 -06:00
Billy Donahue
b9ed29a221
Jsoncpp aliases 2 (#868)
convert JSONCPP_STRING etc from macros to typedefs
2019-01-17 23:26:28 -05:00
Billy Donahue
1c2ed7a10f convert JSONCPP_STRING etc from macros to typedefs 2019-01-17 23:14:18 -05:00
Billy Donahue
6e7cbf8f54
Merge pull request #867 from BillyDonahue/apply_clang_format
Reapply clang-format.
2019-01-17 15:30:37 -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
James Clarke
d3d2e17b64 Switch to the VCPP dll 2019-01-15 09:01:19 -06:00
James Clarke
908383abeb Fix bogus asm setting 2019-01-15 09:01:19 -06:00
James Clarke
fdc0824505 Add amd64 support 2019-01-15 09:01:19 -06:00
James Clarke
4e8b4e313f Add support for VS2017 2019-01-15 09:01:19 -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
Hans Johnson
10a1a38b37 ENH: move travis support scripts to .travis_scripts
Move the build support scripts for travis to a hidden
subdirectory to keep the top level directory more
clean.
2019-01-12 10:35:25 -06:00
Hans Johnson
fa61a49b83 ENH: Use recommended homebrew addon for travis.
Remove unnecessary python3 environment from osx that
made configuring the test environment slower.

Use "addon:" features for installing homebrew
packages more efficiently.

Re-organized the .travis.yml file in a standard
order so that the "before-install" and "install"
steps occur after the configurations of addons and
 matrix, and language features are set.
2019-01-12 10:35:25 -06:00
Hans Johnson
f8ad1ab352 BUG: Fix bug in CI where failure during homebrew update occured. 2019-01-12 10:35:25 -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
Orivej Desh
d8723104f3 Update removeMember docs after #693 2018-12-31 07:37:07 +07:00
Mathias L. Baumann
08ddeed927 JsonValue documentation: Rephrase confusing sentence 2018-12-30 15:33:43 -06: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
b3b92df879 ENH: Provide range for non-warned cmake versions
Allow configuring without cmake policy developer warnings
for a range of cmake versions.

This prevents the need to explicitly enumerate every new
policy for each new cmake version.

===

Moved setting of the CMAKE_CXX_STANDARD to before the project()
directive.
2018-12-30 15:32:57 -06:00
Hans Johnson
892a386018 ENH: Use cmake builtin versioning capabilities
The project directive in cmake 3.1 has a builtin
mechanism for providing consistent versioning
in a package.
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
Kostiantyn Ponomarenko
4bfa962967 Add Meson related info to README
Add information about how one can get a Meson wrap file.

Signed-off-by: Kostiantyn Ponomarenko <konstantin.ponomarenko@gmail.com>
2018-12-30 15:30:35 -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
Christopher Dunn
9026a16ff5
Merge pull request #849 from hjmjohnson/modernize-use-nullptr
COMP: Use nullptr instead of 0 or NULL
2018-12-30 15:23:22 -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
Christopher Dunn
6219eae304
Merge pull request #843 from manang/master
Update json_writer.cpp
2018-12-03 20:20:55 -08:00
manang
b955e0f699
Update json_writer.cpp 2018-12-03 10:26:27 +01:00
Julien Schueller
d501fbe741 Set CMAKE_BUILD_TYPE default on win32 too 2018-12-02 18:37:11 -06: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
a72266d00b Remove useless BUILD_STATIC_LIBS option 2018-12-02 18:37:11 -06:00