Commit 16289f6b authored by Rene Engelhard's avatar Rene Engelhard Committed by Rene Engelhard

Imported Debian patch 0.12~git20141031-1

parents ae93e49d 73e06077
......@@ -6,5 +6,6 @@
/build/gmake
/build/vs*/
/doc/html
/doc/doxygen_*.db
/thirdparty/lib
/intermediate
......@@ -24,7 +24,10 @@ before_install:
install: true
before_script:
- pushd build && premake4 'gmake' && popd
- (cd build && premake4 'gmake')
# hack to avoid Valgrind bug (https://bugs.kde.org/show_bug.cgi?id=326469),
# exposed by merging PR#163 (using -march=native)
- (cd build/gmake && sed -i 's/march=native/msse4.2/' *.make)
script:
- make -C build/gmake -f test.make config=${CONF}${BITS}
......
......@@ -64,7 +64,7 @@ solution "test"
defines { "_CRT_SECURE_NO_WARNINGS" }
configuration "gmake"
buildoptions "-msse4.2 -Wall -Wextra"
buildoptions "-march=native -Wall -Wextra"
project "gtest"
kind "StaticLib"
......@@ -114,7 +114,6 @@ solution "test"
files {
"../include/**.h",
"../test/perftest/**.cpp",
"../test/perftest/**.c",
"../test/perftest/**.h",
}
......@@ -122,9 +121,6 @@ solution "test"
"../include/",
"../thirdparty/gtest/include/",
"../thirdparty/",
"../thirdparty/jsoncpp/include/",
"../thirdparty/libjson/",
"../thirdparty/yajl/include/",
}
libdirs "../thirdparty/lib"
......
rapidjson (0.12~git20141031-1) unstable; urgency=low
* new upstream snapshot
[Philipp A. Hartmann]
* install only doc/html
* remove obsolete/unintended include-binaries
* update debian/copyight and debian/control
* remove unndeeded libjson and libyajl from Build-Depends
* add libgtest-dev as build dependency and add `use-system-gtest.diff' patch
to point to system-wide Google test sources
* drop SSE4.2 hack
* run tests on all platforms
-- Rene Engelhard <rene@debian.org> Sun, 02 Nov 2014 12:47:05 +0100
rapidjson (0.12~git20140926-1) unstable; urgency=low
* Initial release (Closes: #763453)
......
Source: rapidjson
Priority: optional
Maintainer: Rene Engelhard <rene@debian.org>
Build-Depends: debhelper (>= 9), premake4, doxygen, libyajl-dev, libjsoncpp-dev
Standards-Version: 3.9.5
Build-Depends: debhelper (>= 9), premake4, doxygen, libgtest-dev
Standards-Version: 3.9.6
Section: libs
Homepage: https://code.google.com/p/rapidjson/
Homepage: https://miloyip.github.io/rapidjson
#Vcs-Git: git://anonscm.debian.org/collab-maint/rapidjson.git
#Vcs-Browser: http://anonscm.debian.org/?p=collab-maint/rapidjson.git;a=summary
......@@ -13,7 +13,7 @@ Section: libdevel
Architecture: all
Depends: ${misc:Depends}
Description: fast JSON parser/generator for C++ with SAX/DOM style API
Rapidjson is an attempt to create the fastest JSON parser and generator.
RapidJSON is an attempt to create the fastest JSON parser and generator.
.
- Small but complete. Supports both SAX and DOM style API. SAX parser only a
few hundred lines of code.
......@@ -24,7 +24,7 @@ Description: fast JSON parser/generator for C++ with SAX/DOM style API
- Compact. Each JSON value is 16 or 20 bytes for 32 or 64-bit machines
respectively (excluding text string storage). With the custom memory
allocator, parser allocates memory compactly during parsing.
- Full RFC4627 compliance. Supports UTF-8, UTF-16 and UTF-32.
- Full RFC7159 compliance. Supports UTF-8, UTF-16 and UTF-32.
- Support both in-situ parsing (directly decode strings into the source JSON
text) and non-destructive parsing (decode strings into new buffers).
- Parse number to int/unsigned/int64_t/uint64_t/double depending on input
......@@ -36,6 +36,7 @@ Package: rapidjson-doc
Section: doc
Architecture: all
Depends: ${misc:Depends}, libjs-jquery
Description: Documentation for rapidjson
This package contains the documentation for rapidjson
Description: fast JSON parser/generator for C++ (API documentation)
This package contains the documentation for RapidJSON, a fast JSON
parser/generator for C++ with both SAX/DOM style APIs.
This diff is collapsed.
--- rapidjson-0.12~git20140926.orig/build/premake4.lua
+++ rapidjson-0.12~git20140926/build/premake4.lua
@@ -122,9 +122,9 @@ solution "test"
"../include/",
"../thirdparty/gtest/include/",
"../thirdparty/",
- "../thirdparty/jsoncpp/include/",
+ "/usr/include/jsoncpp",
"../thirdparty/libjson/",
- "../thirdparty/yajl/include/",
+ "/usr/include/yajl/",
}
libdirs "../thirdparty/lib"
--- rapidjson-0.12~git20140926.orig/build/premake4.lua
+++ rapidjson-0.12~git20140926/build/premake4.lua
--- a/build/premake4.lua
+++ b/build/premake4.lua
@@ -87,7 +87,7 @@ solution "test"
kind "ConsoleApp"
......@@ -9,7 +9,7 @@
end
files {
@@ -154,7 +154,7 @@ solution "example"
@@ -150,7 +150,7 @@ solution "example"
defines { "_CRT_SECURE_NO_WARNINGS" }
configuration "gmake"
......
external-libs.diff
no-werror.diff
use-system-gtest.diff
single-platform.diff
--- a/build/premake4.lua
+++ b/build/premake4.lua
@@ -46,7 +46,7 @@ end
solution "test"
configurations { "debug", "release" }
- platforms { "x32", "x64" }
+ platforms { "native" }
location ("./" .. (_ACTION or ""))
language "C++"
@@ -127,7 +127,7 @@ solution "test"
solution "example"
configurations { "debug", "release" }
- platforms { "x32", "x64" }
+ platforms { "native" }
location ("./" .. (_ACTION or ""))
language "C++"
flags { "ExtraWarnings" }
--- i/build/premake4.lua
+++ w/build/premake4.lua
@@ -72,13 +72,11 @@ solution "test"
defines { "GTEST_HAS_PTHREAD=0" }
files {
- "../thirdparty/gtest/src/gtest-all.cc",
- "../thirdparty/gtest/src/**.h",
+ "/usr/src/gtest/src/gtest-all.cc",
}
includedirs {
- "../thirdparty/gtest/",
- "../thirdparty/gtest/include",
+ "/usr/src/gtest",
}
setTargetObjDir("../thirdparty/lib")
@@ -98,7 +96,6 @@ solution "test"
includedirs {
"../include/",
- "../thirdparty/gtest/include/",
}
libdirs "../thirdparty/lib"
@@ -119,8 +116,6 @@ solution "test"
includedirs {
"../include/",
- "../thirdparty/gtest/include/",
- "../thirdparty/",
}
libdirs "../thirdparty/lib"
......@@ -27,18 +27,8 @@ include /usr/share/dpkg/default.mk
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
RUN_TESTS=n
ifneq (nocheck,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
ifeq "$(DEB_HOST_ARCH)" "i386"
RUN_TESTS=y
endif
ifeq "$(DEB_HOST_ARCH)" "amd64"
RUN_TESTS=y
endif
endif
override_dh_auto_clean:
if [ -d build/gmake ]; then $(MAKE) -C build/gmake -f test.make config=release$(DEB_HOST_ARCH_BITS) verbose=1 clean; fi
if [ -d build/gmake ]; then $(MAKE) -C build/gmake -f test.make config=release verbose=1 clean; fi
rm -rf build/gmake
rm -rf doc/html doc/doxygen_sqlite3.db
dh_auto_clean
......@@ -47,20 +37,10 @@ override_dh_auto_build:
dh_auto_build
doxygen build/Doxyfile
override_dh_installdocs:
dh_installdocs
rm -f debian/rapidjson-doc/usr/share/doc/rapidjson-doc/diagram/.gitignore
override_dh_auto_test:
ifeq "$(RUN_TESTS)" "y"
cd build && premake4 gmake
ifneq "$(shell grep sse4_2 /proc/cpuinfo)" ""
# needs SSE 4.2! Even doesn't compile without -msse4.2
$(MAKE) -C build/gmake -f test.make config=release$(DEB_HOST_ARCH_BITS) verbose=1 perftest
cd bin && ./perftest_release_x$(DEB_HOST_ARCH_BITS)_gmake
endif
cd build/gmake && for i in *; do perl -pi -e 's/-msse4.2//' $$i; done
$(MAKE) -C build/gmake -f test.make config=release$(DEB_HOST_ARCH_BITS) verbose=1 unittest
cd bin && ./unittest_release_x$(DEB_HOST_ARCH_BITS)_gmake
endif
$(MAKE) -C build/gmake -f test.make config=release verbose=1 perftest
cd bin && ./perftest_release_native_gmake
$(MAKE) -C build/gmake -f test.make config=release verbose=1 unittest
cd bin && ./unittest_release_native_gmake
doc/doxygen_sqlite3.db
doc/html/bc_s.png
doc/html/bdwn.png
doc/html/classrapidjson_1_1_generic_document.png
doc/html/classrapidjson_1_1_generic_member_iterator.png
doc/html/classrapidjson_1_1_pretty_writer.png
doc/html/classrapidjson_1_1_writer.png
doc/html/closed.png
doc/html/doxygen.png
doc/html/ftv2blank.png
doc/html/ftv2doc.png
doc/html/ftv2folderclosed.png
doc/html/ftv2folderopen.png
doc/html/ftv2lastnode.png
doc/html/ftv2link.png
doc/html/ftv2mlastnode.png
doc/html/ftv2mnode.png
doc/html/ftv2node.png
doc/html/ftv2plastnode.png
doc/html/ftv2pnode.png
doc/html/ftv2splitbar.png
doc/html/ftv2vertline.png
doc/html/insituparsing.png
doc/html/iterative-parser-states-diagram.png
doc/html/move1.png
doc/html/move2.png
doc/html/move3.png
doc/html/nav_f.png
doc/html/nav_g.png
doc/html/nav_h.png
doc/html/normalparsing.png
doc/html/open.png
doc/html/rapidjson.png
doc/html/search/close.png
doc/html/search/mag_sel.png
doc/html/search/search_l.png
doc/html/search/search_m.png
doc/html/search/search_r.png
doc/html/simpledom.png
doc/html/singletonrapidjson_1_1_generic_value.png
doc/html/structrapidjson_1_1_u_t_f16.png
doc/html/structrapidjson_1_1_u_t_f16_b_e.png
doc/html/structrapidjson_1_1_u_t_f16_l_e.png
doc/html/structrapidjson_1_1_u_t_f32.png
doc/html/structrapidjson_1_1_u_t_f32_b_e.png
doc/html/structrapidjson_1_1_u_t_f32_l_e.png
doc/html/sync_off.png
doc/html/sync_on.png
doc/html/tab_a.png
doc/html/tab_b.png
doc/html/tab_h.png
doc/html/tab_s.png
doc/html/tutorial.png
......@@ -2,9 +2,15 @@
The old performance article for RapidJSON 0.1 is provided [here](https://code.google.com/p/rapidjson/wiki/Performance).
This file will be updated with new version and better procedures.
The (third-party) performance tests have been removed from this repository
and are now part of a dedicated [native JSON benchmark collection] [1].
In the meantime, you may also refer to the following third-party benchmarks.
This file will be updated with a summary of benchmarking results based on
the above benchmark collection in the future.
[1]: https://github.com/miloyip/nativejson-benchmark
Additionally, you may refer to the following third-party benchmarks.
## Third-party benchmarks
......
......@@ -299,7 +299,8 @@ using namespace rapidjson;
typedef map<string, string> MessageMap;
struct MessageHandler : public BaseReaderHandler<> {
struct MessageHandler
: public BaseReaderHandler<UTF8<>, MessageHandler> {
MessageHandler() : state_(kExpectObjectStart) {
}
......
......@@ -121,9 +121,7 @@ In the following, details about querying individual types are discussed.
By default, `SizeType` is typedef of `unsigned`. In most systems, array is limited to store up to 2^32-1 elements.
You may access the elements in array by integer literal, for example, `a[1]`, `a[2]`. However, `a[0]` will generate a compiler error. It is because two overloaded operators `operator[](SizeType)` and `operator[](const char*)` is available, and C++ can treat `0` as a null pointer. Workarounds:
* `a[SizeType(0)]`
* `a[0u]`
You may access the elements in array by integer literal, for example, `a[0]`, `a[1]`, `a[2]`.
Array is similar to `std::vector`, instead of using indices, you may also use iterator to access all the elements.
~~~~~~~~~~cpp
......
......@@ -17,7 +17,8 @@ RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(effc++)
#endif
struct MessageHandler : public BaseReaderHandler<> {
struct MessageHandler
: public BaseReaderHandler<UTF8<>, MessageHandler> {
MessageHandler() : messages_(), state_(kExpectObjectStart), name_() {}
bool StartObject() {
......
......@@ -72,12 +72,8 @@ int main(int, char*[]) {
for (SizeType i = 0; i < a.Size(); i++) // rapidjson uses SizeType instead of size_t.
printf("a[%d] = %d\n", i, a[i].GetInt());
// Note:
//int x = a[0].GetInt(); // Error: operator[ is ambiguous, as 0 also mean a null pointer of const char* type.
int y = a[SizeType(0)].GetInt(); // Cast to SizeType will work.
int z = a[0u].GetInt(); // This works too.
int y = a[0].GetInt();
(void)y;
(void)z;
// Iterating array with iterators
printf("a = ");
......
......@@ -104,9 +104,6 @@ public:
MemoryPoolAllocator(size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) :
chunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(0), baseAllocator_(baseAllocator), ownBaseAllocator_(0)
{
if (!baseAllocator_)
ownBaseAllocator_ = baseAllocator_ = new BaseAllocator();
AddChunk(chunk_capacity_);
}
//! Constructor with user-supplied buffer.
......@@ -135,7 +132,7 @@ public:
*/
~MemoryPoolAllocator() {
Clear();
delete ownBaseAllocator_;
RAPIDJSON_DELETE(ownBaseAllocator_);
}
//! Deallocates all memory chunks, excluding the user-supplied buffer.
......@@ -216,6 +213,8 @@ private:
/*! \param capacity Capacity of the chunk in bytes.
*/
void AddChunk(size_t capacity) {
if (!baseAllocator_)
ownBaseAllocator_ = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator());
ChunkHeader* chunk = reinterpret_cast<ChunkHeader*>(baseAllocator_->Malloc(sizeof(ChunkHeader) + capacity));
chunk->capacity = capacity;
chunk->size = 0;
......
......@@ -62,6 +62,10 @@ RAPIDJSON_DIAG_OFF(effc++)
#include <iterator> // std::iterator, std::random_access_iterator_tag
#endif
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
#include <utility> // std::move
#endif
namespace rapidjson {
// Forward declaration.
......@@ -451,7 +455,7 @@ public:
\param type Type of the value.
\note Default content for number is zero.
*/
GenericValue(Type type) RAPIDJSON_NOEXCEPT : data_(), flags_() {
explicit GenericValue(Type type) RAPIDJSON_NOEXCEPT : data_(), flags_() {
static const unsigned defaultFlags[7] = {
kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag, kArrayFlag, kConstStringFlag,
kNumberAnyFlag
......@@ -795,22 +799,32 @@ public:
//! Check whether the object is empty.
bool ObjectEmpty() const { RAPIDJSON_ASSERT(IsObject()); return data_.o.size == 0; }
//! Get the value associated with the name.
/*!
//! Get a value from an object associated with the name.
/*! \pre IsObject() == true
\tparam T Either \c Ch or \c const \c Ch (template used for disambiguation with \ref operator[](SizeType))
\note In version 0.1x, if the member is not found, this function returns a null value. This makes issue 7.
Since 0.2, if the name is not correct, it will assert.
If user is unsure whether a member exists, user should use HasMember() first.
A better approach is to use FindMember().
\note Linear time complexity.
*/
GenericValue& operator[](const Ch* name) {
template <typename T>
RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr<internal::IsSame<typename internal::RemoveConst<T>::Type, Ch> >),(GenericValue&)) operator[](T* name) {
GenericValue n(StringRef(name));
return (*this)[n];
}
const GenericValue& operator[](const Ch* name) const { return const_cast<GenericValue&>(*this)[name]; }
template <typename T>
RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr<internal::IsSame<typename internal::RemoveConst<T>::Type, Ch> >),(const GenericValue&)) operator[](T* name) const { return const_cast<GenericValue&>(*this)[name]; }
//! Get a value from an object associated with the name.
/*! \pre IsObject() == true
\tparam SourceAllocator Allocator of the \c name value
\note Compared to \ref operator[](T*), this version is faster because it does not need a StrLen().
And it can also handle strings with embedded null characters.
// This version is faster because it does not need a StrLen().
// It can also handle string with null character.
\note Linear time complexity.
*/
template <typename SourceAllocator>
GenericValue& operator[](const GenericValue<Encoding, SourceAllocator>& name) {
MemberIterator member = FindMember(name);
......@@ -1021,7 +1035,9 @@ public:
//! Remove a member in object by its name.
/*! \param name Name of member to be removed.
\return Whether the member existed.
\note Removing member is implemented by moving the last member. So the ordering of members is changed.
\note This function may reorder the object members. Use \ref
EraseMember(ConstMemberIterator) if you need to preserve the
relative order of the remaining members.
\note Linear time complexity.
*/
bool RemoveMember(const Ch* name) {
......@@ -1043,8 +1059,9 @@ public:
//! Remove a member in object by iterator.
/*! \param m member iterator (obtained by FindMember() or MemberBegin()).
\return the new iterator after removal.
\note Removing member is implemented by moving the last member. So the ordering of members is changed.
\note Use \ref EraseMember(ConstMemberIterator) instead, if you need to rely on a stable member ordering.
\note This function may reorder the object members. Use \ref
EraseMember(ConstMemberIterator) if you need to preserve the
relative order of the remaining members.
\note Constant time complexity.
*/
MemberIterator RemoveMember(MemberIterator m) {
......@@ -1071,7 +1088,8 @@ public:
\pre IsObject() == true && \ref MemberBegin() <= \c pos < \ref MemberEnd()
\return Iterator following the removed element.
If the iterator \c pos refers to the last element, the \ref MemberEnd() iterator is returned.
\note Other than \ref RemoveMember(MemberIterator), this function preserves the ordering of the members.
\note This function preserves the relative order of the remaining object
members. If you do not need this, use the more efficient \ref RemoveMember(MemberIterator).
\note Linear time complexity.
*/
MemberIterator EraseMember(ConstMemberIterator pos) {
......@@ -1083,7 +1101,8 @@ public:
\param last iterator following the last member to remove
\pre IsObject() == true && \ref MemberBegin() <= \c first <= \c last <= \ref MemberEnd()
\return Iterator following the last removed element.
\note Other than \ref RemoveMember(MemberIterator), this function preserves the ordering of the members.
\note This function preserves the relative order of the remaining object
members.
\note Linear time complexity.
*/
MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) {
......@@ -1132,14 +1151,9 @@ public:
}
//! Get an element from array by index.
/*! \param index Zero-based index of element.
\code
Value a(kArrayType);
a.PushBack(123);
int x = a[0].GetInt(); // Error: operator[ is ambiguous, as 0 also mean a null pointer of const char* type.
int y = a[SizeType(0)].GetInt(); // Cast to SizeType will work.
int z = a[0u].GetInt(); // This works too.
\endcode
/*! \pre IsArray() == true
\param index Zero-based index of element.
\see operator[](T*)
*/
GenericValue& operator[](SizeType index) {
RAPIDJSON_ASSERT(IsArray());
......@@ -1620,12 +1634,51 @@ public:
allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
{
if (!allocator_)
ownAllocator_ = allocator_ = new Allocator();
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());
}
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
//! Move constructor in C++11
GenericDocument(GenericDocument&& rhs) RAPIDJSON_NOEXCEPT
: ValueType(std::move(rhs)),
allocator_(rhs.allocator_),
ownAllocator_(rhs.ownAllocator_),
stack_(std::move(rhs.stack_)),
parseResult_(rhs.parseResult_)
{
rhs.allocator_ = 0;
rhs.ownAllocator_ = 0;
rhs.parseResult_ = ParseResult();
}
#endif
~GenericDocument() {
delete ownAllocator_;
Destroy();
}
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
//! Move assignment in C++11
GenericDocument& operator=(GenericDocument&& rhs) RAPIDJSON_NOEXCEPT
{
// The cast to ValueType is necessary here, because otherwise it would
// attempt to call GenericValue's templated assignment operator.
ValueType::operator=(std::forward<ValueType>(rhs));
// Calling the destructor here would prematurely call stack_'s destructor
Destroy();
allocator_ = rhs.allocator_;
ownAllocator_ = rhs.ownAllocator_;
stack_ = std::move(rhs.stack_);
parseResult_ = rhs.parseResult_;
rhs.allocator_ = 0;
rhs.ownAllocator_ = 0;
rhs.parseResult_ = ParseResult();
return *this;
}
#endif
//!@name Parse from stream
//!@{
......@@ -1821,6 +1874,10 @@ private:
stack_.ShrinkToFit();
}
void Destroy() {
RAPIDJSON_DELETE(ownAllocator_);
}
static const size_t kDefaultStackCapacity = 1024;
Allocator* allocator_;
Allocator* ownAllocator_;
......
......@@ -26,7 +26,7 @@
namespace rapidjson {
//! (Depreciated) Wrapper of C file stream for input or output.
//! (Deprecated) Wrapper of C file stream for input or output.
/*!
This simple wrapper does not check the validity of the stream.
\note implements Stream concept
......
......@@ -35,17 +35,56 @@ class Stack {
public:
// Optimization note: Do not allocate memory for stack_ in constructor.
// Do it lazily when first Push() -> Expand() -> Resize().
Stack(Allocator* allocator, size_t stackCapacity) : allocator_(allocator), ownAllocator(0), stack_(0), stackTop_(0), stackEnd_(0), initialCapacity_(stackCapacity) {
Stack(Allocator* allocator, size_t stackCapacity) : allocator_(allocator), ownAllocator_(0), stack_(0), stackTop_(0), stackEnd_(0), initialCapacity_(stackCapacity) {
RAPIDJSON_ASSERT(stackCapacity > 0);
if (!allocator_)
ownAllocator = allocator_ = new Allocator();
}
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
Stack(Stack&& rhs)
: allocator_(rhs.allocator_),
ownAllocator_(rhs.ownAllocator_),
stack_(rhs.stack_),
stackTop_(rhs.stackTop_),
stackEnd_(rhs.stackEnd_),
initialCapacity_(rhs.initialCapacity_)
{
rhs.allocator_ = 0;
rhs.ownAllocator_ = 0;
rhs.stack_ = 0;
rhs.stackTop_ = 0;
rhs.stackEnd_ = 0;
rhs.initialCapacity_ = 0;
}
#endif
~Stack() {
Allocator::Free(stack_);
delete ownAllocator; // Only delete if it is owned by the stack
Destroy();
}
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS