首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

boost 实现xml 解析

后端 3.36KB 35 需要积分: 1
立即下载

资源介绍:

boost中提供了对配置文件读取的支持:property_tree。 property_tree的核心基础是basic_ptree。其接口像std::list。可以执行很多基本的元素操作,比如使用begin()、end()等。此外还加入了操作属性树的get()、get_child()、get_value()、data()等额外的操作。
#include #include #include #include #include #include using namespace std; using namespace boost::property_tree; using namespace boost::property_tree::xml_parser; int main() { string attrStr = ""; /*cout <<"********SigRaw.xml*************"<("root.type"); cout << "attrStr:type---" << attrStr << endl; attrStr = pt1.get("root.separator"); cout << "attrStr:separator---" << attrStr << endl; BOOST_FOREACH(ptree::value_type& v, pt1.get_child("root.fields")) { attrStr = v.second.get(".name"); cout << "attrStr:name---" << attrStr << endl; attrStr = v.second.get(".id"); cout << "attrStr:id---" << attrStr << endl; attrStr = v.second.get(".type"); cout << "attrStr:type---" << attrStr << endl; attrStr = v.second.get(".len"); cout << "attrStr:len---" << attrStr << endl; attrStr = v.second.get(".defvalue"); cout << "attrStr:defvalue---" << attrStr << endl; } */ cout <<"********SigRaw_CQ.xml*************"<"){ attrStr = v.second.get("name"); cout << "attrStr:struct name---" << attrStr << endl; attrStr = v.second.get("alias"); cout << "attrStr:struct alias---" << attrStr << endl; } else if (v.first == "rowkey") { cout << "v.first: " << v.first << endl; attrStr = v.second.get(".class"); cout << "attrStr:rowkey class---" << attrStr << endl; ptree pt3 = pt2.get_child("config.struct.rowkey"); BOOST_FOREACH(ptree::value_type &v1, pt3) { cout << "v1.first--: " << v1.first << endl; //section attrStr = pt3.get("config.struct.rowkey.field.section"); cout << "attrStr:field section---" << attrStr << endl; attrStr = pt3.get("config.struct.rowkey.field.name"); cout << "attrStr:field name---" << attrStr << endl; attrStr = pt3.get("config.struct.rowkey.field.id"); cout << "attrStr:field id---" << attrStr << endl; attrStr = pt3.get("config.struct.rowkey.field.length"); cout << "attrStr:field length---" << attrStr << endl; attrStr = pt3.get("config.struct.rowkey.field.defvalue"); cout << "attrStr:field defvalue---" << attrStr << endl; //value attrStr = v1.second.get("config.struct.rowkey.field.value"); cout << "attrStr:field value---" << attrStr << endl; attrStr = v1.second.get("config.struct.rowkey.field.name"); cout << "attrStr:field name---" << attrStr << endl; attrStr = v1.second.get("config.struct.rowkey.field.id"); cout << "attrStr:field id---" << attrStr << endl; attrStr = v1.second.get("config.struct.rowkey.field.length"); cout << "attrStr:field length---" << attrStr << endl; //normal attrStr = v1.second.get("config.struct.rowkey.field.name"); cout << "attrStr:field name---" << attrStr << endl; attrStr = v1.second.get("config.struct.rowkey.field.id"); cout << "attrStr:field id---" << attrStr << endl; attrStr = v1.second.get("config.struct.rowkey.field.type"); cout << "attrStr:field type---" << attrStr << endl; attrStr = v1.second.get("config.struct.rowkey.field.length"); cout << "attrStr:field length---" << attrStr << endl; attrStr = v1.second.get("config.struct.rowkey.field.defvalue"); cout << "attrStr:field defvalue---" << attrStr << endl; attrStr = v1.second.get("config.struct.rowkey.field.decode"); cout << "attrStr:field decode---" << attrStr << endl; attrStr = v1.second.get("config.struct.rowkey.field.placeholder"); cout << "attrStr:field placeholder---" << attrStr << endl; attrStr = v1.second.get("config.struct.rowkey.field.pos_placeholder"); cout << "attrStr:field pos_placeholder---" << attrStr << endl; } } else if(v.first == "timestamp") { attrStr = v.second.get(".class"); cout << "attrStr:timestamp class---" << attrStr << endl; attrStr = v.second.get(".formula"); cout << "attrStr:timestamp formula---" << attrStr << endl; } else if(v.first == "indexs") { BOOST_FOREACH(ptree::value_type &v1, v.second) { attrStr = v1.second.get(".name"); cout << "attrStr:indexs cf name---" << attrStr << endl; attrStr = v1.second.get(".class"); cout << "attrStr:indexs cf class---" << attrStr << endl; attrStr = v1.second.get("field..name"); cout << "attrStr:field name---" << attrStr << endl; attrStr = v1.second.get("field..id"); cout << "attrStr:field id---" << attrStr << endl; attrStr = v1.second.get("field..type"); cout << "attrStr:field type---" << attrStr << endl; attrStr = v1.second.get("field..length"); cout << "attrStr:field length---" << attrStr << endl; attrStr = v1.second.get("field..defvalue"); cout << "attrStr:field defvalue---" << attrStr << endl; attrStr = v1.second.get("field..decode"); cout << "attrStr:field decode---" << attrStr << endl; attrStr = v1.second.get("field..placeholder"); cout << "attrStr:field placeholder---" << attrStr << endl; attrStr = v1.second.get("field..pos_placeholder"); cout << "attrStr:field pos_placeholder---" << attrStr << endl; }//end BOOST_FOREACH } else if(v.first == "ag") { BOOST_FOREACH(ptree::value_type &v1, v.second) { //cout << "v1.first: " << v1.first << endl; if(v1.first == ""){ attrStr = v1.second.get("name"); cout << "attrStr:ag name---" << attrStr << endl; } else { BOOST_FOREACH(ptree::value_type &v2, v1.second) { //cout << "v2.first: " << v2.first << endl; if(v2.first == ""){ attrStr = v2.second.get("name"); cout << "attrStr:cf name---" << attrStr << endl; } else { BOOST_FOREACH(ptree::value_type &v3, v2.second) { //cout << "v3.first: " << v3.first << endl; if(v3.first == ""){ //it's an attribute attrStr = v3.second.get("name"); cout << "attrStr:cq name---" << attrStr << endl; attrStr = v3.second.get("type"); cout << "attrStr:cq type---" << attrStr << endl; attrStr = v3.second.get("seperator"); cout << "attrStr:cq seperator---" << attrStr << endl; } else { attrStr = v3.second.get(".name"); cout << "attrStr:field name---" << attrStr << endl; attrStr = v3.second.get(".id"); cout << "attrStr:field id---" << attrStr << endl; attrStr = v3.second.get(".type"); cout << "attrStr:field type---" << attrStr << endl; attrStr = v3.second.get(".length"); cout << "attrStr:field length---" << attrStr << endl; attrStr = v3.second.get(".defvalue"); cout << "attrStr:field defvalue---" << attrStr << endl; } }//end BOOST_FOREACH } }//end

资源文件列表:

boost xml parser.zip 大约有5个文件
  1. boost xml parser/
  2. boost xml parser/debug_settings.cpp 1.46KB
  3. boost xml parser/debug_settings.xml 905B
  4. boost xml parser/SigRaw_CQ.xml 2.45KB
  5. boost xml parser/xml_parser_test.cpp 7.92KB
0评论
提交 加载更多评论
其他资源 冰河之刃AsarHelper V.1 ASAR解包工具
拖入ASAR文件后,会自动填充好对应的参数供操作用。省心省事。【碰到权限问题时请使用管理员权限运行,注意在使用管理员运行时拖放功能可能不起作用,到时请使用最右边的“浏览”按钮选择ASAR文件。】 解包时会按照当天日期生成唯一文件夹
win10系统安装.net3.5失败怎么办,下载安装包
21H2版本win10想安装以前的软件发现缺少3.5或者2.0安装包,系统更新失败,解决方案,下载安装包,打开一键安装解决
VisualSVN-VS2022
VisualSVN-VS2022-8.0.5.vsix SVNVS插件,使用VS自带更新速度太慢,可下载后直接安装即可
PetFosterStore-master.zip
PetFosterStore-master.zip
Fuse-Tech,若依vue后台管理项目
Fuse_Tech,若依vue魔改增强项目,集成自研流程服务:表格模式,引擎模式 后台管理系统 1.–观察者设计模式 练习 查看TestHelloController 2.模拟TO C环境, 使用内存预先缓存数据,使用算法匹配查询 3.增加SM4 SM4:无线局域网标准的分组数据算法。对称加密,密钥长度和分组长度均为128位。 我国国家密码管理局在20012年公布了无线局域网产品使用的SM4密码算法——商用密码算法。 软件架构 软件架构说明 流程服务表格模式
111W1EDWQFEWGR
111FEWFQEFER
Python-100个小练习,自己学习用
python小程序代码
VT-ResNet脑肿瘤分类代码
在ResNet模型基础上加入VT模块