设为首页 加入收藏

TOP

boost.property_tree
2015-07-20 17:38:09 来源: 作者: 【 】 浏览:3
Tags:boost.property_tree
//made by davidsu33
//boost.property_tree是一个保存了多个属性值的树形数据结构
//boost.property_tree可以解析xml ini json和info四种格式的文本

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
       
         using namespace std; void putline(const char * str) { cout<
        
         ("conf.theme"); int guiID = pt.get
         
          ("conf.gui"); //int id = pt.get_value
          
           (); assert(guiID == 1); //不存在属性返回默认值 int def = pt.get
           
            ("conf.no", 100000); assert(def = 100000); BOOST_AUTO(childs2, pt.get_child("conf.urls")); PTree childs = pt.get_child("conf.urls"); //??? //int count = pt.count("urls"); //assert(count == 3); //读取多子节点的数据 BOOST_AUTO(it, childs.begin()); BOOST_AUTO(iend, childs.end()); for (; it != iend; ++it) { //迭代器指向ptree的value_type, //它的second成员是子节点自身 //cout<
            
             second.get_value
             
              ()<
              
               second.data()<
               
                (""); //读取XML声明 BOOST_ASSERT(pt.get
                
                 ("conf.gui.
                 
                  .lib") == "QT"); BOOST_ASSERT(pt.get
                  
                   ("conf.theme.
                   
                    .id") == 1002); BOOST_ASSERT(pt.get
                    
                     ("conf.
                     
                      ") == "this is conf comment"); //貌似不支持CDATA,测试未通过 //std::string xmltext = pt.get
                      
                       ("conf.
                       
                        "); //BOOST_ASSERT(pt.get
                        
                         ("conf.
                         
                          ") == "字符数据-character data"); } int _tmain(int argc, _TCHAR* argv[]) { parse_xml(); getchar(); return 0; } 
                         
                        
                       
                      
                     
                    
                   
                  
                 
                
               
              
             
            
           
          
         
        
       
      
     
    
   
  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇NYoj-分数加减法 下一篇SICP 习题 (2.1) 解题总结

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·「链表」是一种怎样 (2025-12-25 19:20:51)
·C 语言中的链表有哪 (2025-12-25 19:20:48)
·c语言中的链表怎么学 (2025-12-25 19:20:45)
·Redis 分布式锁全解 (2025-12-25 17:19:51)
·SpringBoot 整合 Red (2025-12-25 17:19:48)