首页 > 其他 > 详细

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

时间:2015-03-02 11:16:19      阅读:458      评论:0      收藏:0      [点我收藏+]
// 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

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

原文:http://blog.csdn.net/leeboy_wang/article/details/44015135

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!