Fixed linker error on Visual Studio with a shared lib by moving the static methods node_data::equals to an instance method on node.

This commit is contained in:
Jesse Beder
2015-03-29 21:11:53 -05:00
parent 25b2ed0787
commit 7092a0b099
4 changed files with 22 additions and 20 deletions

View File

@@ -56,6 +56,19 @@ struct get_idx<Key, typename boost::enable_if<boost::is_signed<Key> >::type> {
}
};
template <typename T>
inline bool node::equals(const T& rhs, shared_memory_holder pMemory) {
T lhs;
if (convert<T>::decode(Node(*this, pMemory), lhs)) {
return lhs == rhs;
}
return false;
}
inline bool node::equals(const char* rhs, shared_memory_holder pMemory) {
return equals<std::string>(rhs, pMemory);
}
// indexing
template <typename Key>
inline node* node_data::get(const Key& key,
@@ -75,9 +88,10 @@ inline node* node_data::get(const Key& key,
}
for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
if (equals(*it->first, key, pMemory))
if (it->first->equals(key, pMemory)) {
return it->second;
}
}
return NULL;
}
@@ -102,9 +116,10 @@ inline node& node_data::get(const Key& key, shared_memory_holder pMemory) {
}
for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
if (equals(*it->first, key, pMemory))
if (it->first->equals(key, pMemory)) {
return *it->second;
}
}
node& k = convert_to_node(key, pMemory);
node& v = pMemory->create_node();
@@ -148,20 +163,6 @@ inline void node_data::force_insert(const Key& key, const Value& value,
insert_map_pair(k, v);
}
template <typename T>
inline bool node_data::equals(node& node, const T& rhs,
shared_memory_holder pMemory) {
T lhs;
if (convert<T>::decode(Node(node, pMemory), lhs))
return lhs == rhs;
return false;
}
inline bool node_data::equals(node& node, const char* rhs,
shared_memory_holder pMemory) {
return equals<std::string>(node, rhs, pMemory);
}
template <typename T>
inline node& node_data::convert_to_node(const T& rhs,
shared_memory_holder pMemory) {

View File

@@ -31,6 +31,10 @@ class node : private boost::noncopyable {
const std::string& tag() const { return m_pRef->tag(); }
EmitterStyle::value style() const { return m_pRef->style(); }
template <typename T>
bool equals(const T& rhs, shared_memory_holder pMemory);
bool equals(const char* rhs, shared_memory_holder pMemory);
void mark_defined() {
if (is_defined())
return;

View File

@@ -92,10 +92,6 @@ class YAML_CPP_API node_data : private boost::noncopyable {
void convert_to_map(shared_memory_holder pMemory);
void convert_sequence_to_map(shared_memory_holder pMemory);
template <typename T>
static bool equals(node& node, const T& rhs, shared_memory_holder pMemory);
static bool equals(node& node, const char* rhs, shared_memory_holder pMemory);
template <typename T>
static node& convert_to_node(const T& rhs, shared_memory_holder pMemory);

View File

@@ -30,6 +30,7 @@ class YAML_CPP_API Node {
friend class NodeBuilder;
friend class NodeEvents;
friend struct detail::iterator_value;
friend class detail::node;
friend class detail::node_data;
template <typename>
friend class detail::iterator_base;