void XmlWalker::_checkSetAttributes(pugi::xml_node node)
    {
        pugi::xml_attribute attr = node.first_attribute();
        while (attr)
        {
            if (!strcmp(attr.name(), "path"))
            {
                _path = connectPath(_xmlFolder->c_str(), attr.value());
                if (!_path.empty())
                    _path += "/";
            }
            else if (!strcmp(attr.name(), "load"))
            {
                _load = attr.as_bool();
            }
            else if (!strcmp(attr.name(), "scale_factor"))
            {
                _scaleFactor = attr.as_float(1.0f);
            }
            else if (!strcmp(attr.name(), "hit_test"))
            {
                _alphaHitTest = attr.as_bool(false);
            }

            attr = attr.next_attribute();
        }
    }
    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;
        }
    }
Exemple #3
0
    BOOL SObject::InitFromXml( pugi::xml_node xmlNode )
    {
        if(!xmlNode) return FALSE;
#ifdef _DEBUG
        {
            pugi::xml_writer_buff writer;
            xmlNode.print(writer,L"\t",pugi::format_default,pugi::encoding_utf16);
            m_strXml=SStringW(writer.buffer(),writer.size());
        }
#endif

        //设置当前对象的属性

        //优先处理"class"属性
        pugi::xml_attribute attrClass=xmlNode.attribute(L"class");
        if(attrClass)
        {
            attrClass.set_userdata(1);      //预处理过的属性,给属性增加一个userdata
            SetAttribute(attrClass.name(), attrClass.value(), TRUE);
        }
        for (pugi::xml_attribute attr = xmlNode.first_attribute(); attr; attr = attr.next_attribute())
        {
            if(attr.get_userdata()) continue;   //忽略已经被预处理的属性
            SetAttribute(attr.name(), attr.value(), TRUE);
        }
        if(attrClass)
        {
            attrClass.set_userdata(0);
        }
        //调用初始化完成接口
        OnInitFinished(xmlNode);
        return TRUE;
    }
Exemple #4
0
void RainbowTable::print_entry(pugi::xml_node &entry) {
    //prints all data associated with node entry

    cout << endl;//redability

    //print attributes of entry node
    for (pugi::xml_attribute attr = entry.first_attribute();
            attr;
            attr = attr.next_attribute()) {

        if (strcmp("key" , attr.name()) != 0 ) { //ignore key
            cout << attr.name() << ": " << attr.value() << endl;
        }
    }

    //search through child nodes
    for (pugi::xml_node child = entry.first_child();
            child;
            child = child.next_sibling()) {

        cout  << child.name() << endl;

        //is there text outside of the attrubutes?
        if (child.text()) {
            cout << '\t'  << child.first_child().value() << endl;
        }

        //print attributes of child
        for (pugi::xml_attribute attr = child.first_attribute();
                attr;
                attr = attr.next_attribute()) {
            cout << '\t' << attr.name() << ": " << attr.value() << endl;
        }
    }
}
Exemple #5
0
 DivNode::DivNode(const pugi::xml_node& node)
 {
     pugi::xml_attribute attr = node.first_attribute();
     while (attr)
     {
         if (!strcmp(attr.name(), "c") ||
                 !strcmp(attr.name(), "color"))
         {
             color = hex2color(attr.value());
         }
         attr = attr.next_attribute();
     }
 }
void Walker::parsePlace(pugi::xml_node node, std::string parent, bool verbose) {
    map<string, string> params;
    params["parent"] = parent;
    params["type"] = "";
    params["reset"] = "true";
    params["coincidence"] = "true";
    params["fifo"] = "2";
    params["init"] = "false";
    for (pugi::xml_attribute attr = node.first_attribute(); attr;
         attr = attr.next_attribute()) {
        params[attr.name()] = attr.value();
    }
    TreeCorrelator::get()->createPlace(params, verbose);
}