diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pugixml.cpp | 162 | ||||
-rw-r--r-- | src/pugixml.hpp | 149 | ||||
-rw-r--r-- | src/pugixpath.cpp | 1 |
3 files changed, 2 insertions, 310 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 3238a3d..d319069 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -98,6 +98,7 @@ namespace pugi namespace impl { size_t strlen(const char_t* s); + bool strequal(const char_t* src, const char_t* dst); bool strequalrange(const char_t* lhs, const char_t* rhs, size_t count); void widen_ascii(wchar_t* dest, const char* source); } @@ -138,89 +139,6 @@ namespace pugi return lhs[count] == 0; } - // Character set pattern match. - static bool strequalwild_cset(const char_t** src, const char_t** dst) - { - int find = 0, excl = 0, star = 0; - - if (**src == '!') - { - excl = 1; - ++(*src); - } - - while (**src != ']' || star == 1) - { - if (find == 0) - { - if (**src == '-' && *(*src-1) < *(*src+1) && *(*src+1) != ']' && star == 0) - { - if (**dst >= *(*src-1) && **dst <= *(*src+1)) - { - find = 1; - ++(*src); - } - } - else if (**src == **dst) find = 1; - } - ++(*src); - star = 0; - } - - if (excl == 1) find = (1 - find); - if (find == 1) ++(*dst); - - return find == 0; - } - - // Wildcard pattern match. - static bool strequalwild_astr(const char_t** src, const char_t** dst) - { - int find = 1; - ++(*src); - while ((**dst != 0 && **src == '?') || **src == '*') - { - if(**src == '?') ++(*dst); - ++(*src); - } - while (**src == '*') ++(*src); - if (**dst == 0 && **src != 0) return 0; - if (**dst == 0 && **src == 0) return 1; - else - { - if (!impl::strequalwild(*src,*dst)) - { - do - { - ++(*dst); - while(**src != **dst && **src != '[' && **dst != 0) - ++(*dst); - } - while ((**dst != 0) ? !impl::strequalwild(*src,*dst) : 0 != (find=0)); - } - if (**dst == 0 && **src == 0) find = 1; - return find == 0; - } - } - - // Compare two strings, with globbing, and character sets. - bool PUGIXML_FUNCTION strequalwild(const char_t* src, const char_t* dst) - { - int find = 1; - for(; *src != 0 && find == 1 && *dst != 0; ++src) - { - switch (*src) - { - case '?': ++dst; break; - case '[': ++src; find = !strequalwild_cset(&src,&dst); break; - case '*': find = !strequalwild_astr(&src,&dst); --src; break; - default : find = (int) (*src == *dst); ++dst; - } - } - while (*src == '*' && find == 1) ++src; - return (find == 1 && *dst == 0 && *src == 0); - } - #ifdef PUGIXML_WCHAR_MODE // Convert string to wide string, assuming all symbols are ASCII void widen_ascii(wchar_t* dest, const char* source) @@ -3493,16 +3411,6 @@ namespace pugi return xml_node(); } - xml_node xml_node::child_w(const char_t* name) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - if (i->name && impl::strequalwild(name, i->name)) return xml_node(i); - - return xml_node(); - } - xml_attribute xml_node::attribute(const char_t* name) const { if (!_root) return xml_attribute(); @@ -3514,17 +3422,6 @@ namespace pugi return xml_attribute(); } - xml_attribute xml_node::attribute_w(const char_t* name) const - { - if (!_root) return xml_attribute(); - - for (xml_attribute_struct* i = _root->first_attribute; i; i = i->next_attribute) - if (i->name && impl::strequalwild(name, i->name)) - return xml_attribute(i); - - return xml_attribute(); - } - xml_node xml_node::next_sibling(const char_t* name) const { if (!_root) return xml_node(); @@ -3535,16 +3432,6 @@ namespace pugi return xml_node(); } - xml_node xml_node::next_sibling_w(const char_t* name) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->next_sibling; i; i = i->next_sibling) - if (i->name && impl::strequalwild(name, i->name)) return xml_node(i); - - return xml_node(); - } - xml_node xml_node::next_sibling() const { if (!_root) return xml_node(); @@ -3563,16 +3450,6 @@ namespace pugi return xml_node(); } - xml_node xml_node::previous_sibling_w(const char_t* name) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->prev_sibling_c; i->next_sibling; i = i->prev_sibling_c) - if (i->name && impl::strequalwild(name, i->name)) return xml_node(i); - - return xml_node(); - } - xml_node xml_node::previous_sibling() const { if (!_root) return xml_node(); @@ -3615,16 +3492,6 @@ namespace pugi return child(name).child_value(); } - const char_t* xml_node::child_value_w(const char_t* name) const - { - if (!_root) return PUGIXML_TEXT(""); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - if (i->name && impl::strequalwild(name, i->name)) return xml_node(i).child_value(); - - return PUGIXML_TEXT(""); - } - xml_attribute xml_node::first_attribute() const { return _root ? xml_attribute(_root->first_attribute) : xml_attribute(); @@ -3918,21 +3785,6 @@ namespace pugi return xml_node(); } - xml_node xml_node::find_child_by_attribute_w(const char_t* name, const char_t* attr_name, const char_t* attr_value) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - if (i->name && impl::strequalwild(name, i->name)) - { - for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute) - if (impl::strequalwild(attr_name, a->name) && impl::strequalwild(attr_value, a->value)) - return xml_node(i); - } - - return xml_node(); - } - xml_node xml_node::find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const { if (!_root) return xml_node(); @@ -3945,18 +3797,6 @@ namespace pugi return xml_node(); } - xml_node xml_node::find_child_by_attribute_w(const char_t* attr_name, const char_t* attr_value) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute) - if (impl::strequalwild(attr_name, a->name) && impl::strequalwild(attr_value, a->value)) - return xml_node(i); - - return xml_node(); - } - #ifndef PUGIXML_NO_STL string_t xml_node::path(char_t delimiter) const { diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 91a3190..3c9072b 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -108,16 +108,6 @@ namespace pugi } #endif -// Helpers for inline implementation -namespace pugi -{ - namespace impl - { - bool PUGIXML_FUNCTION strequal(const char_t*, const char_t*); - bool PUGIXML_FUNCTION strequalwild(const char_t*, const char_t*); - } -} - /// The PugiXML Parser namespace. namespace pugi { @@ -690,45 +680,6 @@ namespace pugi /// \internal Initializing constructor explicit xml_node(xml_node_struct* p); - private: - template <typename OutputIterator> void all_elements_by_name_helper(const char_t* name, OutputIterator it) const - { - if (!_root) return; - - for (xml_node node = first_child(); node; node = node.next_sibling()) - { - if (node.type() == node_element) - { - if (impl::strequal(name, node.name())) - { - *it = node; - ++it; - } - - if (node.first_child()) node.all_elements_by_name_helper(name, it); - } - } - } - - template <typename OutputIterator> void all_elements_by_name_w_helper(const char_t* name, OutputIterator it) const - { - if (!_root) return; - - for (xml_node node = first_child(); node; node = node.next_sibling()) - { - if (node.type() == node_element) - { - if (impl::strequalwild(name, node.name())) - { - *it = node; - ++it; - } - - if (node.first_child()) node.all_elements_by_name_w_helper(name, it); - } - } - } - public: /** * Default constructor. Constructs an empty node. @@ -873,16 +824,6 @@ namespace pugi xml_node child(const char_t* name) const; /** - * Get child with the name that matches specified pattern - * - * \param name - child name pattern - * \return child with the name that matches pattern, if any; empty node otherwise - * - * \deprecated This function is deprecated - */ - PUGIXML_DEPRECATED xml_node child_w(const char_t* name) const; - - /** * Get attribute with the specified name * * \param name - attribute name @@ -891,16 +832,6 @@ namespace pugi xml_attribute attribute(const char_t* name) const; /** - * Get attribute with the name that matches specified pattern - * - * \param name - attribute name pattern - * \return attribute with the name that matches pattern, if any; empty attribute otherwise - * - * \deprecated This function is deprecated - */ - PUGIXML_DEPRECATED xml_attribute attribute_w(const char_t* name) const; - - /** * Get first of following sibling nodes with the specified name * * \param name - sibling name @@ -909,16 +840,6 @@ namespace pugi xml_node next_sibling(const char_t* name) const; /** - * Get first of the following sibling nodes with the name that matches specified pattern - * - * \param name - sibling name pattern - * \return node with the name that matches pattern, if any; empty node otherwise - * - * \deprecated This function is deprecated - */ - PUGIXML_DEPRECATED xml_node next_sibling_w(const char_t* name) const; - - /** * Get following sibling * * \return following sibling node, if any; empty node otherwise @@ -934,16 +855,6 @@ namespace pugi xml_node previous_sibling(const char_t* name) const; /** - * Get first of the preceding sibling nodes with the name that matches specified pattern - * - * \param name - sibling name pattern - * \return node with the name that matches pattern, if any; empty node otherwise - * - * \deprecated This function is deprecated - */ - PUGIXML_DEPRECATED xml_node previous_sibling_w(const char_t* name) const; - - /** * Get preceding sibling * * \return preceding sibling node, if any; empty node otherwise @@ -980,17 +891,6 @@ namespace pugi */ const char_t* child_value(const char_t* name) const; - /** - * Get child value of child with name that matches the specified pattern. \see child_value - * node.child_value_w(name) is equivalent to node.child_w(name).child_value() - * - * \param name - child name pattern - * \return child value of specified child node, if any; "" otherwise - * - * \deprecated This function is deprecated - */ - PUGIXML_DEPRECATED const char_t* child_value_w(const char_t* name) const; - public: /** * Set node name to \a rhs (for PI/element nodes). \see name @@ -1160,32 +1060,6 @@ namespace pugi xml_attribute last_attribute() const; /** - * Get all elements from subtree with given name - * - * \param name - node name - * \param it - output iterator (for example, std::back_insert_iterator (result of std::back_inserter)) - * - * \deprecated This function is deprecated - */ - template <typename OutputIterator> PUGIXML_DEPRECATED void all_elements_by_name(const char_t* name, OutputIterator it) const - { - all_elements_by_name_helper(name, it); - } - - /** - * Get all elements from subtree with name that matches given pattern - * - * \param name - node name pattern - * \param it - output iterator (for example, std::back_insert_iterator (result of std::back_inserter)) - * - * \deprecated This function is deprecated - */ - template <typename OutputIterator> PUGIXML_DEPRECATED void all_elements_by_name_w(const char_t* name, OutputIterator it) const - { - all_elements_by_name_w_helper(name, it); - } - - /** * Get first child * * \return first child, if any; empty node otherwise @@ -1273,18 +1147,6 @@ namespace pugi xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const; /** - * Find child node with the specified name that has specified attribute (use pattern matching for node name and attribute name/value) - * - * \param name - pattern for child node name - * \param attr_name - pattern for attribute name of child node - * \param attr_value - pattern for attribute value of child node - * \return first matching child node, or empty node - * - * \deprecated This function is deprecated - */ - PUGIXML_DEPRECATED xml_node find_child_by_attribute_w(const char_t* name, const char_t* attr_name, const char_t* attr_value) const; - - /** * Find child node that has specified attribute * * \param attr_name - attribute name of child node @@ -1293,17 +1155,6 @@ namespace pugi */ xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const; - /** - * Find child node that has specified attribute (use pattern matching for attribute name/value) - * - * \param attr_name - pattern for attribute name of child node - * \param attr_value - pattern for attribute value of child node - * \return first matching child node, or empty node - * - * \deprecated This function is deprecated - */ - PUGIXML_DEPRECATED xml_node find_child_by_attribute_w(const char_t* attr_name, const char_t* attr_value) const; - #ifndef PUGIXML_NO_STL /** * Get the absolute node path from root as a text string. diff --git a/src/pugixpath.cpp b/src/pugixpath.cpp index 4040eb9..7ab466c 100644 --- a/src/pugixpath.cpp +++ b/src/pugixpath.cpp @@ -63,6 +63,7 @@ namespace pugi namespace impl { size_t strlen(const char_t* s); + bool strequal(const char_t* src, const char_t* dst); bool strequalrange(const char_t* lhs, const char_t* rhs, size_t count); void widen_ascii(wchar_t* dest, const char* source); } |