本文整理汇总了C++中DomString::substr方法的典型用法代码示例。如果您正苦于以下问题:C++ DomString::substr方法的具体用法?C++ DomString::substr怎么用?C++ DomString::substr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomString
的用法示例。
在下文中一共展示了DomString::substr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insert_data
void DomCharacterData::insert_data(unsigned long offset, const DomString &arg)
{
if (impl)
{
DomString value = impl->get_tree_node()->get_node_value();
if (offset > value.length())
offset = value.length();
impl->get_tree_node()->node_value = value.substr(0, offset) + arg + value.substr(offset);
}
}
示例2: set_child_string_ns
void DomElement::set_child_string_ns(const DomString &namespace_uri, const DomString &qualified_name, const DomString &value)
{
DomString local_name;
DomString::size_type pos = qualified_name.find(L':');
if (pos != DomString::npos)
local_name = qualified_name.substr(pos + 1);
else
local_name = qualified_name;
DomElement element = named_item_ns(namespace_uri, local_name).to_element();
if (element.is_null())
{
element = get_owner_document().create_element_ns(namespace_uri, qualified_name);
append_child(element);
}
DomText dom_text = get_owner_document().create_text_node(value);
if (element.get_first_child().is_text())
{
DomNode temp_domnode = element.get_first_child();
replace_child(dom_text, temp_domnode);
}
else
{
element.append_child(dom_text);
}
}
示例3: delete_data
void DomCharacterData::delete_data(unsigned long offset, unsigned long count)
{
if (impl)
{
DomString value = impl->get_tree_node()->get_node_value();
if (offset > value.length())
offset = value.length();
if (offset + count > value.length())
count = value.length() - offset;
if (count == 0)
return;
if (count < value.length())
{
value = value.substr(0, offset) + value.substr(offset + count);
}
else
{
value = DomString();
}
impl->get_tree_node()->node_value = value;
}
}
示例4: find_namespace_uri
DomString DomNode::find_namespace_uri(const DomString &qualified_name) const
{
static DomString xmlns_prefix("xmlns:");
static DomString xmlns_xml("xml");
static DomString xmlns_xml_uri("http://www.w3.org/XML/1998/namespace");
static DomString xmlns_xmlns("xmlns");
static DomString xmlns_xmlns_uri("http://www.w3.org/2000/xmlns/");
DomString prefix;
DomString::size_type pos = qualified_name.find(':');
if (pos != DomString::npos)
prefix = qualified_name.substr(0, pos);
if (prefix == xmlns_xml)
return xmlns_xml;
else if (prefix == xmlns_xmlns || qualified_name == xmlns_xmlns)
return xmlns_xmlns;
DomDocument_Impl *doc_impl = (DomDocument_Impl *)impl->owner_document.lock().get();
const DomTreeNode *cur = impl->get_tree_node();
while (cur)
{
const DomTreeNode *cur_attr = cur->get_first_attribute(doc_impl);
while (cur_attr)
{
std::string node_name = cur_attr->get_node_name();
if (prefix.empty())
{
if (node_name == xmlns_xmlns)
return cur_attr->get_node_value();
}
else
{
if (node_name.substr(0, 6) == xmlns_prefix && node_name.substr(6) == prefix)
return cur_attr->get_node_value();
}
cur_attr = cur_attr->get_next_sibling(doc_impl);
}
cur = cur->get_parent(doc_impl);
}
return DomString();
}