diff options
Diffstat (limited to 'src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail')
8 files changed, 151 insertions, 113 deletions
diff --git a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/bool_type.h b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/bool_type.h deleted file mode 100644 index 2c80705c9a..0000000000 --- a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/bool_type.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#define NODE_DETAIL_BOOL_TYPE_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 { -namespace detail { -struct unspecified_bool { - struct NOT_ALLOWED; - static void true_value(NOT_ALLOWED*) {} -}; -typedef void (*unspecified_bool_type)(unspecified_bool::NOT_ALLOWED*); -} -} - -#define YAML_CPP_OPERATOR_BOOL() \ - operator YAML::detail::unspecified_bool_type() const { \ - return this->operator!() ? 0 \ - : &YAML::detail::unspecified_bool::true_value; \ - } - -#endif // NODE_DETAIL_BOOL_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/impl.h b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/impl.h index 09e55f838c..b38038dfd2 100644 --- a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/impl.h +++ b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/impl.h @@ -9,6 +9,8 @@ #include "yaml-cpp/node/detail/node.h" #include "yaml-cpp/node/detail/node_data.h" + +#include <algorithm> #include <type_traits> namespace YAML { @@ -17,7 +19,7 @@ template <typename Key, typename Enable = void> struct get_idx { static node* get(const std::vector<node*>& /* sequence */, const Key& /* key */, shared_memory_holder /* pMemory */) { - return 0; + return nullptr; } }; @@ -27,13 +29,13 @@ struct get_idx<Key, !std::is_same<Key, bool>::value>::type> { static node* get(const std::vector<node*>& sequence, const Key& key, shared_memory_holder /* pMemory */) { - return key < sequence.size() ? sequence[key] : 0; + return key < sequence.size() ? sequence[key] : nullptr; } static node* get(std::vector<node*>& sequence, const Key& key, shared_memory_holder pMemory) { - if (key > sequence.size() || (key > 0 && !sequence[key-1]->is_defined())) - return 0; + if (key > sequence.size() || (key > 0 && !sequence[key - 1]->is_defined())) + return nullptr; if (key == sequence.size()) sequence.push_back(&pMemory->create_node()); return sequence[key]; @@ -46,13 +48,51 @@ struct get_idx<Key, typename std::enable_if<std::is_signed<Key>::value>::type> { shared_memory_holder pMemory) { return key >= 0 ? get_idx<std::size_t>::get( sequence, static_cast<std::size_t>(key), pMemory) - : 0; + : nullptr; } static node* get(std::vector<node*>& sequence, const Key& key, shared_memory_holder pMemory) { return key >= 0 ? get_idx<std::size_t>::get( sequence, static_cast<std::size_t>(key), pMemory) - : 0; + : nullptr; + } +}; + +template <typename Key, typename Enable = void> +struct remove_idx { + static bool remove(std::vector<node*>&, const Key&, std::size_t&) { + 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, + std::size_t& seqSize) { + if (key >= sequence.size()) { + return false; + } else { + sequence.erase(sequence.begin() + key); + if (seqSize > key) { + --seqSize; + } + 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, + std::size_t& seqSize) { + return key >= 0 ? remove_idx<std::size_t>::remove( + sequence, static_cast<std::size_t>(key), seqSize) + : false; } }; @@ -66,7 +106,11 @@ inline bool node::equals(const T& rhs, shared_memory_holder pMemory) { } inline bool node::equals(const char* rhs, shared_memory_holder pMemory) { - return equals<std::string>(rhs, pMemory); + std::string lhs; + if (convert<std::string>::decode(Node(*this, std::move(pMemory)), lhs)) { + return lhs == rhs; + } + return false; } // indexing @@ -78,22 +122,20 @@ inline node* node_data::get(const Key& key, break; case NodeType::Undefined: case NodeType::Null: - return NULL; + return nullptr; case NodeType::Sequence: if (node* pNode = get_idx<Key>::get(m_sequence, key, pMemory)) return pNode; - return NULL; + return nullptr; case NodeType::Scalar: - throw BadSubscript(); + throw BadSubscript(m_mark, key); } - for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { - if (it->first->equals(key, pMemory)) { - return it->second; - } - } + auto it = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) { + return m.first->equals(key, pMemory); + }); - return NULL; + return it != m_map.end() ? it->second : nullptr; } template <typename Key> @@ -112,13 +154,15 @@ inline node& node_data::get(const Key& key, shared_memory_holder pMemory) { convert_to_map(pMemory); break; case NodeType::Scalar: - throw BadSubscript(); + throw BadSubscript(m_mark, key); } - for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { - if (it->first->equals(key, pMemory)) { - return *it->second; - } + auto it = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) { + return m.first->equals(key, pMemory); + }); + + if (it != m_map.end()) { + return *it->second; } node& k = convert_to_node(key, pMemory); @@ -129,20 +173,26 @@ inline node& node_data::get(const Key& key, shared_memory_holder pMemory) { template <typename Key> inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) { - if (m_type != NodeType::Map) - return false; - - for (kv_pairs::iterator it = m_undefinedPairs.begin(); - it != m_undefinedPairs.end();) { - kv_pairs::iterator jt = std::next(it); - if (it->first->equals(key, pMemory)) - m_undefinedPairs.erase(it); - it = jt; + if (m_type == NodeType::Sequence) { + return remove_idx<Key>::remove(m_sequence, key, m_seqSize); } - for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) { - if (it->first->equals(key, pMemory)) { - m_map.erase(it); + 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; + } + + auto iter = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) { + return m.first->equals(key, pMemory); + }); + + if (iter != m_map.end()) { + m_map.erase(iter); return true; } } diff --git a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/iterator.h b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/iterator.h index deec8fb62c..997c69a14c 100644 --- a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/iterator.h +++ b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/iterator.h @@ -8,25 +8,25 @@ #endif #include "yaml-cpp/dll.h" +#include "yaml-cpp/node/detail/node_iterator.h" #include "yaml-cpp/node/node.h" #include "yaml-cpp/node/ptr.h" -#include "yaml-cpp/node/detail/node_iterator.h" #include <cstddef> #include <iterator> + namespace YAML { namespace detail { struct iterator_value; template <typename V> -class iterator_base : public std::iterator<std::forward_iterator_tag, V, - std::ptrdiff_t, V*, V> { +class iterator_base { private: template <typename> friend class iterator_base; struct enabler {}; - typedef node_iterator base_type; + using base_type = node_iterator; struct proxy { explicit proxy(const V& x) : m_ref(x) {} @@ -37,7 +37,11 @@ class iterator_base : public std::iterator<std::forward_iterator_tag, V, }; 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: 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; shared_memory_holder m_pMemory; }; -} -} +} // namespace detail +} // namespace YAML #endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/iterator_fwd.h b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/iterator_fwd.h index 5f1ffe7436..75c9de086c 100644 --- a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/iterator_fwd.h +++ b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/iterator_fwd.h @@ -20,8 +20,8 @@ template <typename V> class iterator_base; } -typedef detail::iterator_base<detail::iterator_value> iterator; -typedef detail::iterator_base<const detail::iterator_value> const_iterator; +using iterator = detail::iterator_base<detail::iterator_value>; +using const_iterator = detail::iterator_base<const detail::iterator_value>; } #endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/memory.h b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/memory.h index 8f2bc2657a..e881545bf2 100644 --- a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/memory.h +++ b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/memory.h @@ -22,11 +22,12 @@ namespace YAML { namespace detail { class YAML_CPP_API memory { public: + memory() : m_nodes{} {} node& create_node(); void merge(const memory& rhs); private: - typedef std::set<shared_node> Nodes; + using Nodes = std::set<shared_node>; Nodes m_nodes; }; @@ -40,7 +41,7 @@ class YAML_CPP_API memory_holder { private: shared_memory m_pMemory; }; -} -} +} // namespace detail +} // namespace YAML #endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/node.h b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/node.h index 8a776f62a9..acf60ffb6d 100644 --- a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/node.h +++ b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/node.h @@ -7,18 +7,24 @@ #pragma once #endif -#include "yaml-cpp/emitterstyle.h" #include "yaml-cpp/dll.h" -#include "yaml-cpp/node/type.h" -#include "yaml-cpp/node/ptr.h" +#include "yaml-cpp/emitterstyle.h" #include "yaml-cpp/node/detail/node_ref.h" +#include "yaml-cpp/node/ptr.h" +#include "yaml-cpp/node/type.h" #include <set> +#include <atomic> namespace YAML { namespace detail { class node { + private: + struct less { + bool operator ()(const node* l, const node* r) const {return l->m_index < r->m_index;} + }; + public: - node() : m_pRef(new node_ref) {} + node() : m_pRef(new node_ref), m_dependencies{}, m_index{} {} node(const node&) = delete; node& operator=(const node&) = delete; @@ -42,9 +48,8 @@ class node { return; m_pRef->mark_defined(); - for (nodes::iterator it = m_dependencies.begin(); - it != m_dependencies.end(); ++it) - (*it)->mark_defined(); + for (node* dependency : m_dependencies) + dependency->mark_defined(); m_dependencies.clear(); } @@ -109,6 +114,7 @@ class node { void push_back(node& input, shared_memory_holder pMemory) { m_pRef->push_back(input, pMemory); input.add_dependency(*this); + m_index = m_amount.fetch_add(1); } void insert(node& key, node& value, shared_memory_holder pMemory) { m_pRef->insert(key, value, pMemory); @@ -120,7 +126,7 @@ class node { template <typename Key> node* get(const Key& key, shared_memory_holder pMemory) const { // NOTE: this returns a non-const node so that the top-level Node can wrap - // it, and returns a pointer so that it can be NULL (if there is no such + // it, and returns a pointer so that it can be nullptr (if there is no such // key). return static_cast<const node_ref&>(*m_pRef).get(key, pMemory); } @@ -137,7 +143,7 @@ class node { node* get(node& key, shared_memory_holder pMemory) const { // NOTE: this returns a non-const node so that the top-level Node can wrap - // it, and returns a pointer so that it can be NULL (if there is no such + // it, and returns a pointer so that it can be nullptr (if there is no such // key). return static_cast<const node_ref&>(*m_pRef).get(key, pMemory); } @@ -160,10 +166,12 @@ class node { private: shared_node_ref m_pRef; - typedef std::set<node*> nodes; + using nodes = std::set<node*, less>; nodes m_dependencies; + size_t m_index; + static YAML_CPP_API std::atomic<size_t> m_amount; }; -} -} +} // namespace detail +} // namespace YAML #endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/node_data.h b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/node_data.h index 50bcd74352..07cf81aa09 100644 --- a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/node_data.h +++ b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/node_data.h @@ -60,8 +60,8 @@ class YAML_CPP_API node_data { node_iterator end(); // sequence - void push_back(node& node, shared_memory_holder pMemory); - void insert(node& key, node& value, shared_memory_holder pMemory); + void push_back(node& node, const shared_memory_holder& pMemory); + void insert(node& key, node& value, const shared_memory_holder& pMemory); // indexing template <typename Key> @@ -71,9 +71,9 @@ class YAML_CPP_API node_data { template <typename Key> bool remove(const Key& key, shared_memory_holder pMemory); - node* get(node& key, shared_memory_holder pMemory) const; - node& get(node& key, shared_memory_holder pMemory); - bool remove(node& key, shared_memory_holder pMemory); + node* get(node& key, const shared_memory_holder& pMemory) const; + node& get(node& key, const shared_memory_holder& pMemory); + bool remove(node& key, const shared_memory_holder& pMemory); // map template <typename Key, typename Value> @@ -81,7 +81,7 @@ class YAML_CPP_API node_data { shared_memory_holder pMemory); public: - static std::string empty_scalar; + static const std::string& empty_scalar(); private: void compute_seq_size() const; @@ -91,8 +91,8 @@ class YAML_CPP_API node_data { void reset_map(); void insert_map_pair(node& key, node& value); - void convert_to_map(shared_memory_holder pMemory); - void convert_sequence_to_map(shared_memory_holder pMemory); + void convert_to_map(const shared_memory_holder& pMemory); + void convert_sequence_to_map(const shared_memory_holder& pMemory); template <typename T> static node& convert_to_node(const T& rhs, shared_memory_holder pMemory); @@ -108,17 +108,17 @@ class YAML_CPP_API node_data { std::string m_scalar; // sequence - typedef std::vector<node*> node_seq; + using node_seq = std::vector<node *>; node_seq m_sequence; mutable std::size_t m_seqSize; // map - typedef std::vector<std::pair<node*, node*>> node_map; + using node_map = std::vector<std::pair<node*, node*>>; node_map m_map; - typedef std::pair<node*, node*> kv_pair; - typedef std::list<kv_pair> kv_pairs; + using kv_pair = std::pair<node*, node*>; + using kv_pairs = std::list<kv_pair>; mutable kv_pairs m_undefinedPairs; }; } diff --git a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/node_iterator.h b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/node_iterator.h index 088090fe74..49dcf958db 100644 --- a/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/node_iterator.h +++ b/src/libs/3rdparty/yaml-cpp/include/yaml-cpp/node/detail/node_iterator.h @@ -24,11 +24,11 @@ struct iterator_type { template <typename V> struct node_iterator_value : public std::pair<V*, V*> { - typedef std::pair<V*, V*> kv; + using kv = std::pair<V*, V*>; - node_iterator_value() : kv(), pNode(0) {} + node_iterator_value() : kv(), pNode(nullptr) {} explicit node_iterator_value(V& rhs) : kv(), pNode(&rhs) {} - explicit node_iterator_value(V& key, V& value) : kv(&key, &value), pNode(0) {} + explicit node_iterator_value(V& key, V& value) : kv(&key, &value), pNode(nullptr) {} V& operator*() const { return *pNode; } V& operator->() const { return *pNode; } @@ -36,26 +36,23 @@ struct node_iterator_value : public std::pair<V*, V*> { V* pNode; }; -typedef std::vector<node*> node_seq; -typedef std::vector<std::pair<node*, node*>> node_map; +using node_seq = std::vector<node *>; +using node_map = std::vector<std::pair<node*, node*>>; template <typename V> struct node_iterator_type { - typedef node_seq::iterator seq; - typedef node_map::iterator map; + using seq = node_seq::iterator; + using map = node_map::iterator; }; template <typename V> struct node_iterator_type<const V> { - typedef node_seq::const_iterator seq; - typedef node_map::const_iterator map; + using seq = node_seq::const_iterator; + using map = node_map::const_iterator; }; template <typename V> -class node_iterator_base - : public std::iterator<std::forward_iterator_tag, node_iterator_value<V>, - std::ptrdiff_t, node_iterator_value<V>*, - node_iterator_value<V>> { +class node_iterator_base { private: struct enabler {}; @@ -68,9 +65,13 @@ class node_iterator_base }; public: - typedef typename node_iterator_type<V>::seq SeqIter; - typedef typename node_iterator_type<V>::map MapIter; - typedef node_iterator_value<V> value_type; + using iterator_category = std::forward_iterator_tag; + using value_type = node_iterator_value<V>; + using difference_type = std::ptrdiff_t; + using pointer = node_iterator_value<V>*; + using reference = node_iterator_value<V>; + using SeqIter = typename node_iterator_type<V>::seq; + using MapIter = typename node_iterator_type<V>::map; node_iterator_base() : m_type(iterator_type::NoneType), m_seqIt(), m_mapIt(), m_mapEnd() {} @@ -172,8 +173,8 @@ class node_iterator_base MapIter m_mapIt, m_mapEnd; }; -typedef node_iterator_base<node> node_iterator; -typedef node_iterator_base<const node> const_node_iterator; +using node_iterator = node_iterator_base<node>; +using const_node_iterator = node_iterator_base<const node>; } } |