Skip to content

Commit 720745e

Browse files
committed
Merge branch 'master' into allow-trailing-commas
# Conflicts: # src/test_lib_json/fuzz.cpp
2 parents 8d4ef8b + 2eb20a9 commit 720745e

File tree

16 files changed

+378
-516
lines changed

16 files changed

+378
-516
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ matrix:
6262
BUILD_TYPE=Debug
6363
LIB_TYPE=shared
6464
DESTDIR=/tmp/cmake_json_cpp
65+
before_install:
66+
- pip install --user cpp-coveralls
6567
script: ./.travis_scripts/cmake_builder.sh
68+
after_success:
69+
- coveralls --include src/lib_json --include include
6670
notifications:
6771
email: false

.travis_scripts/meson_builder.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ _COMPILER_NAME=`basename ${CXX}`
6565
_BUILD_DIR_NAME="build-${BUILD_TYPE}_${LIB_TYPE}_${_COMPILER_NAME}"
6666

6767
./.travis_scripts/run-clang-format.sh
68-
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . "${_BUILD_DIR_NAME}"
68+
meson --fatal-meson-warnings --werror --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . "${_BUILD_DIR_NAME}"
6969
ninja -v -j 2 -C "${_BUILD_DIR_NAME}"
7070

7171
cd "${_BUILD_DIR_NAME}"

CMakeLists.txt

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,23 @@ macro(UseCompilationWarningAsError)
104104
if(MSVC)
105105
# Only enabled in debug because some old versions of VS STL generate
106106
# warnings when compiled in release configuration.
107-
add_compile_options($<$<CONFIG:Debug>:/WX>)
107+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
108+
add_compile_options($<$<CONFIG:Debug>:/WX>)
109+
else()
110+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ")
111+
endif()
108112
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
109-
add_compile_options(-Werror)
113+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
114+
add_compile_options(-Werror)
115+
else()
116+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
117+
endif()
110118
if(JSONCPP_WITH_STRICT_ISO)
119+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
111120
add_compile_options(-pedantic-errors)
121+
else()
122+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
123+
endif()
112124
endif()
113125
endif()
114126
endmacro()
@@ -119,29 +131,57 @@ include_directories( ${jsoncpp_SOURCE_DIR}/include )
119131
if(MSVC)
120132
# Only enabled in debug because some old versions of VS STL generate
121133
# unreachable code warning when compiled in release configuration.
122-
add_compile_options($<$<CONFIG:Debug>:/W4>)
134+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
135+
add_compile_options($<$<CONFIG:Debug>:/W4>)
136+
else()
137+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
138+
endif()
123139
endif()
124140

125141
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
126142
# using regular Clang or AppleClang
127-
add_compile_options(-Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare)
143+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
144+
add_compile_options(-Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare)
145+
else()
146+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare")
147+
endif()
128148
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
129149
# using GCC
130-
add_compile_options(-Wall -Wconversion -Wshadow -Wextra)
150+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
151+
add_compile_options(-Wall -Wconversion -Wshadow -Wextra)
152+
else()
153+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Wextra")
154+
endif()
131155
# not yet ready for -Wsign-conversion
132156

133157
if(JSONCPP_WITH_STRICT_ISO)
158+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
134159
add_compile_options(-pedantic)
160+
else()
161+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
162+
endif()
135163
endif()
136164
if(JSONCPP_WITH_WARNING_AS_ERROR)
165+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
137166
add_compile_options(-Werror=conversion)
167+
else()
168+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=conversion")
169+
endif()
138170
endif()
139171
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
140172
# using Intel compiler
141-
add_compile_options(-Wall -Wconversion -Wshadow -Wextra -Werror=conversion)
173+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
174+
add_compile_options(-Wall -Wconversion -Wshadow -Wextra -Werror=conversion)
175+
else()
176+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Wextra -Werror=conversion")
177+
endif()
142178

143179
if(JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
180+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
144181
add_compile_options(-pedantic)
182+
else()
183+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
184+
endif()
145185
endif()
146186
endif()
147187

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# JsonCpp
22

33
[![badge](https://img.shields.io/badge/conan.io-jsoncpp%2F1.8.0-green.svg?logo=data:image/png;base64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAA1VBMVEUAAABhlctjlstkl8tlmMtlmMxlmcxmmcxnmsxpnMxpnM1qnc1sn85voM91oM11oc1xotB2oc56pNF6pNJ2ptJ8ptJ8ptN9ptN8p9N5qNJ9p9N9p9R8qtOBqdSAqtOAqtR%2BrNSCrNJ/rdWDrNWCsNWCsNaJs9eLs9iRvNuVvdyVv9yXwd2Zwt6axN6dxt%2Bfx%2BChyeGiyuGjyuCjyuGly%2BGlzOKmzOGozuKoz%2BKqz%2BOq0OOv1OWw1OWw1eWx1eWy1uay1%2Baz1%2Baz1%2Bez2Oe02Oe12ee22ujUGwH3AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfgBQkREyOxFIh/AAAAiklEQVQI12NgAAMbOwY4sLZ2NtQ1coVKWNvoc/Eq8XDr2wB5Ig62ekza9vaOqpK2TpoMzOxaFtwqZua2Bm4makIM7OzMAjoaCqYuxooSUqJALjs7o4yVpbowvzSUy87KqSwmxQfnsrPISyFzWeWAXCkpMaBVIC4bmCsOdgiUKwh3JojLgAQ4ZCE0AMm2D29tZwe6AAAAAElFTkSuQmCC)](https://bintray.com/theirix/conan-repo/jsoncpp%3Atheirix)
4+
[![badge](https://img.shields.io/badge/license-MIT-blue)](https://github.com/open-source-parsers/jsoncpp/blob/master/LICENSE)
5+
[![badge](https://img.shields.io/badge/document-doxygen-brightgreen)](http://open-source-parsers.github.io/jsoncpp-docs/doxygen/index.html)
6+
[![Coverage Status](https://coveralls.io/repos/github/open-source-parsers/jsoncpp/badge.svg)](https://coveralls.io/github/open-source-parsers/jsoncpp)
7+
48

59
[JSON][json-org] is a lightweight data-interchange format. It can represent
610
numbers, strings, ordered sequences of values, and collections of name/value
@@ -43,13 +47,13 @@ You can download and install JsonCpp using the [vcpkg](https://github.com/Micros
4347
The JsonCpp port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
4448

4549
### Amalgamated source
46-
https://github.com/open-source-parsers/jsoncpp/wiki/Amalgamated
50+
https://github.com/open-source-parsers/jsoncpp/wiki/Amalgamated-(Possibly-outdated)
4751

4852
### The Meson Build System
4953
If you are using the [Meson Build System](http://mesonbuild.com), then you can get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/jsoncpp), or simply use `meson wrap install jsoncpp`.
5054

5155
### Other ways
52-
If you have trouble, see the Wiki, or post a question as an Issue.
56+
If you have trouble, see the [Wiki](https://github.com/open-source-parsers/jsoncpp/wiki), or post a question as an Issue.
5357

5458
## License
5559

include/json/value.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,14 @@ class JSON_API ValueIteratorBase {
772772
char const* memberName(char const** end) const;
773773

774774
protected:
775-
Value& deref() const;
775+
/*! Internal utility functions to assist with implementing
776+
* other iterator functions. The const and non-const versions
777+
* of the "deref" protected methods expose the protected
778+
* current_ member variable in a way that can often be
779+
* optimized away by the compiler.
780+
*/
781+
const Value& deref() const;
782+
Value& deref();
776783

777784
void increment();
778785

@@ -895,9 +902,13 @@ class JSON_API ValueIterator : public ValueIteratorBase {
895902
return *this;
896903
}
897904

898-
reference operator*() const { return deref(); }
899-
900-
pointer operator->() const { return &deref(); }
905+
/*! The return value of non-const iterators can be
906+
* changed, so the these functions are not const
907+
* because the returned references/pointers can be used
908+
* to change state of the base class.
909+
*/
910+
reference operator*() { return deref(); }
911+
pointer operator->() { return &deref(); }
901912
};
902913

903914
inline void swap(Value& a, Value& b) { a.swap(b); }

0 commit comments

Comments
 (0)