Skip to content

Commit

Permalink
Rename PUGI_HAS_STRING_VIEW to PUGIXML_HAS_STRING_VIEW
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Ignatoff committed Oct 22, 2024
1 parent afab50c commit 1514a3d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/pugixml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5441,7 +5441,7 @@ namespace pugi
return impl::strcpy_insitu(_attr->name, _attr->header, impl::xml_memory_page_name_allocated_mask, rhs, size);
}

#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
PUGI_IMPL_FN bool xml_attribute::set_name(string_view_t rhs)
{
if (!_attr) return false;
Expand All @@ -5464,7 +5464,7 @@ namespace pugi
return impl::strcpy_insitu(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, size);
}

#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
PUGI_IMPL_FN bool xml_attribute::set_value(string_view_t rhs)
{
if (!_attr) return false;
Expand Down Expand Up @@ -5866,7 +5866,7 @@ namespace pugi
return impl::strcpy_insitu(_root->name, _root->header, impl::xml_memory_page_name_allocated_mask, rhs, size);
}

#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
PUGI_IMPL_FN bool xml_node::set_name(string_view_t rhs)
{
xml_node_type type_ = _root ? PUGI_IMPL_NODETYPE(_root) : node_null;
Expand Down Expand Up @@ -5898,7 +5898,7 @@ namespace pugi
return impl::strcpy_insitu(_root->value, _root->header, impl::xml_memory_page_value_allocated_mask, rhs, size);
}

#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
PUGI_IMPL_FN bool xml_node::set_value(string_view_t rhs)
{
xml_node_type type_ = _root ? PUGI_IMPL_NODETYPE(_root) : node_null;
Expand Down Expand Up @@ -6799,7 +6799,7 @@ namespace pugi
return dn ? impl::strcpy_insitu(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, size) : false;
}

#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
PUGI_IMPL_FN bool xml_text::set(string_view_t rhs)
{
xml_node_struct* dn = _data_new();
Expand Down
18 changes: 9 additions & 9 deletions src/pugixml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
// Check if std::string_view is both requested and available
#if defined(PUGIXML_STRING_VIEW) && !defined(PUGIXML_NO_STL)
# if __cplusplus >= 201703L
# define PUGI_HAS_STRING_VIEW
# define PUGIXML_HAS_STRING_VIEW
# elif defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
# define PUGI_HAS_STRING_VIEW
# define PUGIXML_HAS_STRING_VIEW
# endif
#endif

// Include string_view if appropriate
#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
# include <string_view>
#endif

Expand Down Expand Up @@ -155,7 +155,7 @@ namespace pugi
typedef std::basic_string<PUGIXML_CHAR> string_t;
#endif

#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
// String view type used for operations that can work with a length delimited string; depends on PUGIXML_WCHAR_MODE
typedef std::basic_string_view<PUGIXML_CHAR> string_view_t;
#endif
Expand Down Expand Up @@ -442,12 +442,12 @@ namespace pugi
// Set attribute name/value (returns false if attribute is empty or there is not enough memory)
bool set_name(const char_t* rhs);
bool set_name(const char_t* rhs, size_t size);
#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
bool set_name(string_view_t rhs);
#endif
bool set_value(const char_t* rhs);
bool set_value(const char_t* rhs, size_t size);
#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
bool set_value(string_view_t rhs);
#endif

Expand Down Expand Up @@ -584,12 +584,12 @@ namespace pugi
// Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
bool set_name(const char_t* rhs);
bool set_name(const char_t* rhs, size_t size);
#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
bool set_name(string_view_t rhs);
#endif
bool set_value(const char_t* rhs);
bool set_value(const char_t* rhs, size_t size);
#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
bool set_value(string_view_t rhs);
#endif

Expand Down Expand Up @@ -821,7 +821,7 @@ namespace pugi
// Set text (returns false if object is empty or there is not enough memory)
bool set(const char_t* rhs);
bool set(const char_t* rhs, size_t size);
#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
bool set(string_view_t rhs);
#endif

Expand Down
6 changes: 3 additions & 3 deletions tests/test_dom_modify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ TEST_XML(dom_attr_set_name_with_size, "<node attr='value' />")
CHECK_NODE(doc, STR("<node n=\"value\"/>"));
}

#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
TEST_XML(dom_attr_set_name_with_string_view, "<node attr='value' />")
{
xml_attribute attr = doc.child(STR("node")).attribute(STR("attr"));
Expand Down Expand Up @@ -242,7 +242,7 @@ TEST_XML(dom_node_set_name_with_size, "<node>text</node>")
CHECK_NODE(doc, STR("<n>text</n>"));
}

#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
TEST_XML(dom_node_set_name_with_string_view, "<node>text</node>")
{
xml_node node = doc.child(STR("node"));
Expand Down Expand Up @@ -288,7 +288,7 @@ TEST_XML(dom_node_set_value_with_size, "<node>text</node>")
CHECK_NODE(doc, STR("<node>no text</node>"));
}

#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
TEST_XML(dom_node_set_value_partially_with_string_view, "<node>text</node>")
{
CHECK(doc.child(STR("node")).first_child().set_value(string_view_t(STR("no text"), 2)));
Expand Down
6 changes: 3 additions & 3 deletions tests/test_dom_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ TEST_XML(dom_text_set_partially_with_size, "<node/>")
CHECK_NODE(node, STR("<node></node>"));
}

#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
TEST_XML(dom_text_set_with_string_view, "<node/>")
{
xml_node node = doc.child(STR("node"));
Expand Down Expand Up @@ -398,7 +398,7 @@ TEST_XML(dom_text_set_value, "<node/>")
CHECK(node.append_child(STR("text1")).text().set(STR("v1")));
CHECK(!xml_text().set(STR("v1")));
CHECK(!xml_text().set(STR("v1"), 2));
#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
CHECK(!xml_text().set(string_view_t(STR("v1"))));
#endif

Expand Down Expand Up @@ -537,7 +537,7 @@ TEST_XML(dom_text_middle, "<node><c1>notthisone</c1>text<c2/></node>")
CHECK(t.data() == node.last_child());
}

#ifdef PUGI_HAS_STRING_VIEW
#ifdef PUGIXML_HAS_STRING_VIEW
TEST_XML(dom_text_middle_string_view, "<node><c1>notthisone</c1>text<c2/></node>")
{
xml_node node = doc.child(STR("node"));
Expand Down

0 comments on commit 1514a3d

Please sign in to comment.