mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-03-06 13:41:35 +01:00
Merge remote-tracking branch 'origin/master' into zh-cn
This commit is contained in:
commit
7b685da2df
21
.gitignore
vendored
21
.gitignore
vendored
@ -2,10 +2,21 @@
|
||||
!/bin/data
|
||||
!/bin/encodings
|
||||
!/bin/jsonchecker
|
||||
/build/*.exe
|
||||
/build/gmake
|
||||
/build/vs*/
|
||||
/build
|
||||
/doc/html
|
||||
/doc/doxygen_*.db
|
||||
/thirdparty/lib
|
||||
/intermediate
|
||||
*.a
|
||||
|
||||
# Temporary files created during CMake build
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
cmake_install.cmake
|
||||
CTestTestfile.cmake
|
||||
Makefile
|
||||
RapidJSON*.cmake
|
||||
RapidJSON.pc
|
||||
Testing
|
||||
/googletest
|
||||
install_manifest.txt
|
||||
Doxyfile
|
||||
DartConfiguration.tcl
|
||||
|
41
.travis.yml
41
.travis.yml
@ -6,36 +6,39 @@ compiler:
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- CONF=debug BITS=64
|
||||
- CONF=release BITS=64
|
||||
- CONF=debug BITS=32
|
||||
- CONF=release BITS=32
|
||||
- CONF=debug ARCH=x86_64
|
||||
- CONF=release ARCH=x86_64
|
||||
- CONF=debug ARCH=x86
|
||||
- CONF=release ARCH=x86
|
||||
global:
|
||||
- ARCH_FLAGS_x86='-m32' # #266: don't use SSE on 32-bit
|
||||
- ARCH_FLAGS_x86_64='-msse4.2' # use SSE4.2 on 64-bit
|
||||
- GITHUB_REPO='miloyip/rapidjson'
|
||||
- DEFINES='-DRAPIDJSON_HAS_STDSTRING'
|
||||
- secure: "HrsaCb+N66EG1HR+LWH1u51SjaJyRwJEDzqJGYMB7LJ/bfqb9mWKF1fLvZGk46W5t7TVaXRDD5KHFx9DPWvKn4gRUVkwTHEy262ah5ORh8M6n/6VVVajeV/AYt2C0sswdkDBDO4Xq+xy5gdw3G8s1A4Inbm73pUh+6vx+7ltBbk="
|
||||
|
||||
before_install:
|
||||
- sudo add-apt-repository -y ppa:codegear/release
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq premake4 valgrind
|
||||
- if [ "$BITS" = 32 ]; then sudo apt-get install -qq g++-multilib libc6-dbg:i386; fi
|
||||
- sudo apt-get install -qq cmake doxygen valgrind
|
||||
- if [ "$ARCH" = "x86" ]; then sudo apt-get install -qq g++-multilib libc6-dbg:i386; fi
|
||||
|
||||
install: true
|
||||
|
||||
before_script:
|
||||
- (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)
|
||||
- sed -i "s/-march=native//" CMakeLists.txt
|
||||
- mkdir build
|
||||
- >
|
||||
eval "ARCH_FLAGS=\${ARCH_FLAGS_${ARCH}}" ;
|
||||
(cd build && cmake
|
||||
-DRAPIDJSON_HAS_STDSTRING=ON
|
||||
-DCMAKE_VERBOSE_MAKEFILE=ON
|
||||
-DCMAKE_BUILD_TYPE=$CONF
|
||||
-DCMAKE_CXX_FLAGS="$ARCH_FLAGS" ..)
|
||||
|
||||
script:
|
||||
- make -C build/gmake -f test.make config=${CONF}${BITS}
|
||||
- make -C build/gmake -f example.make config=${CONF}${BITS}
|
||||
- if [ "$CONF" = "debug" ] && ( objdump -t -C intermediate/${CONF}/gmake/unittest/x${BITS}/namespacetest.o | grep rapidjson ) ; then echo "Symbol check failed!" ; false; fi
|
||||
- pushd bin
|
||||
- ./unittest_${CONF}_x${BITS}_gmake
|
||||
- valgrind --leak-check=full --error-exitcode=1 ./unittest_${CONF}_x${BITS}_gmake
|
||||
- if [ "$CONF" = "release" ]; then ./perftest_${CONF}_x${BITS}_gmake; fi
|
||||
- popd
|
||||
- ./build/travis-doxygen.sh;
|
||||
- cd build
|
||||
- make tests
|
||||
- make examples
|
||||
- ctest -V `[ "$CONF" = "release" ] || echo "-E perftest"`
|
||||
- make travis_doc
|
||||
|
112
CMakeLists.txt
Normal file
112
CMakeLists.txt
Normal file
@ -0,0 +1,112 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules)
|
||||
|
||||
PROJECT(RapidJSON CXX)
|
||||
|
||||
set(LIB_MAJOR_VERSION "0")
|
||||
set(LIB_MINOR_VERSION "12")
|
||||
set(LIB_PATCH_VERSION "0")
|
||||
set(LIB_VERSION_STRING "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VERSION}")
|
||||
|
||||
# compile in release with debug info mode by default
|
||||
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build Type")
|
||||
|
||||
# Build all binaries in a separate directory
|
||||
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
option(RAPIDJSON_BUILD_DOC "Build rapidjson documentation." ON)
|
||||
option(RAPIDJSON_BUILD_EXAMPLES "Build rapidjson examples." ON)
|
||||
option(RAPIDJSON_BUILD_TESTS "Build rapidjson perftests and unittests." ON)
|
||||
|
||||
option(RAPIDJSON_HAS_STDSTRING "" OFF)
|
||||
if(RAPIDJSON_HAS_STDSTRING)
|
||||
add_definitions(-DRAPIDJSON_HAS_STDSTRING)
|
||||
endif()
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
|
||||
endif()
|
||||
|
||||
#add extra search paths for libraries and includes
|
||||
SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in")
|
||||
SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "Directory where lib will install")
|
||||
SET(DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}" CACHE PATH "Path to the documentation")
|
||||
|
||||
IF(UNIX OR CYGWIN)
|
||||
SET(_CMAKE_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME}")
|
||||
ELSEIF(WIN32)
|
||||
SET(_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/cmake")
|
||||
ENDIF()
|
||||
SET(CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" CACHE PATH "The directory cmake fiels are installed in")
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||
|
||||
if(RAPIDJSON_BUILD_DOC)
|
||||
add_subdirectory(doc)
|
||||
endif()
|
||||
|
||||
add_custom_target(travis_doc)
|
||||
add_custom_command(TARGET travis_doc
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/travis-doxygen.sh)
|
||||
|
||||
if(RAPIDJSON_BUILD_EXAMPLES)
|
||||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
if(RAPIDJSON_BUILD_TESTS)
|
||||
if(MSVC11)
|
||||
# required for VS2012 due to missing support for variadic templates
|
||||
add_definitions(-D_VARIADIC_MAX=10)
|
||||
endif(MSVC11)
|
||||
add_subdirectory(test)
|
||||
include(CTest)
|
||||
endif()
|
||||
|
||||
# pkg-config
|
||||
IF (UNIX OR CYGWIN)
|
||||
CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
|
||||
@ONLY)
|
||||
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
|
||||
DESTINATION "${LIB_INSTALL_DIR}/pkgconfig"
|
||||
COMPONENT pkgconfig)
|
||||
ENDIF()
|
||||
|
||||
install(FILES readme.md
|
||||
DESTINATION "${DOC_INSTALL_DIR}"
|
||||
COMPONENT doc)
|
||||
|
||||
install(DIRECTORY include/rapidjson
|
||||
DESTINATION "${INCLUDE_INSTALL_DIR}"
|
||||
COMPONENT dev)
|
||||
|
||||
install(DIRECTORY example/
|
||||
DESTINATION "${DOC_INSTALL_DIR}/examples"
|
||||
COMPONENT examples
|
||||
# Following patterns are for excluding the intermediate/object files
|
||||
# from an install of in-source CMake build.
|
||||
PATTERN "CMakeFiles" EXCLUDE
|
||||
PATTERN "Makefile" EXCLUDE
|
||||
PATTERN "cmake_install.cmake" EXCLUDE)
|
||||
|
||||
# Provide config and version files to be used by other applications
|
||||
# ===============================
|
||||
|
||||
export(PACKAGE ${PROJECT_NAME})
|
||||
|
||||
# cmake-modules
|
||||
CONFIGURE_FILE(${PROJECT_NAME}Config.cmake.in
|
||||
${PROJECT_NAME}Config.cmake
|
||||
@ONLY)
|
||||
CONFIGURE_FILE(${PROJECT_NAME}ConfigVersion.cmake.in
|
||||
${PROJECT_NAME}ConfigVersion.cmake
|
||||
@ONLY)
|
||||
INSTALL(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
||||
DESTINATION "${CMAKE_INSTALL_DIR}"
|
||||
COMPONENT dev)
|
22
CMakeModules/FindGTestSrc.cmake
Normal file
22
CMakeModules/FindGTestSrc.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
SET(GTEST_SEARCH_PATH
|
||||
"${GTEST_SOURCE_DIR}"
|
||||
"${CMAKE_SOURCE_DIR}/thirdparty/gtest")
|
||||
|
||||
IF(UNIX)
|
||||
LIST(INSERT GTEST_SEARCH_PATH 1 "/usr/src/gtest")
|
||||
ENDIF()
|
||||
|
||||
FIND_PATH(GTEST_SOURCE_DIR
|
||||
NAMES CMakeLists.txt src/gtest_main.cc
|
||||
PATHS ${GTEST_SEARCH_PATH})
|
||||
|
||||
# Debian installs gtest include directory in /usr/include, thus need to look
|
||||
# for include directory separately from source directory.
|
||||
FIND_PATH(GTEST_INCLUDE_DIR
|
||||
NAMES gtest/gtest.h
|
||||
PATH_SUFFIXES include
|
||||
PATHS ${GTEST_SEARCH_PATH})
|
||||
|
||||
find_package_handle_standard_args(GTestSrc DEFAULT_MSG
|
||||
GTEST_SOURCE_DIR
|
||||
GTEST_INCLUDE_DIR)
|
7
RapidJSON.pc.in
Normal file
7
RapidJSON.pc.in
Normal file
@ -0,0 +1,7 @@
|
||||
includedir=@INCLUDE_INSTALL_DIR@
|
||||
|
||||
Name: @PROJECT_NAME@
|
||||
Description: A fast JSON parser/generator for C++ with both SAX/DOM style API
|
||||
Version: @LIB_VERSION_STRING@
|
||||
URL: https://github.com/miloyip/rapidjson
|
||||
Cflags: -I${includedir}
|
3
RapidJSONConfig.cmake.in
Normal file
3
RapidJSONConfig.cmake.in
Normal file
@ -0,0 +1,3 @@
|
||||
get_filename_component(RAPIDJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
set(RAPIDJSON_INCLUDE_DIRS "@INCLUDE_INSTALL_DIR@")
|
||||
message(STATUS "RapidJSON found. Headers: ${RAPIDJSON_INCLUDE_DIRS}")
|
10
RapidJSONConfigVersion.cmake.in
Normal file
10
RapidJSONConfigVersion.cmake.in
Normal file
@ -0,0 +1,10 @@
|
||||
SET(PACKAGE_VERSION "@LIB_VERSION_STRING@")
|
||||
|
||||
IF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
|
||||
SET(PACKAGE_VERSION_EXACT "true")
|
||||
ENDIF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
|
||||
IF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
|
||||
SET(PACKAGE_VERSION_COMPATIBLE "true")
|
||||
ELSE (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
|
||||
SET(PACKAGE_VERSION_UNSUITABLE "true")
|
||||
ENDIF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
|
28
appveyor.yml
Normal file
28
appveyor.yml
Normal file
@ -0,0 +1,28 @@
|
||||
version: 0.12.{build}
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- VS_VERSION: 11
|
||||
VS_PLATFORM: win32
|
||||
- VS_VERSION: 11
|
||||
VS_PLATFORM: x64
|
||||
- VS_VERSION: 12
|
||||
VS_PLATFORM: win32
|
||||
- VS_VERSION: 12
|
||||
VS_PLATFORM: x64
|
||||
|
||||
before_build:
|
||||
- git submodule update --init --recursive
|
||||
- cmake -H. -BBuild/VS -G "Visual Studio %VS_VERSION%" -DCMAKE_GENERATOR_PLATFORM=%VS_PLATFORM% -DBUILD_SHARED_LIBS=true -Wno-dev
|
||||
|
||||
build:
|
||||
project: Build\VS\RapidJSON.sln
|
||||
parallel: true
|
||||
verbosity: minimal
|
||||
|
||||
test_script:
|
||||
- cd Build\VS && if %CONFIGURATION%==Debug (ctest --verbose -E perftest --build-config %CONFIGURATION%) else (ctest --verbose --build-config %CONFIGURATION%)
|
@ -1,5 +0,0 @@
|
||||
@echo off
|
||||
premake4 vs2005
|
||||
premake4 vs2008
|
||||
premake4 vs2010
|
||||
premake4 gmake
|
@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
premake4 vs2005
|
||||
premake4 vs2008
|
||||
premake4 vs2010
|
||||
premake4 gmake
|
@ -1,161 +0,0 @@
|
||||
function setTargetObjDir(outDir)
|
||||
for _, cfg in ipairs(configurations()) do
|
||||
for _, plat in ipairs(platforms()) do
|
||||
local action = _ACTION or ""
|
||||
|
||||
local prj = project()
|
||||
|
||||
--"_debug_win32_vs2008"
|
||||
local suffix = "_" .. cfg .. "_" .. plat .. "_" .. action
|
||||
|
||||
targetPath = outDir
|
||||
|
||||
suffix = string.lower(suffix)
|
||||
|
||||
local obj_path = "../intermediate/" .. cfg .. "/" .. action .. "/" .. prj.name
|
||||
|
||||
obj_path = string.lower(obj_path)
|
||||
|
||||
configuration {cfg, plat}
|
||||
targetdir(targetPath)
|
||||
objdir(obj_path)
|
||||
targetsuffix(suffix)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function linkLib(libBaseName)
|
||||
for _, cfg in ipairs(configurations()) do
|
||||
for _, plat in ipairs(platforms()) do
|
||||
local action = _ACTION or ""
|
||||
|
||||
local prj = project()
|
||||
|
||||
local cfgName = cfg
|
||||
|
||||
--"_debug_win32_vs2008"
|
||||
local suffix = "_" .. cfgName .. "_" .. plat .. "_" .. action
|
||||
|
||||
libFullName = libBaseName .. string.lower(suffix)
|
||||
|
||||
configuration {cfg, plat}
|
||||
links(libFullName)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
solution "test"
|
||||
configurations { "debug", "release" }
|
||||
platforms { "x32", "x64" }
|
||||
|
||||
location ("./" .. (_ACTION or ""))
|
||||
language "C++"
|
||||
flags { "ExtraWarnings" }
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG" }
|
||||
flags { "Symbols" }
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
flags { "Optimize" }
|
||||
|
||||
configuration "vs*"
|
||||
defines { "_CRT_SECURE_NO_WARNINGS" }
|
||||
|
||||
configuration "gmake"
|
||||
buildoptions "-march=native -Wall -Wextra"
|
||||
|
||||
project "gtest"
|
||||
kind "StaticLib"
|
||||
|
||||
defines { "GTEST_HAS_PTHREAD=0" }
|
||||
|
||||
files {
|
||||
"../thirdparty/gtest/src/gtest-all.cc",
|
||||
"../thirdparty/gtest/src/**.h",
|
||||
}
|
||||
|
||||
includedirs {
|
||||
"../thirdparty/gtest/",
|
||||
"../thirdparty/gtest/include",
|
||||
}
|
||||
|
||||
setTargetObjDir("../thirdparty/lib")
|
||||
|
||||
project "unittest"
|
||||
kind "ConsoleApp"
|
||||
|
||||
if _ACTION == "gmake" then
|
||||
buildoptions "-Werror -Weffc++ -Wswitch-default"
|
||||
end
|
||||
|
||||
files {
|
||||
"../include/**.h",
|
||||
"../test/unittest/**.cpp",
|
||||
"../test/unittest/**.h",
|
||||
}
|
||||
|
||||
includedirs {
|
||||
"../include/",
|
||||
"../thirdparty/gtest/include/",
|
||||
}
|
||||
|
||||
libdirs "../thirdparty/lib"
|
||||
|
||||
setTargetObjDir("../bin")
|
||||
|
||||
linkLib "gtest"
|
||||
links "gtest"
|
||||
|
||||
project "perftest"
|
||||
kind "ConsoleApp"
|
||||
|
||||
files {
|
||||
"../include/**.h",
|
||||
"../test/perftest/**.cpp",
|
||||
"../test/perftest/**.h",
|
||||
}
|
||||
|
||||
includedirs {
|
||||
"../include/",
|
||||
"../thirdparty/gtest/include/",
|
||||
"../thirdparty/",
|
||||
}
|
||||
|
||||
libdirs "../thirdparty/lib"
|
||||
|
||||
setTargetObjDir("../bin")
|
||||
|
||||
linkLib "gtest"
|
||||
links "gtest"
|
||||
|
||||
solution "example"
|
||||
configurations { "debug", "release" }
|
||||
platforms { "x32", "x64" }
|
||||
location ("./" .. (_ACTION or ""))
|
||||
language "C++"
|
||||
flags { "ExtraWarnings" }
|
||||
includedirs "../include/"
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG" }
|
||||
flags { "Symbols" }
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
flags { "Optimize", "EnableSSE2" }
|
||||
|
||||
configuration "vs*"
|
||||
defines { "_CRT_SECURE_NO_WARNINGS" }
|
||||
|
||||
configuration "gmake"
|
||||
buildoptions "-Werror -Wall -Wextra -Weffc++ -Wswitch-default"
|
||||
|
||||
local examplepaths = os.matchdirs("../example/*")
|
||||
for _, examplepath in ipairs(examplepaths) do
|
||||
project(path.getname(examplepath))
|
||||
kind "ConsoleApp"
|
||||
files(examplepath .. "/*")
|
||||
setTargetObjDir("../bin")
|
||||
end
|
23
doc/CMakeLists.txt
Normal file
23
doc/CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
||||
find_package(Doxygen)
|
||||
|
||||
IF(NOT DOXYGEN_FOUND)
|
||||
MESSAGE(STATUS "No Doxygen found. Documentation won't be built")
|
||||
ELSE()
|
||||
file(GLOB SOURCES ${CMAKE_SOURCE_DIR}/include/*)
|
||||
file(GLOB MARKDOWN_DOC ${CMAKE_SOURCE_DIR}/doc/*.md)
|
||||
list(APPEND MARKDOWN_DOC ${CMAKE_SOURCE_DIR}/readme.md)
|
||||
|
||||
CONFIGURE_FILE(Doxyfile.in Doxyfile @ONLY)
|
||||
|
||||
add_custom_command(OUTPUT html
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/html
|
||||
DEPENDS ${MARKDOWN_DOC} ${SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_custom_target(doc ALL DEPENDS html)
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
||||
DESTINATION ${DOC_INSTALL_DIR}
|
||||
COMPONENT doc)
|
||||
ENDIF()
|
@ -58,7 +58,7 @@ PROJECT_LOGO =
|
||||
# entered, it will be relative to the location where doxygen was started. If
|
||||
# left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY = ./doc
|
||||
OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@
|
||||
|
||||
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
|
||||
# directories (in 2 levels) under the output directory of each output format and
|
||||
@ -764,18 +764,18 @@ WARN_LOGFILE =
|
||||
# spaces.
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = ./include/rapidjson/rapidjson.h \
|
||||
./include/ \
|
||||
./readme.md \
|
||||
./doc/features.md \
|
||||
./doc/tutorial.md \
|
||||
./doc/stream.md \
|
||||
./doc/encoding.md \
|
||||
./doc/dom.md \
|
||||
./doc/sax.md \
|
||||
./doc/performance.md \
|
||||
./doc/internals.md \
|
||||
./doc/faq.md
|
||||
INPUT = readme.md \
|
||||
include/rapidjson/rapidjson.h \
|
||||
include/ \
|
||||
doc/features.md \
|
||||
doc/tutorial.md \
|
||||
doc/stream.md \
|
||||
doc/encoding.md \
|
||||
doc/dom.md \
|
||||
doc/sax.md \
|
||||
doc/performance.md \
|
||||
doc/internals.md \
|
||||
doc/faq.md
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
@ -920,7 +920,7 @@ FILTER_SOURCE_PATTERNS =
|
||||
# (index.html). This can be useful if you have a project on for instance GitHub
|
||||
# and want to reuse the introduction page also for the doxygen output.
|
||||
|
||||
USE_MDFILE_AS_MAINPAGE = ./readme.md
|
||||
USE_MDFILE_AS_MAINPAGE = readme.md
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to source browsing
|
@ -31,7 +31,7 @@ User can customize these template parameters.
|
||||
|
||||
## Encoding {#Encoding}
|
||||
|
||||
The `Encoding` parameter specifies the encoding of JSON String value in memory. Possible options are `UTF8`, `UTF16`, `UTF32`. Note that, these 3 types are also template class. `UTF8<>` is `UTF8<char>`, which means using char to store the characters. You may refer to [Encoding](encoding.md) for details.
|
||||
The `Encoding` parameter specifies the encoding of JSON String value in memory. Possible options are `UTF8`, `UTF16`, `UTF32`. Note that, these 3 types are also template class. `UTF8<>` is `UTF8<char>`, which means using char to store the characters. You may refer to [Encoding](doc/encoding.md) for details.
|
||||
|
||||
Suppose a Windows application would query localization strings stored in JSON files. Unicode-enabled functions in Windows use UTF-16 (wide character) encoding. No matter what encoding was used in JSON files, we can store the strings in UTF-16 in memory.
|
||||
|
||||
@ -106,7 +106,7 @@ GenericDocument& GenericDocument::Parse(const Ch* str);
|
||||
GenericDocument& GenericDocument::Parse(const Ch* str);
|
||||
~~~~~~~~~~
|
||||
|
||||
The examples of [tutorial](tutorial.md) uses (9) for normal parsing of string. The examples of [stream](stream.md) uses the first three. *In situ* parsing will be described soon.
|
||||
The examples of [tutorial](doc/tutorial.md) uses (9) for normal parsing of string. The examples of [stream](doc/stream.md) uses the first three. *In situ* parsing will be described soon.
|
||||
|
||||
The `parseFlags` are combination of the following bit-flags:
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
1. What is RapidJSON?
|
||||
|
||||
RapidJSON is a C++ library for parsing and generating JSON. You may check all [features](features.md) of it.
|
||||
RapidJSON is a C++ library for parsing and generating JSON. You may check all [features](doc/features.md) of it.
|
||||
|
||||
2. Why is RapidJSON named so?
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
This tutorial introduces the basics of the Document Object Model(DOM) API.
|
||||
|
||||
As shown in [Usage at a glance](readme.md), a JSON can be parsed into DOM, and then the DOM can be queried and modified easily, and finally be converted back to JSON.
|
||||
As shown in [Usage at a glance](@ref index), a JSON can be parsed into DOM, and then the DOM can be queried and modified easily, and finally be converted back to JSON.
|
||||
|
||||
[TOC]
|
||||
|
||||
@ -512,4 +512,4 @@ This tutorial shows the basics of DOM tree query and manipulation. There are sev
|
||||
5. [Performance](doc/performance.md) shows some in-house and third-party benchmarks.
|
||||
6. [Internals](doc/internals.md) describes some internal designs and techniques of RapidJSON.
|
||||
|
||||
You may also refer to the [FAQ](faq.md), API documentation, examples and unit tests.
|
||||
You may also refer to the [FAQ](doc/faq.md), API documentation, examples and unit tests.
|
||||
|
29
example/CMakeLists.txt
Normal file
29
example/CMakeLists.txt
Normal file
@ -0,0 +1,29 @@
|
||||
# Copyright (c) 2011 Milo Yip (miloyip@gmail.com)
|
||||
# Copyright (c) 2013 Rafal Jeczalik (rjeczalik@gmail.com)
|
||||
# Distributed under the MIT License (see license.txt file)
|
||||
|
||||
set(EXAMPLES
|
||||
capitalize
|
||||
condense
|
||||
messagereader
|
||||
pretty
|
||||
prettyauto
|
||||
serialize
|
||||
simpledom
|
||||
simplereader
|
||||
simplewriter
|
||||
tutorial)
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
|
||||
endif()
|
||||
|
||||
foreach (example ${EXAMPLES})
|
||||
add_executable(${example} ${example}/${example}.cpp)
|
||||
endforeach()
|
||||
|
||||
add_custom_target(examples ALL DEPENDS ${EXAMPLES})
|
@ -54,7 +54,7 @@ struct MessageHandler
|
||||
enum State {
|
||||
kExpectObjectStart,
|
||||
kExpectNameOrObjectEnd,
|
||||
kExpectValue,
|
||||
kExpectValue
|
||||
}state_;
|
||||
std::string name_;
|
||||
};
|
||||
|
@ -24,12 +24,10 @@ int main(int, char*[]) {
|
||||
return 1;
|
||||
#else
|
||||
// In-situ parsing, decode strings directly in the source string. Source must be string.
|
||||
{
|
||||
char buffer[sizeof(json)];
|
||||
memcpy(buffer, json, sizeof(json));
|
||||
if (document.ParseInsitu(buffer).HasParseError())
|
||||
return 1;
|
||||
}
|
||||
char buffer[sizeof(json)];
|
||||
memcpy(buffer, json, sizeof(json));
|
||||
if (document.ParseInsitu(buffer).HasParseError())
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
printf("\nParsing to document succeeded.\n");
|
||||
|
@ -55,6 +55,9 @@ RAPIDJSON_DIAG_OFF(effc++)
|
||||
|
||||
\hideinitializer
|
||||
*/
|
||||
#endif // !defined(RAPIDJSON_HAS_STDSTRING)
|
||||
|
||||
#if RAPIDJSON_HAS_STDSTRING
|
||||
#include <string>
|
||||
#endif // RAPIDJSON_HAS_STDSTRING
|
||||
|
||||
@ -954,6 +957,44 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Add a constant string value as member (name-value pair) to the object.
|
||||
/*! \param name A string value as name of member.
|
||||
\param value constant string reference as value of member.
|
||||
\param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().
|
||||
\return The value itself for fluent API.
|
||||
\pre IsObject()
|
||||
\note This overload is needed to avoid clashes with the generic primitive type AddMember(GenericValue&,T,Allocator&) overload below.
|
||||
\note Amortized Constant time complexity.
|
||||
*/
|
||||
GenericValue& AddMember(GenericValue& name, StringRefType value, Allocator& allocator) {
|
||||
GenericValue v(value);
|
||||
return AddMember(name, v, allocator);
|
||||
}
|
||||
|
||||
//! Add any primitive value as member (name-value pair) to the object.
|
||||
/*! \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t
|
||||
\param name A string value as name of member.
|
||||
\param value Value of primitive type \c T as value of member
|
||||
\param allocator Allocator for reallocating memory. Commonly use GenericDocument::GetAllocator().
|
||||
\return The value itself for fluent API.
|
||||
\pre IsObject()
|
||||
|
||||
\note The source type \c T explicitly disallows all pointer types,
|
||||
especially (\c const) \ref Ch*. This helps avoiding implicitly
|
||||
referencing character strings with insufficient lifetime, use
|
||||
\ref AddMember(StringRefType, GenericValue&, Allocator&) or \ref
|
||||
AddMember(StringRefType, StringRefType, Allocator&).
|
||||
All other pointer types would implicitly convert to \c bool,
|
||||
use an explicit cast instead, if needed.
|
||||
\note Amortized Constant time complexity.
|
||||
*/
|
||||
template <typename T>
|
||||
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (GenericValue&))
|
||||
AddMember(GenericValue& name, T value, Allocator& allocator) {
|
||||
GenericValue v(value);
|
||||
return AddMember(name, v, allocator);
|
||||
}
|
||||
|
||||
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
|
||||
GenericValue& AddMember(GenericValue&& name, GenericValue&& value, Allocator& allocator) {
|
||||
return AddMember(name, value, allocator);
|
||||
@ -1021,8 +1062,7 @@ public:
|
||||
RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (GenericValue&))
|
||||
AddMember(StringRefType name, T value, Allocator& allocator) {
|
||||
GenericValue n(name);
|
||||
GenericValue v(value);
|
||||
return AddMember(n, v, allocator);
|
||||
return AddMember(n, value, allocator);
|
||||
}
|
||||
|
||||
//! Remove all members in the object.
|
||||
|
@ -30,6 +30,7 @@ RAPIDJSON_DIAG_OFF(4702) // unreachable code
|
||||
#elif defined(__GNUC__)
|
||||
RAPIDJSON_DIAG_PUSH
|
||||
RAPIDJSON_DIAG_OFF(effc++)
|
||||
RAPIDJSON_DIAG_OFF(overflow)
|
||||
#endif
|
||||
|
||||
RAPIDJSON_NAMESPACE_BEGIN
|
||||
|
@ -85,7 +85,7 @@ enum ParseErrorCode {
|
||||
kParseErrorNumberMissExponent, //!< Miss exponent in number.
|
||||
|
||||
kParseErrorTermination, //!< Parsing was terminated.
|
||||
kParseErrorUnspecificSyntaxError, //!< Unspecific syntax error.
|
||||
kParseErrorUnspecificSyntaxError //!< Unspecific syntax error.
|
||||
};
|
||||
|
||||
//! Result of parsing (wraps ParseErrorCode)
|
||||
|
@ -148,7 +148,7 @@ public:
|
||||
}
|
||||
|
||||
bool operator==(const BigInteger& rhs) const {
|
||||
return count_ == rhs.count_ && memcmp(digits_, rhs.digits_, count_ * sizeof(Type)) == 0;
|
||||
return count_ == rhs.count_ && std::memcmp(digits_, rhs.digits_, count_ * sizeof(Type)) == 0;
|
||||
}
|
||||
|
||||
bool operator==(const Type rhs) const {
|
||||
@ -172,7 +172,7 @@ public:
|
||||
};
|
||||
if (exp == 0) return *this;
|
||||
for (; exp >= 27; exp -= 27) *this *= RAPIDJSON_UINT64_C2(0X6765C793, 0XFA10079D); // 5^27
|
||||
for (; exp >= 13; exp -= 13) *this *= 1220703125u; // 5^13
|
||||
for (; exp >= 13; exp -= 13) *this *= static_cast<uint32_t>(1220703125u); // 5^13
|
||||
if (exp > 0) *this *= kPow5[exp - 1];
|
||||
return *this;
|
||||
}
|
||||
@ -252,7 +252,8 @@ private:
|
||||
(*outHigh)++;
|
||||
return low;
|
||||
#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__)
|
||||
unsigned __int128 p = static_cast<unsigned __int128>(a) * static_cast<unsigned __int128>(b);
|
||||
__extension__ typedef unsigned __int128 uint128;
|
||||
uint128 p = static_cast<uint128>(a) * static_cast<uint128>(b);
|
||||
p += k;
|
||||
*outHigh = p >> 64;
|
||||
return static_cast<uint64_t>(p);
|
||||
|
@ -75,7 +75,8 @@ struct DiyFp {
|
||||
h++;
|
||||
return DiyFp(h, e + rhs.e + 64);
|
||||
#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__)
|
||||
unsigned __int128 p = static_cast<unsigned __int128>(f) * static_cast<unsigned __int128>(rhs.f);
|
||||
__extension__ typedef unsigned __int128 uint128;
|
||||
uint128 p = static_cast<uint128>(f) * static_cast<uint128>(rhs.f);
|
||||
uint64_t h = p >> 64;
|
||||
uint64_t l = static_cast<uint64_t>(p);
|
||||
if (l & (uint64_t(1) << 63)) // rounding
|
||||
|
@ -413,7 +413,8 @@ RAPIDJSON_NAMESPACE_END
|
||||
|
||||
#ifndef RAPIDJSON_HAS_CXX11_RVALUE_REFS
|
||||
#if defined(__clang__)
|
||||
#define RAPIDJSON_HAS_CXX11_RVALUE_REFS __has_feature(cxx_rvalue_references)
|
||||
#define RAPIDJSON_HAS_CXX11_RVALUE_REFS __has_feature(cxx_rvalue_references) && \
|
||||
(defined(_LIBCPP_VERSION) || defined(__GLIBCXX__) && __GLIBCXX__ >= 20080306)
|
||||
#elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,3,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \
|
||||
(defined(_MSC_VER) && _MSC_VER >= 1600)
|
||||
|
||||
|
@ -382,7 +382,7 @@ public:
|
||||
typedef typename SourceEncoding::Ch Ch; //!< SourceEncoding character type
|
||||
|
||||
//! Constructor.
|
||||
/*! \param allocator Optional allocator for allocating stack memory. (Only use for non-destructive parsing)
|
||||
/*! \param stackAllocator Optional allocator for allocating stack memory. (Only use for non-destructive parsing)
|
||||
\param stackCapacity stack capacity in bytes for storing a single decoded string. (Only use for non-destructive parsing)
|
||||
*/
|
||||
GenericReader(StackAllocator* stackAllocator = 0, size_t stackCapacity = kDefaultStackCapacity) : stack_(stackAllocator, stackCapacity), parseResult_() {}
|
||||
@ -728,12 +728,12 @@ private:
|
||||
}
|
||||
|
||||
template<typename InputStream, bool backup>
|
||||
class NumberStream {};
|
||||
class NumberStream;
|
||||
|
||||
template<typename InputStream>
|
||||
class NumberStream<InputStream, false> {
|
||||
public:
|
||||
NumberStream(GenericReader& reader, InputStream& is) : is(is) { (void)reader; }
|
||||
NumberStream(GenericReader& reader, InputStream& s) : is(s) { (void)reader; }
|
||||
~NumberStream() {}
|
||||
|
||||
RAPIDJSON_FORCEINLINE Ch Peek() const { return is.Peek(); }
|
||||
|
45
readme.md
45
readme.md
@ -1,10 +1,21 @@
|
||||

|
||||
## A fast JSON parser/generator for C++ with both SAX/DOM style API
|
||||
|
||||
Copyright (c) 2011-2014 Milo Yip (miloyip@gmail.com)
|
||||
|
||||
[RapidJSON GitHub](https://github.com/miloyip/rapidjson/)
|
||||
* [RapidJSON GitHub](https://github.com/miloyip/rapidjson/)
|
||||
* [RapidJSON Documentation](http://miloyip.github.io/rapidjson/)
|
||||
|
||||
[RapidJSON Documentation](http://miloyip.github.io/rapidjson/)
|
||||
## Build status
|
||||
|
||||
| [Linux][lin-link] | [Windows][win-link] |
|
||||
| :---------------: | :-----------------: |
|
||||
| ![lin-badge] | ![win-badge] |
|
||||
|
||||
[lin-badge]: https://travis-ci.org/miloyip/rapidjson.png "Travis build status"
|
||||
[lin-link]: https://travis-ci.org/miloyip/rapidjson "Travis build status"
|
||||
[win-badge]: https://ci.appveyor.com/api/projects/status/u658dcuwxo14a8m9/branch/master?svg=true "AppVeyor build status"
|
||||
[win-link]: https://ci.appveyor.com/project/miloyip/rapidjson/branch/master "AppVeyor build status"
|
||||
|
||||
## Introduction
|
||||
|
||||
@ -41,21 +52,29 @@ Users can build and run the unit tests on their platform/compiler.
|
||||
|
||||
RapidJSON is a header-only C++ library. Just copy the `include/rapidjson` folder to system or project's include path.
|
||||
|
||||
To build the tests and examples:
|
||||
RapidJSON uses following software as its dependencies:
|
||||
* [CMake](http://www.cmake.org) as a general build tool
|
||||
* (optional)[Doxygen](http://www.doxygen.org) to build documentation
|
||||
* (optional)[googletest](https://code.google.com/p/googletest/) for unit and performance testing
|
||||
|
||||
To generate user documentation and run tests please proceed with the steps below:
|
||||
|
||||
1. Execute `git submodule update --init` to get the files of thirdparty submodules (google test).
|
||||
2. Obtain [premake4](http://industriousone.com/premake/download).
|
||||
3. Copy premake4 executable to `rapidjson/build` (or system path).
|
||||
4. Change directory to `rapidjson/build/`, run `premake.bat` on Windows, `premake.sh` on Linux or other platforms.
|
||||
5. On Windows, build the solution at `rapidjson/build/vs2008/` or `/vs2010/`.
|
||||
6. On other platforms, run GNU `make` at `rapidjson/build/gmake/` (e.g., `make -f test.make config=release32`; `make -f example.make config=debug32`).
|
||||
7. On success, the executables are generated at `rapidjson/bin`.
|
||||
2. Create directory called `build` in rapidjson source directory.
|
||||
3. Change to `build` directory and run `cmake ..` command to configure your build. Windows users can do the same with cmake-gui application.
|
||||
4. On Windows, build the solution found in the build directory. On Linux, run `make` from the build directory.
|
||||
|
||||
To build the [Doxygen](http://doxygen.org) documentation:
|
||||
On successfull build you will find compiled test and example binaries in `bin`
|
||||
directory. The generated documentation will be available in `doc/html`
|
||||
directory of the build tree. To run tests after finished build please run `make
|
||||
test` or `ctest` from your build tree. You can get detailed output using `ctest
|
||||
-V` command.
|
||||
|
||||
1. Obtain and install [Doxygen](http://doxygen.org/download.html).
|
||||
2. In the top-level directory, run `doxygen build/Doxyfile`.
|
||||
3. Browse the generated documentation in `doc/html`.
|
||||
It is possible to install library system-wide by running `make install` command
|
||||
from the build tree with administrative privileges. This will install all files
|
||||
according to system preferences. Once RapidJSON is installed, it is possible
|
||||
to use it from other CMake projects by adding `find_package(RapidJSON)` line to
|
||||
your CMakeLists.txt.
|
||||
|
||||
## Usage at a glance
|
||||
|
||||
|
20
test/CMakeLists.txt
Normal file
20
test/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
||||
find_package(GTestSrc)
|
||||
|
||||
IF(GTESTSRC_FOUND)
|
||||
enable_testing()
|
||||
|
||||
if (WIN32 AND (NOT CYGWIN) AND (NOT MINGW))
|
||||
set(gtest_disable_pthreads ON)
|
||||
set(gtest_force_shared_crt ON)
|
||||
endif()
|
||||
|
||||
add_subdirectory(${GTEST_SOURCE_DIR} ${CMAKE_BINARY_DIR}/googletest)
|
||||
include_directories(${GTEST_INCLUDE_DIR})
|
||||
|
||||
set(TEST_LIBRARIES gtest gtest_main)
|
||||
|
||||
add_custom_target(tests ALL)
|
||||
add_subdirectory(perftest)
|
||||
add_subdirectory(unittest)
|
||||
|
||||
ENDIF(GTESTSRC_FOUND)
|
16
test/perftest/CMakeLists.txt
Normal file
16
test/perftest/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
||||
set(PERFTEST_SOURCES
|
||||
misctest.cpp
|
||||
perftest.cpp
|
||||
platformtest.cpp
|
||||
rapidjsontest.cpp)
|
||||
|
||||
add_executable(perftest ${PERFTEST_SOURCES})
|
||||
target_link_libraries(perftest ${TEST_LIBRARIES})
|
||||
|
||||
add_dependencies(tests perftest)
|
||||
|
||||
IF(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
||||
add_test(NAME perftest
|
||||
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/perftest
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
||||
ENDIF()
|
46
test/unittest/CMakeLists.txt
Normal file
46
test/unittest/CMakeLists.txt
Normal file
@ -0,0 +1,46 @@
|
||||
set(UNITTEST_SOURCES
|
||||
bigintegertest.cpp
|
||||
documenttest.cpp
|
||||
encodedstreamtest.cpp
|
||||
encodingstest.cpp
|
||||
filestreamtest.cpp
|
||||
jsoncheckertest.cpp
|
||||
namespacetest.cpp
|
||||
readertest.cpp
|
||||
stringbuffertest.cpp
|
||||
strtodtest.cpp
|
||||
unittest.cpp
|
||||
valuetest.cpp
|
||||
writertest.cpp)
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Weffc++ -Wswitch-default")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Weffc++ -Wswitch-default")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
|
||||
endif()
|
||||
|
||||
add_library(namespacetest STATIC namespacetest.cpp)
|
||||
|
||||
add_executable(unittest ${UNITTEST_SOURCES})
|
||||
target_link_libraries(unittest ${TEST_LIBRARIES} namespacetest)
|
||||
|
||||
add_dependencies(tests unittest)
|
||||
|
||||
add_test(NAME unittest
|
||||
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
||||
|
||||
if(NOT MSVC)
|
||||
add_test(NAME valgrind_unittest
|
||||
COMMAND valgrind --leak-check=full --error-exitcode=1 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_test(NAME symbol_check
|
||||
COMMAND sh -c "objdump -t -C libnamespacetest.a | grep rapidjson ; test $? -ne 0"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
||||
endif(NOT MSVC)
|
@ -253,8 +253,8 @@ TEST(Document, Traits) {
|
||||
|
||||
static_assert(!std::is_nothrow_constructible<Document>::value, "");
|
||||
static_assert(!std::is_nothrow_default_constructible<Document>::value, "");
|
||||
static_assert(!std::is_nothrow_copy_constructible<Document>::value, "");
|
||||
#ifndef _MSC_VER
|
||||
static_assert(!std::is_nothrow_copy_constructible<Document>::value, "");
|
||||
static_assert(std::is_nothrow_move_constructible<Document>::value, "");
|
||||
#endif
|
||||
|
||||
|
@ -83,8 +83,11 @@ TEST(StringBuffer, Traits) {
|
||||
|
||||
static_assert(!std::is_nothrow_constructible<StringBuffer>::value, "");
|
||||
static_assert(!std::is_nothrow_default_constructible<StringBuffer>::value, "");
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER >= 1800
|
||||
static_assert(!std::is_nothrow_copy_constructible<StringBuffer>::value, "");
|
||||
static_assert(!std::is_nothrow_move_constructible<StringBuffer>::value, "");
|
||||
#endif
|
||||
|
||||
static_assert( std::is_assignable<StringBuffer,StringBuffer>::value, "");
|
||||
#ifndef _MSC_VER
|
||||
@ -92,7 +95,10 @@ TEST(StringBuffer, Traits) {
|
||||
#endif
|
||||
static_assert( std::is_move_assignable<StringBuffer>::value, "");
|
||||
|
||||
static_assert(!std::is_nothrow_assignable<StringBuffer,StringBuffer>::value, "");
|
||||
#if !defined(_MSC_VER) || _MSC_VER >= 1800
|
||||
static_assert(!std::is_nothrow_assignable<StringBuffer, StringBuffer>::value, "");
|
||||
#endif
|
||||
|
||||
static_assert(!std::is_nothrow_copy_assignable<StringBuffer>::value, "");
|
||||
static_assert(!std::is_nothrow_move_assignable<StringBuffer>::value, "");
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
#endif
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
|
||||
#pragma GCC diagnostic pop
|
||||
|
@ -54,9 +54,7 @@ TEST(Value, Traits) {
|
||||
#ifndef _MSC_VER
|
||||
static_assert(std::is_nothrow_constructible<Value>::value, "");
|
||||
static_assert(std::is_nothrow_default_constructible<Value>::value, "");
|
||||
#endif
|
||||
static_assert(!std::is_nothrow_copy_constructible<Value>::value, "");
|
||||
#ifndef _MSC_VER
|
||||
static_assert(std::is_nothrow_move_constructible<Value>::value, "");
|
||||
#endif
|
||||
|
||||
@ -921,6 +919,19 @@ TEST(Value, Object) {
|
||||
EXPECT_EQ(8u, o.MemberCount());
|
||||
}
|
||||
|
||||
// AddMember<T>(Value&, T, Allocator)
|
||||
{
|
||||
Value o(kObjectType);
|
||||
|
||||
Value n("s");
|
||||
o.AddMember(n, "string", allocator);
|
||||
EXPECT_EQ(1u, o.MemberCount());
|
||||
|
||||
Value count("#");
|
||||
o.AddMember(count, o.MemberCount(), allocator);
|
||||
EXPECT_EQ(2u, o.MemberCount());
|
||||
}
|
||||
|
||||
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
|
||||
// AddMember(GenericValue&&, ...) variants
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
set -e
|
||||
|
||||
SUDO=sudo
|
||||
DOXYGEN_VER=doxygen-1.8.7
|
||||
DOXYGEN_TAR=${DOXYGEN_VER}.linux.bin.tar.gz
|
||||
DOXYGEN_URL="http://ftp.stack.nl/pub/users/dimitri/${DOXYGEN_TAR}"
|
||||
@ -51,19 +50,18 @@ doxygen_install()
|
||||
{
|
||||
wget -O - "${DOXYGEN_URL}" | \
|
||||
tar xz -C ${TMPDIR-/tmp} ${DOXYGEN_VER}/bin/doxygen
|
||||
$SUDO install -m 755 ${TMPDIR-/tmp}/${DOXYGEN_VER}/bin/doxygen \
|
||||
${DOXYGEN_BIN};
|
||||
export PATH="${TMPDIR-/tmp}/${DOXYGEN_VER}/bin:$PATH"
|
||||
}
|
||||
|
||||
doxygen_run()
|
||||
{
|
||||
cd "${TRAVIS_BUILD_DIR}";
|
||||
doxygen build/Doxyfile;
|
||||
doxygen ${TRAVIS_BUILD_DIR}/build/doc/Doxyfile;
|
||||
}
|
||||
|
||||
gh_pages_prepare()
|
||||
{
|
||||
cd "${TRAVIS_BUILD_DIR}/doc";
|
||||
cd "${TRAVIS_BUILD_DIR}/build/doc";
|
||||
[ ! -d "html" ] || \
|
||||
abort "Doxygen target directory already exists."
|
||||
git --version
|
||||
@ -78,7 +76,7 @@ gh_pages_prepare()
|
||||
}
|
||||
|
||||
gh_pages_commit() {
|
||||
cd "${TRAVIS_BUILD_DIR}/doc/html";
|
||||
cd "${TRAVIS_BUILD_DIR}/build/doc/html";
|
||||
git add --all;
|
||||
git diff-index --quiet HEAD || git commit -m "Automatic doxygen build";
|
||||
}
|
||||
@ -102,7 +100,7 @@ gh_pages_push() {
|
||||
[ "${#GH_TOKEN}" -eq 40 ] || \
|
||||
abort "GitHub token invalid: found ${#GH_TOKEN} characters, expected 40."
|
||||
|
||||
cd "${TRAVIS_BUILD_DIR}/doc/html";
|
||||
cd "${TRAVIS_BUILD_DIR}/build/doc/html";
|
||||
# setup credentials (hide in "set -x" mode)
|
||||
git remote set-url --push origin "${GITHUB_URL}"
|
||||
git config credential.helper 'store'
|
Loading…
x
Reference in New Issue
Block a user