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

// 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章