mirror of
https://github.com/RPCS3/yaml-cpp.git
synced 2026-07-25 20:55:22 -04:00
Compare commits
425 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 572e940c83 | |||
| 01eb370300 | |||
| d760d037ca | |||
| 6105d4cfeb | |||
| e145488547 | |||
| b688c93050 | |||
| 1723523c43 | |||
| d772361f15 | |||
| a441e1a14c | |||
| fb0802097c | |||
| 643ea61a98 | |||
| d1e4c2640c | |||
| ddc578dbd7 | |||
| 8906ae9a0d | |||
| 4e350e5808 | |||
| 7ace0e93d2 | |||
| 0e61ddb6d9 | |||
| 97fa02a484 | |||
| 5024caa69c | |||
| 21ed2b5817 | |||
| 92a35581d7 | |||
| 5b32d89222 | |||
| 812a2dc684 | |||
| add460947b | |||
| 3099d51ba4 | |||
| 6f4608ce05 | |||
| 5abfbf5aac | |||
| d78d16532a | |||
| 62634f53ec | |||
| 860365b263 | |||
| e8e5d4bc40 | |||
| b077e8390e | |||
| c953ce0b07 | |||
| f87dced5c9 | |||
| 62361e6f27 | |||
| 70e1eb3f9c | |||
| 77cc54585f | |||
| e69f51ee16 | |||
| ee795d7e3e | |||
| f6d6c90aa9 | |||
| d9c7bcf32f | |||
| f3b230693a | |||
| f64f619c29 | |||
| 8e5fc0e304 | |||
| 976e8b184c | |||
| e5d0366797 | |||
| c3798d9bd4 | |||
| 40c47f6312 | |||
| e3d5ec189d | |||
| 5be19ccbfd | |||
| 98830a4a15 | |||
| 3a88c4b4a1 | |||
| 69af9b420a | |||
| 0987b234c3 | |||
| 2dfccbb945 | |||
| a9be4849d8 | |||
| b1100d7c54 | |||
| 64e381f2c1 | |||
| f6b728d56c | |||
| edd6650536 | |||
| a04dfdeb07 | |||
| 1721750d9e | |||
| a8f82af604 | |||
| 0c321a6dc6 | |||
| 08b3ddfd3e | |||
| fddc991b60 | |||
| 3337df7ca2 | |||
| 41533a8c49 | |||
| a6e1d4cf74 | |||
| 5397a93702 | |||
| b9583dde76 | |||
| f22f38f7f2 | |||
| 9e62bf8349 | |||
| f9d826c22a | |||
| 4770ec798c | |||
| 4568dd0b19 | |||
| a308b73e8a | |||
| c2a8a2c1f7 | |||
| a03af5dd73 | |||
| b50264e74d | |||
| ecdd9cc66d | |||
| 3a90454d50 | |||
| 2d81e46655 | |||
| b4963ab0fa | |||
| 432268917b | |||
| 2d06df474b | |||
| 03fc837236 | |||
| 80cf3c98db | |||
| f7b2247217 | |||
| 36c63980b9 | |||
| 0d1b5224c8 | |||
| ac81d7c883 | |||
| 78b7a1b8a9 | |||
| 12364895cb | |||
| 5012063143 | |||
| c3b0ba9d61 | |||
| 4fdbb748ec | |||
| b1730ea3da | |||
| 3865d37bc7 | |||
| f5a9d4c8e3 | |||
| 09beb5c47a | |||
| 6e03bebeb0 | |||
| a7bdf08c7e | |||
| cf198080d0 | |||
| 190a556756 | |||
| 9aa3eb56f2 | |||
| ff1a8fc59a | |||
| 7bbf712c36 | |||
| 9b985c5ce2 | |||
| d3bbd08273 | |||
| 4f8680b540 | |||
| ec95e61c04 | |||
| 6ffc9ac788 | |||
| 0e197b8723 | |||
| 3d84f57008 | |||
| a7ebb3615a | |||
| a95baeafd6 | |||
| 1ab16bac62 | |||
| 4aa61944fe | |||
| e225509210 | |||
| d1eca90216 | |||
| 020cd97915 | |||
| f0174ca08b | |||
| fed95c5da4 | |||
| a530630f1c | |||
| 00e4a56d15 | |||
| 1e6877043e | |||
| 248b18a2d0 | |||
| 7e79edc058 | |||
| 8b97dfe77e | |||
| 3eeb270ef5 | |||
| c1d75dd4f7 | |||
| dd1eb715c4 | |||
| fadca5a89d | |||
| 7e129c9b64 | |||
| 3e94c0a037 | |||
| d7feb2e9b9 | |||
| 8ba5e3fbf6 | |||
| 857c7d93a0 | |||
| b690648308 | |||
| d904b600a9 | |||
| bacb74e8ec | |||
| b1ac3289b8 | |||
| 835b86d9f7 | |||
| 94dc63af04 | |||
| 50474b6b9f | |||
| 4c3926a5c7 | |||
| 9fbcfe9ec5 | |||
| d98687afc3 | |||
| f42580be41 | |||
| 6e0e9554c6 | |||
| dc5bd4afce | |||
| c67b41c966 | |||
| 221d17b0c6 | |||
| 9a72702a61 | |||
| ebdfeb0349 | |||
| 6152fb345e | |||
| f9e1a882e8 | |||
| 681c862f54 | |||
| bb463d8d8b | |||
| 943d000ab3 | |||
| cb632b3968 | |||
| b9d4ccd254 | |||
| d6aeb16450 | |||
| a518d87cfc | |||
| 27617ec2be | |||
| 1f9cc2d327 | |||
| 9128d841f5 | |||
| ca5992b971 | |||
| ced50538fe | |||
| 1371fc446c | |||
| 7998db8397 | |||
| 39c396ab01 | |||
| 1e0c36c5cc | |||
| f34d60ca65 | |||
| 4caedfda74 | |||
| 2faeb76e2d | |||
| 75a2fbe564 | |||
| 4d95e4da74 | |||
| 802cc6bcd6 | |||
| 04bc13caf8 | |||
| c65a7dfc7c | |||
| d1cb1aa74f | |||
| be1b14f369 | |||
| 337cb553d0 | |||
| 99089bf218 | |||
| e293d4af8a | |||
| a6afaabcb0 | |||
| d508203ed8 | |||
| f1697dea15 | |||
| 6b7cb45ac8 | |||
| 1e4210401f | |||
| a04e2da1ff | |||
| 51c84f1c02 | |||
| 18a805e46c | |||
| a19336fd98 | |||
| 9ad3a1b905 | |||
| 21be19d493 | |||
| 5b8ca9ce01 | |||
| a71c03a18b | |||
| 0a02403fb0 | |||
| 9820d13840 | |||
| 326899815f | |||
| 083a97b171 | |||
| 2226987442 | |||
| bca7737463 | |||
| 6f40b09525 | |||
| 3a755de572 | |||
| 9718e58120 | |||
| 8723b8f358 | |||
| 03df73a7b0 | |||
| 3307f0941c | |||
| 54b68230ae | |||
| 32491166ac | |||
| 6f94f954bb | |||
| 90fd24d149 | |||
| 9a21a3ec8d | |||
| 3779e4255d | |||
| ec62dc547e | |||
| a9b9e1ccec | |||
| e04be7890a | |||
| ecb30132e9 | |||
| 52be1ccfb9 | |||
| 3405a6fe01 | |||
| d372729b92 | |||
| fadc2ad39f | |||
| a5607f82a3 | |||
| f4c683ac22 | |||
| 8c9c9d90da | |||
| a372bfdc60 | |||
| fe57829aca | |||
| b5c53d9e3a | |||
| f2a2d25ec0 | |||
| a706ffaf62 | |||
| 8f48e693fe | |||
| a0bf12e7a1 | |||
| 2314c04d5d | |||
| 22410f46f5 | |||
| 9559a661aa | |||
| beb524489c | |||
| 4ffb93c12b | |||
| ae06a40fe6 | |||
| 315b00065b | |||
| 6f02f7556e | |||
| fa0af88dfe | |||
| bce845bb1f | |||
| ed570b9f7c | |||
| 59b0e986bf | |||
| cffb98d15b | |||
| 3e1ba0f3b4 | |||
| d0b5bf4b7b | |||
| 7db39e66b8 | |||
| 94eb7f1dbd | |||
| 5733b77b84 | |||
| 98bebfb628 | |||
| 7c4cc9bf5f | |||
| fa885d1813 | |||
| da4614eb8b | |||
| 4dcd222d1f | |||
| 7bdd31b34b | |||
| a4b8521efe | |||
| 7037562998 | |||
| f3ff6ffc55 | |||
| e3ff87ecde | |||
| 45ac700fff | |||
| 2aab5acab4 | |||
| e9d760eea9 | |||
| d485d0a834 | |||
| 973ac4b3bd | |||
| e91a152e06 | |||
| 5217149ed4 | |||
| e7ac6b3bf1 | |||
| 9a1f4f9a0d | |||
| 07443495c8 | |||
| 729fb4d30b | |||
| 91163d2296 | |||
| 75477ade65 | |||
| 0e1638d7b5 | |||
| 19673ff01a | |||
| 1db573dd30 | |||
| 873ad336f8 | |||
| 0d41a7de7c | |||
| 1b240d3576 | |||
| 4b6a0b382c | |||
| b789a1c5f9 | |||
| a1460169e6 | |||
| abe0af76c5 | |||
| 8e636436f8 | |||
| 8c33523b15 | |||
| 81c2e6b6ca | |||
| ba11f5ae15 | |||
| d92ca21bcc | |||
| 487f381ae9 | |||
| d506dae914 | |||
| 7a89920441 | |||
| 382f1ba3c7 | |||
| ae41e58ca3 | |||
| 72919adf55 | |||
| 1507fcd36d | |||
| b1ce042535 | |||
| 9b78bd459b | |||
| c225a55344 | |||
| 555fb5c3a0 | |||
| 2160bb2bcc | |||
| 946d3260d7 | |||
| 2f3821ca98 | |||
| 980c4cb0ce | |||
| 670a3e952a | |||
| 5b7f931cd7 | |||
| ff6e6bdfd5 | |||
| a84c1af98a | |||
| 3e0179fd6e | |||
| 6c8600ab52 | |||
| 174f2c1fe7 | |||
| 11f98f1cc6 | |||
| 464bb70114 | |||
| 781fb4d093 | |||
| b113c37819 | |||
| 6f44e89b7f | |||
| b929eb94a0 | |||
| a7b8879494 | |||
| 81f5348ea9 | |||
| 620c58abec | |||
| d2e037396e | |||
| 1cde7fbfc0 | |||
| 9585797b41 | |||
| 441a230509 | |||
| e06104d77c | |||
| 67f49d96d9 | |||
| 820f45b10b | |||
| 9a1a3974c6 | |||
| e76521c0e9 | |||
| b952bc594f | |||
| 24b0663828 | |||
| 5139ebf7ba | |||
| b51a32ae14 | |||
| 69ef85526a | |||
| de1c6171ee | |||
| 9245f9253a | |||
| b3a5a519f2 | |||
| 9d0e0c6a48 | |||
| f9c0725684 | |||
| a6d5902ebf | |||
| 2768927782 | |||
| 5c54431b3b | |||
| 7214ffc107 | |||
| d98f9d8713 | |||
| 27bd791ea0 | |||
| 5a2a317d62 | |||
| f8d81fff8c | |||
| 043bbddcf0 | |||
| 9969ff512e | |||
| 14cdec770c | |||
| 6e4317e37c | |||
| 907be0660c | |||
| 3ed09b89f8 | |||
| 1406b84016 | |||
| c175be7d4c | |||
| 9d403d08f0 | |||
| 45322566c7 | |||
| a45f083e00 | |||
| 5c0db0d21b | |||
| 80db86e771 | |||
| b16f958660 | |||
| ec2ecad197 | |||
| 813817f1ab | |||
| d45bb667b6 | |||
| cc87c83b01 | |||
| 09d7ab365f | |||
| 2eab1e025e | |||
| 2e2c489e29 | |||
| f3a2c8497a | |||
| 771cc6fa25 | |||
| ef630abeee | |||
| cadc04ce47 | |||
| 4cfa233888 | |||
| 03e6b5b991 | |||
| c0c55fe50b | |||
| a8a0fb41cb | |||
| 6c2946bf58 | |||
| 115cf601e9 | |||
| 2a0ddc8cb2 | |||
| dacc631968 | |||
| d98007b0be | |||
| ed488e5197 | |||
| 2be40919de | |||
| 2ccbfeff47 | |||
| 901d16a96f | |||
| d56b54b34f | |||
| f7358701f2 | |||
| 4c5a488f68 | |||
| 8180a85a3b | |||
| 121c2e577f | |||
| c1966ba3fc | |||
| 852e5b63e5 | |||
| b6a0ef207b | |||
| ed6c294749 | |||
| 07d4cac48f | |||
| 2b8628922f | |||
| 0683cbf859 | |||
| 5f8252ee6f | |||
| ff99f85a6d | |||
| 0d5a97bffe | |||
| 6c193d6fbd | |||
| d076252dff | |||
| 2e27c5d9c3 | |||
| 72b443375c | |||
| 43ea59a4ed | |||
| 01ef70a6f9 | |||
| c63ebbd878 | |||
| 11706abbb7 | |||
| 49a75b2d78 | |||
| a224c7818b | |||
| 8fca02fb2a | |||
| de29068110 | |||
| 4e435b1321 | |||
| 873dbc2421 | |||
| 31f7db5a0d | |||
| a3961d047f | |||
| 8ae7b48188 | |||
| bcbca461de | |||
| 4ed7f62431 | |||
| e22eea26b1 | |||
| 110a7f06a8 | |||
| bb55b0ba91 |
+243
-38
@@ -1,77 +1,282 @@
|
||||
###
|
||||
### CMake settings
|
||||
###
|
||||
## Due to Mac OSX we need to keep compatibility with CMake 2.6
|
||||
# see http://www.cmake.org/Wiki/CMake_Policies
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
# see http://www.cmake.org/cmake/help/cmake-2-8-docs.html#policy:CMP0012
|
||||
if(POLICY CMP0012)
|
||||
cmake_policy(SET CMP0012 OLD)
|
||||
endif()
|
||||
# see http://www.cmake.org/cmake/help/cmake-2-8-docs.html#policy:CMP0015
|
||||
if(POLICY CMP0015)
|
||||
cmake_policy(SET CMP0015 OLD)
|
||||
endif()
|
||||
|
||||
project (YAML_CPP)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
set(LIB_TYPE SHARED)
|
||||
|
||||
if(IPHONE)
|
||||
set(CMAKE_OSX_SYSROOT iphoneos2.2.1)
|
||||
set(LIB_TYPE)
|
||||
endif(IPHONE)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set(CMAKE_CXX_FLAGS "-O2 -Wall -Wextra -pedantic -Wno-long-long ${CMAKE_CXX_FLAGS}")
|
||||
endif(CMAKE_COMPILER_IS_GNUCC)
|
||||
|
||||
if(MSVC)
|
||||
set(LIB_TYPE) # I can't figure out how CMake handles Windows shared libraries
|
||||
set(CMAKE_CXX_FLAGS "/W3 /wd4127 /wd4355 /D_SCL_SECURE_NO_WARNINGS ${CMAKE_CXX_FLAGS}")
|
||||
endif(MSVC)
|
||||
###
|
||||
### Project settings
|
||||
###
|
||||
project(YAML_CPP)
|
||||
|
||||
set(YAML_CPP_VERSION_MAJOR "0")
|
||||
set(YAML_CPP_VERSION_MINOR "2")
|
||||
set(YAML_CPP_VERSION_PATCH "5")
|
||||
set(YAML_CPP_VERSION_MINOR "3")
|
||||
set(YAML_CPP_VERSION_PATCH "0")
|
||||
set(YAML_CPP_VERSION "${YAML_CPP_VERSION_MAJOR}.${YAML_CPP_VERSION_MINOR}.${YAML_CPP_VERSION_PATCH}")
|
||||
|
||||
enable_testing()
|
||||
|
||||
option(YAML_CPP_BUILD_TOOLS "Enables or disables testing and parse tools" true)
|
||||
|
||||
###
|
||||
### Project options
|
||||
###
|
||||
## Project stuff
|
||||
option(YAML_CPP_BUILD_TOOLS "Enable testing and parse tools" ON)
|
||||
option(YAML_CPP_BUILD_CONTRIB "Enable contrib stuff in library" ON)
|
||||
|
||||
## Build options
|
||||
# --> General
|
||||
# see http://www.cmake.org/cmake/help/cmake2.6docs.html#variable:BUILD_SHARED_LIBS
|
||||
# http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_library
|
||||
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
|
||||
|
||||
# --> Apple
|
||||
option(APPLE_UNIVERSAL_BIN "Apple: Build universal binary" OFF)
|
||||
|
||||
# --> Microsoft Visual C++
|
||||
# see http://msdn.microsoft.com/en-us/library/aa278396(v=VS.60).aspx
|
||||
# http://msdn.microsoft.com/en-us/library/2kzt1wy3(v=VS.71).aspx
|
||||
option(MSVC_SHARED_RT "MSVC: Build with shared runtime libs (/MD)" ON)
|
||||
option(MSVC_STHREADED_RT "MSVC: Build with single-threaded static runtime libs (/ML until VS .NET 2003)" OFF)
|
||||
|
||||
###
|
||||
### Sources, headers, directories and libs
|
||||
###
|
||||
set(header_directory "include/yaml-cpp/")
|
||||
|
||||
file(GLOB sources "src/[a-zA-Z]*.cpp")
|
||||
file(GLOB public_headers "include/yaml-cpp/[a-zA-Z]*.h")
|
||||
file(GLOB private_headers "src/[a-zA-Z]*.h")
|
||||
|
||||
if(YAML_CPP_BUILD_CONTRIB)
|
||||
file(GLOB contrib_sources "src/contrib/[a-zA-Z]*.cpp")
|
||||
file(GLOB contrib_public_headers "include/yaml-cpp/contrib/[a-zA-Z]*.h")
|
||||
file(GLOB contrib_private_headers "src/contrib/[a-zA-Z]*.h")
|
||||
else()
|
||||
add_definitions(-DYAML_CPP_NO_CONTRIB)
|
||||
endif()
|
||||
|
||||
if(VERBOSE)
|
||||
message(STATUS "sources: ${sources}")
|
||||
message(STATUS "public_headers: ${public_headers}")
|
||||
message(STATUS "private_headers: ${private_headers}")
|
||||
message(STATUS "contrib_sources: ${contrib_sources}")
|
||||
message(STATUS "contrib_public_headers: ${contrib_public_headers}")
|
||||
message(STATUS "contrib_private_headers: ${contrib_private_headers}")
|
||||
endif()
|
||||
|
||||
include_directories(${YAML_CPP_SOURCE_DIR}/include)
|
||||
include_directories(${YAML_CPP_SOURCE_DIR}/src)
|
||||
|
||||
|
||||
###
|
||||
### General compilation settings
|
||||
###
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(LABEL_SUFFIX "shared")
|
||||
else()
|
||||
set(LABEL_SUFFIX "static")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
if(APPLE_UNIVERSAL_BIN)
|
||||
set(CMAKE_OSX_ARCHITECTURES ppc;i386)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(IPHONE)
|
||||
set(CMAKE_OSX_SYSROOT "iphoneos4.2")
|
||||
set(CMAKE_OSX_ARCHITECTURES "armv6;armv7")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(_library_dir bin) # .dll are in PATH, like executables
|
||||
else(WIN32)
|
||||
set(_library_dir lib)
|
||||
endif(WIN32)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_definitions(-D${PROJECT_NAME}_DLL) # use or build Windows DLL
|
||||
endif()
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "C:/")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(INCLUDE_INSTALL_DIR include/yaml-cpp)
|
||||
set(LIB_INSTALL_DIR ${_library_dir}${LIB_SUFFIX})
|
||||
# GCC specialities
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
### General stuff
|
||||
if(WIN32)
|
||||
set(CMAKE_SHARED_LIBRARY_PREFIX "") # DLLs do not have a "lib" prefix
|
||||
set(CMAKE_IMPORT_LIBRARY_PREFIX "") # same for DLL import libs
|
||||
set(CMAKE_LINK_DEF_FILE_FLAG "") # CMake workaround (2.8.3)
|
||||
endif()
|
||||
|
||||
### Project stuff
|
||||
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
#
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
|
||||
#
|
||||
set(GCC_EXTRA_OPTIONS "")
|
||||
#
|
||||
set(FLAG_TESTED "-Wextra")
|
||||
check_cxx_compiler_flag(${FLAG_TESTED} FLAG_WEXTRA)
|
||||
if(FLAG_WEXTRA)
|
||||
set(GCC_EXTRA_OPTIONS "${GCC_EXTRA_OPTIONS} ${FLAG_TESTED}")
|
||||
endif()
|
||||
#
|
||||
set(CMAKE_CXX_FLAGS "-Wall ${GCC_EXTRA_OPTIONS} -pedantic -Wno-long-long ${CMAKE_CXX_FLAGS}")
|
||||
#
|
||||
add_custom_target(debuggable $(MAKE) clean
|
||||
COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR}
|
||||
COMMENT "Adjusting settings for debug compilation"
|
||||
VERBATIM)
|
||||
add_custom_target(releasable $(MAKE) clean
|
||||
COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
|
||||
COMMENT "Adjusting settings for release compilation"
|
||||
VERBATIM)
|
||||
endif()
|
||||
|
||||
# Microsoft VisualC++ specialities
|
||||
if(MSVC)
|
||||
### General stuff
|
||||
# a) Change MSVC runtime library settings (/MD[d], /MT[d], /ML[d] (single-threaded until VS 2003))
|
||||
# plus set lib suffix for later use and project label accordingly
|
||||
# see http://msdn.microsoft.com/en-us/library/aa278396(v=VS.60).aspx
|
||||
# http://msdn.microsoft.com/en-us/library/2kzt1wy3(v=VS.71).aspx
|
||||
set(LIB_RT_SUFFIX "md") # CMake defaults to /MD for MSVC
|
||||
set(LIB_RT_OPTION "/MD")
|
||||
#
|
||||
if(NOT MSVC_SHARED_RT) # User wants to have static runtime libraries (/MT, /ML)
|
||||
if(MSVC_STHREADED_RT) # User wants to have old single-threaded static runtime libraries
|
||||
set(LIB_RT_SUFFIX "ml")
|
||||
set(LIB_RT_OPTION "/ML")
|
||||
if(NOT ${MSVC_VERSION} LESS 1400)
|
||||
message(FATAL_ERROR "Single-threaded static runtime libraries (/ML) only available until VS .NET 2003 (7.1).")
|
||||
endif()
|
||||
else()
|
||||
set(LIB_RT_SUFFIX "mt")
|
||||
set(LIB_RT_OPTION "/MT")
|
||||
endif()
|
||||
|
||||
# correct linker options
|
||||
foreach(flag_var CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
||||
foreach(config_name "" DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
|
||||
set(var_name "${flag_var}")
|
||||
if(NOT "${config_name}" STREQUAL "")
|
||||
set(var_name "${var_name}_${config_name}")
|
||||
endif()
|
||||
string(REPLACE "/MD" "${LIB_RT_OPTION}" ${var_name} "${${var_name}}")
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
#
|
||||
set(LABEL_SUFFIX "${LABEL_SUFFIX} ${LIB_RT_SUFFIX}")
|
||||
|
||||
# b) Change prefix for static libraries
|
||||
set(CMAKE_STATIC_LIBRARY_PREFIX "lib") # to distinguish static libraries from DLL import libs
|
||||
|
||||
# c) Correct suffixes for static libraries
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
### General stuff
|
||||
set(LIB_TARGET_SUFFIX "${LIB_SUFFIX}${LIB_RT_SUFFIX}")
|
||||
endif()
|
||||
|
||||
### Project stuff
|
||||
# /W3 = set warning level; see http://msdn.microsoft.com/en-us/library/thxezb7y.aspx
|
||||
# /wd4127 = disable warning C4127 "conditional expression is constant"; see http://msdn.microsoft.com/en-us/library/6t66728h.aspx
|
||||
# /wd4355 = disable warning C4355 "'this' : used in base member initializer list"; http://msdn.microsoft.com/en-us/library/3c594ae3.aspx
|
||||
set(CMAKE_CXX_FLAGS "/W3 /wd4127 /wd4355 /D_SCL_SECURE_NO_WARNINGS ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
|
||||
|
||||
###
|
||||
### General install settings
|
||||
###
|
||||
if(WIN32)
|
||||
set(_library_dir bin) # .dll are in PATH, like executables
|
||||
else()
|
||||
set(_library_dir lib)
|
||||
endif()
|
||||
|
||||
set(INCLUDE_INSTALL_ROOT_DIR include)
|
||||
|
||||
set(INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_ROOT_DIR}/yaml-cpp)
|
||||
set(LIB_INSTALL_DIR "${_library_dir}${LIB_SUFFIX}")
|
||||
|
||||
#
|
||||
set(_INSTALL_DESTINATIONS
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX}
|
||||
ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
|
||||
)
|
||||
#
|
||||
file(GLOB public_headers include/[a-z]*.h)
|
||||
file(GLOB private_headers src/[a-z]*.h)
|
||||
file(GLOB sources src/[a-z]*.cpp)
|
||||
|
||||
include_directories(${YAML_CPP_SOURCE_DIR}/include)
|
||||
|
||||
###
|
||||
### Library
|
||||
###
|
||||
add_library(yaml-cpp
|
||||
${LIB_TYPE}
|
||||
${sources}
|
||||
${public_headers}
|
||||
${private_headers}
|
||||
${sources}
|
||||
${contrib_sources}
|
||||
${contrib_public_headers}
|
||||
${contrib_private_headers}
|
||||
)
|
||||
|
||||
set_target_properties(yaml-cpp PROPERTIES
|
||||
VERSION "${YAML_CPP_VERSION}"
|
||||
SOVERSION "${YAML_CPP_VERSION_MAJOR}.${YAML_CPP_VERSION_MINOR}"
|
||||
PROJECT_LABEL "yaml-cpp ${LABEL_SUFFIX}"
|
||||
)
|
||||
|
||||
if(IPHONE)
|
||||
set_target_properties(yaml-cpp PROPERTIES
|
||||
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "3.0"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
# correct library names
|
||||
set_target_properties(yaml-cpp PROPERTIES
|
||||
DEBUG_POSTFIX "${LIB_TARGET_SUFFIX}d"
|
||||
RELEASE_POSTFIX "${LIB_TARGET_SUFFIX}"
|
||||
MINSIZEREL_POSTFIX "${LIB_TARGET_SUFFIX}"
|
||||
RELWITHDEBINFO_POSTFIX "${LIB_TARGET_SUFFIX}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(TARGETS yaml-cpp ${_INSTALL_DESTINATIONS})
|
||||
install(
|
||||
FILES ${public_headers}
|
||||
DIRECTORY ${header_directory}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
set(PC_FILE ${CMAKE_BINARY_DIR}/yaml-cpp.pc)
|
||||
configure_file("yaml-cpp.pc.cmake" ${PC_FILE} @ONLY)
|
||||
install(FILES ${PC_FILE} DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
|
||||
endif(UNIX)
|
||||
endif()
|
||||
|
||||
|
||||
###
|
||||
### Extras
|
||||
###
|
||||
if(YAML_CPP_BUILD_TOOLS)
|
||||
add_subdirectory (test)
|
||||
add_subdirectory (util)
|
||||
endif(YAML_CPP_BUILD_TOOLS)
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(util)
|
||||
endif()
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
|
||||
#include "null.h"
|
||||
#include "traits.h"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
inline bool Convert(const std::string& input, std::string& output) {
|
||||
output = input;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Convert(const std::string& input, bool& output);
|
||||
bool Convert(const std::string& input, _Null& output);
|
||||
|
||||
template <typename T>
|
||||
inline bool Convert(const std::string& input, T& output, typename enable_if<is_numeric<T> >::type * = 0) {
|
||||
std::stringstream stream(input);
|
||||
stream.unsetf(std::ios::dec);
|
||||
stream >> output;
|
||||
return !!stream;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,161 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
|
||||
#include "mark.h"
|
||||
#include "traits.h"
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
// error messages
|
||||
namespace ErrorMsg
|
||||
{
|
||||
const std::string YAML_DIRECTIVE_ARGS = "YAML directives must have exactly one argument";
|
||||
const std::string YAML_VERSION = "bad YAML version: ";
|
||||
const std::string YAML_MAJOR_VERSION = "YAML major version too large";
|
||||
const std::string REPEATED_YAML_DIRECTIVE= "repeated YAML directive";
|
||||
const std::string TAG_DIRECTIVE_ARGS = "TAG directives must have exactly two arguments";
|
||||
const std::string REPEATED_TAG_DIRECTIVE = "repeated TAG directive";
|
||||
const std::string CHAR_IN_TAG_HANDLE = "illegal character found while scanning tag handle";
|
||||
const std::string TAG_WITH_NO_SUFFIX = "tag handle with no suffix";
|
||||
const std::string END_OF_VERBATIM_TAG = "end of verbatim tag not found";
|
||||
const std::string END_OF_MAP = "end of map not found";
|
||||
const std::string END_OF_MAP_FLOW = "end of map flow not found";
|
||||
const std::string END_OF_SEQ = "end of sequence not found";
|
||||
const std::string END_OF_SEQ_FLOW = "end of sequence flow not found";
|
||||
const std::string MULTIPLE_TAGS = "cannot assign multiple tags to the same node";
|
||||
const std::string MULTIPLE_ANCHORS = "cannot assign multiple anchors to the same node";
|
||||
const std::string MULTIPLE_ALIASES = "cannot assign multiple aliases to the same node";
|
||||
const std::string ALIAS_CONTENT = "aliases can't have any content, *including* tags";
|
||||
const std::string INVALID_HEX = "bad character found while scanning hex number";
|
||||
const std::string INVALID_UNICODE = "invalid unicode: ";
|
||||
const std::string INVALID_ESCAPE = "unknown escape character: ";
|
||||
const std::string UNKNOWN_TOKEN = "unknown token";
|
||||
const std::string DOC_IN_SCALAR = "illegal document indicator in scalar";
|
||||
const std::string EOF_IN_SCALAR = "illegal EOF in scalar";
|
||||
const std::string CHAR_IN_SCALAR = "illegal character in scalar";
|
||||
const std::string TAB_IN_INDENTATION = "illegal tab when looking for indentation";
|
||||
const std::string FLOW_END = "illegal flow end";
|
||||
const std::string BLOCK_ENTRY = "illegal block entry";
|
||||
const std::string MAP_KEY = "illegal map key";
|
||||
const std::string MAP_VALUE = "illegal map value";
|
||||
const std::string ALIAS_NOT_FOUND = "alias not found after *";
|
||||
const std::string ANCHOR_NOT_FOUND = "anchor not found after &";
|
||||
const std::string CHAR_IN_ALIAS = "illegal character found while scanning alias";
|
||||
const std::string CHAR_IN_ANCHOR = "illegal character found while scanning anchor";
|
||||
const std::string ZERO_INDENT_IN_BLOCK = "cannot set zero indentation for a block scalar";
|
||||
const std::string CHAR_IN_BLOCK = "unexpected character in block scalar";
|
||||
const std::string AMBIGUOUS_ANCHOR = "cannot assign the same alias to multiple nodes";
|
||||
const std::string UNKNOWN_ANCHOR = "the referenced anchor is not defined";
|
||||
|
||||
const std::string INVALID_SCALAR = "invalid scalar";
|
||||
const std::string KEY_NOT_FOUND = "key not found";
|
||||
const std::string BAD_DEREFERENCE = "bad dereference";
|
||||
|
||||
const std::string UNMATCHED_GROUP_TAG = "unmatched group tag";
|
||||
const std::string UNEXPECTED_END_SEQ = "unexpected end sequence token";
|
||||
const std::string UNEXPECTED_END_MAP = "unexpected end map token";
|
||||
const std::string SINGLE_QUOTED_CHAR = "invalid character in single-quoted string";
|
||||
const std::string INVALID_ANCHOR = "invalid anchor";
|
||||
const std::string INVALID_ALIAS = "invalid alias";
|
||||
const std::string INVALID_TAG = "invalid tag";
|
||||
const std::string EXPECTED_KEY_TOKEN = "expected key token";
|
||||
const std::string EXPECTED_VALUE_TOKEN = "expected value token";
|
||||
const std::string UNEXPECTED_KEY_TOKEN = "unexpected key token";
|
||||
const std::string UNEXPECTED_VALUE_TOKEN = "unexpected value token";
|
||||
|
||||
template <typename T>
|
||||
inline const std::string KEY_NOT_FOUND_WITH_KEY(const T&, typename disable_if<is_numeric<T> >::type * = 0) {
|
||||
return KEY_NOT_FOUND;
|
||||
}
|
||||
|
||||
inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) {
|
||||
return KEY_NOT_FOUND + ": " + key;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const std::string KEY_NOT_FOUND_WITH_KEY(const T& key, typename enable_if<is_numeric<T> >::type * = 0) {
|
||||
std::stringstream stream;
|
||||
stream << KEY_NOT_FOUND << ": " << key;
|
||||
return stream.str();
|
||||
}
|
||||
}
|
||||
|
||||
class Exception: public std::exception {
|
||||
public:
|
||||
Exception(const Mark& mark_, const std::string& msg_)
|
||||
: mark(mark_), msg(msg_) {
|
||||
std::stringstream output;
|
||||
output << "yaml-cpp: error at line " << mark.line+1 << ", column " << mark.column+1 << ": " << msg;
|
||||
what_ = output.str();
|
||||
}
|
||||
virtual ~Exception() throw() {}
|
||||
virtual const char *what() const throw() { return what_.c_str(); }
|
||||
|
||||
Mark mark;
|
||||
std::string msg;
|
||||
|
||||
private:
|
||||
std::string what_;
|
||||
};
|
||||
|
||||
class ParserException: public Exception {
|
||||
public:
|
||||
ParserException(const Mark& mark_, const std::string& msg_)
|
||||
: Exception(mark_, msg_) {}
|
||||
};
|
||||
|
||||
class RepresentationException: public Exception {
|
||||
public:
|
||||
RepresentationException(const Mark& mark_, const std::string& msg_)
|
||||
: Exception(mark_, msg_) {}
|
||||
};
|
||||
|
||||
// representation exceptions
|
||||
class InvalidScalar: public RepresentationException {
|
||||
public:
|
||||
InvalidScalar(const Mark& mark_)
|
||||
: RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {}
|
||||
};
|
||||
|
||||
class KeyNotFound: public RepresentationException {
|
||||
public:
|
||||
template <typename T>
|
||||
KeyNotFound(const Mark& mark_, const T& key_)
|
||||
: RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class TypedKeyNotFound: public KeyNotFound {
|
||||
public:
|
||||
TypedKeyNotFound(const Mark& mark_, const T& key_)
|
||||
: KeyNotFound(mark_, key_), key(key_) {}
|
||||
virtual ~TypedKeyNotFound() throw() {}
|
||||
|
||||
T key;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline TypedKeyNotFound <T> MakeTypedKeyNotFound(const Mark& mark, const T& key) {
|
||||
return TypedKeyNotFound <T> (mark, key);
|
||||
}
|
||||
|
||||
class BadDereference: public RepresentationException {
|
||||
public:
|
||||
BadDereference()
|
||||
: RepresentationException(Mark::null(), ErrorMsg::BAD_DEREFERENCE) {}
|
||||
};
|
||||
|
||||
class EmitterException: public Exception {
|
||||
public:
|
||||
EmitterException(const std::string& msg_)
|
||||
: Exception(Mark::null(), msg_) {}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,118 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
|
||||
#include "nodeutil.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
// implementation of templated things
|
||||
template <typename T>
|
||||
inline const T Node::Read() const {
|
||||
T value;
|
||||
*this >> value;
|
||||
return value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Node::operator T() const {
|
||||
return Read<T>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void operator >> (const Node& node, T& value) {
|
||||
if(!ConvertScalar(node, value))
|
||||
throw InvalidScalar(node.m_mark);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const Node *Node::FindValue(const T& key) const {
|
||||
switch(GetType()) {
|
||||
case CT_MAP:
|
||||
return FindValueForKey(key);
|
||||
case CT_SEQUENCE:
|
||||
return FindFromNodeAtIndex(*this, key);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const Node *Node::FindValueForKey(const T& key) const {
|
||||
for(Iterator it=begin();it!=end();++it) {
|
||||
T t;
|
||||
if(it.first().Read(t)) {
|
||||
if(key == t)
|
||||
return &it.second();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const Node& Node::GetValue(const T& key) const {
|
||||
if(!m_pContent)
|
||||
throw BadDereference();
|
||||
|
||||
const Node *pValue = FindValue(key);
|
||||
if(!pValue)
|
||||
throw MakeTypedKeyNotFound(m_mark, key);
|
||||
|
||||
return *pValue;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const Node& Node::operator [] (const T& key) const {
|
||||
return GetValue(key);
|
||||
}
|
||||
|
||||
inline const Node *Node::FindValue(const char *key) const {
|
||||
return FindValue(std::string(key));
|
||||
}
|
||||
|
||||
inline const Node& Node::operator [] (const char *key) const {
|
||||
return GetValue(std::string(key));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool operator == (const T& value, const Node& node) {
|
||||
return value == node.operator T();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool operator == (const Node& node, const T& value) {
|
||||
return value == node.operator T();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool operator != (const T& value, const Node& node) {
|
||||
return value != node.operator T();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool operator != (const Node& node, const T& value) {
|
||||
return value != node.operator T();
|
||||
}
|
||||
|
||||
inline bool operator == (const char *value, const Node& node) {
|
||||
return std::string(value) == node;
|
||||
}
|
||||
|
||||
inline bool operator == (const Node& node, const char *value) {
|
||||
return std::string(value) == node;
|
||||
}
|
||||
|
||||
inline bool operator != (const char *value, const Node& node) {
|
||||
return std::string(value) != node;
|
||||
}
|
||||
|
||||
inline bool operator != (const Node& node, const char *value) {
|
||||
return std::string(value) != node;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NODEPROPERTIES_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEPROPERTIES_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
struct NodeProperties {
|
||||
std::string tag;
|
||||
std::string anchor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NODEPROPERTIES_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,22 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
// this is basically boost::noncopyable
|
||||
class noncopyable
|
||||
{
|
||||
protected:
|
||||
noncopyable() {}
|
||||
~noncopyable() {}
|
||||
|
||||
private:
|
||||
noncopyable(const noncopyable&);
|
||||
const noncopyable& operator = (const noncopyable&);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,44 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
template <typename T>
|
||||
inline Emitter& operator << (Emitter& emitter, const std::vector <T>& v) {
|
||||
typedef typename std::vector <T> vec;
|
||||
emitter << BeginSeq;
|
||||
for(typename vec::const_iterator it=v.begin();it!=v.end();++it)
|
||||
emitter << *it;
|
||||
emitter << EndSeq;
|
||||
return emitter;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline Emitter& operator << (Emitter& emitter, const std::list <T>& v) {
|
||||
typedef typename std::list <T> list;
|
||||
emitter << BeginSeq;
|
||||
for(typename list::const_iterator it=v.begin();it!=v.end();++it)
|
||||
emitter << *it;
|
||||
emitter << EndSeq;
|
||||
return emitter;
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
inline Emitter& operator << (Emitter& emitter, const std::map <K, V>& m) {
|
||||
typedef typename std::map <K, V> map;
|
||||
emitter << BeginMap;
|
||||
for(typename map::const_iterator it=m.begin();it!=m.end();++it)
|
||||
emitter << Key << it->first << Value << it->second;
|
||||
emitter << EndMap;
|
||||
return emitter;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef ALIASMANAGER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ALIASMANAGER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#include "anchor.h"
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/anchor.h"
|
||||
#include <map>
|
||||
|
||||
namespace YAML
|
||||
@@ -16,18 +18,12 @@ namespace YAML
|
||||
AliasManager();
|
||||
|
||||
void RegisterReference(const Node& node);
|
||||
|
||||
const Node *LookupReference(const Node& node) const;
|
||||
anchor_t LookupAnchor(const Node& node) const;
|
||||
|
||||
private:
|
||||
const Node *_LookupReference(const Node& oldIdentity) const;
|
||||
anchor_t _CreateNewAnchor();
|
||||
|
||||
private:
|
||||
typedef std::map<const Node*, const Node*> NodeByNode;
|
||||
NodeByNode m_newIdentityByOldIdentity;
|
||||
|
||||
typedef std::map<const Node*, anchor_t> AnchorByIdentity;
|
||||
AnchorByIdentity m_anchorByIdentity;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace YAML
|
||||
@@ -0,0 +1,66 @@
|
||||
#ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
|
||||
std::string EncodeBase64(const unsigned char *data, std::size_t size);
|
||||
std::vector<unsigned char> DecodeBase64(const std::string& input);
|
||||
|
||||
class Binary {
|
||||
public:
|
||||
Binary(): m_unownedData(0), m_unownedSize(0) {}
|
||||
Binary(const unsigned char *data, std::size_t size): m_unownedData(data), m_unownedSize(size) {}
|
||||
|
||||
bool owned() const { return !m_unownedData; }
|
||||
std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; }
|
||||
const unsigned char *data() const { return owned() ? &m_data[0] : m_unownedData; }
|
||||
|
||||
void swap(std::vector<unsigned char>& rhs) {
|
||||
if(m_unownedData) {
|
||||
m_data.swap(rhs);
|
||||
rhs.clear();
|
||||
rhs.resize(m_unownedSize);
|
||||
std::copy(m_unownedData, m_unownedData + m_unownedSize, &rhs[0]);
|
||||
m_unownedData = 0;
|
||||
m_unownedSize = 0;
|
||||
} else {
|
||||
m_data.swap(rhs);
|
||||
}
|
||||
}
|
||||
|
||||
bool operator == (const Binary& rhs) const {
|
||||
const std::size_t s = size();
|
||||
if(s != rhs.size())
|
||||
return false;
|
||||
const unsigned char *d1 = data();
|
||||
const unsigned char *d2 = rhs.data();
|
||||
for(std::size_t i=0;i<s;i++) {
|
||||
if(*d1++ != *d2++)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator != (const Binary& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<unsigned char> m_data;
|
||||
const unsigned char *m_unownedData;
|
||||
std::size_t m_unownedSize;
|
||||
};
|
||||
|
||||
void operator >> (const Node& node, Binary& binary);
|
||||
}
|
||||
|
||||
#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "anchor.h"
|
||||
#include "../anchor.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
@@ -1,11 +1,16 @@
|
||||
#ifndef GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/mark.h"
|
||||
#include <string>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
struct Mark;
|
||||
class Parser;
|
||||
|
||||
// GraphBuilderInterface
|
||||
// . Abstraction of node creation
|
||||
@@ -15,7 +20,7 @@ namespace YAML
|
||||
{
|
||||
public:
|
||||
// Create and return a new node with a null value.
|
||||
virtual void *NewNull(const std::string& tag, void *pParentNode) = 0;
|
||||
virtual void *NewNull(const Mark& mark, void *pParentNode) = 0;
|
||||
|
||||
// Create and return a new node with the given tag and value.
|
||||
virtual void *NewScalar(const Mark& mark, const std::string& tag, void *pParentNode, const std::string& value) = 0;
|
||||
@@ -69,8 +74,8 @@ namespace YAML
|
||||
|
||||
GraphBuilderInterface& AsBuilderInterface() {return *this;}
|
||||
|
||||
virtual void *NewNull(const std::string& tag, void* pParentNode) {
|
||||
return CheckType<Node>(m_impl.NewNull(tag, AsNode(pParentNode)));
|
||||
virtual void *NewNull(const Mark& mark, void* pParentNode) {
|
||||
return CheckType<Node>(m_impl.NewNull(mark, AsNode(pParentNode)));
|
||||
}
|
||||
|
||||
virtual void *NewScalar(const Mark& mark, const std::string& tag, void *pParentNode, const std::string& value) {
|
||||
@@ -112,6 +117,17 @@ namespace YAML
|
||||
static Sequence *AsSequence(void *pSeq) {return static_cast<Sequence*>(pSeq);}
|
||||
static Map *AsMap(void *pMap) {return static_cast<Map*>(pMap);}
|
||||
};
|
||||
|
||||
void *BuildGraphOfNextDocument(Parser& parser, GraphBuilderInterface& graphBuilder);
|
||||
|
||||
template <class Impl>
|
||||
typename Impl::Node *BuildGraphOfNextDocument(Parser& parser, Impl& impl)
|
||||
{
|
||||
GraphBuilder<Impl> graphBuilder(impl);
|
||||
return static_cast<typename Impl::Node *>(BuildGraphOfNextDocument(
|
||||
parser, graphBuilder
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -0,0 +1,75 @@
|
||||
#ifndef CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "yaml-cpp/null.h"
|
||||
#include "yaml-cpp/traits.h"
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
// traits for conversion
|
||||
|
||||
template<typename T>
|
||||
struct is_scalar_convertible { enum { value = is_numeric<T>::value }; };
|
||||
|
||||
template<> struct is_scalar_convertible<std::string> { enum { value = true }; };
|
||||
template<> struct is_scalar_convertible<bool> { enum { value = true }; };
|
||||
template<> struct is_scalar_convertible<_Null> { enum { value = true }; };
|
||||
|
||||
// actual conversion
|
||||
|
||||
inline bool Convert(const std::string& input, std::string& output) {
|
||||
output = input;
|
||||
return true;
|
||||
}
|
||||
|
||||
YAML_CPP_API bool Convert(const std::string& input, bool& output);
|
||||
YAML_CPP_API bool Convert(const std::string& input, _Null& output);
|
||||
|
||||
inline bool IsInfinity(const std::string& input) {
|
||||
return input == ".inf" || input == ".Inf" || input == ".INF" || input == "+.inf" || input == "+.Inf" || input == "+.INF";
|
||||
}
|
||||
|
||||
inline bool IsNegativeInfinity(const std::string& input) {
|
||||
return input == "-.inf" || input == "-.Inf" || input == "-.INF";
|
||||
}
|
||||
|
||||
inline bool IsNaN(const std::string& input) {
|
||||
return input == ".nan" || input == ".NaN" || input == ".NAN";
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline bool Convert(const std::string& input, T& output, typename enable_if<is_numeric<T> >::type * = 0) {
|
||||
std::stringstream stream(input);
|
||||
stream.unsetf(std::ios::dec);
|
||||
if((stream >> output) && (stream >> std::ws).eof())
|
||||
return true;
|
||||
|
||||
if(std::numeric_limits<T>::has_infinity) {
|
||||
if(IsInfinity(input)) {
|
||||
output = std::numeric_limits<T>::infinity();
|
||||
return true;
|
||||
} else if(IsNegativeInfinity(input)) {
|
||||
output = -std::numeric_limits<T>::infinity();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(std::numeric_limits<T>::has_quiet_NaN && IsNaN(input)) {
|
||||
output = std::numeric_limits<T>::quiet_NaN();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// The following ifdef block is the standard way of creating macros which make exporting
|
||||
// from a DLL simpler. All files within this DLL are compiled with the yaml_cpp_EXPORTS
|
||||
// symbol defined on the command line. this symbol should not be defined on any project
|
||||
// that uses this DLL. This way any other project whose source files include this file see
|
||||
// YAML_CPP_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
#undef YAML_CPP_API
|
||||
|
||||
#ifdef YAML_CPP_DLL // Using or Building YAML-CPP DLL (definition defined manually)
|
||||
#ifdef yaml_cpp_EXPORTS // Building YAML-CPP DLL (definition created by CMake or defined manually)
|
||||
// #pragma message( "Defining YAML_CPP_API for DLL export" )
|
||||
#define YAML_CPP_API __declspec(dllexport)
|
||||
#else // yaml_cpp_EXPORTS
|
||||
// #pragma message( "Defining YAML_CPP_API for DLL import" )
|
||||
#define YAML_CPP_API __declspec(dllimport)
|
||||
#endif // yaml_cpp_EXPORTS
|
||||
#else //YAML_CPP_DLL
|
||||
#define YAML_CPP_API
|
||||
#endif // YAML_CPP_DLL
|
||||
|
||||
#endif // DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#include "eventhandler.h"
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include <stack>
|
||||
|
||||
namespace YAML
|
||||
@@ -18,7 +20,7 @@ namespace YAML
|
||||
virtual void OnDocumentStart(const Mark& mark);
|
||||
virtual void OnDocumentEnd();
|
||||
|
||||
virtual void OnNull(const std::string& tag, anchor_t anchor);
|
||||
virtual void OnNull(const Mark& mark, anchor_t anchor);
|
||||
virtual void OnAlias(const Mark& mark, anchor_t anchor);
|
||||
virtual void OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value);
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "emittermanip.h"
|
||||
#include "ostream.h"
|
||||
#include "null.h"
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/binary.h"
|
||||
#include "yaml-cpp/emittermanip.h"
|
||||
#include "yaml-cpp/ostream.h"
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
#include "yaml-cpp/null.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
@@ -15,7 +20,7 @@ namespace YAML
|
||||
{
|
||||
class EmitterState;
|
||||
|
||||
class Emitter
|
||||
class YAML_CPP_API Emitter: private noncopyable
|
||||
{
|
||||
public:
|
||||
Emitter();
|
||||
@@ -39,19 +44,24 @@ namespace YAML
|
||||
bool SetIndent(unsigned n);
|
||||
bool SetPreCommentIndent(unsigned n);
|
||||
bool SetPostCommentIndent(unsigned n);
|
||||
bool SetFloatPrecision(unsigned n);
|
||||
bool SetDoublePrecision(unsigned n);
|
||||
|
||||
// local setters
|
||||
Emitter& SetLocalValue(EMITTER_MANIP value);
|
||||
Emitter& SetLocalIndent(const _Indent& indent);
|
||||
Emitter& SetLocalPrecision(const _Precision& precision);
|
||||
|
||||
// overloads of write
|
||||
Emitter& Write(const std::string& str);
|
||||
Emitter& Write(bool b);
|
||||
Emitter& Write(char ch);
|
||||
Emitter& Write(const _Alias& alias);
|
||||
Emitter& Write(const _Anchor& anchor);
|
||||
Emitter& Write(const _Tag& tag);
|
||||
Emitter& Write(const _Comment& comment);
|
||||
Emitter& Write(const _Null& null);
|
||||
Emitter& Write(const Binary& binary);
|
||||
|
||||
template <typename T>
|
||||
Emitter& WriteIntegralType(T value);
|
||||
@@ -61,25 +71,35 @@ namespace YAML
|
||||
|
||||
private:
|
||||
void PreWriteIntegralType(std::stringstream& str);
|
||||
void PreWriteStreamable(std::stringstream& str);
|
||||
void PostWriteIntegralType(const std::stringstream& str);
|
||||
void PostWriteStreamable(const std::stringstream& str);
|
||||
|
||||
template<typename T> void SetStreamablePrecision(std::stringstream&) {}
|
||||
unsigned GetFloatPrecision() const;
|
||||
unsigned GetDoublePrecision() const;
|
||||
|
||||
private:
|
||||
enum ATOMIC_TYPE { AT_SCALAR, AT_SEQ, AT_BLOCK_SEQ, AT_FLOW_SEQ, AT_MAP, AT_BLOCK_MAP, AT_FLOW_MAP };
|
||||
|
||||
void PreAtomicWrite();
|
||||
bool GotoNextPreAtomicState();
|
||||
void PostAtomicWrite();
|
||||
void EmitSeparationIfNecessary();
|
||||
|
||||
void EmitBeginDoc();
|
||||
void EmitEndDoc();
|
||||
void EmitBeginSeq();
|
||||
void EmitEndSeq();
|
||||
void EmitBeginMap();
|
||||
void EmitEndMap();
|
||||
void EmitKey();
|
||||
void EmitValue();
|
||||
void EmitNewline();
|
||||
void EmitKindTag();
|
||||
void EmitTag(bool verbatim, const _Tag& tag);
|
||||
|
||||
const char *ComputeFullBoolName(bool b) const;
|
||||
bool CanEmitNewline() const;
|
||||
|
||||
private:
|
||||
ostream m_stream;
|
||||
std::auto_ptr <EmitterState> m_pState;
|
||||
@@ -104,25 +124,37 @@ namespace YAML
|
||||
if(!good())
|
||||
return *this;
|
||||
|
||||
PreAtomicWrite();
|
||||
EmitSeparationIfNecessary();
|
||||
|
||||
std::stringstream str;
|
||||
PreWriteStreamable(str);
|
||||
SetStreamablePrecision<T>(str);
|
||||
str << value;
|
||||
m_stream << str.str();
|
||||
|
||||
PostAtomicWrite();
|
||||
PostWriteStreamable(str);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void Emitter::SetStreamablePrecision<float>(std::stringstream& str)
|
||||
{
|
||||
str.precision(GetFloatPrecision());
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void Emitter::SetStreamablePrecision<double>(std::stringstream& str)
|
||||
{
|
||||
str.precision(GetDoublePrecision());
|
||||
}
|
||||
|
||||
// overloads of insertion
|
||||
inline Emitter& operator << (Emitter& emitter, const std::string& v) { return emitter.Write(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, bool v) { return emitter.Write(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, char v) { return emitter.Write(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, unsigned char v) { return emitter.Write(static_cast<char>(v)); }
|
||||
inline Emitter& operator << (Emitter& emitter, const _Alias& v) { return emitter.Write(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, const _Anchor& v) { return emitter.Write(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, const _Tag& v) { return emitter.Write(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, const _Comment& v) { return emitter.Write(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, const _Null& v) { return emitter.Write(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, const Binary& b) { return emitter.Write(b); }
|
||||
|
||||
inline Emitter& operator << (Emitter& emitter, const char *v) { return emitter.Write(std::string(v)); }
|
||||
|
||||
@@ -132,6 +164,8 @@ namespace YAML
|
||||
inline Emitter& operator << (Emitter& emitter, unsigned short v) { return emitter.WriteIntegralType(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, long v) { return emitter.WriteIntegralType(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, unsigned long v) { return emitter.WriteIntegralType(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, long long v) { return emitter.WriteIntegralType(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, unsigned long long v) { return emitter.WriteIntegralType(v); }
|
||||
|
||||
inline Emitter& operator << (Emitter& emitter, float v) { return emitter.WriteStreamable(v); }
|
||||
inline Emitter& operator << (Emitter& emitter, double v) { return emitter.WriteStreamable(v); }
|
||||
@@ -143,6 +177,10 @@ namespace YAML
|
||||
inline Emitter& operator << (Emitter& emitter, _Indent indent) {
|
||||
return emitter.SetLocalIndent(indent);
|
||||
}
|
||||
|
||||
inline Emitter& operator << (Emitter& emitter, _Precision precision) {
|
||||
return emitter.SetLocalPrecision(precision);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -12,6 +14,7 @@ namespace YAML
|
||||
// general manipulators
|
||||
Auto,
|
||||
TagByKind,
|
||||
Newline,
|
||||
|
||||
// output character set
|
||||
EmitNonAscii,
|
||||
@@ -38,6 +41,10 @@ namespace YAML
|
||||
Hex,
|
||||
Oct,
|
||||
|
||||
// document manipulators
|
||||
BeginDoc,
|
||||
EndDoc,
|
||||
|
||||
// sequence manipulators
|
||||
BeginSeq,
|
||||
EndSeq,
|
||||
@@ -83,24 +90,32 @@ namespace YAML
|
||||
}
|
||||
|
||||
struct _Tag {
|
||||
explicit _Tag(const std::string& content_)
|
||||
: content(content_), verbatim(true)
|
||||
struct Type { enum value { Verbatim, PrimaryHandle, NamedHandle }; };
|
||||
|
||||
explicit _Tag(const std::string& prefix_, const std::string& content_, Type::value type_)
|
||||
: prefix(prefix_), content(content_), type(type_)
|
||||
{
|
||||
}
|
||||
std::string prefix;
|
||||
std::string content;
|
||||
bool verbatim;
|
||||
Type::value type;
|
||||
};
|
||||
|
||||
typedef _Tag VerbatimTag;
|
||||
|
||||
struct LocalTag : public _Tag
|
||||
{
|
||||
explicit LocalTag(const std::string& content_)
|
||||
: _Tag(content_)
|
||||
{
|
||||
verbatim = false;
|
||||
}
|
||||
};
|
||||
inline _Tag VerbatimTag(const std::string content) {
|
||||
return _Tag("", content, _Tag::Type::Verbatim);
|
||||
}
|
||||
|
||||
inline _Tag LocalTag(const std::string content) {
|
||||
return _Tag("", content, _Tag::Type::PrimaryHandle);
|
||||
}
|
||||
|
||||
inline _Tag LocalTag(const std::string& prefix, const std::string content) {
|
||||
return _Tag(prefix, content, _Tag::Type::NamedHandle);
|
||||
}
|
||||
|
||||
inline _Tag SecondaryTag(const std::string content) {
|
||||
return _Tag("", content, _Tag::Type::NamedHandle);
|
||||
}
|
||||
|
||||
struct _Comment {
|
||||
_Comment(const std::string& content_): content(content_) {}
|
||||
@@ -110,6 +125,25 @@ namespace YAML
|
||||
inline _Comment Comment(const std::string content) {
|
||||
return _Comment(content);
|
||||
}
|
||||
|
||||
struct _Precision {
|
||||
_Precision(int floatPrecision_, int doublePrecision_): floatPrecision(floatPrecision_), doublePrecision(doublePrecision_) {}
|
||||
|
||||
int floatPrecision;
|
||||
int doublePrecision;
|
||||
};
|
||||
|
||||
inline _Precision FloatPrecision(int n) {
|
||||
return _Precision(n, -1);
|
||||
}
|
||||
|
||||
inline _Precision DoublePrecision(int n) {
|
||||
return _Precision(-1, n);
|
||||
}
|
||||
|
||||
inline _Precision Precision(int n) {
|
||||
return _Precision(n, n);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#include "anchor.h"
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/anchor.h"
|
||||
#include <string>
|
||||
|
||||
namespace YAML
|
||||
@@ -18,7 +20,7 @@ namespace YAML
|
||||
virtual void OnDocumentStart(const Mark& mark) = 0;
|
||||
virtual void OnDocumentEnd() = 0;
|
||||
|
||||
virtual void OnNull(const std::string& tag, anchor_t anchor) = 0;
|
||||
virtual void OnNull(const Mark& mark, anchor_t anchor) = 0;
|
||||
virtual void OnAlias(const Mark& mark, anchor_t anchor) = 0;
|
||||
virtual void OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value) = 0;
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
#ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "yaml-cpp/mark.h"
|
||||
#include "yaml-cpp/traits.h"
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
// error messages
|
||||
namespace ErrorMsg
|
||||
{
|
||||
const char * const YAML_DIRECTIVE_ARGS = "YAML directives must have exactly one argument";
|
||||
const char * const YAML_VERSION = "bad YAML version: ";
|
||||
const char * const YAML_MAJOR_VERSION = "YAML major version too large";
|
||||
const char * const REPEATED_YAML_DIRECTIVE= "repeated YAML directive";
|
||||
const char * const TAG_DIRECTIVE_ARGS = "TAG directives must have exactly two arguments";
|
||||
const char * const REPEATED_TAG_DIRECTIVE = "repeated TAG directive";
|
||||
const char * const CHAR_IN_TAG_HANDLE = "illegal character found while scanning tag handle";
|
||||
const char * const TAG_WITH_NO_SUFFIX = "tag handle with no suffix";
|
||||
const char * const END_OF_VERBATIM_TAG = "end of verbatim tag not found";
|
||||
const char * const END_OF_MAP = "end of map not found";
|
||||
const char * const END_OF_MAP_FLOW = "end of map flow not found";
|
||||
const char * const END_OF_SEQ = "end of sequence not found";
|
||||
const char * const END_OF_SEQ_FLOW = "end of sequence flow not found";
|
||||
const char * const MULTIPLE_TAGS = "cannot assign multiple tags to the same node";
|
||||
const char * const MULTIPLE_ANCHORS = "cannot assign multiple anchors to the same node";
|
||||
const char * const MULTIPLE_ALIASES = "cannot assign multiple aliases to the same node";
|
||||
const char * const ALIAS_CONTENT = "aliases can't have any content, *including* tags";
|
||||
const char * const INVALID_HEX = "bad character found while scanning hex number";
|
||||
const char * const INVALID_UNICODE = "invalid unicode: ";
|
||||
const char * const INVALID_ESCAPE = "unknown escape character: ";
|
||||
const char * const UNKNOWN_TOKEN = "unknown token";
|
||||
const char * const DOC_IN_SCALAR = "illegal document indicator in scalar";
|
||||
const char * const EOF_IN_SCALAR = "illegal EOF in scalar";
|
||||
const char * const CHAR_IN_SCALAR = "illegal character in scalar";
|
||||
const char * const TAB_IN_INDENTATION = "illegal tab when looking for indentation";
|
||||
const char * const FLOW_END = "illegal flow end";
|
||||
const char * const BLOCK_ENTRY = "illegal block entry";
|
||||
const char * const MAP_KEY = "illegal map key";
|
||||
const char * const MAP_VALUE = "illegal map value";
|
||||
const char * const ALIAS_NOT_FOUND = "alias not found after *";
|
||||
const char * const ANCHOR_NOT_FOUND = "anchor not found after &";
|
||||
const char * const CHAR_IN_ALIAS = "illegal character found while scanning alias";
|
||||
const char * const CHAR_IN_ANCHOR = "illegal character found while scanning anchor";
|
||||
const char * const ZERO_INDENT_IN_BLOCK = "cannot set zero indentation for a block scalar";
|
||||
const char * const CHAR_IN_BLOCK = "unexpected character in block scalar";
|
||||
const char * const AMBIGUOUS_ANCHOR = "cannot assign the same alias to multiple nodes";
|
||||
const char * const UNKNOWN_ANCHOR = "the referenced anchor is not defined";
|
||||
|
||||
const char * const INVALID_SCALAR = "invalid scalar";
|
||||
const char * const KEY_NOT_FOUND = "key not found";
|
||||
const char * const BAD_DEREFERENCE = "bad dereference";
|
||||
|
||||
const char * const UNMATCHED_GROUP_TAG = "unmatched group tag";
|
||||
const char * const UNEXPECTED_END_SEQ = "unexpected end sequence token";
|
||||
const char * const UNEXPECTED_END_MAP = "unexpected end map token";
|
||||
const char * const SINGLE_QUOTED_CHAR = "invalid character in single-quoted string";
|
||||
const char * const INVALID_ANCHOR = "invalid anchor";
|
||||
const char * const INVALID_ALIAS = "invalid alias";
|
||||
const char * const INVALID_TAG = "invalid tag";
|
||||
const char * const EXPECTED_KEY_TOKEN = "expected key token";
|
||||
const char * const EXPECTED_VALUE_TOKEN = "expected value token";
|
||||
const char * const UNEXPECTED_KEY_TOKEN = "unexpected key token";
|
||||
const char * const UNEXPECTED_VALUE_TOKEN = "unexpected value token";
|
||||
|
||||
template <typename T>
|
||||
inline const std::string KEY_NOT_FOUND_WITH_KEY(const T&, typename disable_if<is_numeric<T> >::type * = 0) {
|
||||
return KEY_NOT_FOUND;
|
||||
}
|
||||
|
||||
inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) {
|
||||
std::stringstream stream;
|
||||
stream << KEY_NOT_FOUND << ": " << key;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const std::string KEY_NOT_FOUND_WITH_KEY(const T& key, typename enable_if<is_numeric<T> >::type * = 0) {
|
||||
std::stringstream stream;
|
||||
stream << KEY_NOT_FOUND << ": " << key;
|
||||
return stream.str();
|
||||
}
|
||||
}
|
||||
|
||||
class Exception: public std::runtime_error {
|
||||
public:
|
||||
Exception(const Mark& mark_, const std::string& msg_)
|
||||
: std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {}
|
||||
virtual ~Exception() throw() {}
|
||||
|
||||
Mark mark;
|
||||
std::string msg;
|
||||
|
||||
private:
|
||||
static const std::string build_what(const Mark& mark, const std::string& msg) {
|
||||
std::stringstream output;
|
||||
output << "yaml-cpp: error at line " << mark.line+1 << ", column " << mark.column+1 << ": " << msg;
|
||||
return output.str();
|
||||
}
|
||||
};
|
||||
|
||||
class ParserException: public Exception {
|
||||
public:
|
||||
ParserException(const Mark& mark_, const std::string& msg_)
|
||||
: Exception(mark_, msg_) {}
|
||||
};
|
||||
|
||||
class RepresentationException: public Exception {
|
||||
public:
|
||||
RepresentationException(const Mark& mark_, const std::string& msg_)
|
||||
: Exception(mark_, msg_) {}
|
||||
};
|
||||
|
||||
// representation exceptions
|
||||
class InvalidScalar: public RepresentationException {
|
||||
public:
|
||||
InvalidScalar(const Mark& mark_)
|
||||
: RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {}
|
||||
};
|
||||
|
||||
class KeyNotFound: public RepresentationException {
|
||||
public:
|
||||
template <typename T>
|
||||
KeyNotFound(const Mark& mark_, const T& key_)
|
||||
: RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class TypedKeyNotFound: public KeyNotFound {
|
||||
public:
|
||||
TypedKeyNotFound(const Mark& mark_, const T& key_)
|
||||
: KeyNotFound(mark_, key_), key(key_) {}
|
||||
virtual ~TypedKeyNotFound() throw() {}
|
||||
|
||||
T key;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline TypedKeyNotFound <T> MakeTypedKeyNotFound(const Mark& mark, const T& key) {
|
||||
return TypedKeyNotFound <T> (mark, key);
|
||||
}
|
||||
|
||||
class BadDereference: public RepresentationException {
|
||||
public:
|
||||
BadDereference()
|
||||
: RepresentationException(Mark::null(), ErrorMsg::BAD_DEREFERENCE) {}
|
||||
};
|
||||
|
||||
class EmitterException: public Exception {
|
||||
public:
|
||||
EmitterException(const std::string& msg_)
|
||||
: Exception(Mark::null(), msg_) {}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,19 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include <memory>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
struct IterPriv;
|
||||
|
||||
class Iterator
|
||||
class YAML_CPP_API Iterator
|
||||
{
|
||||
public:
|
||||
Iterator();
|
||||
Iterator(IterPriv *pData);
|
||||
Iterator(std::auto_ptr<IterPriv> pData);
|
||||
Iterator(const Iterator& rhs);
|
||||
~Iterator();
|
||||
|
||||
@@ -25,11 +29,11 @@ namespace YAML
|
||||
const Node& first() const;
|
||||
const Node& second() const;
|
||||
|
||||
friend bool operator == (const Iterator& it, const Iterator& jt);
|
||||
friend bool operator != (const Iterator& it, const Iterator& jt);
|
||||
friend YAML_CPP_API bool operator == (const Iterator& it, const Iterator& jt);
|
||||
friend YAML_CPP_API bool operator != (const Iterator& it, const Iterator& jt);
|
||||
|
||||
private:
|
||||
IterPriv *m_pData;
|
||||
std::auto_ptr<IterPriv> m_pData;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
@@ -1,12 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
struct Mark {
|
||||
struct YAML_CPP_API Mark {
|
||||
Mark(): pos(0), line(0), column(0) {}
|
||||
|
||||
static const Mark null() { return Mark(-1, -1, -1); }
|
||||
@@ -1,34 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "conversion.h"
|
||||
#include "exceptions.h"
|
||||
#include "iterator.h"
|
||||
#include "mark.h"
|
||||
#include "noncopyable.h"
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "yaml-cpp/mark.h"
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
#include "yaml-cpp/conversion.h"
|
||||
#include "yaml-cpp/iterator.h"
|
||||
#include "yaml-cpp/ltnode.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class AliasManager;
|
||||
class Content;
|
||||
class NodeOwnership;
|
||||
class Scanner;
|
||||
class Emitter;
|
||||
class EventHandler;
|
||||
struct NodeProperties;
|
||||
|
||||
enum CONTENT_TYPE { CT_NONE, CT_SCALAR, CT_SEQUENCE, CT_MAP };
|
||||
struct NodeType { enum value { Null, Scalar, Sequence, Map }; };
|
||||
|
||||
class Node: private noncopyable
|
||||
class YAML_CPP_API Node: private noncopyable
|
||||
{
|
||||
public:
|
||||
friend class NodeOwnership;
|
||||
friend class NodeBuilder;
|
||||
|
||||
Node();
|
||||
~Node();
|
||||
|
||||
@@ -36,16 +43,9 @@ namespace YAML
|
||||
std::auto_ptr<Node> Clone() const;
|
||||
void EmitEvents(EventHandler& eventHandler) const;
|
||||
void EmitEvents(AliasManager& am, EventHandler& eventHandler) const;
|
||||
|
||||
void Init(CONTENT_TYPE type, const Mark& mark, const std::string& tag);
|
||||
void InitNull(const std::string& tag);
|
||||
void InitAlias(const Mark& mark, const Node& identity);
|
||||
|
||||
void SetData(const std::string& data);
|
||||
void Append(std::auto_ptr<Node> pNode);
|
||||
void Insert(std::auto_ptr<Node> pKey, std::auto_ptr<Node> pValue);
|
||||
|
||||
CONTENT_TYPE GetType() const;
|
||||
NodeType::value Type() const { return m_type; }
|
||||
bool IsAliased() const;
|
||||
|
||||
// file location of start of this node
|
||||
const Mark GetMark() const { return m_mark; }
|
||||
@@ -63,13 +63,10 @@ namespace YAML
|
||||
bool Read(T& value) const;
|
||||
|
||||
template <typename T>
|
||||
const T Read() const;
|
||||
|
||||
template <typename T>
|
||||
operator T() const;
|
||||
const T to() const;
|
||||
|
||||
template <typename T>
|
||||
friend void operator >> (const Node& node, T& value);
|
||||
friend YAML_CPP_API typename enable_if<is_scalar_convertible<T> >::type operator >> (const Node& node, T& value);
|
||||
|
||||
// retrieval for maps and sequences
|
||||
template <typename T>
|
||||
@@ -80,24 +77,31 @@ namespace YAML
|
||||
|
||||
// specific to maps
|
||||
const Node *FindValue(const char *key) const;
|
||||
const Node *FindValue(char *key) const;
|
||||
const Node& operator [] (const char *key) const;
|
||||
const Node& operator [] (char *key) const;
|
||||
|
||||
// for anchors/aliases
|
||||
const Node *Identity() const { return m_pIdentity; }
|
||||
bool IsAlias() const { return m_alias; }
|
||||
bool IsReferenced() const { return m_referenced; }
|
||||
|
||||
// for tags
|
||||
const std::string GetTag() const { return IsAlias() ? m_pIdentity->GetTag() : m_tag; }
|
||||
const std::string& Tag() const { return m_tag; }
|
||||
|
||||
// emitting
|
||||
friend Emitter& operator << (Emitter& out, const Node& node);
|
||||
friend YAML_CPP_API Emitter& operator << (Emitter& out, const Node& node);
|
||||
|
||||
// ordering
|
||||
int Compare(const Node& rhs) const;
|
||||
friend bool operator < (const Node& n1, const Node& n2);
|
||||
|
||||
private:
|
||||
explicit Node(NodeOwnership& owner);
|
||||
Node& CreateNode();
|
||||
|
||||
void Init(NodeType::value type, const Mark& mark, const std::string& tag);
|
||||
|
||||
void MarkAsAliased();
|
||||
void SetScalarData(const std::string& data);
|
||||
void Append(Node& node);
|
||||
void Insert(Node& key, Node& value);
|
||||
|
||||
// helper for sequences
|
||||
template <typename, bool> friend struct _FindFromNodeAtIndex;
|
||||
const Node *FindAtIndex(std::size_t i) const;
|
||||
@@ -110,34 +114,22 @@ namespace YAML
|
||||
const Node *FindValueForKey(const T& key) const;
|
||||
|
||||
private:
|
||||
std::auto_ptr<NodeOwnership> m_pOwnership;
|
||||
|
||||
Mark m_mark;
|
||||
std::string m_tag;
|
||||
Content *m_pContent;
|
||||
bool m_alias;
|
||||
const Node *m_pIdentity;
|
||||
mutable bool m_referenced;
|
||||
|
||||
typedef std::vector<Node *> node_seq;
|
||||
typedef std::map<Node *, Node *, ltnode> node_map;
|
||||
|
||||
NodeType::value m_type;
|
||||
std::string m_scalarData;
|
||||
node_seq m_seqData;
|
||||
node_map m_mapData;
|
||||
};
|
||||
|
||||
// comparisons with auto-conversion
|
||||
template <typename T>
|
||||
bool operator == (const T& value, const Node& node);
|
||||
|
||||
template <typename T>
|
||||
bool operator == (const Node& node, const T& value);
|
||||
|
||||
template <typename T>
|
||||
bool operator != (const T& value, const Node& node);
|
||||
|
||||
template <typename T>
|
||||
bool operator != (const Node& node, const T& value);
|
||||
|
||||
bool operator == (const char *value, const Node& node);
|
||||
bool operator == (const Node& node, const char *value);
|
||||
bool operator != (const char *value, const Node& node);
|
||||
bool operator != (const Node& node, const char *value);
|
||||
}
|
||||
|
||||
#include "nodeimpl.h"
|
||||
#include "nodereadimpl.h"
|
||||
#include "yaml-cpp/nodeimpl.h"
|
||||
#include "yaml-cpp/nodereadimpl.h"
|
||||
|
||||
#endif // NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -0,0 +1,85 @@
|
||||
#ifndef NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "yaml-cpp/nodeutil.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
// implementation of templated things
|
||||
template <typename T>
|
||||
inline const T Node::to() const {
|
||||
T value;
|
||||
*this >> value;
|
||||
return value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline typename enable_if<is_scalar_convertible<T> >::type operator >> (const Node& node, T& value) {
|
||||
if(!ConvertScalar(node, value))
|
||||
throw InvalidScalar(node.m_mark);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const Node *Node::FindValue(const T& key) const {
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
case NodeType::Scalar:
|
||||
throw BadDereference();
|
||||
case NodeType::Sequence:
|
||||
return FindFromNodeAtIndex(*this, key);
|
||||
case NodeType::Map:
|
||||
return FindValueForKey(key);
|
||||
}
|
||||
assert(false);
|
||||
throw BadDereference();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const Node *Node::FindValueForKey(const T& key) const {
|
||||
for(Iterator it=begin();it!=end();++it) {
|
||||
T t;
|
||||
if(it.first().Read(t)) {
|
||||
if(key == t)
|
||||
return &it.second();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const Node& Node::GetValue(const T& key) const {
|
||||
if(const Node *pValue = FindValue(key))
|
||||
return *pValue;
|
||||
throw MakeTypedKeyNotFound(m_mark, key);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const Node& Node::operator [] (const T& key) const {
|
||||
return GetValue(key);
|
||||
}
|
||||
|
||||
inline const Node *Node::FindValue(const char *key) const {
|
||||
return FindValue(std::string(key));
|
||||
}
|
||||
|
||||
inline const Node *Node::FindValue(char *key) const {
|
||||
return FindValue(std::string(key));
|
||||
}
|
||||
|
||||
inline const Node& Node::operator [] (const char *key) const {
|
||||
return GetValue(std::string(key));
|
||||
}
|
||||
|
||||
inline const Node& Node::operator [] (char *key) const {
|
||||
return GetValue(std::string(key));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,4 +1,10 @@
|
||||
#ifndef NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
@@ -76,3 +82,5 @@ namespace YAML
|
||||
return Convert(scalar, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
// this is basically boost::noncopyable
|
||||
class YAML_CPP_API noncopyable
|
||||
{
|
||||
protected:
|
||||
noncopyable() {}
|
||||
~noncopyable() {}
|
||||
|
||||
private:
|
||||
noncopyable(const noncopyable&);
|
||||
const noncopyable& operator = (const noncopyable&);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,20 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
|
||||
struct _Null {};
|
||||
struct YAML_CPP_API _Null {};
|
||||
inline bool operator == (const _Null&, const _Null&) { return true; }
|
||||
inline bool operator != (const _Null&, const _Null&) { return false; }
|
||||
|
||||
bool IsNull(const Node& node);
|
||||
YAML_CPP_API bool IsNull(const Node& node); // old API only
|
||||
|
||||
extern _Null Null;
|
||||
extern YAML_CPP_API _Null Null;
|
||||
}
|
||||
|
||||
#endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "graphbuilder.h"
|
||||
#include "noncopyable.h"
|
||||
|
||||
#include "yaml-cpp/dll.h"
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
#include <ios>
|
||||
#include <memory>
|
||||
|
||||
@@ -15,11 +17,10 @@ namespace YAML
|
||||
struct Mark;
|
||||
struct Token;
|
||||
class EventHandler;
|
||||
class GraphBuilderInterface;
|
||||
class Node;
|
||||
class Scanner;
|
||||
|
||||
class Parser: private noncopyable
|
||||
class YAML_CPP_API Parser: private noncopyable
|
||||
{
|
||||
public:
|
||||
Parser();
|
||||
@@ -31,17 +32,8 @@ namespace YAML
|
||||
void Load(std::istream& in);
|
||||
bool HandleNextDocument(EventHandler& eventHandler);
|
||||
|
||||
void *BuildNextDocumentGraph(GraphBuilderInterface& graphBuilder);
|
||||
template <class Builder>
|
||||
typename Builder::Node *BuildNextDocumentGraph(Builder& graphBuilder)
|
||||
{
|
||||
GraphBuilder<Builder> wrapper(graphBuilder); // Must be lvalue to make C++ happy
|
||||
return static_cast<typename Builder::Node *>(
|
||||
BuildNextDocumentGraph(wrapper.AsBuilderInterface())
|
||||
);
|
||||
}
|
||||
bool GetNextDocument(Node& document); // old API only
|
||||
|
||||
bool GetNextDocument(Node& document);
|
||||
void PrintTokens(std::ostream& out);
|
||||
|
||||
private:
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
template<typename Seq>
|
||||
inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) {
|
||||
emitter << BeginSeq;
|
||||
for(typename Seq::const_iterator it=seq.begin();it!=seq.end();++it)
|
||||
emitter << *it;
|
||||
emitter << EndSeq;
|
||||
return emitter;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline Emitter& operator << (Emitter& emitter, const std::vector<T>& v) {
|
||||
return EmitSeq(emitter, v);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline Emitter& operator << (Emitter& emitter, const std::list<T>& v) {
|
||||
return EmitSeq(emitter, v);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline Emitter& operator << (Emitter& emitter, const std::set<T>& v) {
|
||||
return EmitSeq(emitter, v);
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
inline Emitter& operator << (Emitter& emitter, const std::map<K, V>& m) {
|
||||
typedef typename std::map <K, V> map;
|
||||
emitter << BeginMap;
|
||||
for(typename map::const_iterator it=m.begin();it!=m.end();++it)
|
||||
emitter << Key << it->first << Value << it->second;
|
||||
emitter << EndMap;
|
||||
return emitter;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
@@ -17,8 +19,13 @@ namespace YAML
|
||||
template <> struct is_numeric <unsigned long int> { enum { value = true }; };
|
||||
template <> struct is_numeric <short int> { enum { value = true }; };
|
||||
template <> struct is_numeric <unsigned short int> { enum { value = true }; };
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1310)
|
||||
template <> struct is_numeric <__int64> { enum { value = true }; };
|
||||
template <> struct is_numeric <unsigned __int64> { enum { value = true }; };
|
||||
#else
|
||||
template <> struct is_numeric <long long> { enum { value = true }; };
|
||||
template <> struct is_numeric <unsigned long long> { enum { value = true }; };
|
||||
#endif
|
||||
template <> struct is_numeric <float> { enum { value = true }; };
|
||||
template <> struct is_numeric <double> { enum { value = true }; };
|
||||
template <> struct is_numeric <long double> { enum { value = true }; };
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/parser.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "yaml-cpp/stlemitter.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
|
||||
#include "yaml-cpp/node.h"
|
||||
#include "yaml-cpp/stlnode.h"
|
||||
#include "yaml-cpp/iterator.h"
|
||||
|
||||
#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
|
||||
#include "parser.h"
|
||||
#include "node.h"
|
||||
#include "stlnode.h"
|
||||
#include "iterator.h"
|
||||
#include "emitter.h"
|
||||
#include "stlemitter.h"
|
||||
#include "exceptions.h"
|
||||
|
||||
#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
+18
-18
@@ -1,19 +1,19 @@
|
||||
Copyright (c) 2008 Jesse Beder.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
Copyright (c) 2008 Jesse Beder.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
-194
@@ -1,194 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="parse"
|
||||
ProjectGUID="{CD007B57-7812-4930-A5E2-6E5E56338814}"
|
||||
RootNamespace="parse"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/D_SCL_SECURE_NO_WARNINGS"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="include"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
DisableSpecificWarnings="4127;4355"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="yamlcppd.lib"
|
||||
AdditionalLibraryDirectories="lib"
|
||||
GenerateDebugInformation="true"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/D_SCL_SECURE_NO_WARNINGS"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="include"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
DisableSpecificWarnings="4127;4355"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="yamlcpp.lib"
|
||||
AdditionalLibraryDirectories="lib"
|
||||
GenerateDebugInformation="true"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\util\parse.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -1,83 +0,0 @@
|
||||
#include "aliascontent.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
AliasContent::AliasContent(Content* pNodeContent): m_pRef(pNodeContent)
|
||||
{
|
||||
}
|
||||
|
||||
bool AliasContent::GetBegin(std::vector <Node *>::const_iterator& i) const
|
||||
{
|
||||
return m_pRef->GetBegin(i);
|
||||
}
|
||||
|
||||
bool AliasContent::GetBegin(std::map <Node *, Node *, ltnode>::const_iterator& i) const
|
||||
{
|
||||
return m_pRef->GetBegin(i);
|
||||
}
|
||||
|
||||
bool AliasContent::GetEnd(std::vector <Node *>::const_iterator& i) const
|
||||
{
|
||||
return m_pRef->GetEnd(i);
|
||||
}
|
||||
|
||||
bool AliasContent::GetEnd(std::map <Node *, Node *, ltnode>::const_iterator& i) const
|
||||
{
|
||||
return m_pRef->GetEnd(i);
|
||||
}
|
||||
|
||||
Node* AliasContent::GetNode(std::size_t n) const
|
||||
{
|
||||
return m_pRef->GetNode(n);
|
||||
}
|
||||
|
||||
std::size_t AliasContent::GetSize() const
|
||||
{
|
||||
return m_pRef->GetSize();
|
||||
}
|
||||
|
||||
bool AliasContent::IsScalar() const
|
||||
{
|
||||
return m_pRef->IsScalar();
|
||||
}
|
||||
|
||||
bool AliasContent::IsMap() const
|
||||
{
|
||||
return m_pRef->IsMap();
|
||||
}
|
||||
|
||||
bool AliasContent::IsSequence() const
|
||||
{
|
||||
return m_pRef->IsSequence();
|
||||
}
|
||||
|
||||
bool AliasContent::GetScalar(std::string& scalar) const
|
||||
{
|
||||
return m_pRef->GetScalar(scalar);
|
||||
}
|
||||
|
||||
void AliasContent::EmitEvents(AliasManager& am, EventHandler& eventHandler, const Mark& mark, const std::string& tag, anchor_t anchor) const
|
||||
{
|
||||
m_pRef->EmitEvents(am, eventHandler, mark, tag, anchor);
|
||||
}
|
||||
|
||||
int AliasContent::Compare(Content *pContent)
|
||||
{
|
||||
return m_pRef->Compare(pContent);
|
||||
}
|
||||
|
||||
int AliasContent::Compare(Scalar *pScalar)
|
||||
{
|
||||
return m_pRef->Compare(pScalar);
|
||||
}
|
||||
|
||||
int AliasContent::Compare(Sequence *pSequence)
|
||||
{
|
||||
return m_pRef->Compare(pSequence);
|
||||
}
|
||||
|
||||
int AliasContent::Compare(Map *pMap)
|
||||
{
|
||||
return m_pRef->Compare(pMap);
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef ALIASCONTENT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ALIASCONTENT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
|
||||
#include "content.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class AliasContent : public Content
|
||||
{
|
||||
public:
|
||||
AliasContent(Content *pNodeContent);
|
||||
|
||||
virtual bool GetBegin(std::vector <Node *>::const_iterator&) const;
|
||||
virtual bool GetBegin(std::map <Node *, Node *, ltnode>::const_iterator&) const;
|
||||
virtual bool GetEnd(std::vector <Node *>::const_iterator&) const;
|
||||
virtual bool GetEnd(std::map <Node *, Node *, ltnode>::const_iterator&) const;
|
||||
virtual Node* GetNode(std::size_t) const;
|
||||
virtual std::size_t GetSize() const;
|
||||
virtual bool IsScalar() const;
|
||||
virtual bool IsMap() const;
|
||||
virtual bool IsSequence() const;
|
||||
|
||||
virtual bool GetScalar(std::string& s) const;
|
||||
virtual void EmitEvents(AliasManager& am, EventHandler& eventHandler, const Mark& mark, const std::string& tag, anchor_t anchor) const;
|
||||
|
||||
virtual int Compare(Content *);
|
||||
virtual int Compare(Scalar *);
|
||||
virtual int Compare(Sequence *);
|
||||
virtual int Compare(Map *);
|
||||
|
||||
private:
|
||||
Content* m_pRef;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ALIASCONTENT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
+4
-20
@@ -1,5 +1,5 @@
|
||||
#include "aliasmanager.h"
|
||||
#include "node.h"
|
||||
#include "yaml-cpp/aliasmanager.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
@@ -11,33 +11,17 @@ namespace YAML
|
||||
|
||||
void AliasManager::RegisterReference(const Node& node)
|
||||
{
|
||||
const Node *pIdentity = node.Identity();
|
||||
m_newIdentityByOldIdentity.insert(std::make_pair(pIdentity, &node));
|
||||
m_anchorByIdentity.insert(std::make_pair(&node, _CreateNewAnchor()));
|
||||
}
|
||||
|
||||
const Node *AliasManager::LookupReference(const Node& node) const
|
||||
{
|
||||
const Node *pIdentity = node.Identity();
|
||||
return _LookupReference(*pIdentity);
|
||||
}
|
||||
|
||||
|
||||
anchor_t AliasManager::LookupAnchor(const Node& node) const
|
||||
{
|
||||
AnchorByIdentity::const_iterator it = m_anchorByIdentity.find(&node);
|
||||
if(it == m_anchorByIdentity.end())
|
||||
assert(false); // TODO: throw
|
||||
return it->second;
|
||||
}
|
||||
|
||||
const Node *AliasManager::_LookupReference(const Node& oldIdentity) const
|
||||
{
|
||||
NodeByNode::const_iterator it = m_newIdentityByOldIdentity.find(&oldIdentity);
|
||||
if(it == m_newIdentityByOldIdentity.end())
|
||||
return 0;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
||||
anchor_t AliasManager::_CreateNewAnchor()
|
||||
{
|
||||
return ++m_curAnchor;
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
#include "yaml-cpp/binary.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
static const char encoding[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
std::string EncodeBase64(const unsigned char *data, std::size_t size)
|
||||
{
|
||||
const char PAD = '=';
|
||||
|
||||
std::string ret;
|
||||
ret.resize(4 * size / 3 + 3);
|
||||
char *out = &ret[0];
|
||||
|
||||
std::size_t chunks = size / 3;
|
||||
std::size_t remainder = size % 3;
|
||||
|
||||
for(std::size_t i=0;i<chunks;i++, data += 3) {
|
||||
*out++ = encoding[data[0] >> 2];
|
||||
*out++ = encoding[((data[0] & 0x3) << 4) | (data[1] >> 4)];
|
||||
*out++ = encoding[((data[1] & 0xf) << 2) | (data[2] >> 6)];
|
||||
*out++ = encoding[data[2] & 0x3f];
|
||||
}
|
||||
|
||||
switch(remainder) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
*out++ = encoding[data[0] >> 2];
|
||||
*out++ = encoding[((data[0] & 0x3) << 4)];
|
||||
*out++ = PAD;
|
||||
*out++ = PAD;
|
||||
break;
|
||||
case 2:
|
||||
*out++ = encoding[data[0] >> 2];
|
||||
*out++ = encoding[((data[0] & 0x3) << 4) | (data[1] >> 4)];
|
||||
*out++ = encoding[((data[1] & 0xf) << 2)];
|
||||
*out++ = PAD;
|
||||
break;
|
||||
}
|
||||
|
||||
ret.resize(out - &ret[0]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const unsigned char decoding[] = {
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255, 62,255,255,255, 63,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,255,255,255, 0,255,255,
|
||||
255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,255,255,255,255,255,
|
||||
255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
||||
};
|
||||
|
||||
std::vector<unsigned char> DecodeBase64(const std::string& input)
|
||||
{
|
||||
typedef std::vector<unsigned char> ret_type;
|
||||
if(input.empty())
|
||||
return ret_type();
|
||||
|
||||
ret_type ret(3 * input.size() / 4 + 1);
|
||||
unsigned char *out = &ret[0];
|
||||
|
||||
unsigned value = 0;
|
||||
for(std::size_t i=0;i<input.size();i++) {
|
||||
unsigned char d = decoding[static_cast<unsigned>(input[i])];
|
||||
if(d == 255)
|
||||
return ret_type();
|
||||
|
||||
value = (value << 6) | d;
|
||||
if(i % 4 == 3) {
|
||||
*out++ = value >> 16;
|
||||
if(i > 0 && input[i - 1] != '=')
|
||||
*out++ = value >> 8;
|
||||
if(input[i] != '=')
|
||||
*out++ = value;
|
||||
}
|
||||
}
|
||||
|
||||
ret.resize(out - &ret[0]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void operator >> (const Node& node, Binary& binary)
|
||||
{
|
||||
std::string scalar;
|
||||
node.GetScalar(scalar);
|
||||
std::vector<unsigned char> data = DecodeBase64(scalar);
|
||||
binary.swap(data);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <stack>
|
||||
#include <cassert>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#include "content.h"
|
||||
#include "node.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
void Content::SetData(const std::string&)
|
||||
{
|
||||
assert(false); // TODO: throw
|
||||
}
|
||||
|
||||
void Content::Append(std::auto_ptr<Node>)
|
||||
{
|
||||
assert(false); // TODO: throw
|
||||
}
|
||||
|
||||
void Content::Insert(std::auto_ptr<Node>, std::auto_ptr<Node>)
|
||||
{
|
||||
assert(false); // TODO: throw
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef CONTENT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define CONTENT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
|
||||
#include "anchor.h"
|
||||
#include "exceptions.h"
|
||||
#include "ltnode.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
struct Mark;
|
||||
struct NodeProperties;
|
||||
class AliasManager;
|
||||
class EventHandler;
|
||||
class Map;
|
||||
class Node;
|
||||
class Scalar;
|
||||
class Scanner;
|
||||
class Sequence;
|
||||
|
||||
class Content
|
||||
{
|
||||
public:
|
||||
Content() {}
|
||||
virtual ~Content() {}
|
||||
|
||||
virtual bool GetBegin(std::vector <Node *>::const_iterator&) const { return false; }
|
||||
virtual bool GetBegin(std::map <Node *, Node *, ltnode>::const_iterator&) const { return false; }
|
||||
virtual bool GetEnd(std::vector <Node *>::const_iterator&) const { return false; }
|
||||
virtual bool GetEnd(std::map <Node *, Node *, ltnode>::const_iterator&) const { return false; }
|
||||
virtual Node *GetNode(std::size_t) const { return 0; }
|
||||
virtual std::size_t GetSize() const { return 0; }
|
||||
virtual bool IsScalar() const { return false; }
|
||||
virtual bool IsMap() const { return false; }
|
||||
virtual bool IsSequence() const { return false; }
|
||||
|
||||
virtual void SetData(const std::string& data);
|
||||
virtual void Append(std::auto_ptr<Node> pNode);
|
||||
virtual void Insert(std::auto_ptr<Node> pKey, std::auto_ptr<Node> pValue);
|
||||
virtual void EmitEvents(AliasManager& am, EventHandler& eventHandler, const Mark& mark, const std::string& tag, anchor_t anchor) const = 0;
|
||||
|
||||
// extraction
|
||||
virtual bool GetScalar(std::string&) const { return false; }
|
||||
|
||||
// ordering
|
||||
virtual int Compare(Content *) { return 0; }
|
||||
virtual int Compare(Scalar *) { return 0; }
|
||||
virtual int Compare(Sequence *) { return 0; }
|
||||
virtual int Compare(Map *) { return 0; }
|
||||
|
||||
protected:
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CONTENT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "yaml-cpp/parser.h"
|
||||
#include "yaml-cpp/contrib/graphbuilder.h"
|
||||
#include "graphbuilderadapter.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
void *BuildGraphOfNextDocument(Parser& parser, GraphBuilderInterface& graphBuilder)
|
||||
{
|
||||
GraphBuilderAdapter eventHandler(graphBuilder);
|
||||
if (parser.HandleNextDocument(eventHandler)) {
|
||||
return eventHandler.RootNode();
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,10 @@ namespace YAML
|
||||
{
|
||||
int GraphBuilderAdapter::ContainerFrame::sequenceMarker;
|
||||
|
||||
void GraphBuilderAdapter::OnNull(const std::string& tag, anchor_t anchor)
|
||||
void GraphBuilderAdapter::OnNull(const Mark& mark, anchor_t anchor)
|
||||
{
|
||||
void *pParent = GetCurrentParent();
|
||||
void *pNode = m_builder.NewNull(tag, pParent);
|
||||
void *pNode = m_builder.NewNull(mark, pParent);
|
||||
RegisterAnchor(anchor, pNode);
|
||||
|
||||
DispositionNode(pNode);
|
||||
@@ -1,11 +1,16 @@
|
||||
#ifndef GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
#include <map>
|
||||
#include <stack>
|
||||
#include "anchordict.h"
|
||||
#include "eventhandler.h"
|
||||
#include "graphbuilder.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include "yaml-cpp/contrib/anchordict.h"
|
||||
#include "yaml-cpp/contrib/graphbuilder.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
@@ -20,7 +25,7 @@ namespace YAML
|
||||
virtual void OnDocumentStart(const Mark& mark) {(void)mark;}
|
||||
virtual void OnDocumentEnd() {}
|
||||
|
||||
virtual void OnNull(const std::string& tag, anchor_t anchor);
|
||||
virtual void OnNull(const Mark& mark, anchor_t anchor);
|
||||
virtual void OnAlias(const Mark& mark, anchor_t anchor);
|
||||
virtual void OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value);
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#include "conversion.h"
|
||||
#include "yaml-cpp/conversion.h"
|
||||
#include <algorithm>
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
+4
-2
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "emitfromevents.h"
|
||||
#include "emitter.h"
|
||||
#include "null.h"
|
||||
#include "yaml-cpp/emitfromevents.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "yaml-cpp/null.h"
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
@@ -26,12 +26,11 @@ namespace YAML
|
||||
{
|
||||
}
|
||||
|
||||
void EmitFromEvents::OnNull(const std::string& tag, anchor_t anchor)
|
||||
void EmitFromEvents::OnNull(const Mark&, anchor_t anchor)
|
||||
{
|
||||
BeginNode();
|
||||
EmitProps(tag, anchor);
|
||||
if(tag.empty())
|
||||
m_emitter << Null;
|
||||
EmitProps("", anchor);
|
||||
m_emitter << Null;
|
||||
}
|
||||
|
||||
void EmitFromEvents::OnAlias(const Mark&, anchor_t anchor)
|
||||
@@ -98,7 +97,7 @@ namespace YAML
|
||||
|
||||
void EmitFromEvents::EmitProps(const std::string& tag, anchor_t anchor)
|
||||
{
|
||||
if(!tag.empty())
|
||||
if(!tag.empty() && tag != "?")
|
||||
m_emitter << VerbatimTag(tag);
|
||||
if(anchor)
|
||||
m_emitter << Anchor(ToString(anchor));
|
||||
|
||||
+245
-64
@@ -1,8 +1,8 @@
|
||||
#include "emitter.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "emitterstate.h"
|
||||
#include "emitterutils.h"
|
||||
#include "indentation.h"
|
||||
#include "exceptions.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include <sstream>
|
||||
|
||||
namespace YAML
|
||||
@@ -93,6 +93,16 @@ namespace YAML
|
||||
{
|
||||
return m_pState->SetPostCommentIndent(n, GLOBAL);
|
||||
}
|
||||
|
||||
bool Emitter::SetFloatPrecision(unsigned n)
|
||||
{
|
||||
return m_pState->SetFloatPrecision(n, GLOBAL);
|
||||
}
|
||||
|
||||
bool Emitter::SetDoublePrecision(unsigned n)
|
||||
{
|
||||
return m_pState->SetDoublePrecision(n, GLOBAL);
|
||||
}
|
||||
|
||||
// SetLocalValue
|
||||
// . Either start/end a group, or set a modifier locally
|
||||
@@ -102,6 +112,12 @@ namespace YAML
|
||||
return *this;
|
||||
|
||||
switch(value) {
|
||||
case BeginDoc:
|
||||
EmitBeginDoc();
|
||||
break;
|
||||
case EndDoc:
|
||||
EmitEndDoc();
|
||||
break;
|
||||
case BeginSeq:
|
||||
EmitBeginSeq();
|
||||
break;
|
||||
@@ -123,6 +139,9 @@ namespace YAML
|
||||
case TagByKind:
|
||||
EmitKindTag();
|
||||
break;
|
||||
case Newline:
|
||||
EmitNewline();
|
||||
break;
|
||||
default:
|
||||
m_pState->SetLocalValue(value);
|
||||
break;
|
||||
@@ -136,6 +155,15 @@ namespace YAML
|
||||
return *this;
|
||||
}
|
||||
|
||||
Emitter& Emitter::SetLocalPrecision(const _Precision& precision)
|
||||
{
|
||||
if(precision.floatPrecision >= 0)
|
||||
m_pState->SetFloatPrecision(precision.floatPrecision, LOCAL);
|
||||
if(precision.doublePrecision >= 0)
|
||||
m_pState->SetDoublePrecision(precision.doublePrecision, LOCAL);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// GotoNextPreAtomicState
|
||||
// . Runs the state machine, emitting if necessary, and returns 'true' if done (i.e., ready to emit an atom)
|
||||
bool Emitter::GotoNextPreAtomicState()
|
||||
@@ -149,17 +177,18 @@ namespace YAML
|
||||
switch(curState) {
|
||||
// document-level
|
||||
case ES_WAITING_FOR_DOC:
|
||||
m_stream << "---";
|
||||
m_pState->RequireSeparation();
|
||||
m_pState->SwitchState(ES_WRITING_DOC);
|
||||
return true;
|
||||
case ES_WRITING_DOC:
|
||||
return true;
|
||||
case ES_DONE_WITH_DOC:
|
||||
EmitBeginDoc();
|
||||
return false;
|
||||
|
||||
// block sequence
|
||||
case ES_WAITING_FOR_BLOCK_SEQ_ENTRY:
|
||||
m_stream << IndentTo(curIndent) << "-";
|
||||
m_pState->RequireSeparation();
|
||||
m_pState->RequireSoftSeparation();
|
||||
m_pState->SwitchState(ES_WRITING_BLOCK_SEQ_ENTRY);
|
||||
return true;
|
||||
case ES_WRITING_BLOCK_SEQ_ENTRY:
|
||||
@@ -176,8 +205,9 @@ namespace YAML
|
||||
case ES_WRITING_FLOW_SEQ_ENTRY:
|
||||
return true;
|
||||
case ES_DONE_WITH_FLOW_SEQ_ENTRY:
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << ',';
|
||||
m_pState->RequireSeparation();
|
||||
m_pState->RequireSoftSeparation();
|
||||
m_pState->SwitchState(ES_WAITING_FOR_FLOW_SEQ_ENTRY);
|
||||
return false;
|
||||
|
||||
@@ -188,7 +218,7 @@ namespace YAML
|
||||
case ES_WAITING_FOR_BLOCK_MAP_KEY:
|
||||
if(m_pState->CurrentlyInLongKey()) {
|
||||
m_stream << IndentTo(curIndent) << '?';
|
||||
m_pState->RequireSeparation();
|
||||
m_pState->RequireSoftSeparation();
|
||||
}
|
||||
m_pState->SwitchState(ES_WRITING_BLOCK_MAP_KEY);
|
||||
return true;
|
||||
@@ -198,10 +228,6 @@ namespace YAML
|
||||
m_pState->SetError(ErrorMsg::EXPECTED_VALUE_TOKEN);
|
||||
return true;
|
||||
case ES_WAITING_FOR_BLOCK_MAP_VALUE:
|
||||
if(m_pState->CurrentlyInLongKey())
|
||||
m_stream << IndentTo(curIndent);
|
||||
m_stream << ':';
|
||||
m_pState->RequireSeparation();
|
||||
m_pState->SwitchState(ES_WRITING_BLOCK_MAP_VALUE);
|
||||
return true;
|
||||
case ES_WRITING_BLOCK_MAP_VALUE:
|
||||
@@ -215,11 +241,11 @@ namespace YAML
|
||||
m_pState->SetError(ErrorMsg::EXPECTED_KEY_TOKEN);
|
||||
return true;
|
||||
case ES_WAITING_FOR_FLOW_MAP_KEY:
|
||||
EmitSeparationIfNecessary();
|
||||
m_pState->SwitchState(ES_WRITING_FLOW_MAP_KEY);
|
||||
if(m_pState->CurrentlyInLongKey()) {
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << '?';
|
||||
m_pState->RequireSeparation();
|
||||
m_pState->RequireSoftSeparation();
|
||||
}
|
||||
return true;
|
||||
case ES_WRITING_FLOW_MAP_KEY:
|
||||
@@ -228,8 +254,9 @@ namespace YAML
|
||||
m_pState->SetError(ErrorMsg::EXPECTED_VALUE_TOKEN);
|
||||
return true;
|
||||
case ES_WAITING_FOR_FLOW_MAP_VALUE:
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << ':';
|
||||
m_pState->RequireSeparation();
|
||||
m_pState->RequireSoftSeparation();
|
||||
m_pState->SwitchState(ES_WRITING_FLOW_MAP_VALUE);
|
||||
return true;
|
||||
case ES_WRITING_FLOW_MAP_VALUE:
|
||||
@@ -283,6 +310,10 @@ namespace YAML
|
||||
|
||||
// block map
|
||||
case ES_WRITING_BLOCK_MAP_KEY:
|
||||
if(!m_pState->CurrentlyInLongKey()) {
|
||||
m_stream << ':';
|
||||
m_pState->RequireSoftSeparation();
|
||||
}
|
||||
m_pState->SwitchState(ES_DONE_WITH_BLOCK_MAP_KEY);
|
||||
break;
|
||||
case ES_WRITING_BLOCK_MAP_VALUE:
|
||||
@@ -309,11 +340,54 @@ namespace YAML
|
||||
if(!good())
|
||||
return;
|
||||
|
||||
if(m_pState->RequiresSeparation())
|
||||
if(m_pState->RequiresSoftSeparation())
|
||||
m_stream << ' ';
|
||||
else if(m_pState->RequiresHardSeparation())
|
||||
m_stream << '\n';
|
||||
m_pState->UnsetSeparation();
|
||||
}
|
||||
|
||||
// EmitBeginDoc
|
||||
void Emitter::EmitBeginDoc()
|
||||
{
|
||||
if(!good())
|
||||
return;
|
||||
|
||||
EMITTER_STATE curState = m_pState->GetCurState();
|
||||
if(curState != ES_WAITING_FOR_DOC && curState != ES_WRITING_DOC && curState != ES_DONE_WITH_DOC) {
|
||||
m_pState->SetError("Unexpected begin document");
|
||||
return;
|
||||
}
|
||||
|
||||
if(curState == ES_WRITING_DOC || curState == ES_DONE_WITH_DOC)
|
||||
m_stream << '\n';
|
||||
m_stream << "---\n";
|
||||
|
||||
m_pState->UnsetSeparation();
|
||||
m_pState->SwitchState(ES_WAITING_FOR_DOC);
|
||||
}
|
||||
|
||||
// EmitEndDoc
|
||||
void Emitter::EmitEndDoc()
|
||||
{
|
||||
if(!good())
|
||||
return;
|
||||
|
||||
|
||||
EMITTER_STATE curState = m_pState->GetCurState();
|
||||
if(curState != ES_WAITING_FOR_DOC && curState != ES_WRITING_DOC && curState != ES_DONE_WITH_DOC) {
|
||||
m_pState->SetError("Unexpected end document");
|
||||
return;
|
||||
}
|
||||
|
||||
if(curState == ES_WRITING_DOC || curState == ES_DONE_WITH_DOC)
|
||||
m_stream << '\n';
|
||||
m_stream << "...\n";
|
||||
|
||||
m_pState->UnsetSeparation();
|
||||
m_pState->SwitchState(ES_WAITING_FOR_DOC);
|
||||
}
|
||||
|
||||
// EmitBeginSeq
|
||||
void Emitter::EmitBeginSeq()
|
||||
{
|
||||
@@ -332,8 +406,10 @@ namespace YAML
|
||||
curState == ES_WRITING_BLOCK_MAP_KEY || curState == ES_WRITING_BLOCK_MAP_VALUE ||
|
||||
curState == ES_WRITING_DOC
|
||||
) {
|
||||
m_stream << "\n";
|
||||
m_pState->UnsetSeparation();
|
||||
if(m_pState->RequiresHardSeparation() || curState != ES_WRITING_DOC) {
|
||||
m_stream << "\n";
|
||||
m_pState->UnsetSeparation();
|
||||
}
|
||||
}
|
||||
m_pState->PushState(ES_WAITING_FOR_BLOCK_SEQ_ENTRY);
|
||||
} else if(flowType == Flow) {
|
||||
@@ -400,8 +476,10 @@ namespace YAML
|
||||
curState == ES_WRITING_BLOCK_MAP_KEY || curState == ES_WRITING_BLOCK_MAP_VALUE ||
|
||||
curState == ES_WRITING_DOC
|
||||
) {
|
||||
m_stream << "\n";
|
||||
m_pState->UnsetSeparation();
|
||||
if(m_pState->RequiresHardSeparation() || (curState != ES_WRITING_DOC && curState != ES_WRITING_BLOCK_SEQ_ENTRY)) {
|
||||
m_stream << "\n";
|
||||
m_pState->UnsetSeparation();
|
||||
}
|
||||
}
|
||||
m_pState->PushState(ES_WAITING_FOR_BLOCK_MAP_ENTRY);
|
||||
} else if(flowType == Flow) {
|
||||
@@ -439,6 +517,7 @@ namespace YAML
|
||||
} else if(flowType == FT_FLOW) {
|
||||
// Note: flow maps are allowed to be empty
|
||||
assert(curState == ES_DONE_WITH_FLOW_MAP_VALUE || curState == ES_WAITING_FOR_FLOW_MAP_ENTRY);
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << "}";
|
||||
} else
|
||||
assert(false);
|
||||
@@ -466,11 +545,13 @@ namespace YAML
|
||||
m_stream << '\n';
|
||||
unsigned curIndent = m_pState->GetCurIndent();
|
||||
m_stream << IndentTo(curIndent);
|
||||
m_pState->UnsetSeparation();
|
||||
m_pState->SwitchState(ES_WAITING_FOR_BLOCK_MAP_KEY);
|
||||
} else if(flowType == FT_FLOW) {
|
||||
EmitSeparationIfNecessary();
|
||||
if(curState == ES_DONE_WITH_FLOW_MAP_VALUE) {
|
||||
m_stream << ',';
|
||||
m_pState->RequireSeparation();
|
||||
m_pState->RequireSoftSeparation();
|
||||
}
|
||||
m_pState->SwitchState(ES_WAITING_FOR_FLOW_MAP_KEY);
|
||||
} else
|
||||
@@ -496,8 +577,12 @@ namespace YAML
|
||||
return m_pState->SetError(ErrorMsg::UNEXPECTED_VALUE_TOKEN);
|
||||
|
||||
if(flowType == FT_BLOCK) {
|
||||
if(m_pState->CurrentlyInLongKey())
|
||||
if(m_pState->CurrentlyInLongKey()) {
|
||||
m_stream << '\n';
|
||||
m_stream << IndentTo(m_pState->GetCurIndent());
|
||||
m_stream << ':';
|
||||
m_pState->RequireSoftSeparation();
|
||||
}
|
||||
m_pState->SwitchState(ES_WAITING_FOR_BLOCK_MAP_VALUE);
|
||||
} else if(flowType == FT_FLOW) {
|
||||
m_pState->SwitchState(ES_WAITING_FOR_FLOW_MAP_VALUE);
|
||||
@@ -505,6 +590,28 @@ namespace YAML
|
||||
assert(false);
|
||||
}
|
||||
|
||||
// EmitNewline
|
||||
void Emitter::EmitNewline()
|
||||
{
|
||||
if(!good())
|
||||
return;
|
||||
|
||||
if(CanEmitNewline()) {
|
||||
m_stream << '\n';
|
||||
m_pState->UnsetSeparation();
|
||||
}
|
||||
}
|
||||
|
||||
bool Emitter::CanEmitNewline() const
|
||||
{
|
||||
FLOW_TYPE flowType = m_pState->GetCurGroupFlowType();
|
||||
if(flowType == FT_BLOCK && m_pState->CurrentlyInLongKey())
|
||||
return true;
|
||||
|
||||
EMITTER_STATE curState = m_pState->GetCurState();
|
||||
return curState != ES_DONE_WITH_BLOCK_MAP_KEY && curState != ES_WAITING_FOR_BLOCK_MAP_VALUE && curState != ES_WRITING_BLOCK_MAP_VALUE;
|
||||
}
|
||||
|
||||
// *******************************************************************************************
|
||||
// overloads of Write
|
||||
|
||||
@@ -551,7 +658,7 @@ namespace YAML
|
||||
PostAtomicWrite();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Emitter::PreWriteIntegralType(std::stringstream& str)
|
||||
{
|
||||
PreAtomicWrite();
|
||||
@@ -563,22 +670,81 @@ namespace YAML
|
||||
str << std::dec;
|
||||
break;
|
||||
case Hex:
|
||||
str << "0x";
|
||||
str << std::hex;
|
||||
break;
|
||||
case Oct:
|
||||
case Oct:
|
||||
str << "0";
|
||||
str << std::oct;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Emitter::PreWriteStreamable(std::stringstream&)
|
||||
{
|
||||
PreAtomicWrite();
|
||||
EmitSeparationIfNecessary();
|
||||
}
|
||||
|
||||
unsigned Emitter::GetFloatPrecision() const
|
||||
{
|
||||
return m_pState->GetFloatPrecision();
|
||||
}
|
||||
|
||||
unsigned Emitter::GetDoublePrecision() const
|
||||
{
|
||||
return m_pState->GetDoublePrecision();
|
||||
}
|
||||
|
||||
void Emitter::PostWriteIntegralType(const std::stringstream& str)
|
||||
{
|
||||
m_stream << str.str();
|
||||
PostAtomicWrite();
|
||||
}
|
||||
|
||||
|
||||
void Emitter::PostWriteStreamable(const std::stringstream& str)
|
||||
{
|
||||
m_stream << str.str();
|
||||
PostAtomicWrite();
|
||||
}
|
||||
|
||||
const char *Emitter::ComputeFullBoolName(bool b) const
|
||||
{
|
||||
const EMITTER_MANIP mainFmt = (m_pState->GetBoolLengthFormat() == ShortBool ? YesNoBool : m_pState->GetBoolFormat());
|
||||
const EMITTER_MANIP caseFmt = m_pState->GetBoolCaseFormat();
|
||||
switch(mainFmt) {
|
||||
case YesNoBool:
|
||||
switch(caseFmt) {
|
||||
case UpperCase: return b ? "YES" : "NO";
|
||||
case CamelCase: return b ? "Yes" : "No";
|
||||
case LowerCase: return b ? "yes" : "no";
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
case OnOffBool:
|
||||
switch(caseFmt) {
|
||||
case UpperCase: return b ? "ON" : "OFF";
|
||||
case CamelCase: return b ? "On" : "Off";
|
||||
case LowerCase: return b ? "on" : "off";
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
case TrueFalseBool:
|
||||
switch(caseFmt) {
|
||||
case UpperCase: return b ? "TRUE" : "FALSE";
|
||||
case CamelCase: return b ? "True" : "False";
|
||||
case LowerCase: return b ? "true" : "false";
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return b ? "y" : "n"; // should never get here, but it can't hurt to give these answers
|
||||
}
|
||||
|
||||
Emitter& Emitter::Write(bool b)
|
||||
{
|
||||
if(!good())
|
||||
@@ -586,33 +752,26 @@ namespace YAML
|
||||
|
||||
PreAtomicWrite();
|
||||
EmitSeparationIfNecessary();
|
||||
|
||||
// set up all possible bools to write
|
||||
struct BoolName { std::string trueName, falseName; };
|
||||
struct BoolFormatNames { BoolName upper, lower, camel; };
|
||||
struct BoolTypes { BoolFormatNames yesNo, trueFalse, onOff; };
|
||||
|
||||
static const BoolTypes boolTypes = {
|
||||
{ { "YES", "NO" }, { "yes", "no" }, { "Yes", "No" } },
|
||||
{ { "TRUE", "FALSE" }, { "true", "false" }, { "True", "False" } },
|
||||
{ { "ON", "OFF" }, { "on", "off" }, { "On", "Off" } }
|
||||
};
|
||||
|
||||
// select the right one
|
||||
EMITTER_MANIP boolFmt = m_pState->GetBoolFormat();
|
||||
EMITTER_MANIP boolLengthFmt = m_pState->GetBoolLengthFormat();
|
||||
EMITTER_MANIP boolCaseFmt = m_pState->GetBoolCaseFormat();
|
||||
|
||||
const BoolFormatNames& fmtNames = (boolFmt == YesNoBool ? boolTypes.yesNo : boolFmt == TrueFalseBool ? boolTypes.trueFalse : boolTypes.onOff);
|
||||
const BoolName& boolName = (boolCaseFmt == UpperCase ? fmtNames.upper : boolCaseFmt == LowerCase ? fmtNames.lower : fmtNames.camel);
|
||||
const std::string& name = (b ? boolName.trueName : boolName.falseName);
|
||||
|
||||
// and say it!
|
||||
// TODO: should we disallow writing OnOffBool with ShortBool? (it'll just print "o" for both, which is silly)
|
||||
if(boolLengthFmt == ShortBool)
|
||||
|
||||
const char *name = ComputeFullBoolName(b);
|
||||
if(m_pState->GetBoolLengthFormat() == ShortBool)
|
||||
m_stream << name[0];
|
||||
else
|
||||
m_stream << name;
|
||||
|
||||
PostAtomicWrite();
|
||||
return *this;
|
||||
}
|
||||
|
||||
Emitter& Emitter::Write(char ch)
|
||||
{
|
||||
if(!good())
|
||||
return *this;
|
||||
|
||||
PreAtomicWrite();
|
||||
EmitSeparationIfNecessary();
|
||||
|
||||
Utils::WriteChar(m_stream, ch);
|
||||
|
||||
PostAtomicWrite();
|
||||
return *this;
|
||||
@@ -644,7 +803,7 @@ namespace YAML
|
||||
m_pState->SetError(ErrorMsg::INVALID_ANCHOR);
|
||||
return *this;
|
||||
}
|
||||
m_pState->RequireSeparation();
|
||||
m_pState->RequireHardSeparation();
|
||||
// Note: no PostAtomicWrite() because we need another value for this node
|
||||
return *this;
|
||||
}
|
||||
@@ -653,27 +812,31 @@ namespace YAML
|
||||
{
|
||||
if(!good())
|
||||
return *this;
|
||||
|
||||
EmitTag(tag.verbatim, tag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Emitter::EmitTag(bool verbatim, const _Tag& tag)
|
||||
{
|
||||
|
||||
PreAtomicWrite();
|
||||
EmitSeparationIfNecessary();
|
||||
if(!Utils::WriteTag(m_stream, tag.content, verbatim)) {
|
||||
|
||||
bool success = false;
|
||||
if(tag.type == _Tag::Type::Verbatim)
|
||||
success = Utils::WriteTag(m_stream, tag.content, true);
|
||||
else if(tag.type == _Tag::Type::PrimaryHandle)
|
||||
success = Utils::WriteTag(m_stream, tag.content, false);
|
||||
else
|
||||
success = Utils::WriteTagWithPrefix(m_stream, tag.prefix, tag.content);
|
||||
|
||||
if(!success) {
|
||||
m_pState->SetError(ErrorMsg::INVALID_TAG);
|
||||
return;
|
||||
return *this;
|
||||
}
|
||||
m_pState->RequireSeparation();
|
||||
|
||||
m_pState->RequireHardSeparation();
|
||||
// Note: no PostAtomicWrite() because we need another value for this node
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Emitter::EmitKindTag()
|
||||
{
|
||||
_Tag tag("");
|
||||
EmitTag(false, tag);
|
||||
Write(LocalTag(""));
|
||||
}
|
||||
|
||||
Emitter& Emitter::Write(const _Comment& comment)
|
||||
@@ -681,8 +844,12 @@ namespace YAML
|
||||
if(!good())
|
||||
return *this;
|
||||
|
||||
m_stream << Indentation(m_pState->GetPreCommentIndent());
|
||||
if(m_stream.col() > 0)
|
||||
m_stream << Indentation(m_pState->GetPreCommentIndent());
|
||||
Utils::WriteComment(m_stream, comment.content, m_pState->GetPostCommentIndent());
|
||||
m_pState->RequireHardSeparation();
|
||||
m_pState->ForceHardSeparation();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -697,5 +864,19 @@ namespace YAML
|
||||
PostAtomicWrite();
|
||||
return *this;
|
||||
}
|
||||
|
||||
Emitter& Emitter::Write(const Binary& binary)
|
||||
{
|
||||
Write(SecondaryTag("binary"));
|
||||
|
||||
if(!good())
|
||||
return *this;
|
||||
|
||||
PreAtomicWrite();
|
||||
EmitSeparationIfNecessary();
|
||||
Utils::WriteBinary(m_stream, binary);
|
||||
PostAtomicWrite();
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+31
-24
@@ -1,9 +1,10 @@
|
||||
#include "emitterstate.h"
|
||||
#include "exceptions.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include <limits>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
EmitterState::EmitterState(): m_isGood(true), m_curIndent(0), m_requiresSeparation(false)
|
||||
EmitterState::EmitterState(): m_isGood(true), m_curIndent(0), m_requiresSoftSeparation(false), m_requiresHardSeparation(false)
|
||||
{
|
||||
// start up
|
||||
m_stateStack.push(ES_WAITING_FOR_DOC);
|
||||
@@ -21,22 +22,12 @@ namespace YAML
|
||||
m_seqFmt.set(Block);
|
||||
m_mapFmt.set(Block);
|
||||
m_mapKeyFmt.set(Auto);
|
||||
m_floatPrecision.set(6);
|
||||
m_doublePrecision.set(15);
|
||||
}
|
||||
|
||||
EmitterState::~EmitterState()
|
||||
{
|
||||
while(!m_groups.empty())
|
||||
_PopGroup();
|
||||
}
|
||||
|
||||
std::auto_ptr <EmitterState::Group> EmitterState::_PopGroup()
|
||||
{
|
||||
if(m_groups.empty())
|
||||
return std::auto_ptr <Group> (0);
|
||||
|
||||
std::auto_ptr <Group> pGroup(m_groups.top());
|
||||
m_groups.pop();
|
||||
return pGroup;
|
||||
}
|
||||
|
||||
// SetLocalValue
|
||||
@@ -57,10 +48,10 @@ namespace YAML
|
||||
|
||||
void EmitterState::BeginGroup(GROUP_TYPE type)
|
||||
{
|
||||
unsigned lastIndent = (m_groups.empty() ? 0 : m_groups.top()->indent);
|
||||
unsigned lastIndent = (m_groups.empty() ? 0 : m_groups.top().indent);
|
||||
m_curIndent += lastIndent;
|
||||
|
||||
std::auto_ptr <Group> pGroup(new Group(type));
|
||||
std::auto_ptr<Group> pGroup(new Group(type));
|
||||
|
||||
// transfer settings (which last until this group is done)
|
||||
pGroup->modifiedSettings = m_modifiedSettings;
|
||||
@@ -70,7 +61,7 @@ namespace YAML
|
||||
pGroup->indent = GetIndent();
|
||||
pGroup->usingLongKey = (GetMapKeyFormat() == LongKey ? true : false);
|
||||
|
||||
m_groups.push(pGroup.release());
|
||||
m_groups.push(pGroup);
|
||||
}
|
||||
|
||||
void EmitterState::EndGroup(GROUP_TYPE type)
|
||||
@@ -80,13 +71,13 @@ namespace YAML
|
||||
|
||||
// get rid of the current group
|
||||
{
|
||||
std::auto_ptr <Group> pFinishedGroup = _PopGroup();
|
||||
std::auto_ptr<Group> pFinishedGroup = m_groups.pop();
|
||||
if(pFinishedGroup->type != type)
|
||||
return SetError(ErrorMsg::UNMATCHED_GROUP_TAG);
|
||||
}
|
||||
|
||||
// reset old settings
|
||||
unsigned lastIndent = (m_groups.empty() ? 0 : m_groups.top()->indent);
|
||||
unsigned lastIndent = (m_groups.empty() ? 0 : m_groups.top().indent);
|
||||
assert(m_curIndent >= lastIndent);
|
||||
m_curIndent -= lastIndent;
|
||||
|
||||
@@ -100,7 +91,7 @@ namespace YAML
|
||||
if(m_groups.empty())
|
||||
return GT_NONE;
|
||||
|
||||
return m_groups.top()->type;
|
||||
return m_groups.top().type;
|
||||
}
|
||||
|
||||
FLOW_TYPE EmitterState::GetCurGroupFlowType() const
|
||||
@@ -108,26 +99,26 @@ namespace YAML
|
||||
if(m_groups.empty())
|
||||
return FT_NONE;
|
||||
|
||||
return (m_groups.top()->flow == Flow ? FT_FLOW : FT_BLOCK);
|
||||
return (m_groups.top().flow == Flow ? FT_FLOW : FT_BLOCK);
|
||||
}
|
||||
|
||||
bool EmitterState::CurrentlyInLongKey()
|
||||
{
|
||||
if(m_groups.empty())
|
||||
return false;
|
||||
return m_groups.top()->usingLongKey;
|
||||
return m_groups.top().usingLongKey;
|
||||
}
|
||||
|
||||
void EmitterState::StartLongKey()
|
||||
{
|
||||
if(!m_groups.empty())
|
||||
m_groups.top()->usingLongKey = true;
|
||||
m_groups.top().usingLongKey = true;
|
||||
}
|
||||
|
||||
void EmitterState::StartSimpleKey()
|
||||
{
|
||||
if(!m_groups.empty())
|
||||
m_groups.top()->usingLongKey = false;
|
||||
m_groups.top().usingLongKey = false;
|
||||
}
|
||||
|
||||
void EmitterState::ClearModifiedSettings()
|
||||
@@ -273,5 +264,21 @@ namespace YAML
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool EmitterState::SetFloatPrecision(int value, FMT_SCOPE scope)
|
||||
{
|
||||
if(value < 0 || value > std::numeric_limits<float>::digits10)
|
||||
return false;
|
||||
_Set(m_floatPrecision, value, scope);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EmitterState::SetDoublePrecision(int value, FMT_SCOPE scope)
|
||||
{
|
||||
if(value < 0 || value > std::numeric_limits<double>::digits10)
|
||||
return false;
|
||||
_Set(m_doublePrecision, value, scope);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+35
-23
@@ -1,11 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "ptr_stack.h"
|
||||
#include "setting.h"
|
||||
#include "emittermanip.h"
|
||||
#include "yaml-cpp/emittermanip.h"
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
@@ -101,9 +104,12 @@ namespace YAML
|
||||
void StartLongKey();
|
||||
void StartSimpleKey();
|
||||
|
||||
bool RequiresSeparation() const { return m_requiresSeparation; }
|
||||
void RequireSeparation() { m_requiresSeparation = true; }
|
||||
void UnsetSeparation() { m_requiresSeparation = false; }
|
||||
bool RequiresSoftSeparation() const { return m_requiresSoftSeparation; }
|
||||
bool RequiresHardSeparation() const { return m_requiresHardSeparation; }
|
||||
void RequireSoftSeparation() { m_requiresSoftSeparation = true; }
|
||||
void RequireHardSeparation() { m_requiresSoftSeparation = true; m_requiresHardSeparation = true; }
|
||||
void ForceHardSeparation() { m_requiresSoftSeparation = false; }
|
||||
void UnsetSeparation() { m_requiresSoftSeparation = false; m_requiresHardSeparation = false; }
|
||||
|
||||
void ClearModifiedSettings();
|
||||
|
||||
@@ -139,6 +145,11 @@ namespace YAML
|
||||
|
||||
bool SetMapKeyFormat(EMITTER_MANIP value, FMT_SCOPE scope);
|
||||
EMITTER_MANIP GetMapKeyFormat() const { return m_mapKeyFmt.get(); }
|
||||
|
||||
bool SetFloatPrecision(int value, FMT_SCOPE scope);
|
||||
unsigned GetFloatPrecision() const { return m_floatPrecision.get(); }
|
||||
bool SetDoublePrecision(int value, FMT_SCOPE scope);
|
||||
unsigned GetDoublePrecision() const { return m_doublePrecision.get(); }
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
@@ -150,19 +161,21 @@ namespace YAML
|
||||
std::string m_lastError;
|
||||
|
||||
// other state
|
||||
std::stack <EMITTER_STATE> m_stateStack;
|
||||
std::stack<EMITTER_STATE> m_stateStack;
|
||||
|
||||
Setting <EMITTER_MANIP> m_charset;
|
||||
Setting <EMITTER_MANIP> m_strFmt;
|
||||
Setting <EMITTER_MANIP> m_boolFmt;
|
||||
Setting <EMITTER_MANIP> m_boolLengthFmt;
|
||||
Setting <EMITTER_MANIP> m_boolCaseFmt;
|
||||
Setting <EMITTER_MANIP> m_intFmt;
|
||||
Setting <unsigned> m_indent;
|
||||
Setting <unsigned> m_preCommentIndent, m_postCommentIndent;
|
||||
Setting <EMITTER_MANIP> m_seqFmt;
|
||||
Setting <EMITTER_MANIP> m_mapFmt;
|
||||
Setting <EMITTER_MANIP> m_mapKeyFmt;
|
||||
Setting<EMITTER_MANIP> m_charset;
|
||||
Setting<EMITTER_MANIP> m_strFmt;
|
||||
Setting<EMITTER_MANIP> m_boolFmt;
|
||||
Setting<EMITTER_MANIP> m_boolLengthFmt;
|
||||
Setting<EMITTER_MANIP> m_boolCaseFmt;
|
||||
Setting<EMITTER_MANIP> m_intFmt;
|
||||
Setting<unsigned> m_indent;
|
||||
Setting<unsigned> m_preCommentIndent, m_postCommentIndent;
|
||||
Setting<EMITTER_MANIP> m_seqFmt;
|
||||
Setting<EMITTER_MANIP> m_mapFmt;
|
||||
Setting<EMITTER_MANIP> m_mapKeyFmt;
|
||||
Setting<int> m_floatPrecision;
|
||||
Setting<int> m_doublePrecision;
|
||||
|
||||
SettingChanges m_modifiedSettings;
|
||||
SettingChanges m_globalModifiedSettings;
|
||||
@@ -177,12 +190,11 @@ namespace YAML
|
||||
|
||||
SettingChanges modifiedSettings;
|
||||
};
|
||||
|
||||
std::auto_ptr <Group> _PopGroup();
|
||||
|
||||
std::stack <Group *> m_groups;
|
||||
|
||||
ptr_stack<Group> m_groups;
|
||||
unsigned m_curIndent;
|
||||
bool m_requiresSeparation;
|
||||
bool m_requiresSoftSeparation;
|
||||
bool m_requiresHardSeparation;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
||||
+62
-2
@@ -1,7 +1,8 @@
|
||||
#include "emitterutils.h"
|
||||
#include "exp.h"
|
||||
#include "indentation.h"
|
||||
#include "exceptions.h"
|
||||
#include "yaml-cpp/binary.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "stringsource.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
@@ -128,6 +129,9 @@ namespace YAML
|
||||
}
|
||||
|
||||
bool IsValidPlainScalar(const std::string& str, bool inFlow, bool allowOnlyAscii) {
|
||||
if(str.empty())
|
||||
return false;
|
||||
|
||||
// first check the start
|
||||
const RegEx& start = (inFlow ? Exp::PlainScalarInFlow() : Exp::PlainScalar());
|
||||
if(!start.Matches(str))
|
||||
@@ -265,9 +269,29 @@ namespace YAML
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WriteChar(ostream& out, char ch)
|
||||
{
|
||||
if(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'))
|
||||
out << ch;
|
||||
else if((0x20 <= ch && ch <= 0x7e) || ch == ' ')
|
||||
out << "\"" << ch << "\"";
|
||||
else if(ch == '\t')
|
||||
out << "\"\\t\"";
|
||||
else if(ch == '\n')
|
||||
out << "\"\\n\"";
|
||||
else if(ch == '\b')
|
||||
out << "\"\\b\"";
|
||||
else {
|
||||
out << "\"";
|
||||
WriteDoubleQuoteEscapeSequence(out, ch);
|
||||
out << "\"";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WriteComment(ostream& out, const std::string& str, int postCommentIndent)
|
||||
{
|
||||
unsigned curIndent = out.col();
|
||||
const unsigned curIndent = out.col();
|
||||
out << "#" << Indentation(postCommentIndent);
|
||||
int codePoint;
|
||||
for(std::string::const_iterator i = str.begin();
|
||||
@@ -313,6 +337,42 @@ namespace YAML
|
||||
out << ">";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WriteTagWithPrefix(ostream& out, const std::string& prefix, const std::string& tag)
|
||||
{
|
||||
out << "!";
|
||||
StringCharSource prefixBuffer(prefix.c_str(), prefix.size());
|
||||
while(prefixBuffer) {
|
||||
int n = Exp::URI().Match(prefixBuffer);
|
||||
if(n <= 0)
|
||||
return false;
|
||||
|
||||
while(--n >= 0) {
|
||||
out << prefixBuffer[0];
|
||||
++prefixBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
out << "!";
|
||||
StringCharSource tagBuffer(tag.c_str(), tag.size());
|
||||
while(tagBuffer) {
|
||||
int n = Exp::Tag().Match(tagBuffer);
|
||||
if(n <= 0)
|
||||
return false;
|
||||
|
||||
while(--n >= 0) {
|
||||
out << tagBuffer[0];
|
||||
++tagBuffer;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WriteBinary(ostream& out, const Binary& binary)
|
||||
{
|
||||
WriteDoubleQuotedString(out, EncodeBase64(binary.data(), binary.size()), false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-3
@@ -1,24 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "ostream.h"
|
||||
|
||||
#include "yaml-cpp/ostream.h"
|
||||
#include <string>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Binary;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
bool WriteString(ostream& out, const std::string& str, bool inFlow, bool escapeNonAscii);
|
||||
bool WriteSingleQuotedString(ostream& out, const std::string& str);
|
||||
bool WriteDoubleQuotedString(ostream& out, const std::string& str, bool escapeNonAscii);
|
||||
bool WriteLiteralString(ostream& out, const std::string& str, int indent);
|
||||
bool WriteChar(ostream& out, char ch);
|
||||
bool WriteComment(ostream& out, const std::string& str, int postCommentIndent);
|
||||
bool WriteAlias(ostream& out, const std::string& str);
|
||||
bool WriteAnchor(ostream& out, const std::string& str);
|
||||
bool WriteTag(ostream& out, const std::string& str, bool verbatim);
|
||||
bool WriteTagWithPrefix(ostream& out, const std::string& prefix, const std::string& tag);
|
||||
bool WriteBinary(ostream& out, const Binary& binary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
#include "exp.h"
|
||||
#include "exceptions.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include <sstream>
|
||||
|
||||
namespace YAML
|
||||
@@ -107,7 +107,7 @@ namespace YAML
|
||||
}
|
||||
|
||||
std::stringstream msg;
|
||||
throw ParserException(in.mark(), ErrorMsg::INVALID_ESCAPE + ch);
|
||||
throw ParserException(in.mark(), std::string(ErrorMsg::INVALID_ESCAPE) + ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "regex.h"
|
||||
#include <string>
|
||||
@@ -112,6 +114,10 @@ namespace YAML
|
||||
static const RegEx e = RegEx('#');
|
||||
return e;
|
||||
}
|
||||
inline const RegEx& Anchor() {
|
||||
static const RegEx e = !(RegEx("[]{},", REGEX_OR) || BlankOrBreak());
|
||||
return e;
|
||||
}
|
||||
inline const RegEx& AnchorEnd() {
|
||||
static const RegEx e = RegEx("?:,]}%@`", REGEX_OR) || BlankOrBreak();
|
||||
return e;
|
||||
@@ -131,7 +137,7 @@ namespace YAML
|
||||
// . In the block context - ? : must be not be followed with a space.
|
||||
// . In the flow context ? is illegal and : and - must not be followed with a space.
|
||||
inline const RegEx& PlainScalar() {
|
||||
static const RegEx e = !(BlankOrBreak() || RegEx(",[]{}#&*!|>\'\"%@`", REGEX_OR) || (RegEx("-?:", REGEX_OR) + Blank()));
|
||||
static const RegEx e = !(BlankOrBreak() || RegEx(",[]{}#&*!|>\'\"%@`", REGEX_OR) || (RegEx("-?:", REGEX_OR) + (BlankOrBreak() || RegEx())));
|
||||
return e;
|
||||
}
|
||||
inline const RegEx& PlainScalarInFlow() {
|
||||
@@ -143,7 +149,7 @@ namespace YAML
|
||||
return e;
|
||||
}
|
||||
inline const RegEx& EndScalarInFlow() {
|
||||
static const RegEx e = (RegEx(':') + (BlankOrBreak() || RegEx(",]}", REGEX_OR))) || RegEx(",?[]{}", REGEX_OR);
|
||||
static const RegEx e = (RegEx(':') + (BlankOrBreak() || RegEx() || RegEx(",]}", REGEX_OR))) || RegEx(",?[]{}", REGEX_OR);
|
||||
return e;
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "ostream.h"
|
||||
|
||||
#include "yaml-cpp/ostream.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace YAML
|
||||
|
||||
+9
-13
@@ -1,21 +1,19 @@
|
||||
#include "node.h"
|
||||
#include "exceptions.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "iterpriv.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
Iterator::Iterator(): m_pData(0)
|
||||
{
|
||||
m_pData = new IterPriv;
|
||||
}
|
||||
|
||||
Iterator::Iterator(IterPriv *pData): m_pData(pData)
|
||||
Iterator::Iterator(): m_pData(new IterPriv)
|
||||
{
|
||||
}
|
||||
|
||||
Iterator::Iterator(const Iterator& rhs): m_pData(0)
|
||||
Iterator::Iterator(std::auto_ptr<IterPriv> pData): m_pData(pData)
|
||||
{
|
||||
}
|
||||
|
||||
Iterator::Iterator(const Iterator& rhs): m_pData(new IterPriv(*rhs.m_pData))
|
||||
{
|
||||
m_pData = new IterPriv(*rhs.m_pData);
|
||||
}
|
||||
|
||||
Iterator& Iterator::operator = (const Iterator& rhs)
|
||||
@@ -23,14 +21,12 @@ namespace YAML
|
||||
if(this == &rhs)
|
||||
return *this;
|
||||
|
||||
delete m_pData;
|
||||
m_pData = new IterPriv(*rhs.m_pData);
|
||||
m_pData.reset(new IterPriv(*rhs.m_pData));
|
||||
return *this;
|
||||
}
|
||||
|
||||
Iterator::~Iterator()
|
||||
{
|
||||
delete m_pData;
|
||||
}
|
||||
|
||||
Iterator& Iterator::operator ++ ()
|
||||
|
||||
+5
-3
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "ltnode.h"
|
||||
|
||||
#include "yaml-cpp/ltnode.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
||||
-91
@@ -1,91 +0,0 @@
|
||||
#include "map.h"
|
||||
#include "node.h"
|
||||
#include "eventhandler.h"
|
||||
#include "exceptions.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
Map::Map()
|
||||
{
|
||||
}
|
||||
|
||||
Map::~Map()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Map::Clear()
|
||||
{
|
||||
for(node_map::const_iterator it=m_data.begin();it!=m_data.end();++it) {
|
||||
delete it->first;
|
||||
delete it->second;
|
||||
}
|
||||
m_data.clear();
|
||||
}
|
||||
|
||||
bool Map::GetBegin(std::map <Node *, Node *, ltnode>::const_iterator& it) const
|
||||
{
|
||||
it = m_data.begin();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Map::GetEnd(std::map <Node *, Node *, ltnode>::const_iterator& it) const
|
||||
{
|
||||
it = m_data.end();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::size_t Map::GetSize() const
|
||||
{
|
||||
return m_data.size();
|
||||
}
|
||||
|
||||
void Map::Insert(std::auto_ptr<Node> pKey, std::auto_ptr<Node> pValue)
|
||||
{
|
||||
node_map::const_iterator it = m_data.find(pKey.get());
|
||||
if(it != m_data.end())
|
||||
return;
|
||||
|
||||
m_data[pKey.release()] = pValue.release();
|
||||
}
|
||||
|
||||
void Map::EmitEvents(AliasManager& am, EventHandler& eventHandler, const Mark& mark, const std::string& tag, anchor_t anchor) const
|
||||
{
|
||||
eventHandler.OnMapStart(mark, tag, anchor);
|
||||
for(node_map::const_iterator it=m_data.begin();it!=m_data.end();++it) {
|
||||
it->first->EmitEvents(am, eventHandler);
|
||||
it->second->EmitEvents(am, eventHandler);
|
||||
}
|
||||
eventHandler.OnMapEnd();
|
||||
}
|
||||
|
||||
int Map::Compare(Content *pContent)
|
||||
{
|
||||
return -pContent->Compare(this);
|
||||
}
|
||||
|
||||
int Map::Compare(Map *pMap)
|
||||
{
|
||||
node_map::const_iterator it = m_data.begin(), jt = pMap->m_data.begin();
|
||||
while(1) {
|
||||
if(it == m_data.end()) {
|
||||
if(jt == pMap->m_data.end())
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
if(jt == pMap->m_data.end())
|
||||
return 1;
|
||||
|
||||
int cmp = it->first->Compare(*jt->first);
|
||||
if(cmp != 0)
|
||||
return cmp;
|
||||
|
||||
cmp = it->second->Compare(*jt->second);
|
||||
if(cmp != 0)
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef MAP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define MAP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
|
||||
#include "content.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
|
||||
class Map: public Content
|
||||
{
|
||||
private:
|
||||
typedef std::map <Node *, Node *, ltnode> node_map;
|
||||
|
||||
public:
|
||||
Map();
|
||||
virtual ~Map();
|
||||
|
||||
void Clear();
|
||||
|
||||
virtual bool GetBegin(std::map <Node *, Node *, ltnode>::const_iterator& it) const;
|
||||
virtual bool GetEnd(std::map <Node *, Node *, ltnode>::const_iterator& it) const;
|
||||
virtual std::size_t GetSize() const;
|
||||
|
||||
virtual void Insert(std::auto_ptr<Node> pKey, std::auto_ptr<Node> pValue);
|
||||
virtual void EmitEvents(AliasManager& am, EventHandler& eventHandler, const Mark& mark, const std::string& tag, anchor_t anchor) const;
|
||||
|
||||
virtual bool IsMap() const { return true; }
|
||||
|
||||
// ordering
|
||||
virtual int Compare(Content *pContent);
|
||||
virtual int Compare(Scalar *) { return 1; }
|
||||
virtual int Compare(Sequence *) { return 1; }
|
||||
virtual int Compare(Map *pMap);
|
||||
|
||||
private:
|
||||
node_map m_data;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // MAP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
+148
-135
@@ -1,18 +1,12 @@
|
||||
#include "node.h"
|
||||
#include "aliascontent.h"
|
||||
#include "aliasmanager.h"
|
||||
#include "content.h"
|
||||
#include "emitfromevents.h"
|
||||
#include "emitter.h"
|
||||
#include "eventhandler.h"
|
||||
#include "graphbuilderadapter.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
#include "yaml-cpp/aliasmanager.h"
|
||||
#include "yaml-cpp/emitfromevents.h"
|
||||
#include "yaml-cpp/emitter.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include "iterpriv.h"
|
||||
#include "map.h"
|
||||
#include "nodebuilder.h"
|
||||
#include "nodeproperties.h"
|
||||
#include "scalar.h"
|
||||
#include "nodeownership.h"
|
||||
#include "scanner.h"
|
||||
#include "sequence.h"
|
||||
#include "tag.h"
|
||||
#include "token.h"
|
||||
#include <cassert>
|
||||
@@ -20,13 +14,15 @@
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
// the ordering!
|
||||
bool ltnode::operator ()(const Node *pNode1, const Node *pNode2) const
|
||||
{
|
||||
bool ltnode::operator()(const Node *pNode1, const Node *pNode2) const {
|
||||
return *pNode1 < *pNode2;
|
||||
}
|
||||
|
||||
Node::Node(): m_pContent(0), m_alias(false), m_pIdentity(this), m_referenced(false)
|
||||
Node::Node(): m_pOwnership(new NodeOwnership), m_type(NodeType::Null)
|
||||
{
|
||||
}
|
||||
|
||||
Node::Node(NodeOwnership& owner): m_pOwnership(new NodeOwnership(&owner)), m_type(NodeType::Null)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,20 +33,29 @@ namespace YAML
|
||||
|
||||
void Node::Clear()
|
||||
{
|
||||
delete m_pContent;
|
||||
m_pContent = 0;
|
||||
m_alias = false;
|
||||
m_referenced = false;
|
||||
m_pOwnership.reset(new NodeOwnership);
|
||||
m_type = NodeType::Null;
|
||||
m_tag.clear();
|
||||
m_scalarData.clear();
|
||||
m_seqData.clear();
|
||||
m_mapData.clear();
|
||||
}
|
||||
|
||||
bool Node::IsAliased() const
|
||||
{
|
||||
return m_pOwnership->IsAliased(*this);
|
||||
}
|
||||
|
||||
Node& Node::CreateNode()
|
||||
{
|
||||
return m_pOwnership->Create();
|
||||
}
|
||||
|
||||
std::auto_ptr<Node> Node::Clone() const
|
||||
{
|
||||
std::auto_ptr<Node> pNode(new Node);
|
||||
NodeBuilder nodeBuilder(*pNode);
|
||||
GraphBuilder<NodeBuilder> graphBuilder(nodeBuilder);
|
||||
GraphBuilderAdapter eventHandler(graphBuilder);
|
||||
EmitEvents(eventHandler);
|
||||
EmitEvents(nodeBuilder);
|
||||
return pNode;
|
||||
}
|
||||
|
||||
@@ -65,9 +70,10 @@ namespace YAML
|
||||
void Node::EmitEvents(AliasManager& am, EventHandler& eventHandler) const
|
||||
{
|
||||
anchor_t anchor = NullAnchor;
|
||||
if(m_referenced || m_alias) {
|
||||
if(const Node *pOther = am.LookupReference(*this)) {
|
||||
eventHandler.OnAlias(m_mark, am.LookupAnchor(*pOther));
|
||||
if(IsAliased()) {
|
||||
anchor = am.LookupAnchor(*this);
|
||||
if(anchor) {
|
||||
eventHandler.OnAlias(m_mark, anchor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,105 +81,76 @@ namespace YAML
|
||||
anchor = am.LookupAnchor(*this);
|
||||
}
|
||||
|
||||
if(m_pContent)
|
||||
m_pContent->EmitEvents(am, eventHandler, m_mark, GetTag(), anchor);
|
||||
else
|
||||
eventHandler.OnNull(GetTag(), anchor);
|
||||
}
|
||||
|
||||
void Node::Init(CONTENT_TYPE type, const Mark& mark, const std::string& tag)
|
||||
{
|
||||
Clear();
|
||||
m_mark = mark;
|
||||
m_tag = tag;
|
||||
m_alias = false;
|
||||
m_pIdentity = this;
|
||||
m_referenced = false;
|
||||
|
||||
switch(type) {
|
||||
case CT_SCALAR:
|
||||
m_pContent = new Scalar;
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
eventHandler.OnNull(m_mark, anchor);
|
||||
break;
|
||||
case CT_SEQUENCE:
|
||||
m_pContent = new Sequence;
|
||||
case NodeType::Scalar:
|
||||
eventHandler.OnScalar(m_mark, m_tag, anchor, m_scalarData);
|
||||
break;
|
||||
case CT_MAP:
|
||||
m_pContent = new Map;
|
||||
case NodeType::Sequence:
|
||||
eventHandler.OnSequenceStart(m_mark, m_tag, anchor);
|
||||
for(std::size_t i=0;i<m_seqData.size();i++)
|
||||
m_seqData[i]->EmitEvents(am, eventHandler);
|
||||
eventHandler.OnSequenceEnd();
|
||||
break;
|
||||
default:
|
||||
m_pContent = 0;
|
||||
case NodeType::Map:
|
||||
eventHandler.OnMapStart(m_mark, m_tag, anchor);
|
||||
for(node_map::const_iterator it=m_mapData.begin();it!=m_mapData.end();++it) {
|
||||
it->first->EmitEvents(am, eventHandler);
|
||||
it->second->EmitEvents(am, eventHandler);
|
||||
}
|
||||
eventHandler.OnMapEnd();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Node::InitNull(const std::string& tag)
|
||||
{
|
||||
Clear();
|
||||
m_tag = tag;
|
||||
m_alias = false;
|
||||
m_pIdentity = this;
|
||||
m_referenced = false;
|
||||
}
|
||||
|
||||
void Node::InitAlias(const Mark& mark, const Node& identity)
|
||||
void Node::Init(NodeType::value type, const Mark& mark, const std::string& tag)
|
||||
{
|
||||
Clear();
|
||||
m_mark = mark;
|
||||
m_alias = true;
|
||||
m_pIdentity = &identity;
|
||||
if(identity.m_pContent)
|
||||
m_pContent = new AliasContent(identity.m_pContent);
|
||||
identity.m_referenced = true;
|
||||
m_type = type;
|
||||
m_tag = tag;
|
||||
}
|
||||
|
||||
void Node::SetData(const std::string& data)
|
||||
void Node::MarkAsAliased()
|
||||
{
|
||||
assert(m_pContent); // TODO: throw
|
||||
m_pContent->SetData(data);
|
||||
}
|
||||
|
||||
void Node::Append(std::auto_ptr<Node> pNode)
|
||||
{
|
||||
assert(m_pContent); // TODO: throw
|
||||
m_pContent->Append(pNode);
|
||||
m_pOwnership->MarkAsAliased(*this);
|
||||
}
|
||||
|
||||
void Node::Insert(std::auto_ptr<Node> pKey, std::auto_ptr<Node> pValue)
|
||||
void Node::SetScalarData(const std::string& data)
|
||||
{
|
||||
assert(m_pContent); // TODO: throw
|
||||
m_pContent->Insert(pKey, pValue);
|
||||
assert(m_type == NodeType::Scalar); // TODO: throw?
|
||||
m_scalarData = data;
|
||||
}
|
||||
|
||||
CONTENT_TYPE Node::GetType() const
|
||||
void Node::Append(Node& node)
|
||||
{
|
||||
if(!m_pContent)
|
||||
return CT_NONE;
|
||||
|
||||
if(m_pContent->IsScalar())
|
||||
return CT_SCALAR;
|
||||
else if(m_pContent->IsSequence())
|
||||
return CT_SEQUENCE;
|
||||
else if(m_pContent->IsMap())
|
||||
return CT_MAP;
|
||||
|
||||
return CT_NONE;
|
||||
assert(m_type == NodeType::Sequence); // TODO: throw?
|
||||
m_seqData.push_back(&node);
|
||||
}
|
||||
|
||||
void Node::Insert(Node& key, Node& value)
|
||||
{
|
||||
assert(m_type == NodeType::Map); // TODO: throw?
|
||||
m_mapData[&key] = &value;
|
||||
}
|
||||
|
||||
// begin
|
||||
// Returns an iterator to the beginning of this (sequence or map).
|
||||
Iterator Node::begin() const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return Iterator();
|
||||
|
||||
std::vector <Node *>::const_iterator seqIter;
|
||||
if(m_pContent->GetBegin(seqIter))
|
||||
return Iterator(new IterPriv(seqIter));
|
||||
|
||||
std::map <Node *, Node *, ltnode>::const_iterator mapIter;
|
||||
if(m_pContent->GetBegin(mapIter))
|
||||
return Iterator(new IterPriv(mapIter));
|
||||
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
case NodeType::Scalar:
|
||||
return Iterator();
|
||||
case NodeType::Sequence:
|
||||
return Iterator(std::auto_ptr<IterPriv>(new IterPriv(m_seqData.begin())));
|
||||
case NodeType::Map:
|
||||
return Iterator(std::auto_ptr<IterPriv>(new IterPriv(m_mapData.begin())));
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return Iterator();
|
||||
}
|
||||
|
||||
@@ -181,50 +158,62 @@ namespace YAML
|
||||
// . Returns an iterator to the end of this (sequence or map).
|
||||
Iterator Node::end() const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return Iterator();
|
||||
|
||||
std::vector <Node *>::const_iterator seqIter;
|
||||
if(m_pContent->GetEnd(seqIter))
|
||||
return Iterator(new IterPriv(seqIter));
|
||||
|
||||
std::map <Node *, Node *, ltnode>::const_iterator mapIter;
|
||||
if(m_pContent->GetEnd(mapIter))
|
||||
return Iterator(new IterPriv(mapIter));
|
||||
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
case NodeType::Scalar:
|
||||
return Iterator();
|
||||
case NodeType::Sequence:
|
||||
return Iterator(std::auto_ptr<IterPriv>(new IterPriv(m_seqData.end())));
|
||||
case NodeType::Map:
|
||||
return Iterator(std::auto_ptr<IterPriv>(new IterPriv(m_mapData.end())));
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return Iterator();
|
||||
}
|
||||
|
||||
// size
|
||||
// . Returns the size of this node, if it's a sequence node.
|
||||
// . Returns the size of a sequence or map node
|
||||
// . Otherwise, returns zero.
|
||||
std::size_t Node::size() const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return 0;
|
||||
|
||||
return m_pContent->GetSize();
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
case NodeType::Scalar:
|
||||
return 0;
|
||||
case NodeType::Sequence:
|
||||
return m_seqData.size();
|
||||
case NodeType::Map:
|
||||
return m_mapData.size();
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Node *Node::FindAtIndex(std::size_t i) const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return 0;
|
||||
|
||||
return m_pContent->GetNode(i);
|
||||
if(m_type == NodeType::Sequence)
|
||||
return m_seqData[i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Node::GetScalar(std::string& s) const
|
||||
{
|
||||
if(!m_pContent) {
|
||||
if(m_tag.empty())
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
s = "~";
|
||||
else
|
||||
s = "";
|
||||
return true;
|
||||
return true;
|
||||
case NodeType::Scalar:
|
||||
s = m_scalarData;
|
||||
return true;
|
||||
case NodeType::Sequence:
|
||||
case NodeType::Map:
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_pContent->GetScalar(s);
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
Emitter& operator << (Emitter& out, const Node& node)
|
||||
@@ -236,17 +225,41 @@ namespace YAML
|
||||
|
||||
int Node::Compare(const Node& rhs) const
|
||||
{
|
||||
// Step 1: no content is the smallest
|
||||
if(!m_pContent) {
|
||||
if(rhs.m_pContent)
|
||||
return -1;
|
||||
else
|
||||
if(m_type != rhs.m_type)
|
||||
return rhs.m_type - m_type;
|
||||
|
||||
switch(m_type) {
|
||||
case NodeType::Null:
|
||||
return 0;
|
||||
case NodeType::Scalar:
|
||||
return m_scalarData.compare(rhs.m_scalarData);
|
||||
case NodeType::Sequence:
|
||||
if(m_seqData.size() < rhs.m_seqData.size())
|
||||
return 1;
|
||||
else if(m_seqData.size() > rhs.m_seqData.size())
|
||||
return -1;
|
||||
for(std::size_t i=0;i<m_seqData.size();i++)
|
||||
if(int cmp = m_seqData[i]->Compare(*rhs.m_seqData[i]))
|
||||
return cmp;
|
||||
return 0;
|
||||
case NodeType::Map:
|
||||
if(m_mapData.size() < rhs.m_mapData.size())
|
||||
return 1;
|
||||
else if(m_mapData.size() > rhs.m_mapData.size())
|
||||
return -1;
|
||||
node_map::const_iterator it = m_mapData.begin();
|
||||
node_map::const_iterator jt = rhs.m_mapData.begin();
|
||||
for(;it!=m_mapData.end() && jt!=rhs.m_mapData.end();it++, jt++) {
|
||||
if(int cmp = it->first->Compare(*jt->first))
|
||||
return cmp;
|
||||
if(int cmp = it->second->Compare(*jt->second))
|
||||
return cmp;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if(!rhs.m_pContent)
|
||||
return 1;
|
||||
|
||||
return m_pContent->Compare(rhs.m_pContent);
|
||||
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool operator < (const Node& n1, const Node& n2)
|
||||
|
||||
+104
-49
@@ -1,90 +1,145 @@
|
||||
#include "nodebuilder.h"
|
||||
#include "mark.h"
|
||||
#include "node.h"
|
||||
#include "nodeproperties.h"
|
||||
#include "yaml-cpp/mark.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
NodeBuilder::NodeBuilder(Node& root): m_root(root), m_initializedRoot(false)
|
||||
NodeBuilder::NodeBuilder(Node& root): m_root(root), m_initializedRoot(false), m_finished(false)
|
||||
{
|
||||
m_root.Clear();
|
||||
}
|
||||
|
||||
NodeBuilder::NodeBuilder(const NodeBuilder& o): m_root(o.m_root), m_initializedRoot(o.m_initializedRoot)
|
||||
{
|
||||
m_anchors.push_back(0); // since the anchors start at 1
|
||||
}
|
||||
|
||||
NodeBuilder::~NodeBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
Node *NodeBuilder::NewNull(const std::string& tag, Node *pParent)
|
||||
void NodeBuilder::OnDocumentStart(const Mark&)
|
||||
{
|
||||
(void)pParent;
|
||||
Node *pNode = NewNode();
|
||||
pNode->InitNull(tag);
|
||||
return pNode;
|
||||
}
|
||||
|
||||
Node *NodeBuilder::AnchorReference(const Mark& mark, Node *pNode)
|
||||
void NodeBuilder::OnDocumentEnd()
|
||||
{
|
||||
Node *pAlias = NewNode();
|
||||
pAlias->InitAlias(mark, *pNode);
|
||||
return pAlias;
|
||||
assert(m_finished);
|
||||
}
|
||||
|
||||
Node *NodeBuilder::NewScalar(const Mark& mark, const std::string& tag, Node *pParent, const std::string& value)
|
||||
void NodeBuilder::OnNull(const Mark& mark, anchor_t anchor)
|
||||
{
|
||||
(void)pParent;
|
||||
Node *pNode = NewNode();
|
||||
pNode->Init(CT_SCALAR, mark, tag);
|
||||
pNode->SetData(value);
|
||||
return pNode;
|
||||
Node& node = Push(anchor);
|
||||
node.Init(NodeType::Null, mark, "");
|
||||
Pop();
|
||||
}
|
||||
|
||||
NodeBuilder::Sequence *NodeBuilder::NewSequence(const Mark& mark, const std::string& tag, Node *pParent)
|
||||
void NodeBuilder::OnAlias(const Mark& /*mark*/, anchor_t anchor)
|
||||
{
|
||||
(void)pParent;
|
||||
Node *pNode = NewNode();
|
||||
pNode->Init(CT_SEQUENCE, mark, tag);
|
||||
return pNode;
|
||||
Node& node = *m_anchors[anchor];
|
||||
Insert(node);
|
||||
node.MarkAsAliased();
|
||||
}
|
||||
|
||||
void NodeBuilder::AppendToSequence(Sequence *pSequence, Node *pNode)
|
||||
void NodeBuilder::OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value)
|
||||
{
|
||||
std::auto_ptr<Node> apNode(m_unlinked.pop(pNode));
|
||||
assert(apNode.get());
|
||||
pSequence->Append(apNode);
|
||||
Node& node = Push(anchor);
|
||||
node.Init(NodeType::Scalar, mark, tag);
|
||||
node.SetScalarData(value);
|
||||
Pop();
|
||||
}
|
||||
|
||||
NodeBuilder::Map *NodeBuilder::NewMap(const Mark& mark, const std::string& tag, Node* pParent)
|
||||
void NodeBuilder::OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor)
|
||||
{
|
||||
(void)pParent;
|
||||
Node *pNode = NewNode();
|
||||
pNode->Init(CT_MAP, mark, tag);
|
||||
return pNode;
|
||||
Node& node = Push(anchor);
|
||||
node.Init(NodeType::Sequence, mark, tag);
|
||||
}
|
||||
|
||||
void NodeBuilder::AssignInMap(Map *pMap, Node *pKeyNode, Node *pValueNode)
|
||||
void NodeBuilder::OnSequenceEnd()
|
||||
{
|
||||
std::auto_ptr<Node> apKeyNode(m_unlinked.pop(pKeyNode));
|
||||
std::auto_ptr<Node> apValueNode(m_unlinked.pop(pValueNode));
|
||||
assert(apKeyNode.get() && apValueNode.get());
|
||||
pMap->Insert(apKeyNode, apValueNode);
|
||||
Pop();
|
||||
}
|
||||
|
||||
void NodeBuilder::OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor)
|
||||
{
|
||||
Node& node = Push(anchor);
|
||||
node.Init(NodeType::Map, mark, tag);
|
||||
m_didPushKey.push(false);
|
||||
}
|
||||
|
||||
void NodeBuilder::OnMapEnd()
|
||||
{
|
||||
m_didPushKey.pop();
|
||||
Pop();
|
||||
}
|
||||
|
||||
Node* NodeBuilder::NewNode()
|
||||
Node& NodeBuilder::Push(anchor_t anchor)
|
||||
{
|
||||
Node& node = Push();
|
||||
RegisterAnchor(anchor, node);
|
||||
return node;
|
||||
}
|
||||
|
||||
Node& NodeBuilder::Push()
|
||||
{
|
||||
if(!m_initializedRoot) {
|
||||
m_initializedRoot = true;
|
||||
return &m_root;
|
||||
return m_root;
|
||||
}
|
||||
|
||||
std::auto_ptr<Node> pNode(new Node);
|
||||
Node* pResult = pNode.get();
|
||||
// Save the pointer in a collection that will free it on exception
|
||||
m_unlinked.push(pNode);
|
||||
return pResult;
|
||||
Node& node = m_root.CreateNode();
|
||||
m_stack.push(&node);
|
||||
return node;
|
||||
}
|
||||
|
||||
Node& NodeBuilder::Top()
|
||||
{
|
||||
return m_stack.empty() ? m_root : *m_stack.top();
|
||||
}
|
||||
|
||||
void NodeBuilder::Pop()
|
||||
{
|
||||
assert(!m_finished);
|
||||
if(m_stack.empty()) {
|
||||
m_finished = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Node& node = *m_stack.top();
|
||||
m_stack.pop();
|
||||
Insert(node);
|
||||
}
|
||||
|
||||
void NodeBuilder::Insert(Node& node)
|
||||
{
|
||||
Node& curTop = Top();
|
||||
switch(curTop.Type()) {
|
||||
case NodeType::Null:
|
||||
case NodeType::Scalar:
|
||||
assert(false);
|
||||
break;
|
||||
case NodeType::Sequence:
|
||||
curTop.Append(node);
|
||||
break;
|
||||
case NodeType::Map:
|
||||
assert(!m_didPushKey.empty());
|
||||
if(m_didPushKey.top()) {
|
||||
assert(!m_pendingKeys.empty());
|
||||
|
||||
Node& key = *m_pendingKeys.top();
|
||||
m_pendingKeys.pop();
|
||||
curTop.Insert(key, node);
|
||||
m_didPushKey.top() = false;
|
||||
} else {
|
||||
m_pendingKeys.push(&node);
|
||||
m_didPushKey.top() = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void NodeBuilder::RegisterAnchor(anchor_t anchor, Node& node)
|
||||
{
|
||||
if(anchor) {
|
||||
assert(anchor == m_anchors.size());
|
||||
m_anchors.push_back(&node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+31
-23
@@ -1,51 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
|
||||
#include "ptr_stack.h"
|
||||
#include <vector>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
class Mark;
|
||||
|
||||
class NodeBuilder
|
||||
class NodeBuilder: public EventHandler
|
||||
{
|
||||
public:
|
||||
typedef YAML::Node Node;
|
||||
typedef YAML::Node Map;
|
||||
typedef YAML::Node Sequence;
|
||||
|
||||
explicit NodeBuilder(Node& root);
|
||||
NodeBuilder(const NodeBuilder& o);
|
||||
virtual ~NodeBuilder();
|
||||
|
||||
Node *NewNull(const std::string& tag, Node *pParent);
|
||||
Node *AnchorReference(const Mark& mark, Node *pNode);
|
||||
Node *NewScalar(const Mark& mark, const std::string& tag, Node *pParent, const std::string& value);
|
||||
virtual void OnDocumentStart(const Mark& mark);
|
||||
virtual void OnDocumentEnd();
|
||||
|
||||
Sequence *NewSequence(const Mark& mark, const std::string& tag, Node *pParent);
|
||||
void AppendToSequence(Sequence *pSequence, Node *pNode);
|
||||
void SequenceComplete(Sequence *pSequence) {(void)pSequence;}
|
||||
virtual void OnNull(const Mark& mark, anchor_t anchor);
|
||||
virtual void OnAlias(const Mark& mark, anchor_t anchor);
|
||||
virtual void OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value);
|
||||
|
||||
Map *NewMap(const Mark& mark, const std::string& tag, Node *pParent);
|
||||
void AssignInMap(Map *pMap, Node *pKeyNode, Node *pValueNode);
|
||||
void MapComplete(Map *pMap) {(void)pMap;}
|
||||
virtual void OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor);
|
||||
virtual void OnSequenceEnd();
|
||||
|
||||
virtual void OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor);
|
||||
virtual void OnMapEnd();
|
||||
|
||||
private:
|
||||
Node* NewNode();
|
||||
Node& Push(anchor_t anchor);
|
||||
Node& Push();
|
||||
Node& Top();
|
||||
void Pop();
|
||||
|
||||
void Insert(Node& node);
|
||||
void RegisterAnchor(anchor_t anchor, Node& node);
|
||||
|
||||
private:
|
||||
Node& m_root;
|
||||
bool m_initializedRoot;
|
||||
bool m_finished;
|
||||
|
||||
ptr_stack<Node> m_unlinked;
|
||||
std::stack<Node *> m_stack;
|
||||
std::stack<Node *> m_pendingKeys;
|
||||
std::stack<bool> m_didPushKey;
|
||||
|
||||
typedef std::vector<Node *> Anchors;
|
||||
Anchors m_anchors;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "nodeownership.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
NodeOwnership::NodeOwnership(NodeOwnership *pOwner): m_pOwner(pOwner)
|
||||
{
|
||||
if(!m_pOwner)
|
||||
m_pOwner = this;
|
||||
}
|
||||
|
||||
NodeOwnership::~NodeOwnership()
|
||||
{
|
||||
}
|
||||
|
||||
Node& NodeOwnership::_Create()
|
||||
{
|
||||
m_nodes.push_back(std::auto_ptr<Node>(new Node));
|
||||
return m_nodes.back();
|
||||
}
|
||||
|
||||
void NodeOwnership::_MarkAsAliased(const Node& node)
|
||||
{
|
||||
m_aliasedNodes.insert(&node);
|
||||
}
|
||||
|
||||
bool NodeOwnership::_IsAliased(const Node& node) const
|
||||
{
|
||||
return m_aliasedNodes.count(&node) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
#include "ptr_vector.h"
|
||||
#include <set>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
|
||||
class NodeOwnership: private noncopyable
|
||||
{
|
||||
public:
|
||||
explicit NodeOwnership(NodeOwnership *pOwner = 0);
|
||||
~NodeOwnership();
|
||||
|
||||
Node& Create() { return m_pOwner->_Create(); }
|
||||
void MarkAsAliased(const Node& node) { m_pOwner->_MarkAsAliased(node); }
|
||||
bool IsAliased(const Node& node) const { return m_pOwner->_IsAliased(node); }
|
||||
|
||||
private:
|
||||
Node& _Create();
|
||||
void _MarkAsAliased(const Node& node);
|
||||
bool _IsAliased(const Node& node) const;
|
||||
|
||||
private:
|
||||
ptr_vector<Node> m_nodes;
|
||||
std::set<const Node *> m_aliasedNodes;
|
||||
NodeOwnership *m_pOwner;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
#include "null.h"
|
||||
#include "node.h"
|
||||
#include "yaml-cpp/null.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#include "ostream.h"
|
||||
#include "yaml-cpp/ostream.h"
|
||||
#include <cstring>
|
||||
|
||||
namespace YAML
|
||||
|
||||
+6
-20
@@ -1,9 +1,8 @@
|
||||
#include "parser.h"
|
||||
#include "yaml-cpp/parser.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "yaml-cpp/node.h"
|
||||
#include "directives.h"
|
||||
#include "eventhandler.h"
|
||||
#include "exceptions.h"
|
||||
#include "graphbuilderadapter.h"
|
||||
#include "node.h"
|
||||
#include "nodebuilder.h"
|
||||
#include "scanner.h"
|
||||
#include "singledocparser.h"
|
||||
@@ -55,19 +54,6 @@ namespace YAML
|
||||
sdp.HandleDocument(eventHandler);
|
||||
return true;
|
||||
}
|
||||
|
||||
// BuildNextDocumentGraph
|
||||
// . Builds a graph of the next document
|
||||
// . Returns NULL if there are no more documents
|
||||
void *Parser::BuildNextDocumentGraph(GraphBuilderInterface& graphBuilder)
|
||||
{
|
||||
GraphBuilderAdapter eventHandler(graphBuilder);
|
||||
if (HandleNextDocument(eventHandler)) {
|
||||
return eventHandler.RootNode();
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// GetNextDocument
|
||||
// . Reads the next document in the queue (of tokens).
|
||||
@@ -75,7 +61,7 @@ namespace YAML
|
||||
bool Parser::GetNextDocument(Node& document)
|
||||
{
|
||||
NodeBuilder builder(document);
|
||||
return BuildNextDocumentGraph(builder);
|
||||
return HandleNextDocument(builder);
|
||||
}
|
||||
|
||||
// ParseDirectives
|
||||
@@ -126,7 +112,7 @@ namespace YAML
|
||||
str.get();
|
||||
str >> m_pDirectives->version.minor;
|
||||
if(!str || str.peek() != EOF)
|
||||
throw ParserException(token.mark, ErrorMsg::YAML_VERSION + token.params[0]);
|
||||
throw ParserException(token.mark, std::string(ErrorMsg::YAML_VERSION) + token.params[0]);
|
||||
|
||||
if(m_pDirectives->version.major > 1)
|
||||
throw ParserException(token.mark, ErrorMsg::YAML_MAJOR_VERSION);
|
||||
|
||||
+10
-19
@@ -1,16 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#include <algorithm>
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "noncopyable.h"
|
||||
|
||||
template <typename T>
|
||||
class ptr_stack : private YAML::noncopyable
|
||||
class ptr_stack: private YAML::noncopyable
|
||||
{
|
||||
public:
|
||||
ptr_stack() {}
|
||||
@@ -26,8 +28,6 @@ public:
|
||||
bool empty() const { return m_data.empty(); }
|
||||
|
||||
void push(std::auto_ptr<T> t) {
|
||||
// Make sure that the space is available before releasing the
|
||||
// auto_ptr to it. NULL can be deleted safely.
|
||||
m_data.push_back(NULL);
|
||||
m_data.back() = t.release();
|
||||
}
|
||||
@@ -36,17 +36,8 @@ public:
|
||||
m_data.pop_back();
|
||||
return t;
|
||||
}
|
||||
std::auto_ptr<T> pop(T* val) {
|
||||
typename std::vector<T*>::reverse_iterator itVal =
|
||||
std::find(m_data.rbegin(), m_data.rend(), val);
|
||||
std::auto_ptr<T> t;
|
||||
if (itVal != m_data.rend()) {
|
||||
t.reset(*itVal);
|
||||
m_data.erase((itVal + 1).base());
|
||||
}
|
||||
return t;
|
||||
}
|
||||
T& top() const { return *m_data.back(); }
|
||||
T& top() { return *m_data.back(); }
|
||||
const T& top() const { return *m_data.back(); }
|
||||
|
||||
private:
|
||||
std::vector<T*> m_data;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace YAML {
|
||||
|
||||
template <typename T>
|
||||
class ptr_vector: private YAML::noncopyable
|
||||
{
|
||||
public:
|
||||
ptr_vector() {}
|
||||
~ptr_vector() { clear(); }
|
||||
|
||||
void clear() {
|
||||
for(unsigned i=0;i<m_data.size();i++)
|
||||
delete m_data[i];
|
||||
m_data.clear();
|
||||
}
|
||||
|
||||
std::size_t size() const { return m_data.size(); }
|
||||
bool empty() const { return m_data.empty(); }
|
||||
|
||||
void push_back(std::auto_ptr<T> t) {
|
||||
m_data.push_back(NULL);
|
||||
m_data.back() = t.release();
|
||||
}
|
||||
T& operator[](std::size_t i) { return *m_data[i]; }
|
||||
const T& operator[](std::size_t i) const { return *m_data[i]; }
|
||||
|
||||
T& back() { return *m_data.back(); }
|
||||
const T& back() const { return *m_data.back(); }
|
||||
|
||||
private:
|
||||
std::vector<T*> m_data;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
+4
-2
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
+11
-3
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "stream.h"
|
||||
#include "stringsource.h"
|
||||
@@ -58,7 +60,13 @@ namespace YAML
|
||||
template<>
|
||||
inline bool RegEx::IsValidSource<StringCharSource>(const StringCharSource&source) const
|
||||
{
|
||||
return source || m_op == REGEX_EMPTY;
|
||||
switch(m_op) {
|
||||
case REGEX_MATCH:
|
||||
case REGEX_RANGE:
|
||||
return source;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Source>
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#include "scalar.h"
|
||||
#include "eventhandler.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
Scalar::Scalar()
|
||||
{
|
||||
}
|
||||
|
||||
Scalar::~Scalar()
|
||||
{
|
||||
}
|
||||
|
||||
void Scalar::EmitEvents(AliasManager&, EventHandler& eventHandler, const Mark& mark, const std::string& tag, anchor_t anchor) const
|
||||
{
|
||||
eventHandler.OnScalar(mark, tag, anchor, m_data);
|
||||
}
|
||||
|
||||
int Scalar::Compare(Content *pContent)
|
||||
{
|
||||
return -pContent->Compare(this);
|
||||
}
|
||||
|
||||
int Scalar::Compare(Scalar *pScalar)
|
||||
{
|
||||
if(m_data < pScalar->m_data)
|
||||
return -1;
|
||||
else if(m_data > pScalar->m_data)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef SCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
|
||||
#include "content.h"
|
||||
#include <string>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Scalar: public Content
|
||||
{
|
||||
public:
|
||||
Scalar();
|
||||
virtual ~Scalar();
|
||||
|
||||
virtual void SetData(const std::string& data) { m_data = data; }
|
||||
|
||||
virtual bool IsScalar() const { return true; }
|
||||
virtual void EmitEvents(AliasManager& am, EventHandler& eventHandler, const Mark& mark, const std::string& tag, anchor_t anchor) const;
|
||||
|
||||
// extraction
|
||||
virtual bool GetScalar(std::string& scalar) const {
|
||||
scalar = m_data;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ordering
|
||||
virtual int Compare(Content *pContent);
|
||||
virtual int Compare(Scalar *pScalar);
|
||||
virtual int Compare(Sequence *) { return -1; }
|
||||
virtual int Compare(Map *) { return -1; }
|
||||
|
||||
protected:
|
||||
std::string m_data;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
+6
-8
@@ -1,6 +1,6 @@
|
||||
#include "scanner.h"
|
||||
#include "token.h"
|
||||
#include "exceptions.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "exp.h"
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
@@ -14,9 +14,6 @@ namespace YAML
|
||||
|
||||
Scanner::~Scanner()
|
||||
{
|
||||
for(unsigned i=0;i<m_indentRefs.size();i++)
|
||||
delete m_indentRefs[i];
|
||||
m_indentRefs.clear();
|
||||
}
|
||||
|
||||
// empty
|
||||
@@ -237,9 +234,9 @@ namespace YAML
|
||||
{
|
||||
m_startedStream = true;
|
||||
m_simpleKeyAllowed = true;
|
||||
IndentMarker *pIndent = new IndentMarker(-1, IndentMarker::NONE);
|
||||
std::auto_ptr<IndentMarker> pIndent(new IndentMarker(-1, IndentMarker::NONE));
|
||||
m_indentRefs.push_back(pIndent);
|
||||
m_indents.push(pIndent);
|
||||
m_indents.push(&m_indentRefs.back());
|
||||
}
|
||||
|
||||
// EndStream
|
||||
@@ -271,6 +268,7 @@ namespace YAML
|
||||
case IndentMarker::NONE: assert(false); break;
|
||||
}
|
||||
assert(false);
|
||||
throw std::runtime_error("yaml-cpp: internal error, invalid indent type");
|
||||
}
|
||||
|
||||
// PushIndentTo
|
||||
@@ -298,8 +296,8 @@ namespace YAML
|
||||
|
||||
// and then the indent
|
||||
m_indents.push(&indent);
|
||||
m_indentRefs.push_back(pIndent.release());
|
||||
return m_indentRefs.back();
|
||||
m_indentRefs.push_back(pIndent);
|
||||
return &m_indentRefs.back();
|
||||
}
|
||||
|
||||
// PopIndentToHere
|
||||
|
||||
+10
-7
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <ios>
|
||||
#include <string>
|
||||
@@ -10,6 +12,7 @@
|
||||
#include <stack>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include "ptr_vector.h"
|
||||
#include "stream.h"
|
||||
#include "token.h"
|
||||
|
||||
@@ -112,16 +115,16 @@ namespace YAML
|
||||
Stream INPUT;
|
||||
|
||||
// the output (tokens)
|
||||
std::queue <Token> m_tokens;
|
||||
std::queue<Token> m_tokens;
|
||||
|
||||
// state info
|
||||
bool m_startedStream, m_endedStream;
|
||||
bool m_simpleKeyAllowed;
|
||||
bool m_canBeJSONFlow;
|
||||
std::stack <SimpleKey> m_simpleKeys;
|
||||
std::stack <IndentMarker *> m_indents;
|
||||
std::vector <IndentMarker *> m_indentRefs; // for "garbage collection"
|
||||
std::stack <FLOW_MARKER> m_flows;
|
||||
std::stack<SimpleKey> m_simpleKeys;
|
||||
std::stack<IndentMarker *> m_indents;
|
||||
ptr_vector<IndentMarker> m_indentRefs; // for "garbage collection"
|
||||
std::stack<FLOW_MARKER> m_flows;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+34
-8
@@ -1,7 +1,7 @@
|
||||
#include "scanscalar.h"
|
||||
#include "scanner.h"
|
||||
#include "exp.h"
|
||||
#include "exceptions.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "token.h"
|
||||
|
||||
namespace YAML
|
||||
@@ -23,6 +23,7 @@ namespace YAML
|
||||
bool emptyLine = false, moreIndented = false;
|
||||
int foldedNewlineCount = 0;
|
||||
bool foldedNewlineStartedMoreIndented = false;
|
||||
std::size_t lastEscapedChar = std::string::npos;
|
||||
std::string scalar;
|
||||
params.leadingSpaces = false;
|
||||
|
||||
@@ -52,6 +53,7 @@ namespace YAML
|
||||
// eat escape character and get out (but preserve trailing whitespace!)
|
||||
INPUT.get();
|
||||
lastNonWhitespaceChar = scalar.size();
|
||||
lastEscapedChar = scalar.size();
|
||||
escapedNewline = true;
|
||||
break;
|
||||
}
|
||||
@@ -60,6 +62,7 @@ namespace YAML
|
||||
if(INPUT.peek() == params.escape) {
|
||||
scalar += Exp::Escape(INPUT);
|
||||
lastNonWhitespaceChar = scalar.size();
|
||||
lastEscapedChar = scalar.size();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -143,7 +146,7 @@ namespace YAML
|
||||
|
||||
if(!nextEmptyLine && foldedNewlineCount > 0) {
|
||||
scalar += std::string(foldedNewlineCount - 1, '\n');
|
||||
if(foldedNewlineStartedMoreIndented || nextMoreIndented)
|
||||
if(foldedNewlineStartedMoreIndented || nextMoreIndented | !foundNonEmptyLine)
|
||||
scalar += "\n";
|
||||
foldedNewlineCount = 0;
|
||||
}
|
||||
@@ -171,16 +174,39 @@ namespace YAML
|
||||
// post-processing
|
||||
if(params.trimTrailingSpaces) {
|
||||
std::size_t pos = scalar.find_last_not_of(' ');
|
||||
if(lastEscapedChar != std::string::npos) {
|
||||
if(pos < lastEscapedChar || pos == std::string::npos)
|
||||
pos = lastEscapedChar;
|
||||
}
|
||||
if(pos < scalar.size())
|
||||
scalar.erase(pos + 1);
|
||||
}
|
||||
|
||||
if(params.chomp == STRIP || params.chomp == CLIP) {
|
||||
std::size_t pos = scalar.find_last_not_of('\n');
|
||||
if(params.chomp == CLIP && pos + 1 < scalar.size())
|
||||
scalar.erase(pos + 2);
|
||||
else if(params.chomp == STRIP && pos < scalar.size())
|
||||
scalar.erase(pos + 1);
|
||||
switch(params.chomp) {
|
||||
case CLIP: {
|
||||
std::size_t pos = scalar.find_last_not_of('\n');
|
||||
if(lastEscapedChar != std::string::npos) {
|
||||
if(pos < lastEscapedChar || pos == std::string::npos)
|
||||
pos = lastEscapedChar;
|
||||
}
|
||||
if(pos == std::string::npos)
|
||||
scalar.erase();
|
||||
else if(pos + 1 < scalar.size())
|
||||
scalar.erase(pos + 2);
|
||||
} break;
|
||||
case STRIP: {
|
||||
std::size_t pos = scalar.find_last_not_of('\n');
|
||||
if(lastEscapedChar != std::string::npos) {
|
||||
if(pos < lastEscapedChar || pos == std::string::npos)
|
||||
pos = lastEscapedChar;
|
||||
}
|
||||
if(pos == std::string::npos)
|
||||
scalar.erase();
|
||||
else if(pos < scalar.size())
|
||||
scalar.erase(pos + 1);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return scalar;
|
||||
|
||||
+4
-2
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "regex.h"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#include "scanner.h"
|
||||
#include "regex.h"
|
||||
#include "exp.h"
|
||||
#include "exceptions.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
|
||||
+4
-2
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "stream.h"
|
||||
|
||||
+5
-6
@@ -1,6 +1,6 @@
|
||||
#include "scanner.h"
|
||||
#include "token.h"
|
||||
#include "exceptions.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "exp.h"
|
||||
#include "scanscalar.h"
|
||||
#include "scantag.h"
|
||||
@@ -238,7 +238,7 @@ namespace YAML
|
||||
alias = (indicator == Keys::Alias);
|
||||
|
||||
// now eat the content
|
||||
while(Exp::AlphaNumeric().Matches(INPUT))
|
||||
while(INPUT && Exp::Anchor().Matches(INPUT))
|
||||
name += INPUT.get();
|
||||
|
||||
// we need to have read SOMETHING!
|
||||
@@ -326,9 +326,8 @@ namespace YAML
|
||||
//if(Exp::IllegalCharInScalar.Matches(INPUT))
|
||||
// throw ParserException(INPUT.mark(), ErrorMsg::CHAR_IN_SCALAR);
|
||||
|
||||
Token token(Token::SCALAR, mark);
|
||||
Token token(Token::PLAIN_SCALAR, mark);
|
||||
token.value = scalar;
|
||||
token.params.push_back(Token::PLAIN_SCALAR);
|
||||
m_tokens.push(token);
|
||||
}
|
||||
|
||||
@@ -366,7 +365,7 @@ namespace YAML
|
||||
m_simpleKeyAllowed = false;
|
||||
m_canBeJSONFlow = true;
|
||||
|
||||
Token token(Token::SCALAR, mark);
|
||||
Token token(Token::NON_PLAIN_SCALAR, mark);
|
||||
token.value = scalar;
|
||||
m_tokens.push(token);
|
||||
}
|
||||
@@ -433,7 +432,7 @@ namespace YAML
|
||||
m_simpleKeyAllowed = true;
|
||||
m_canBeJSONFlow = false;
|
||||
|
||||
Token token(Token::SCALAR, mark);
|
||||
Token token(Token::NON_PLAIN_SCALAR, mark);
|
||||
token.value = scalar;
|
||||
m_tokens.push(token);
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
#include "sequence.h"
|
||||
#include "eventhandler.h"
|
||||
#include "node.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
Sequence::Sequence()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Sequence::~Sequence()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Sequence::Clear()
|
||||
{
|
||||
for(std::size_t i=0;i<m_data.size();i++)
|
||||
delete m_data[i];
|
||||
m_data.clear();
|
||||
}
|
||||
|
||||
bool Sequence::GetBegin(std::vector <Node *>::const_iterator& it) const
|
||||
{
|
||||
it = m_data.begin();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Sequence::GetEnd(std::vector <Node *>::const_iterator& it) const
|
||||
{
|
||||
it = m_data.end();
|
||||
return true;
|
||||
}
|
||||
|
||||
Node *Sequence::GetNode(std::size_t i) const
|
||||
{
|
||||
if(i < m_data.size())
|
||||
return m_data[i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::size_t Sequence::GetSize() const
|
||||
{
|
||||
return m_data.size();
|
||||
}
|
||||
|
||||
void Sequence::Append(std::auto_ptr<Node> pNode)
|
||||
{
|
||||
m_data.push_back(pNode.release());
|
||||
}
|
||||
|
||||
void Sequence::EmitEvents(AliasManager& am, EventHandler& eventHandler, const Mark& mark, const std::string& tag, anchor_t anchor) const
|
||||
{
|
||||
eventHandler.OnSequenceStart(mark, tag, anchor);
|
||||
for(std::size_t i=0;i<m_data.size();i++)
|
||||
m_data[i]->EmitEvents(am, eventHandler);
|
||||
eventHandler.OnSequenceEnd();
|
||||
}
|
||||
|
||||
int Sequence::Compare(Content *pContent)
|
||||
{
|
||||
return -pContent->Compare(this);
|
||||
}
|
||||
|
||||
int Sequence::Compare(Sequence *pSeq)
|
||||
{
|
||||
std::size_t n = m_data.size(), m = pSeq->m_data.size();
|
||||
if(n < m)
|
||||
return -1;
|
||||
else if(n > m)
|
||||
return 1;
|
||||
|
||||
for(std::size_t i=0;i<n;i++) {
|
||||
int cmp = m_data[i]->Compare(*pSeq->m_data[i]);
|
||||
if(cmp != 0)
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef SEQUENCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SEQUENCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
|
||||
#include "content.h"
|
||||
#include <vector>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
class Node;
|
||||
|
||||
class Sequence: public Content
|
||||
{
|
||||
public:
|
||||
Sequence();
|
||||
virtual ~Sequence();
|
||||
|
||||
void Clear();
|
||||
|
||||
virtual bool GetBegin(std::vector <Node *>::const_iterator& it) const;
|
||||
virtual bool GetEnd(std::vector <Node *>::const_iterator& it) const;
|
||||
virtual Node *GetNode(std::size_t i) const;
|
||||
virtual std::size_t GetSize() const;
|
||||
|
||||
virtual void Append(std::auto_ptr<Node> pNode);
|
||||
virtual void EmitEvents(AliasManager& am, EventHandler& eventHandler, const Mark& mark, const std::string& tag, anchor_t anchor) const;
|
||||
|
||||
virtual bool IsSequence() const { return true; }
|
||||
|
||||
// ordering
|
||||
virtual int Compare(Content *pContent);
|
||||
virtual int Compare(Scalar *) { return 1; }
|
||||
virtual int Compare(Sequence *pSeq);
|
||||
virtual int Compare(Map *) { return -1; }
|
||||
|
||||
protected:
|
||||
std::vector <Node *> m_data;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SEQUENCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
+5
-3
@@ -1,12 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "noncopyable.h"
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include "scanner.h"
|
||||
#include "token.h"
|
||||
#include "exceptions.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "exp.h"
|
||||
|
||||
namespace YAML
|
||||
|
||||
+24
-24
@@ -1,8 +1,8 @@
|
||||
#include "singledocparser.h"
|
||||
#include "collectionstack.h"
|
||||
#include "directives.h"
|
||||
#include "eventhandler.h"
|
||||
#include "exceptions.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include "scanner.h"
|
||||
#include "tag.h"
|
||||
#include "token.h"
|
||||
@@ -48,7 +48,7 @@ namespace YAML
|
||||
{
|
||||
// an empty node *is* a possibility
|
||||
if(m_scanner.empty()) {
|
||||
eventHandler.OnNull("", NullAnchor);
|
||||
eventHandler.OnNull(Mark::null(), NullAnchor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -74,21 +74,17 @@ namespace YAML
|
||||
anchor_t anchor;
|
||||
ParseProperties(tag, anchor);
|
||||
|
||||
if (tag.empty()) {
|
||||
const Token& token = m_scanner.peek();
|
||||
const std::vector<std::string>& tparams = token.params;
|
||||
if (token.type != Token::SCALAR ||
|
||||
std::find(tparams.begin(), tparams.end(), Token::PLAIN_SCALAR) != tparams.end()) {
|
||||
tag = "?";
|
||||
} else {
|
||||
tag = "!";
|
||||
}
|
||||
}
|
||||
const Token& token = m_scanner.peek();
|
||||
|
||||
// add non-specific tags
|
||||
if(tag.empty())
|
||||
tag = (token.type == Token::NON_PLAIN_SCALAR ? "!" : "?");
|
||||
|
||||
// now split based on what kind of node we should be
|
||||
switch(m_scanner.peek().type) {
|
||||
case Token::SCALAR:
|
||||
eventHandler.OnScalar(mark, tag, anchor, m_scanner.peek().value);
|
||||
switch(token.type) {
|
||||
case Token::PLAIN_SCALAR:
|
||||
case Token::NON_PLAIN_SCALAR:
|
||||
eventHandler.OnScalar(mark, tag, anchor, token.value);
|
||||
m_scanner.pop();
|
||||
return;
|
||||
case Token::FLOW_SEQ_START:
|
||||
@@ -116,7 +112,10 @@ namespace YAML
|
||||
break;
|
||||
}
|
||||
|
||||
eventHandler.OnNull(tag, anchor);
|
||||
if(tag == "?")
|
||||
eventHandler.OnNull(mark, anchor);
|
||||
else
|
||||
eventHandler.OnScalar(mark, tag, anchor, "");
|
||||
}
|
||||
|
||||
void SingleDocParser::HandleSequence(EventHandler& eventHandler)
|
||||
@@ -151,7 +150,7 @@ namespace YAML
|
||||
if(!m_scanner.empty()) {
|
||||
const Token& token = m_scanner.peek();
|
||||
if(token.type == Token::BLOCK_ENTRY || token.type == Token::BLOCK_SEQ_END) {
|
||||
eventHandler.OnNull("", NullAnchor);
|
||||
eventHandler.OnNull(token.mark, NullAnchor);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -228,7 +227,7 @@ namespace YAML
|
||||
m_scanner.pop();
|
||||
HandleNode(eventHandler);
|
||||
} else {
|
||||
eventHandler.OnNull("", NullAnchor);
|
||||
eventHandler.OnNull(token.mark, NullAnchor);
|
||||
}
|
||||
|
||||
// now grab value (optional)
|
||||
@@ -236,7 +235,7 @@ namespace YAML
|
||||
m_scanner.pop();
|
||||
HandleNode(eventHandler);
|
||||
} else {
|
||||
eventHandler.OnNull("", NullAnchor);
|
||||
eventHandler.OnNull(token.mark, NullAnchor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +264,7 @@ namespace YAML
|
||||
m_scanner.pop();
|
||||
HandleNode(eventHandler);
|
||||
} else {
|
||||
eventHandler.OnNull("", NullAnchor);
|
||||
eventHandler.OnNull(token.mark, NullAnchor);
|
||||
}
|
||||
|
||||
// now grab value (optional)
|
||||
@@ -273,7 +272,7 @@ namespace YAML
|
||||
m_scanner.pop();
|
||||
HandleNode(eventHandler);
|
||||
} else {
|
||||
eventHandler.OnNull("", NullAnchor);
|
||||
eventHandler.OnNull(token.mark, NullAnchor);
|
||||
}
|
||||
|
||||
// now eat the separator (or could be a map end, which we ignore - but if it's neither, then it's a bad node)
|
||||
@@ -293,6 +292,7 @@ namespace YAML
|
||||
m_pCollectionStack->PushCollectionType(CollectionType::CompactMap);
|
||||
|
||||
// grab key
|
||||
Mark mark = m_scanner.peek().mark;
|
||||
m_scanner.pop();
|
||||
HandleNode(eventHandler);
|
||||
|
||||
@@ -301,7 +301,7 @@ namespace YAML
|
||||
m_scanner.pop();
|
||||
HandleNode(eventHandler);
|
||||
} else {
|
||||
eventHandler.OnNull("", NullAnchor);
|
||||
eventHandler.OnNull(mark, NullAnchor);
|
||||
}
|
||||
|
||||
m_pCollectionStack->PopCollectionType(CollectionType::CompactMap);
|
||||
@@ -313,7 +313,7 @@ namespace YAML
|
||||
m_pCollectionStack->PushCollectionType(CollectionType::CompactMap);
|
||||
|
||||
// null key
|
||||
eventHandler.OnNull("", NullAnchor);
|
||||
eventHandler.OnNull(m_scanner.peek().mark, NullAnchor);
|
||||
|
||||
// grab value
|
||||
m_scanner.pop();
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "anchor.h"
|
||||
#include "noncopyable.h"
|
||||
|
||||
#include "yaml-cpp/anchor.h"
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
+7
-13
@@ -178,7 +178,7 @@ namespace YAML
|
||||
}
|
||||
|
||||
Stream::Stream(std::istream& input)
|
||||
: m_input(input), m_nPushedBack(0),
|
||||
: m_input(input),
|
||||
m_pPrefetched(new unsigned char[YAML_PREFETCH_SIZE]),
|
||||
m_nPrefetchedAvailable(0), m_nPrefetchedUsed(0)
|
||||
{
|
||||
@@ -192,18 +192,17 @@ namespace YAML
|
||||
char_traits::int_type intro[4];
|
||||
int nIntroUsed = 0;
|
||||
UtfIntroState state = uis_start;
|
||||
for (; !s_introFinalState[state]; ) {
|
||||
for(; !s_introFinalState[state]; ) {
|
||||
std::istream::int_type ch = input.get();
|
||||
intro[nIntroUsed++] = ch;
|
||||
UtfIntroCharType charType = IntroCharTypeOf(ch);
|
||||
UtfIntroState newState = s_introTransitions[state][charType];
|
||||
int nUngets = s_introUngetCount[state][charType];
|
||||
if (nUngets > 0) {
|
||||
for (; nUngets > 0; --nUngets) {
|
||||
if (char_traits::eof() != intro[--nIntroUsed]) {
|
||||
m_bufPushback[m_nPushedBack++] =
|
||||
char_traits::to_char_type(intro[nIntroUsed]);
|
||||
}
|
||||
if(nUngets > 0) {
|
||||
input.clear();
|
||||
for(; nUngets > 0; --nUngets) {
|
||||
if(char_traits::eof() != intro[--nIntroUsed])
|
||||
input.putback(char_traits::to_char_type(intro[nIntroUsed]));
|
||||
}
|
||||
}
|
||||
state = newState;
|
||||
@@ -398,11 +397,6 @@ namespace YAML
|
||||
|
||||
unsigned char Stream::GetNextByte() const
|
||||
{
|
||||
if (m_nPushedBack)
|
||||
{
|
||||
return m_bufPushback[--m_nPushedBack];
|
||||
}
|
||||
|
||||
if (m_nPrefetchedUsed >= m_nPrefetchedAvailable)
|
||||
{
|
||||
std::streambuf *pBuf = m_input.rdbuf();
|
||||
|
||||
+8
-9
@@ -1,21 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "noncopyable.h"
|
||||
#include "mark.h"
|
||||
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
#include "yaml-cpp/mark.h"
|
||||
#include <cstddef>
|
||||
#include <deque>
|
||||
#include <ios>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
static const size_t MAX_PARSER_PUSHBACK = 8;
|
||||
|
||||
class Stream: private noncopyable
|
||||
{
|
||||
public:
|
||||
@@ -47,8 +48,6 @@ namespace YAML
|
||||
Mark m_mark;
|
||||
|
||||
CharacterSet m_charSet;
|
||||
unsigned char m_bufPushback[MAX_PARSER_PUSHBACK];
|
||||
mutable size_t m_nPushedBack;
|
||||
mutable std::deque<char> m_readahead;
|
||||
unsigned char* const m_pPrefetched;
|
||||
mutable size_t m_nPrefetchedAvailable;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "noncopyable.h"
|
||||
|
||||
#include "yaml-cpp/noncopyable.h"
|
||||
#include <cstddef>
|
||||
|
||||
namespace YAML
|
||||
|
||||
+4
-2
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "directives.h"
|
||||
#include "token.h"
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
@@ -45,6 +46,7 @@ namespace YAML
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
throw std::runtime_error("yaml-cpp: internal error, bad tag type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace YAML
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#include "token.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
const std::string Token::PLAIN_SCALAR("pln");
|
||||
}
|
||||
+8
-7
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "mark.h"
|
||||
|
||||
#include "yaml-cpp/mark.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -57,11 +59,10 @@ namespace YAML
|
||||
ANCHOR,
|
||||
ALIAS,
|
||||
TAG,
|
||||
SCALAR
|
||||
PLAIN_SCALAR,
|
||||
NON_PLAIN_SCALAR
|
||||
};
|
||||
|
||||
static const std::string PLAIN_SCALAR;
|
||||
|
||||
|
||||
// data
|
||||
Token(TYPE type_, const Mark& mark_): status(VALID), type(type_), mark(mark_), data(0) {}
|
||||
|
||||
|
||||
-226
@@ -1,226 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="test"
|
||||
ProjectGUID="{D1108F40-6ADF-467E-A95A-236C39A515C5}"
|
||||
RootNamespace="test"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/D_SCL_SECURE_NO_WARNINGS"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="include"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
DisableSpecificWarnings="4127;4355"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="yamlcppd.lib"
|
||||
AdditionalLibraryDirectories="lib"
|
||||
GenerateDebugInformation="true"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/D_SCL_SECURE_NO_WARNINGS"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="include"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
DisableSpecificWarnings="4127;4355"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="yamlcpp.lib"
|
||||
AdditionalLibraryDirectories="lib"
|
||||
GenerateDebugInformation="true"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\test\emittertests.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\test\main.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\test\parsertests.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\test\spectests.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\test\tests.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\test\emittertests.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\test\parsertests.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\test\spectests.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\test\tests.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user