本文整理汇总了C++中ConfigFile::Value方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile::Value方法的具体用法?C++ ConfigFile::Value怎么用?C++ ConfigFile::Value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::Value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
int fd0, fd1, fd2;
pid_t pid = fork();
if (pid < 0) {
exit(1);
} else if (pid != 0) {
exit(0);
}
setsid();
if (chdir("/") < 0) {
exit(1);
}
fd0 = open("/dev/null", O_RDWR);
fd1 = dup(0);
fd2 = dup(0);
FILE * g_pFile;
g_pFile = fopen("/home/lvhongliang/autoAnswer/AutoAnswer/log.txt", "a+");
const char* configLoc = "/home/lvhongliang/autoAnswer/AutoAnswer/configLoc.txt";
ConfigFile config;
config.load(configLoc);
QuestionVectorFactory qvFactory(&config);
DBBase db;
int conRet = db.openConnection(config.Value("database", "server").c_str(),
config.Value("database", "dbname").c_str(),
config.Value("database", "user").c_str(),
config.Value("database", "password").c_str());
if (200 != conRet) {
cout << dberror(conRet);
exit(1);
}
//fprintf(g_pFile, "%s\n", "all data is loaded successfully! start the web server...");
RelatedQuestions ser(g_pFile, &qvFactory, &db);
ser.serv(9999, 10);
return 0;
}
示例2: getValFromConfig
std::string getValFromConfig(ConfigFile &config, const char* section, const char* valueName) {
std::string value = config.Value(section,valueName);
size_t first = value.find_first_not_of(' ');
return value.substr(first, value.length()-first);
}