问题描述
这是我的代码:
我的Config.h
:
#include <string>
#include <boost/property_tree/ini_parser.hpp>
namespace pt = boost::property_tree;
class Config {
public:
Config(std::string conf);
template<typename T>
T GetConfigValue(std::string configKey,T value = 0){
pt::ptree tree;
pt::read_ini(_configFile,tree);
return tree.get<T>(configKey,value);
}
private:
std::string _configFile;
};
这就是我的称呼:
#include "Logger.h"
#include "Config.h"
int main() {
Config * config = new Config("/WorldServer.conf.dist");
std::string def = "nothing there.";
Logger::Log(config->GetConfigValue("WorldServer.MaxPingTime",def));
}
[WorldServer]
MaxPingTime = 30
MysqL.User = "root"
执行时
Logger::Log(config->GetConfigValue("WorldServer.MaxPingTime",def));
我看到30
是正确的结果,但是当我执行时:
Logger::Log(config->GetConfigValue("WorldServer.MysqL.User",def));
我认为结果为nothing there.
据我了解,.
中的MysqL.User
引起了问题。
我的问题是我可以使用boost属性树来解析ini配置,使其以点方式工作吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)