Merge remote-tracking branch 'origin/master' into autoconf-support
This commit is contained in:
commit
22bf0e1c05
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
build/
|
build/
|
||||||
|
/tags
|
||||||
|
|||||||
@ -1,26 +1,11 @@
|
|||||||
###
|
###
|
||||||
### CMake settings
|
### CMake settings
|
||||||
###
|
###
|
||||||
## Due to Mac OSX we need to keep compatibility with CMake 2.6
|
|
||||||
# see http://www.cmake.org/Wiki/CMake_Policies
|
# see http://www.cmake.org/Wiki/CMake_Policies
|
||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 3.1)
|
||||||
# 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()
|
|
||||||
# see https://cmake.org/cmake/help/latest/policy/CMP0042.html
|
|
||||||
if(POLICY CMP0042)
|
|
||||||
# Enable MACOSX_RPATH by default.
|
|
||||||
cmake_policy(SET CMP0042 NEW)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
### Project settings
|
### Project settings
|
||||||
###
|
###
|
||||||
@ -31,8 +16,6 @@ set(YAML_CPP_VERSION_MINOR "6")
|
|||||||
set(YAML_CPP_VERSION_PATCH "2")
|
set(YAML_CPP_VERSION_PATCH "2")
|
||||||
set(YAML_CPP_VERSION "${YAML_CPP_VERSION_MAJOR}.${YAML_CPP_VERSION_MINOR}.${YAML_CPP_VERSION_PATCH}")
|
set(YAML_CPP_VERSION "${YAML_CPP_VERSION_MAJOR}.${YAML_CPP_VERSION_MINOR}.${YAML_CPP_VERSION_PATCH}")
|
||||||
|
|
||||||
enable_testing()
|
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
### Project options
|
### Project options
|
||||||
@ -48,6 +31,10 @@ option(YAML_CPP_BUILD_CONTRIB "Enable contrib stuff in library" ON)
|
|||||||
# http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_library
|
# http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_library
|
||||||
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
|
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
|
||||||
|
|
||||||
|
# Set minimum C++ to 2011 standards
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
# --> Apple
|
# --> Apple
|
||||||
option(APPLE_UNIVERSAL_BIN "Apple: Build universal binary" OFF)
|
option(APPLE_UNIVERSAL_BIN "Apple: Build universal binary" OFF)
|
||||||
|
|
||||||
@ -116,9 +103,10 @@ if(VERBOSE)
|
|||||||
message(STATUS "contrib_private_headers: ${contrib_private_headers}")
|
message(STATUS "contrib_private_headers: ${contrib_private_headers}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(${YAML_CPP_SOURCE_DIR}/src)
|
if (CMAKE_VERSION VERSION_LESS 2.8.12)
|
||||||
include_directories(${YAML_CPP_SOURCE_DIR}/include)
|
include_directories(${YAML_CPP_SOURCE_DIR}/src)
|
||||||
|
include_directories(${YAML_CPP_SOURCE_DIR}/include)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
@ -187,7 +175,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
|
|||||||
set(GCC_EXTRA_OPTIONS "${GCC_EXTRA_OPTIONS} ${FLAG_TESTED}")
|
set(GCC_EXTRA_OPTIONS "${GCC_EXTRA_OPTIONS} ${FLAG_TESTED}")
|
||||||
endif()
|
endif()
|
||||||
#
|
#
|
||||||
set(yaml_cxx_flags "-Wall ${GCC_EXTRA_OPTIONS} -pedantic -Wno-long-long -std=c++11 ${yaml_cxx_flags}")
|
set(yaml_cxx_flags "-Wall ${GCC_EXTRA_OPTIONS} -pedantic -Wno-long-long ${yaml_cxx_flags}")
|
||||||
|
|
||||||
### Make specific
|
### Make specific
|
||||||
if(${CMAKE_BUILD_TOOL} MATCHES make OR ${CMAKE_BUILD_TOOL} MATCHES gmake)
|
if(${CMAKE_BUILD_TOOL} MATCHES make OR ${CMAKE_BUILD_TOOL} MATCHES gmake)
|
||||||
@ -275,6 +263,14 @@ set(_INSTALL_DESTINATIONS
|
|||||||
### Library
|
### Library
|
||||||
###
|
###
|
||||||
add_library(yaml-cpp ${library_sources})
|
add_library(yaml-cpp ${library_sources})
|
||||||
|
|
||||||
|
if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
|
||||||
|
target_include_directories(yaml-cpp
|
||||||
|
PUBLIC $<BUILD_INTERFACE:${YAML_CPP_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_ROOT_DIR}>
|
||||||
|
PRIVATE $<BUILD_INTERFACE:${YAML_CPP_SOURCE_DIR}/src>)
|
||||||
|
endif()
|
||||||
|
|
||||||
set_target_properties(yaml-cpp PROPERTIES
|
set_target_properties(yaml-cpp PROPERTIES
|
||||||
COMPILE_FLAGS "${yaml_c_flags} ${yaml_cxx_flags}"
|
COMPILE_FLAGS "${yaml_c_flags} ${yaml_cxx_flags}"
|
||||||
)
|
)
|
||||||
@ -351,6 +347,7 @@ endif()
|
|||||||
### Extras
|
### Extras
|
||||||
###
|
###
|
||||||
if(YAML_CPP_BUILD_TESTS)
|
if(YAML_CPP_BUILD_TESTS)
|
||||||
|
enable_testing()
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
if(YAML_CPP_BUILD_TOOLS)
|
if(YAML_CPP_BUILD_TOOLS)
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
// This is here for compatibility with older versions of Visual Studio
|
// This is here for compatibility with older versions of Visual Studio
|
||||||
// which don't support noexcept
|
// which don't support noexcept
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||||
#define YAML_CPP_NOEXCEPT _NOEXCEPT
|
#define YAML_CPP_NOEXCEPT _NOEXCEPT
|
||||||
#else
|
#else
|
||||||
#define YAML_CPP_NOEXCEPT noexcept
|
#define YAML_CPP_NOEXCEPT noexcept
|
||||||
|
|||||||
@ -32,7 +32,7 @@ struct get_idx<Key,
|
|||||||
|
|
||||||
static node* get(std::vector<node*>& sequence, const Key& key,
|
static node* get(std::vector<node*>& sequence, const Key& key,
|
||||||
shared_memory_holder pMemory) {
|
shared_memory_holder pMemory) {
|
||||||
if (key > sequence.size() || (key > 0 && !sequence[key-1]->is_defined()))
|
if (key > sequence.size() || (key > 0 && !sequence[key - 1]->is_defined()))
|
||||||
return 0;
|
return 0;
|
||||||
if (key == sequence.size())
|
if (key == sequence.size())
|
||||||
sequence.push_back(&pMemory->create_node());
|
sequence.push_back(&pMemory->create_node());
|
||||||
@ -56,6 +56,37 @@ struct get_idx<Key, typename std::enable_if<std::is_signed<Key>::value>::type> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename Key, typename Enable = void>
|
||||||
|
struct remove_idx {
|
||||||
|
static bool remove(std::vector<node*>&, const Key&) { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Key>
|
||||||
|
struct remove_idx<
|
||||||
|
Key, typename std::enable_if<std::is_unsigned<Key>::value &&
|
||||||
|
!std::is_same<Key, bool>::value>::type> {
|
||||||
|
|
||||||
|
static bool remove(std::vector<node*>& sequence, const Key& key) {
|
||||||
|
if (key >= sequence.size()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
sequence.erase(sequence.begin() + key);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Key>
|
||||||
|
struct remove_idx<Key,
|
||||||
|
typename std::enable_if<std::is_signed<Key>::value>::type> {
|
||||||
|
|
||||||
|
static bool remove(std::vector<node*>& sequence, const Key& key) {
|
||||||
|
return key >= 0 ? remove_idx<std::size_t>::remove(
|
||||||
|
sequence, static_cast<std::size_t>(key))
|
||||||
|
: false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool node::equals(const T& rhs, shared_memory_holder pMemory) {
|
inline bool node::equals(const T& rhs, shared_memory_holder pMemory) {
|
||||||
T lhs;
|
T lhs;
|
||||||
@ -129,21 +160,23 @@ inline node& node_data::get(const Key& key, shared_memory_holder pMemory) {
|
|||||||
|
|
||||||
template <typename Key>
|
template <typename Key>
|
||||||
inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) {
|
inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) {
|
||||||
if (m_type != NodeType::Map)
|
if (m_type == NodeType::Sequence) {
|
||||||
return false;
|
return remove_idx<Key>::remove(m_sequence, key);
|
||||||
|
} else if (m_type == NodeType::Map) {
|
||||||
|
kv_pairs::iterator it = m_undefinedPairs.begin();
|
||||||
|
while (it != m_undefinedPairs.end()) {
|
||||||
|
kv_pairs::iterator jt = std::next(it);
|
||||||
|
if (it->first->equals(key, pMemory)) {
|
||||||
|
m_undefinedPairs.erase(it);
|
||||||
|
}
|
||||||
|
it = jt;
|
||||||
|
}
|
||||||
|
|
||||||
for (kv_pairs::iterator it = m_undefinedPairs.begin();
|
for (node_map::iterator iter = m_map.begin(); iter != m_map.end(); ++iter) {
|
||||||
it != m_undefinedPairs.end();) {
|
if (iter->first->equals(key, pMemory)) {
|
||||||
kv_pairs::iterator jt = std::next(it);
|
m_map.erase(iter);
|
||||||
if (it->first->equals(key, pMemory))
|
return true;
|
||||||
m_undefinedPairs.erase(it);
|
}
|
||||||
it = jt;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) {
|
|
||||||
if (it->first->equals(key, pMemory)) {
|
|
||||||
m_map.erase(it);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,19 +8,19 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "yaml-cpp/dll.h"
|
#include "yaml-cpp/dll.h"
|
||||||
|
#include "yaml-cpp/node/detail/node_iterator.h"
|
||||||
#include "yaml-cpp/node/node.h"
|
#include "yaml-cpp/node/node.h"
|
||||||
#include "yaml-cpp/node/ptr.h"
|
#include "yaml-cpp/node/ptr.h"
|
||||||
#include "yaml-cpp/node/detail/node_iterator.h"
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
|
||||||
namespace YAML {
|
namespace YAML {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
struct iterator_value;
|
struct iterator_value;
|
||||||
|
|
||||||
template <typename V>
|
template <typename V>
|
||||||
class iterator_base : public std::iterator<std::forward_iterator_tag, V,
|
class iterator_base {
|
||||||
std::ptrdiff_t, V*, V> {
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename>
|
template <typename>
|
||||||
@ -37,7 +37,11 @@ class iterator_base : public std::iterator<std::forward_iterator_tag, V,
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename iterator_base::value_type value_type;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
using value_type = V;
|
||||||
|
using difference_type = std::ptrdiff_t;
|
||||||
|
using pointer = V*;
|
||||||
|
using reference = V;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
iterator_base() : m_iterator(), m_pMemory() {}
|
iterator_base() : m_iterator(), m_pMemory() {}
|
||||||
@ -86,7 +90,7 @@ class iterator_base : public std::iterator<std::forward_iterator_tag, V,
|
|||||||
base_type m_iterator;
|
base_type m_iterator;
|
||||||
shared_memory_holder m_pMemory;
|
shared_memory_holder m_pMemory;
|
||||||
};
|
};
|
||||||
}
|
} // namespace detail
|
||||||
}
|
} // namespace YAML
|
||||||
|
|
||||||
#endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
#endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||||
|
|||||||
@ -81,7 +81,7 @@ class YAML_CPP_API node_data {
|
|||||||
shared_memory_holder pMemory);
|
shared_memory_holder pMemory);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::string empty_scalar;
|
static const std::string& empty_scalar();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void compute_seq_size() const;
|
void compute_seq_size() const;
|
||||||
|
|||||||
@ -156,13 +156,13 @@ inline T Node::as(const S& fallback) const {
|
|||||||
inline const std::string& Node::Scalar() const {
|
inline const std::string& Node::Scalar() const {
|
||||||
if (!m_isValid)
|
if (!m_isValid)
|
||||||
throw InvalidNode();
|
throw InvalidNode();
|
||||||
return m_pNode ? m_pNode->scalar() : detail::node_data::empty_scalar;
|
return m_pNode ? m_pNode->scalar() : detail::node_data::empty_scalar();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::string& Node::Tag() const {
|
inline const std::string& Node::Tag() const {
|
||||||
if (!m_isValid)
|
if (!m_isValid)
|
||||||
throw InvalidNode();
|
throw InvalidNode();
|
||||||
return m_pNode ? m_pNode->tag() : detail::node_data::empty_scalar;
|
return m_pNode ? m_pNode->tag() : detail::node_data::empty_scalar();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Node::SetTag(const std::string& tag) {
|
inline void Node::SetTag(const std::string& tag) {
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "yaml-cpp/binary.h"
|
#include "yaml-cpp/binary.h"
|
||||||
|
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
namespace YAML {
|
namespace YAML {
|
||||||
static const char encoding[] =
|
static const char encoding[] =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
@ -72,19 +74,24 @@ std::vector<unsigned char> DecodeBase64(const std::string &input) {
|
|||||||
unsigned char *out = &ret[0];
|
unsigned char *out = &ret[0];
|
||||||
|
|
||||||
unsigned value = 0;
|
unsigned value = 0;
|
||||||
for (std::size_t i = 0; i < input.size(); i++) {
|
for (std::size_t i = 0, cnt = 0; i < input.size(); i++) {
|
||||||
|
if (std::isspace(input[i])) {
|
||||||
|
// skip newlines
|
||||||
|
continue;
|
||||||
|
}
|
||||||
unsigned char d = decoding[static_cast<unsigned>(input[i])];
|
unsigned char d = decoding[static_cast<unsigned>(input[i])];
|
||||||
if (d == 255)
|
if (d == 255)
|
||||||
return ret_type();
|
return ret_type();
|
||||||
|
|
||||||
value = (value << 6) | d;
|
value = (value << 6) | d;
|
||||||
if (i % 4 == 3) {
|
if (cnt % 4 == 3) {
|
||||||
*out++ = value >> 16;
|
*out++ = value >> 16;
|
||||||
if (i > 0 && input[i - 1] != '=')
|
if (i > 0 && input[i - 1] != '=')
|
||||||
*out++ = value >> 8;
|
*out++ = value >> 8;
|
||||||
if (input[i] != '=')
|
if (input[i] != '=')
|
||||||
*out++ = value;
|
*out++ = value;
|
||||||
}
|
}
|
||||||
|
++cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.resize(out - &ret[0]);
|
ret.resize(out - &ret[0]);
|
||||||
|
|||||||
@ -28,6 +28,7 @@ class CollectionStack {
|
|||||||
}
|
}
|
||||||
void PopCollectionType(CollectionType::value type) {
|
void PopCollectionType(CollectionType::value type) {
|
||||||
assert(type == GetCurCollectionType());
|
assert(type == GetCurCollectionType());
|
||||||
|
(void)type;
|
||||||
collectionStack.pop();
|
collectionStack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ void* BuildGraphOfNextDocument(Parser& parser,
|
|||||||
if (parser.HandleNextDocument(eventHandler)) {
|
if (parser.HandleNextDocument(eventHandler)) {
|
||||||
return eventHandler.RootNode();
|
return eventHandler.RootNode();
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ void GraphBuilderAdapter::OnMapStart(const Mark &mark, const std::string &tag,
|
|||||||
EmitterStyle::value /* style */) {
|
EmitterStyle::value /* style */) {
|
||||||
void *pNode = m_builder.NewMap(mark, tag, GetCurrentParent());
|
void *pNode = m_builder.NewMap(mark, tag, GetCurrentParent());
|
||||||
m_containers.push(ContainerFrame(pNode, m_pKeyNode));
|
m_containers.push(ContainerFrame(pNode, m_pKeyNode));
|
||||||
m_pKeyNode = NULL;
|
m_pKeyNode = nullptr;
|
||||||
RegisterAnchor(anchor, pNode);
|
RegisterAnchor(anchor, pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ void GraphBuilderAdapter::OnMapEnd() {
|
|||||||
|
|
||||||
void *GraphBuilderAdapter::GetCurrentParent() const {
|
void *GraphBuilderAdapter::GetCurrentParent() const {
|
||||||
if (m_containers.empty()) {
|
if (m_containers.empty()) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return m_containers.top().pContainer;
|
return m_containers.top().pContainer;
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ void GraphBuilderAdapter::DispositionNode(void *pNode) {
|
|||||||
if (m_containers.top().isMap()) {
|
if (m_containers.top().isMap()) {
|
||||||
if (m_pKeyNode) {
|
if (m_pKeyNode) {
|
||||||
m_builder.AssignInMap(pContainer, m_pKeyNode, pNode);
|
m_builder.AssignInMap(pContainer, m_pKeyNode, pNode);
|
||||||
m_pKeyNode = NULL;
|
m_pKeyNode = nullptr;
|
||||||
} else {
|
} else {
|
||||||
m_pKeyNode = pNode;
|
m_pKeyNode = pNode;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,7 @@ namespace YAML {
|
|||||||
class GraphBuilderAdapter : public EventHandler {
|
class GraphBuilderAdapter : public EventHandler {
|
||||||
public:
|
public:
|
||||||
GraphBuilderAdapter(GraphBuilderInterface& builder)
|
GraphBuilderAdapter(GraphBuilderInterface& builder)
|
||||||
: m_builder(builder), m_pRootNode(NULL), m_pKeyNode(NULL) {}
|
: m_builder(builder), m_pRootNode(nullptr), m_pKeyNode(nullptr) {}
|
||||||
|
|
||||||
virtual void OnDocumentStart(const Mark& mark) { (void)mark; }
|
virtual void OnDocumentStart(const Mark& mark) { (void)mark; }
|
||||||
virtual void OnDocumentEnd() {}
|
virtual void OnDocumentEnd() {}
|
||||||
|
|||||||
@ -134,12 +134,12 @@ void WriteCodePoint(ostream_wrapper& out, int codePoint) {
|
|||||||
if (codePoint < 0 || codePoint > 0x10FFFF) {
|
if (codePoint < 0 || codePoint > 0x10FFFF) {
|
||||||
codePoint = REPLACEMENT_CHARACTER;
|
codePoint = REPLACEMENT_CHARACTER;
|
||||||
}
|
}
|
||||||
if (codePoint < 0x7F) {
|
if (codePoint <= 0x7F) {
|
||||||
out << static_cast<char>(codePoint);
|
out << static_cast<char>(codePoint);
|
||||||
} else if (codePoint < 0x7FF) {
|
} else if (codePoint <= 0x7FF) {
|
||||||
out << static_cast<char>(0xC0 | (codePoint >> 6))
|
out << static_cast<char>(0xC0 | (codePoint >> 6))
|
||||||
<< static_cast<char>(0x80 | (codePoint & 0x3F));
|
<< static_cast<char>(0x80 | (codePoint & 0x3F));
|
||||||
} else if (codePoint < 0xFFFF) {
|
} else if (codePoint <= 0xFFFF) {
|
||||||
out << static_cast<char>(0xE0 | (codePoint >> 12))
|
out << static_cast<char>(0xE0 | (codePoint >> 12))
|
||||||
<< static_cast<char>(0x80 | ((codePoint >> 6) & 0x3F))
|
<< static_cast<char>(0x80 | ((codePoint >> 6) & 0x3F))
|
||||||
<< static_cast<char>(0x80 | (codePoint & 0x3F));
|
<< static_cast<char>(0x80 | (codePoint & 0x3F));
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// This is here for compatibility with older versions of Visual Studio
|
// This is here for compatibility with older versions of Visual Studio
|
||||||
// which don't support noexcept
|
// which don't support noexcept
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||||
#define YAML_CPP_NOEXCEPT _NOEXCEPT
|
#define YAML_CPP_NOEXCEPT _NOEXCEPT
|
||||||
#else
|
#else
|
||||||
#define YAML_CPP_NOEXCEPT noexcept
|
#define YAML_CPP_NOEXCEPT noexcept
|
||||||
|
|||||||
@ -13,7 +13,10 @@
|
|||||||
namespace YAML {
|
namespace YAML {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
std::string node_data::empty_scalar;
|
const std::string& node_data::empty_scalar() {
|
||||||
|
static const std::string svalue;
|
||||||
|
return svalue;
|
||||||
|
}
|
||||||
|
|
||||||
node_data::node_data()
|
node_data::node_data()
|
||||||
: m_isDefined(false),
|
: m_isDefined(false),
|
||||||
@ -197,7 +200,7 @@ void node_data::insert(node& key, node& value, shared_memory_holder pMemory) {
|
|||||||
// indexing
|
// indexing
|
||||||
node* node_data::get(node& key, shared_memory_holder /* pMemory */) const {
|
node* node_data::get(node& key, shared_memory_holder /* pMemory */) const {
|
||||||
if (m_type != NodeType::Map) {
|
if (m_type != NodeType::Map) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
|
for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
|
||||||
@ -205,7 +208,7 @@ node* node_data::get(node& key, shared_memory_holder /* pMemory */) const {
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
node& node_data::get(node& key, shared_memory_holder pMemory) {
|
node& node_data::get(node& key, shared_memory_holder pMemory) {
|
||||||
@ -235,6 +238,14 @@ bool node_data::remove(node& key, shared_memory_holder /* pMemory */) {
|
|||||||
if (m_type != NodeType::Map)
|
if (m_type != NodeType::Map)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
kv_pairs::iterator it = m_undefinedPairs.begin();
|
||||||
|
while (it != m_undefinedPairs.end()) {
|
||||||
|
kv_pairs::iterator jt = std::next(it);
|
||||||
|
if (it->first->is(key))
|
||||||
|
m_undefinedPairs.erase(it);
|
||||||
|
it = jt;
|
||||||
|
}
|
||||||
|
|
||||||
for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) {
|
for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) {
|
||||||
if (it->first->is(key)) {
|
if (it->first->is(key)) {
|
||||||
m_map.erase(it);
|
m_map.erase(it);
|
||||||
|
|||||||
@ -11,8 +11,8 @@ namespace YAML {
|
|||||||
struct Mark;
|
struct Mark;
|
||||||
|
|
||||||
NodeBuilder::NodeBuilder()
|
NodeBuilder::NodeBuilder()
|
||||||
: m_pMemory(new detail::memory_holder), m_pRoot(0), m_mapDepth(0) {
|
: m_pMemory(new detail::memory_holder), m_pRoot(nullptr), m_mapDepth(0) {
|
||||||
m_anchors.push_back(0); // since the anchors start at 1
|
m_anchors.push_back(nullptr); // since the anchors start at 1
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeBuilder::~NodeBuilder() {}
|
NodeBuilder::~NodeBuilder() {}
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
namespace YAML {
|
namespace YAML {
|
||||||
ostream_wrapper::ostream_wrapper()
|
ostream_wrapper::ostream_wrapper()
|
||||||
: m_buffer(1, '\0'),
|
: m_buffer(1, '\0'),
|
||||||
m_pStream(0),
|
m_pStream(nullptr),
|
||||||
m_pos(0),
|
m_pos(0),
|
||||||
m_row(0),
|
m_row(0),
|
||||||
m_col(0),
|
m_col(0),
|
||||||
|
|||||||
@ -77,10 +77,11 @@ class YAML_CPP_API RegEx {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
REGEX_OP m_op;
|
REGEX_OP m_op;
|
||||||
char m_a, m_z;
|
char m_a{};
|
||||||
|
char m_z{};
|
||||||
std::vector<RegEx> m_params;
|
std::vector<RegEx> m_params;
|
||||||
};
|
};
|
||||||
}
|
} // namespace YAML
|
||||||
|
|
||||||
#include "regeximpl.h"
|
#include "regeximpl.h"
|
||||||
|
|
||||||
|
|||||||
@ -282,7 +282,7 @@ Scanner::IndentMarker* Scanner::PushIndentTo(int column,
|
|||||||
IndentMarker::INDENT_TYPE type) {
|
IndentMarker::INDENT_TYPE type) {
|
||||||
// are we in flow?
|
// are we in flow?
|
||||||
if (InFlowContext()) {
|
if (InFlowContext()) {
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<IndentMarker> pIndent(new IndentMarker(column, type));
|
std::unique_ptr<IndentMarker> pIndent(new IndentMarker(column, type));
|
||||||
@ -291,12 +291,12 @@ Scanner::IndentMarker* Scanner::PushIndentTo(int column,
|
|||||||
|
|
||||||
// is this actually an indentation?
|
// is this actually an indentation?
|
||||||
if (indent.column < lastIndent.column) {
|
if (indent.column < lastIndent.column) {
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (indent.column == lastIndent.column &&
|
if (indent.column == lastIndent.column &&
|
||||||
!(indent.type == IndentMarker::SEQ &&
|
!(indent.type == IndentMarker::SEQ &&
|
||||||
lastIndent.type == IndentMarker::MAP)) {
|
lastIndent.type == IndentMarker::MAP)) {
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// push a start token
|
// push a start token
|
||||||
|
|||||||
@ -49,7 +49,7 @@ class Scanner {
|
|||||||
enum INDENT_TYPE { MAP, SEQ, NONE };
|
enum INDENT_TYPE { MAP, SEQ, NONE };
|
||||||
enum STATUS { VALID, INVALID, UNKNOWN };
|
enum STATUS { VALID, INVALID, UNKNOWN };
|
||||||
IndentMarker(int column_, INDENT_TYPE type_)
|
IndentMarker(int column_, INDENT_TYPE type_)
|
||||||
: column(column_), type(type_), status(VALID), pStartToken(0) {}
|
: column(column_), type(type_), status(VALID), pStartToken(nullptr) {}
|
||||||
|
|
||||||
int column;
|
int column;
|
||||||
INDENT_TYPE type;
|
INDENT_TYPE type;
|
||||||
|
|||||||
@ -5,7 +5,7 @@ namespace YAML {
|
|||||||
struct Mark;
|
struct Mark;
|
||||||
|
|
||||||
Scanner::SimpleKey::SimpleKey(const Mark& mark_, std::size_t flowLevel_)
|
Scanner::SimpleKey::SimpleKey(const Mark& mark_, std::size_t flowLevel_)
|
||||||
: mark(mark_), flowLevel(flowLevel_), pIndent(0), pMapStart(0), pKey(0) {}
|
: mark(mark_), flowLevel(flowLevel_), pIndent(nullptr), pMapStart(nullptr), pKey(nullptr) {}
|
||||||
|
|
||||||
void Scanner::SimpleKey::Validate() {
|
void Scanner::SimpleKey::Validate() {
|
||||||
// Note: pIndent will *not* be garbage here;
|
// Note: pIndent will *not* be garbage here;
|
||||||
|
|||||||
@ -1,26 +1,39 @@
|
|||||||
set(gtest_force_shared_crt ${MSVC_SHARED_RT} CACHE BOOL
|
include(ExternalProject)
|
||||||
"Use shared (DLL) run-time lib even when Google Test built as a static lib.")
|
|
||||||
add_subdirectory(gtest-1.8.0)
|
|
||||||
include_directories(SYSTEM gtest-1.8.0/googlemock/include)
|
|
||||||
include_directories(SYSTEM gtest-1.8.0/googletest/include)
|
|
||||||
|
|
||||||
if(WIN32 AND BUILD_SHARED_LIBS)
|
if(MSVC)
|
||||||
add_definitions("-DGTEST_LINKED_AS_SHARED_LIBRARY")
|
# MS Visual Studio expects lib prefix on static libraries,
|
||||||
|
# but CMake compiles them without prefix
|
||||||
|
# See https://gitlab.kitware.com/cmake/cmake/issues/17338
|
||||||
|
set(CMAKE_STATIC_LIBRARY_PREFIX "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
ExternalProject_Add(
|
||||||
|
googletest_project
|
||||||
|
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/gtest-1.8.0"
|
||||||
|
INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/prefix"
|
||||||
|
CMAKE_ARGS
|
||||||
|
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||||
|
-DBUILD_GMOCK=ON
|
||||||
|
-Dgtest_force_shared_crt=ON
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(gmock UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(gmock PROPERTIES
|
||||||
|
IMPORTED_LOCATION
|
||||||
|
${PROJECT_BINARY_DIR}/test/prefix/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_package(Threads)
|
||||||
|
|
||||||
|
include_directories(SYSTEM "${PROJECT_BINARY_DIR}/test/prefix/include")
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
|
||||||
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
set(yaml_test_flags "-Wno-variadic-macros -Wno-sign-compare")
|
set(yaml_test_flags "-Wno-variadic-macros -Wno-sign-compare")
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
set(yaml_test_flags "${yaml_test_flags} -Wno-c99-extensions")
|
set(yaml_test_flags "${yaml_test_flags} -Wno-c99-extensions")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
set(yaml_test_flags "${yaml_test_flags} -std=gnu++11")
|
|
||||||
else()
|
|
||||||
set(yaml_test_flags "${yaml_test_flags} -std=c++11")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
file(GLOB test_headers [a-z_]*.h)
|
file(GLOB test_headers [a-z_]*.h)
|
||||||
@ -30,15 +43,22 @@ file(GLOB test_new_api_sources new-api/[a-z]*.cpp)
|
|||||||
list(APPEND test_sources ${test_new_api_sources})
|
list(APPEND test_sources ${test_new_api_sources})
|
||||||
add_sources(${test_sources} ${test_headers})
|
add_sources(${test_sources} ${test_headers})
|
||||||
|
|
||||||
|
include_directories(${YAML_CPP_SOURCE_DIR}/src)
|
||||||
include_directories(${YAML_CPP_SOURCE_DIR}/test)
|
include_directories(${YAML_CPP_SOURCE_DIR}/test)
|
||||||
|
|
||||||
add_executable(run-tests
|
add_executable(run-tests
|
||||||
${test_sources}
|
${test_sources}
|
||||||
${test_headers}
|
${test_headers}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_dependencies(run-tests googletest_project)
|
||||||
|
|
||||||
set_target_properties(run-tests PROPERTIES
|
set_target_properties(run-tests PROPERTIES
|
||||||
COMPILE_FLAGS "${yaml_c_flags} ${yaml_cxx_flags} ${yaml_test_flags}"
|
COMPILE_FLAGS "${yaml_c_flags} ${yaml_cxx_flags} ${yaml_test_flags}"
|
||||||
)
|
)
|
||||||
target_link_libraries(run-tests yaml-cpp gmock)
|
target_link_libraries(run-tests
|
||||||
|
yaml-cpp
|
||||||
|
gmock
|
||||||
|
${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
|
||||||
add_test(yaml-test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/run-tests)
|
add_test(yaml-test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/run-tests)
|
||||||
|
|||||||
@ -55,6 +55,26 @@ TEST(LoadNodeTest, Binary) {
|
|||||||
node[1].as<Binary>());
|
node[1].as<Binary>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(LoadNodeTest, BinaryWithWhitespaces) {
|
||||||
|
Node node = Load(
|
||||||
|
"binaryText: !binary |-\n"
|
||||||
|
" TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieS\n"
|
||||||
|
" B0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIG\n"
|
||||||
|
" x1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbi\n"
|
||||||
|
" B0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZG\n"
|
||||||
|
" dlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS\n"
|
||||||
|
" 4K");
|
||||||
|
EXPECT_EQ(Binary(reinterpret_cast<const unsigned char*>(
|
||||||
|
"Man is distinguished, not only by his reason, "
|
||||||
|
"but by this singular passion from other "
|
||||||
|
"animals, which is a lust of the mind, that by "
|
||||||
|
"a perseverance of delight in the continued and "
|
||||||
|
"indefatigable generation of knowledge, exceeds "
|
||||||
|
"the short vehemence of any carnal pleasure.\n"),
|
||||||
|
270),
|
||||||
|
node["binaryText"].as<Binary>());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(LoadNodeTest, IterateSequence) {
|
TEST(LoadNodeTest, IterateSequence) {
|
||||||
Node node = Load("[1, 3, 5, 7]");
|
Node node = Load("[1, 3, 5, 7]");
|
||||||
int seq[] = {1, 3, 5, 7};
|
int seq[] = {1, 3, 5, 7};
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
#include "yaml-cpp/emitter.h"
|
|
||||||
#include "yaml-cpp/node/emit.h"
|
|
||||||
#include "yaml-cpp/node/node.h"
|
#include "yaml-cpp/node/node.h"
|
||||||
#include "yaml-cpp/node/impl.h"
|
#include "yaml-cpp/emitter.h"
|
||||||
#include "yaml-cpp/node/convert.h"
|
#include "yaml-cpp/node/convert.h"
|
||||||
#include "yaml-cpp/node/iterator.h"
|
|
||||||
#include "yaml-cpp/node/detail/impl.h"
|
#include "yaml-cpp/node/detail/impl.h"
|
||||||
|
#include "yaml-cpp/node/emit.h"
|
||||||
|
#include "yaml-cpp/node/impl.h"
|
||||||
|
#include "yaml-cpp/node/iterator.h"
|
||||||
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
@ -47,6 +47,30 @@ TEST(NodeTest, SimpleAppendSequence) {
|
|||||||
EXPECT_TRUE(node.IsSequence());
|
EXPECT_TRUE(node.IsSequence());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(NodeTest, SequenceElementRemoval) {
|
||||||
|
Node node;
|
||||||
|
node[0] = "a";
|
||||||
|
node[1] = "b";
|
||||||
|
node[2] = "c";
|
||||||
|
node.remove(1);
|
||||||
|
EXPECT_TRUE(node.IsSequence());
|
||||||
|
EXPECT_EQ(2, node.size());
|
||||||
|
EXPECT_EQ("a", node[0].as<std::string>());
|
||||||
|
EXPECT_EQ("c", node[1].as<std::string>());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(NodeTest, SequenceLastElementRemoval) {
|
||||||
|
Node node;
|
||||||
|
node[0] = "a";
|
||||||
|
node[1] = "b";
|
||||||
|
node[2] = "c";
|
||||||
|
node.remove(2);
|
||||||
|
EXPECT_TRUE(node.IsSequence());
|
||||||
|
EXPECT_EQ(2, node.size());
|
||||||
|
EXPECT_EQ("a", node[0].as<std::string>());
|
||||||
|
EXPECT_EQ("b", node[1].as<std::string>());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(NodeTest, MapElementRemoval) {
|
TEST(NodeTest, MapElementRemoval) {
|
||||||
Node node;
|
Node node;
|
||||||
node["foo"] = "bar";
|
node["foo"] = "bar";
|
||||||
@ -54,6 +78,16 @@ TEST(NodeTest, MapElementRemoval) {
|
|||||||
EXPECT_TRUE(!node["foo"]);
|
EXPECT_TRUE(!node["foo"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(NodeTest, MapIntegerElementRemoval) {
|
||||||
|
Node node;
|
||||||
|
node[1] = "hello";
|
||||||
|
node[2] = 'c';
|
||||||
|
node["foo"] = "bar";
|
||||||
|
EXPECT_TRUE(node.IsMap());
|
||||||
|
node.remove(1);
|
||||||
|
EXPECT_TRUE(node.IsMap());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(NodeTest, SimpleAssignSequence) {
|
TEST(NodeTest, SimpleAssignSequence) {
|
||||||
Node node;
|
Node node;
|
||||||
node[0] = 10;
|
node[0] = 10;
|
||||||
@ -106,6 +140,14 @@ TEST(NodeTest, RemoveUnassignedNode) {
|
|||||||
EXPECT_EQ(0, node.size());
|
EXPECT_EQ(0, node.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(NodeTest, RemoveUnassignedNodeFromMap) {
|
||||||
|
Node node(NodeType::Map);
|
||||||
|
Node n;
|
||||||
|
node[n];
|
||||||
|
node.remove(n);
|
||||||
|
EXPECT_EQ(0, node.size());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(NodeTest, MapForceInsert) {
|
TEST(NodeTest, MapForceInsert) {
|
||||||
Node node;
|
Node node;
|
||||||
Node k1("k1");
|
Node k1("k1");
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
add_sources(parse.cpp)
|
add_sources(parse.cpp)
|
||||||
add_executable(parse parse.cpp)
|
add_executable(parse parse.cpp)
|
||||||
target_link_libraries(parse yaml-cpp)
|
target_link_libraries(parse yaml-cpp)
|
||||||
set_target_properties(parse PROPERTIES COMPILE_FLAGS "-std=c++11")
|
|
||||||
|
|
||||||
add_sources(sandbox.cpp)
|
add_sources(sandbox.cpp)
|
||||||
add_executable(sandbox sandbox.cpp)
|
add_executable(sandbox sandbox.cpp)
|
||||||
target_link_libraries(sandbox yaml-cpp)
|
target_link_libraries(sandbox yaml-cpp)
|
||||||
set_target_properties(sandbox PROPERTIES COMPILE_FLAGS "-std=c++11")
|
|
||||||
|
|
||||||
add_sources(read.cpp)
|
add_sources(read.cpp)
|
||||||
add_executable(read read.cpp)
|
add_executable(read read.cpp)
|
||||||
target_link_libraries(read yaml-cpp)
|
target_link_libraries(read yaml-cpp)
|
||||||
set_target_properties(read PROPERTIES COMPILE_FLAGS "-std=c++11")
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user