boost库之ptree的ini配置文件解析

来源:互联网 发布:qq飞车大q吧奇迹数据 编辑:程序博客网 时间:2024/05/22 05:05
// FirstTest.cpp : 定义控制台应用程序的入口点。//ptree解析ini文件,get<Type>(treename, translator)  :translator类型实例#include "stdafx.h"#include <boost/property_tree/ptree.hpp>  #include <boost/property_tree/ini_parser.hpp>  #include <string>  using namespace std; int main(){boost::property_tree::ptree m_pt;string ini_file = "test.ini";boost::property_tree::ini_parser::read_ini(ini_file, m_pt);  string path  = m_pt.get<string>("LogPath","");int maxcount  = m_pt.get<int>("LogMaxCount", 1);cout << path << "::"  << maxcount<<endl;system("pause");return 0;}
LogPath=/home/smc
LogMaxCount=3
0 0
原创粉丝点击