当前位置: 首页>>代码示例>>C++>>正文


C++ Document::FirstChildElement方法代码示例

本文整理汇总了C++中Document::FirstChildElement方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::FirstChildElement方法的具体用法?C++ Document::FirstChildElement怎么用?C++ Document::FirstChildElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Document的用法示例。


在下文中一共展示了Document::FirstChildElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: load

void Bank::load( const string& path, bool append )
{
    if( path.empty() ) return;

    if( append == false ) 
    {
        clear();	
        path_ = path;
    }

    try {
      	Document doc = Document( path );
        doc.LoadFile();

        Element* bankElement = doc.FirstChildElement( "Bank", true );
        if( append == false )
        {
            bankElement->GetAttribute( "name",  &name_ );
            bankElement->GetAttribute( "program",  &programNum_ );
        }
    
        Iterator< Element > it( "Program" );
        for( it = it.begin( bankElement ); it != it.end(); it++ )
        {
            Element* programElement = it.Get();
            Program* program        = new Program();
        
            try {
                readProgram( programElement, program );
                push_back( program );
            }
            catch( const exception& e ) {       // parse error, skip program
                TRACE( e.what() );
            }
        }

        if( programNum_ >= (INT32)size() )
            programNum_ = 0;

        if( append == false && programNum_ < (INT32)size() )     // create current program
            currentProgram_ = *at( programNum_ );
    }
    catch( const exception& e )                 // file error, use default program
    {
        TRACE( e.what() );
        newBank( "New Bank.nexus", "New Bank", false );
    }
}
开发者ID:dreieier,项目名称:Nexus,代码行数:48,代码来源:Bank.cpp

示例2: parseXmlString

void XmlParser::parseXmlString( std::string &xml, RadioRepresentation &radio)
{
    try{
        Document doc;
        doc.Parse(xml);

        //Pull out the root element
        Element* head = doc.FirstChildElement();
        string headValue = head->Value();
        if( headValue == "softwareradio")
        {
            readSoftwareRadio(*head, radio);
        }else{
            throw XmlParsingException("The top element of the xml configuration must be softwareradio.");
        }

        //Instruct the radio description to build a graph of the radio
        radio.buildGraphs();
    }
    catch( Exception& ex )
    {
        throw XmlParsingException(ex.what());
    }
}
开发者ID:andrepuschmann,项目名称:iris_core,代码行数:24,代码来源:XmlParser.cpp

示例3: readProgram

void Bank::readProgram( const Document& doc, Program* program )
{
    Element* programElement = doc.FirstChildElement( "Program", true );
    readProgram( programElement, program );
}
开发者ID:dreieier,项目名称:Nexus,代码行数:5,代码来源:Bank.cpp

示例4: record_parser_from_xml

tsdb::RecordParser* record_parser_from_xml(const std::string parse_instruction_filename, tsdb::Timeseries* out_ts) {
    using namespace std;
    using namespace ticpp;

    Document doc = Document(parse_instruction_filename);
    doc.LoadFile();

    cout << "Loaded '" << parse_instruction_filename << "'." << endl;
    cout << "Creating parser..." << endl;

    /* Create the RecordParser */
    tsdb::RecordParser* recordparser = new tsdb::RecordParser();
    recordparser->setRecordStructure(out_ts->structure().get());

    Iterator<Element> child;
    string name;
    string value;
    auto_ptr<Node> delimparser;
    for(child = child.begin(doc.FirstChildElement()); child != child.end(); child++) {
        child->GetValue(&value);
        if(value == "delimparser") {
            delimparser = child->Clone();
            break;
        }
    }

    string delim = delimparser->ToElement()->GetAttribute("field_delim");
    if(delim == "") {
        delim = ",";
    }

    string escape = delimparser->ToElement()->GetAttribute("escape_chars");
    if(escape == "") {
        escape="\\";
    }

    string quote = delimparser->ToElement()->GetAttribute("quote_chars");
    if(quote == "") {
        quote="\"'";
    }
    
    string mode = delimparser->ToElement()->GetAttribute("parse_mode");
    if(mode == "extended") {
        recordparser->setSimpleParse(false);
        recordparser->setDelimiter(delim);				
        recordparser->setEscapeCharacter(escape);
        recordparser->setQuoteCharacter(quote);
        cout << "   - field delimiter(s): '" << delim << "'" << endl;
        cout << "   - quote character(s): '" << quote << "'" << endl;
        cout << "   - escape character(s): '" << escape << "'" << endl;
    } else {
        recordparser->setSimpleParse(true);
        recordparser->setDelimiter(delim.substr(0,1));
        cout << "   - field delimiter: '" << delim.substr(0,1) << "'" << endl;
    }
    



    

    cout << "   Processing parser elements:" << endl;


    /* Loop through the RecordParser and look for TokenFilters or FieldParsers */
    typedef boost::tokenizer< boost::escaped_list_separator<char> > Tokenizer;
    string tokens,comparison,format_string,type,missing_token_replacement;
    bool missing_tokens_ok = false;

    vector<string> vec;
    vector<size_t> apply_to_tokens;
    size_t i;
    for(child = child.begin(delimparser.get()); child != child.end(); child++) {
        child->GetValue(&value);


        if(value == "tokenfilter") {
            
            
            tokens = child->GetAttribute("tokens");
            comparison = child->GetAttribute("comparison");
            value = child->GetAttribute("value");
            
            Tokenizer tok(tokens);
            vec.assign(tok.begin(),tok.end());

            apply_to_tokens.clear();
            for(i=0;i<vec.size();i++) {
                apply_to_tokens.push_back(atoi(vec.at(i).c_str()));
            }

            /* Write out some information */
            cout << "      - TokenFilter:" << endl;
            cout << "         apply to tokens: (";
            for(i=0;i<apply_to_tokens.size();) {
                cout << apply_to_tokens.at(i);
                i++;
                if(i<apply_to_tokens.size()) {
                    cout << ",";
                }
//.........这里部分代码省略.........
开发者ID:afiedler,项目名称:tsdb,代码行数:101,代码来源:tsdbimport.cpp


注:本文中的Document::FirstChildElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。