Пример #1
0
    virtual bool for_each(pugi::xml_node& node) {

        Log::log(logModule, level, "XML node type = [%s], name = [%s], value = [%s]",
                node_types[node.type()], node.name(), 
                node.type() == pugi::node_cdata || node.type() == pugi::node_pcdata ? node.text().get() : node.value());
        for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
            Log::log(logModule, level, "  attribute name = [%s], value = [%s]",
                    ait->name(), ait->value());
        }
        return true;
    }
Пример #2
0
    void read_xml_node( pugi::xml_node node, Ptree &pt, int flags)
    {
        typedef typename Ptree::key_type::value_type Ch;

        switch ( node.type() )
        {
            case pugi::node_element:
                {
                    Ptree &tmp = pt.push_back(std::make_pair( node.name(), Ptree()))->second;
                    for ( pugi::xml_attribute attr = node.first_attribute(); attr; attr = attr.next_attribute() )
                        tmp.put( xmlattr<Ch>() + "." + attr.name(), attr.value());
                    for ( pugi::xml_node child = node.first_child(); child; child = child.next_sibling())
                        read_xml_node(child, tmp, flags);
                }
                break;
            case pugi::node_pcdata:
                {
                    if (flags & no_concat_text)
                        pt.push_back(std::make_pair(xmltext<Ch>(), Ptree( node.value() )));
                    else
                        pt.data() += node.value();
                }
                break;
            case pugi::node_comment:
                {
                    if (!(flags & no_comments))
                        pt.push_back(std::make_pair(xmlcomment<Ch>(), Ptree( node.value() )));
                }
                break;
            default:
                // skip other types
                break;
        }
    }
    virtual bool for_each(pugi::xml_node &node) {
        for (int i = 0; i < depth(); ++i) std::cout << "  "; // indentation

        std::cout << node_types[node.type()] << ": name='" << node.name() << "', value='" << node.value() << "'\n";

        return true; // continue traversal
    }
Пример #4
0
bool XMLFile::CombineText(const pugi::xml_node& patch, const pugi::xml_node& original, bool prepend) const
{
    if (!patch || !original)
        return false;

    if ((patch.type() == pugi::node_pcdata && original.type() == pugi::node_pcdata) ||
        (patch.type() == pugi::node_cdata && original.type() == pugi::node_cdata))
    {
        if (prepend)
            const_cast<pugi::xml_node&>(original).set_value(Urho3D::ToString("%s%s", patch.value(), original.value()).CString());
        else
            const_cast<pugi::xml_node&>(original).set_value(Urho3D::ToString("%s%s", original.value(), patch.value()).CString());

        return true;
    }

    return false;
}
Пример #5
0
tiny_string XMLNode::toString_priv(pugi::xml_node outputNode)
{
	if(outputNode.type() == pugi::node_null)
		return "";

	ostringstream buf;
	outputNode.print(buf);
	tiny_string ret = tiny_string(buf.str());
	return ret;
}