mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-15 15:16:47 +02:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
30d923f155 | ||
![]() |
2f4e40bc95 | ||
![]() |
505e086ebc | ||
![]() |
c6582415d8 | ||
![]() |
0ee7e2426f | ||
![]() |
1522e4dfb1 | ||
![]() |
09b8670536 | ||
![]() |
f164288646 | ||
![]() |
3bfd215938 | ||
![]() |
400b744195 | ||
![]() |
bd55164089 | ||
![]() |
4c5832a0be | ||
![]() |
8ba9875962 | ||
![]() |
9c91b995dd |
@@ -59,7 +59,7 @@ def amalgamate_source(source_top_dir=None,
|
|||||||
print("Amalgating header...")
|
print("Amalgating header...")
|
||||||
header = AmalgamationFile(source_top_dir)
|
header = AmalgamationFile(source_top_dir)
|
||||||
header.add_text("/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).")
|
header.add_text("/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).")
|
||||||
header.add_text("/// It is intented to be used with #include <%s>" % header_include_path)
|
header.add_text('/// It is intended to be used with #include "%s"' % header_include_path)
|
||||||
header.add_file("LICENSE", wrap_in_comment=True)
|
header.add_file("LICENSE", wrap_in_comment=True)
|
||||||
header.add_text("#ifndef JSON_AMALGATED_H_INCLUDED")
|
header.add_text("#ifndef JSON_AMALGATED_H_INCLUDED")
|
||||||
header.add_text("# define JSON_AMALGATED_H_INCLUDED")
|
header.add_text("# define JSON_AMALGATED_H_INCLUDED")
|
||||||
@@ -85,7 +85,7 @@ def amalgamate_source(source_top_dir=None,
|
|||||||
print("Amalgating forward header...")
|
print("Amalgating forward header...")
|
||||||
header = AmalgamationFile(source_top_dir)
|
header = AmalgamationFile(source_top_dir)
|
||||||
header.add_text("/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).")
|
header.add_text("/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).")
|
||||||
header.add_text("/// It is intented to be used with #include <%s>" % forward_header_include_path)
|
header.add_text('/// It is intended to be used with #include "%s"' % forward_header_include_path)
|
||||||
header.add_text("/// This header provides forward declaration for all JsonCpp types.")
|
header.add_text("/// This header provides forward declaration for all JsonCpp types.")
|
||||||
header.add_file("LICENSE", wrap_in_comment=True)
|
header.add_file("LICENSE", wrap_in_comment=True)
|
||||||
header.add_text("#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED")
|
header.add_text("#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED")
|
||||||
@@ -105,10 +105,15 @@ def amalgamate_source(source_top_dir=None,
|
|||||||
print("Amalgating source...")
|
print("Amalgating source...")
|
||||||
source = AmalgamationFile(source_top_dir)
|
source = AmalgamationFile(source_top_dir)
|
||||||
source.add_text("/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).")
|
source.add_text("/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).")
|
||||||
source.add_text("/// It is intented to be used with #include <%s>" % header_include_path)
|
source.add_text('/// It is intended to be used with #include "%s"' % header_include_path)
|
||||||
source.add_file("LICENSE", wrap_in_comment=True)
|
source.add_file("LICENSE", wrap_in_comment=True)
|
||||||
source.add_text("")
|
source.add_text("")
|
||||||
source.add_text("#include <%s>" % header_include_path)
|
source.add_text('#include "%s"' % header_include_path)
|
||||||
|
source.add_text("""
|
||||||
|
#ifndef JSON_IS_AMALGAMATION
|
||||||
|
#error "Compile with -I PATH_TO_JSON_DIRECTORY"
|
||||||
|
#endif
|
||||||
|
""")
|
||||||
source.add_text("")
|
source.add_text("")
|
||||||
lib_json = "src/lib_json"
|
lib_json = "src/lib_json"
|
||||||
source.add_file(os.path.join(lib_json, "json_tool.h"))
|
source.add_file(os.path.join(lib_json, "json_tool.h"))
|
||||||
|
21
dev.makefile
21
dev.makefile
@@ -1,5 +1,19 @@
|
|||||||
all: build test-amalgamate
|
# This is only for jsoncpp developers/contributors.
|
||||||
|
# We use this to sign releases, generate documentation, etc.
|
||||||
|
VER?=$(shell cat version)
|
||||||
|
|
||||||
|
default:
|
||||||
|
@echo "VER=${VER}"
|
||||||
|
sign: jsoncpp-${VER}.tar.gz
|
||||||
|
gpg --armor --detach-sign $<
|
||||||
|
gpg --verify $<.asc
|
||||||
|
# Then upload .asc to the release.
|
||||||
|
jsoncpp-%.tar.gz:
|
||||||
|
curl https://github.com/open-source-parsers/jsoncpp/archive/$*.tar.gz -o $@
|
||||||
|
dox:
|
||||||
|
python doxybuild.py --doxygen=$$(which doxygen) --in doc/web_doxyfile.in
|
||||||
|
rsync -va --delete dist/doxygen/jsoncpp-api-html-${VER}/ ../jsoncpp-docs/doxygen/
|
||||||
|
# Then 'git add -A' and 'git push' in jsoncpp-docs.
|
||||||
build:
|
build:
|
||||||
mkdir -p build/debug
|
mkdir -p build/debug
|
||||||
cd build/debug; cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_SHARED=ON -G "Unix Makefiles" ../..
|
cd build/debug; cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_SHARED=ON -G "Unix Makefiles" ../..
|
||||||
@@ -7,8 +21,11 @@ build:
|
|||||||
|
|
||||||
# Currently, this depends on include/json/version.h generated
|
# Currently, this depends on include/json/version.h generated
|
||||||
# by cmake.
|
# by cmake.
|
||||||
test-amalgamate: build
|
test-amalgamate:
|
||||||
python2.7 amalgamate.py
|
python2.7 amalgamate.py
|
||||||
python3.4 amalgamate.py
|
python3.4 amalgamate.py
|
||||||
|
|
||||||
|
clean:
|
||||||
|
\rm -rf *.gz *.asc dist/
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
#if JSON_USE_EXCEPTION
|
#if JSON_USE_EXCEPTION
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#define JSON_ASSERT(condition) \
|
#define JSON_ASSERT(condition) \
|
||||||
assert(condition); // @todo <= change this into an exception throw
|
if (!(condition)) {throw std::runtime_error( "assert json failed" );} // @todo <= add detail about condition in exception
|
||||||
#define JSON_FAIL_MESSAGE(message) do{std::ostringstream oss; oss << message; throw std::runtime_error(oss.str());}while(0)
|
#define JSON_FAIL_MESSAGE(message) do{std::ostringstream oss; oss << message; throw std::runtime_error(oss.str());}while(0)
|
||||||
//#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message)
|
//#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message)
|
||||||
#else // JSON_USE_EXCEPTION
|
#else // JSON_USE_EXCEPTION
|
||||||
|
@@ -946,7 +946,7 @@ public:
|
|||||||
bool operator!=(const SelfType& other) const { return !isEqual(other); }
|
bool operator!=(const SelfType& other) const { return !isEqual(other); }
|
||||||
|
|
||||||
difference_type operator-(const SelfType& other) const {
|
difference_type operator-(const SelfType& other) const {
|
||||||
return computeDistance(other);
|
return other.computeDistance(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return either the index or the member name of the referenced value as a
|
/// Return either the index or the member name of the referenced value as a
|
||||||
|
@@ -4,10 +4,10 @@
|
|||||||
#ifndef JSON_VERSION_H_INCLUDED
|
#ifndef JSON_VERSION_H_INCLUDED
|
||||||
# define JSON_VERSION_H_INCLUDED
|
# define JSON_VERSION_H_INCLUDED
|
||||||
|
|
||||||
# define JSONCPP_VERSION_STRING "1.4.1"
|
# define JSONCPP_VERSION_STRING "1.4.3"
|
||||||
# define JSONCPP_VERSION_MAJOR 1
|
# define JSONCPP_VERSION_MAJOR 1
|
||||||
# define JSONCPP_VERSION_MINOR 4
|
# define JSONCPP_VERSION_MINOR 4
|
||||||
# define JSONCPP_VERSION_PATCH 1
|
# define JSONCPP_VERSION_PATCH 3
|
||||||
# define JSONCPP_VERSION_QUALIFIER
|
# define JSONCPP_VERSION_QUALIFIER
|
||||||
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
||||||
|
|
||||||
|
@@ -77,7 +77,7 @@ ValueIteratorBase::difference_type
|
|||||||
ValueIteratorBase::computeDistance(const SelfType& other) const {
|
ValueIteratorBase::computeDistance(const SelfType& other) const {
|
||||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
#ifdef JSON_USE_CPPTL_SMALLMAP
|
#ifdef JSON_USE_CPPTL_SMALLMAP
|
||||||
return current_ - other.current_;
|
return other.current_ - current_;
|
||||||
#else
|
#else
|
||||||
// Iterator for null value are initialized using the default
|
// Iterator for null value are initialized using the default
|
||||||
// constructor, which initialize current_ to the default
|
// constructor, which initialize current_ to the default
|
||||||
|
@@ -1861,6 +1861,23 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, commentAfterBool) {
|
|||||||
JSONTEST_ASSERT_EQUAL(true, root.asBool());
|
JSONTEST_ASSERT_EQUAL(true, root.asBool());
|
||||||
delete reader;
|
delete reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct IteratorTest : JsonTest::TestCase {};
|
||||||
|
|
||||||
|
JSONTEST_FIXTURE(IteratorTest, distance) {
|
||||||
|
Json::Value json;
|
||||||
|
json["k1"] = "a";
|
||||||
|
json["k2"] = "b";
|
||||||
|
int dist;
|
||||||
|
std::string str;
|
||||||
|
for (Json::ValueIterator it = json.begin(); it != json.end(); ++it) {
|
||||||
|
dist = it - json.begin();
|
||||||
|
str = it->asString().c_str();
|
||||||
|
}
|
||||||
|
JSONTEST_ASSERT_EQUAL(1, dist);
|
||||||
|
JSONTEST_ASSERT_STRING_EQUAL("b", str);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
JsonTest::Runner runner;
|
JsonTest::Runner runner;
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, checkNormalizeFloatingPointStr);
|
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, checkNormalizeFloatingPointStr);
|
||||||
@@ -1884,6 +1901,9 @@ int main(int argc, const char* argv[]) {
|
|||||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, offsetAccessors);
|
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, offsetAccessors);
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, typeChecksThrowExceptions);
|
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, typeChecksThrowExceptions);
|
||||||
|
|
||||||
|
JSONTEST_REGISTER_FIXTURE(runner, WriterTest, dropNullPlaceholders);
|
||||||
|
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, dropNullPlaceholders);
|
||||||
|
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, ReaderTest, parseWithNoErrors);
|
JSONTEST_REGISTER_FIXTURE(runner, ReaderTest, parseWithNoErrors);
|
||||||
JSONTEST_REGISTER_FIXTURE(
|
JSONTEST_REGISTER_FIXTURE(
|
||||||
runner, ReaderTest, parseWithNoErrorsTestingOffsets);
|
runner, ReaderTest, parseWithNoErrorsTestingOffsets);
|
||||||
@@ -1905,8 +1925,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
JSONTEST_REGISTER_FIXTURE(runner, CharReaderFailIfExtraTest, commentAfterArray);
|
JSONTEST_REGISTER_FIXTURE(runner, CharReaderFailIfExtraTest, commentAfterArray);
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, CharReaderFailIfExtraTest, commentAfterBool);
|
JSONTEST_REGISTER_FIXTURE(runner, CharReaderFailIfExtraTest, commentAfterBool);
|
||||||
|
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, WriterTest, dropNullPlaceholders);
|
JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, distance);
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, dropNullPlaceholders);
|
|
||||||
|
|
||||||
return runner.runCommandLine(argc, argv);
|
return runner.runCommandLine(argc, argv);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user