//read simple valuestd::stringdescription = pt.get<std::string>("description");intversion = pt.get<int>("version"); 2.2 读一组对象 //read list of objsstd::cout << std::endl <<"read list of objs"<<std::endl;for(auto ptItem : pt.get_child("list")) { std::stringkey =ptIte...
遍历孩子使用:auto child = pt.get_child("conf.urls");//获取urls的孩子节点,这里的孩子既包括urls的属性,也包括urls的注释、也包括urls里面的多个子节点www.baidu.comwww.sina.com,当孩子是一个url节点的时候,迭代器的first是节点的名字url,second是ptree结构,可以继续使用get()方法获取url的属性值,注释值,...
get_child("get_dict").get<std::string>("username"); cout << "姓名: " << username << endl; // 解析多层字典 boost::property_tree::ptree root_ptr, item; root_ptr = ptr.get_child("user_dict"); // 输出第二层 for (boost::property_tree::ptree::iterator it = root_ptr.begin(...
boost::property_tree::xml_parser::read_xml("E:\\测试\\test.xml",wpt); 2)get ptree pt; read_xml("D://test1.xml",pt); //读入一个xml文件 cout<<"ID is "<<pt.get<int>("con.id")<<endl;//读取节点中的信息 3)get_child child = pt.get_child("con.urls"); for(BOOST_AUTO(...
boost::optional e = pt.get_child_optional("E:"); std::cout << e.is_initialized() <<'\n'; } 示例25.3 定义了转换器 string_to_int_translator,它将 std::string 类型的值转换为 int。翻译器作为附加参数传递给 get()。因为翻译器只是用来阅读的,所以它只定义了一个成员函数,get_value()。如果...
int filenum = pt.get<int>("root.delfile.filenum"); //将 xml文件中, root节点,下一层delfile 下一层的filenum 作为int类型取出,存在在filenum变量中。 cout << "filenum: " << filenum << endl;//不注释了 - - BOOST_AUTO(child, pt.get_child("root.delfile.paths")); //BOOST_AUTO自...
CMyData_Child d2; std::istringstream is(content); boost::archive::binary_iarchive ia(is); ia >> d2;//从一个保存序列化数据的string里面反序列化,从而得到原来的对象。 std::cout << "CMyData_Child tag: " << d2.GetTag() << ", text: " << d2.GetText() << ", number: "<<d2...
读取值的数组:使用属性树对象的get_child函数和BOOST_FOREACH宏来遍历XML中的数组值。例如: 代码语言:txt 复制 boost::property_tree::ptree arrayNode = pt.get_child("root.array"); BOOST_FOREACH(boost::property_tree::ptree::value_type& value, arrayNode) { int arrayValue = value.second.g...
voidgetTreeInfoOfPan(PanIndex_index); /*返回面板对象列表*/ inlinepanNames_tgetPanList(void)const{returnm_panobj;} /*返回当前面板下的树列表对象*/ inlineptree_nodes_tgetPtreeNodeList(void)const{returnm_ptreeobj;} private: CProcessXmlConfigFile(conststring&xmlfile); CProcessXmlConfigFile(...
get_address(), 1, region.get_size()); //Launch child process std::string s(argv[0]); s += " child "; if(0 != std::system(s.c_str())) return 1; } else{ //Open already created shared memory object. shared_memory_object shm (open_only, "MySharedMemory", read_only); /...