int PlayListFile::parse(PlayListFile *pls, QTextStream *stream) { int parsed = 0; QString d = stream->read(); CfgReader cfg; cfg.parse(d.toAscii(), d.length()); int num_entries = cfg.getIntVal("playlist", "numberofentries", -1); // Some pls files have "numberofentries", some has "NumberOfEntries". if (num_entries == -1) num_entries = cfg.getIntVal("playlist", "NumberOfEntries", -1); for (int n = 1; n <= num_entries; n++) { PlayListFileEntry *e = new PlayListFileEntry(); QString t_key = QString("Title%1").arg(n); QString f_key = QString("File%1").arg(n); QString l_key = QString("Length%1").arg(n); e->setFile(cfg.getStrVal("playlist", f_key)); e->setTitle(cfg.getStrVal("playlist", t_key)); e->setLength(cfg.getIntVal("playlist", l_key)); pls->add(e); parsed++; } return parsed; }
static std::vector<std::string> GetConfig() { std::vector<std::string> result; CfgReader reader; reader.Read("./Gateway.cfg"); std::string ip = reader["GatewayIP"]; std::string port = reader["GatewayPort"]; std::string pool_size = reader["IoServicePoolSize"]; if (ip.empty() || port.empty()) { LOG("Please check Gateway.cfg!"); return result; } if (pool_size.empty()) { pool_size = "1"; } result.push_back(ip); result.push_back(port); result.push_back(pool_size); return result; }
static DriverStartupConfig GetConfig() { DriverStartupConfig config; CfgReader reader; reader.Read("./Driver.cfg"); config.service_name = reader["ServiceName"]; config.rpc_server_addr = reader["RpcProxyServerAddr"]; config.gateway_name = reader["GatewayServiceName"]; std::string pool_size = reader["IoServicePoolSize"]; if (config.service_name.empty() || config.rpc_server_addr.empty() || config.gateway_name.empty()) { printf("Please check the cfg file\n"); return config; } if (pool_size.empty()) { pool_size = "1"; } config.pool_size = atoi(pool_size.c_str()); return config; }