本文整理汇总了C++中CConfig::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ CConfig::GetString方法的具体用法?C++ CConfig::GetString怎么用?C++ CConfig::GetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CConfig
的用法示例。
在下文中一共展示了CConfig::GetString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initFromConfig
//Set the default values
void CLogger::initFromConfig()
{
CConfig config;
std::wstring wcsLogDir = config.GetString(CConfig::EIDMW_CONFIG_PARAM_LOGGING_DIRNAME);
std::wstring wcsPrefix = config.GetString(CConfig::EIDMW_CONFIG_PARAM_LOGGING_PREFIX);
long lFileNbr = config.GetLong(CConfig::EIDMW_CONFIG_PARAM_LOGGING_FILENUMBER);
long lFileSize = config.GetLong(CConfig::EIDMW_CONFIG_PARAM_LOGGING_FILESIZE);
std::wstring wcsMaxLevel = config.GetString(CConfig::EIDMW_CONFIG_PARAM_LOGGING_LEVEL);
tLOG_Level maxLevel = MapLevel(wcsMaxLevel.c_str());
long lGroup = config.GetLong(CConfig::EIDMW_CONFIG_PARAM_LOGGING_GROUP);
init(wcsLogDir.c_str(), wcsPrefix.c_str(), lFileSize, lFileNbr, maxLevel, (lGroup?true:false));
}
示例2: x_GetDoubleParam
double CIncreasingTime::x_GetDoubleParam(CConfig& conf,
const string& driver_name,
const SParam& param)
{
string value = conf.GetString(driver_name,
param.m_ParamName,
CConfig::eErr_NoThrow,
"");
if ( value.empty() && param.m_ParamName2 ) {
value = conf.GetString(driver_name,
param.m_ParamName2,
CConfig::eErr_NoThrow,
"");
}
if ( value.empty() ) {
return param.m_DefaultValue;
}
return NStr::StringToDouble(value, NStr::fDecimalPosixOrLocal);
}
示例3: CreateSimpleRebalanceStrategy
CRef<CSimpleRebalanceStrategy>
CreateSimpleRebalanceStrategy(CConfig& config, const string& driver_name)
{
return CRef<CSimpleRebalanceStrategy>(new CSimpleRebalanceStrategy(
config.GetInt(driver_name, "rebalance_requests",
CConfig::eErr_NoThrow, REBALANCE_REQUESTS_DEFAULT),
s_SecondsToMilliseconds(config.GetString(driver_name,
"rebalance_time", CConfig::eErr_NoThrow,
NCBI_AS_STRING(REBALANCE_TIME_DEFAULT)),
SECONDS_DOUBLE_TO_MS_UL(REBALANCE_TIME_DEFAULT))));
}
示例4: main
int main( int argc, char **argv )
{
string CFGFile = "update_dota_elo.cfg";
if( argc > 1 && argv[1] )
CFGFile = argv[1];
CConfig CFG;
CFG.Read( CFGFile );
string Server = CFG.GetString( "db_mysql_server", string( ) );
string Database = CFG.GetString( "db_mysql_database", "ghost" );
string User = CFG.GetString( "db_mysql_user", string( ) );
string Password = CFG.GetString( "db_mysql_password", string( ) );
int Port = CFG.GetInt( "db_mysql_port", 0 );
cout << "connecting to database server" << endl;
MYSQL *Connection = NULL;
if( !( Connection = mysql_init( NULL ) ) )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
my_bool Reconnect = true;
mysql_options( Connection, MYSQL_OPT_RECONNECT, &Reconnect );
if( !( mysql_real_connect( Connection, Server.c_str( ), User.c_str( ), Password.c_str( ), Database.c_str( ), Port, NULL, 0 ) ) )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
cout << "connected" << endl;
cout << "beginning transaction" << endl;
string QBegin = "BEGIN";
if( mysql_real_query( Connection, QBegin.c_str( ), QBegin.size( ) ) != 0 )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
cout << "creating tables" << endl;
string QCreate1 = "CREATE TABLE IF NOT EXISTS dota_elo_scores ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(15) NOT NULL, server VARCHAR(100) NOT NULL, score REAL NOT NULL )";
string QCreate2 = "CREATE TABLE IF NOT EXISTS dota_elo_games_scored ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, gameid INT NOT NULL )";
if( mysql_real_query( Connection, QCreate1.c_str( ), QCreate1.size( ) ) != 0 )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
if( mysql_real_query( Connection, QCreate2.c_str( ), QCreate2.size( ) ) != 0 )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
cout << "getting unscored games" << endl;
queue<uint32_t> UnscoredGames;
string QSelectUnscored = "SELECT id FROM games WHERE id NOT IN ( SELECT gameid FROM dota_elo_games_scored ) ORDER BY id";
if( mysql_real_query( Connection, QSelectUnscored.c_str( ), QSelectUnscored.size( ) ) != 0 )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
else
{
MYSQL_RES *Result = mysql_store_result( Connection );
if( Result )
{
vector<string> Row = MySQLFetchRow( Result );
while( !Row.empty( ) )
{
UnscoredGames.push( UTIL_ToUInt32( Row[0] ) );
Row = MySQLFetchRow( Result );
}
mysql_free_result( Result );
}
else
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
}
cout << "found " << UnscoredGames.size( ) << " unscored games" << endl;
while( !UnscoredGames.empty( ) )
{
uint32_t GameID = UnscoredGames.front( );
UnscoredGames.pop( );
//.........这里部分代码省略.........
示例5: main
int main( int argc, char **argv )
{
string CFGFile = "update_w3mmd_elo.cfg";
if( argc > 1 && argv[1] )
CFGFile = argv[1];
CConfig CFG;
CFG.Read( CFGFile );
string Server = CFG.GetString( "db_mysql_server", string( ) );
string Database = CFG.GetString( "db_mysql_database", "ghost" );
string User = CFG.GetString( "db_mysql_user", string( ) );
string Password = CFG.GetString( "db_mysql_password", string( ) );
int Port = CFG.GetInt( "db_mysql_port", 0 );
string Category = CFG.GetString( "update_category", string( ) );
string PlayerA = CFG.GetString("oh_main_user", string( ) );
string PlayerB = CFG.GetString("oh_user_to_main_user", string( ) );
if( PlayerA.empty() || PlayerB.empty())
{
cout << "Skipping this game, no correct configs for player to merge found" << endl;
return 1;
}
if( Category.empty( ) )
{
cout << "no update_category specified in config file" << endl;
return 1;
}
cout << "connecting to database server" << endl;
MYSQL *Connection = NULL;
if( !( Connection = mysql_init( NULL ) ) )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
my_bool Reconnect = true;
mysql_options( Connection, MYSQL_OPT_RECONNECT, &Reconnect );
if( !( mysql_real_connect( Connection, Server.c_str( ), User.c_str( ), Password.c_str( ), Database.c_str( ), Port, NULL, 0 ) ) )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
cout << "connected" << endl;
cout << "beginning transaction" << endl;
string QBegin = "BEGIN";
if( mysql_real_query( Connection, QBegin.c_str( ), QBegin.size( ) ) != 0 )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
cout << "creating tables" << endl;
string QCreate1 = "CREATE TABLE IF NOT EXISTS w3mmd_elo_scores ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, category VARCHAR(25) NOT NULL, name VARCHAR(15) NOT NULL, server VARCHAR(100) NOT NULL, score REAL NOT NULL )";
string QCreate2 = "CREATE TABLE IF NOT EXISTS w3mmd_elo_games_scored ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, category VARCHAR(25), gameid INT NOT NULL )";
if( mysql_real_query( Connection, QCreate1.c_str( ), QCreate1.size( ) ) != 0 )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
if( mysql_real_query( Connection, QCreate2.c_str( ), QCreate2.size( ) ) != 0 )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
cout << "getting unscored games" << endl;
queue<uint32_t> UnscoredGames;
string QSelectUnscored = "SELECT g.id FROM games as g LEFT JOIN gamepalyers as gp ON gp.gameid=g.id WHERE gp.name = '"+PlayerA+"' OR gp.name = '"+PlayerB+"'";
if( mysql_real_query( Connection, QSelectUnscored.c_str( ), QSelectUnscored.size( ) ) != 0 )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
else
{
MYSQL_RES *Result = mysql_store_result( Connection );
if( Result )
{
vector<string> Row = MySQLFetchRow( Result );
while( !Row.empty( ) )
{
UnscoredGames.push( UTIL_ToUInt32( Row[0] ) );
Row = MySQLFetchRow( Result );
}
mysql_free_result( Result );
//.........这里部分代码省略.........
示例6: main
int main( int argc, char **argv )
{
string CFGFile = "update_dota_elo.cfg";
if( argc > 1 && argv[1] )
CFGFile = argv[1];
CConfig CFG;
CFG.Read( CFGFile );
string Server = CFG.GetString( "db_mysql_server", string( ) );
string Database = CFG.GetString( "db_mysql_database", "ghost" );
string User = CFG.GetString( "db_mysql_user", string( ) );
string Password = CFG.GetString( "db_mysql_password", string( ) );
int Port = CFG.GetInt( "db_mysql_port", 0 );
bool DontUpdateScoresToAdmins = CFG.GetInt("elo_dont_calculate_score_to_admins", 0) == 1 ? true : false;
vector<string> AdminsList; AdminsList.clear();
cout << "connecting to database server" << endl;
MYSQL *Connection = NULL;
if( !( Connection = mysql_init( NULL ) ) )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
my_bool Reconnect = true;
mysql_options( Connection, MYSQL_OPT_RECONNECT, &Reconnect );
if( !( mysql_real_connect( Connection, Server.c_str( ), User.c_str( ), Password.c_str( ), Database.c_str( ), Port, NULL, 0 ) ) )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
cout << "Checking Admins List" << endl;
string QAdminsList = "SELECT name FROM admins;";
if( mysql_real_query( Connection, QAdminsList.c_str( ), QAdminsList.size( ) ) != 0 )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
else
{
MYSQL_RES *Result = mysql_store_result( Connection );
if( Result )
{
vector<string> Row = MySQLFetchRow( Result );
while( !Row.empty( ) )
{
string name = Row[0];
transform( name.begin( ), name.end( ), name.begin( ), (int(*)(int))tolower );
AdminsList.push_back( name );
Row = MySQLFetchRow( Result );
}
mysql_free_result( Result );
}
else
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
}
cout << "beginning transaction" << endl;
string QBegin = "BEGIN";
if( mysql_real_query( Connection, QBegin.c_str( ), QBegin.size( ) ) != 0 )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
cout << "creating tables" << endl;
string QCreate1 = "CREATE TABLE IF NOT EXISTS dota_elo_scores ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(15) NOT NULL, server VARCHAR(100) NOT NULL, score REAL NOT NULL )";
string QCreate2 = "CREATE TABLE IF NOT EXISTS dota_elo_games_scored ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, gameid INT NOT NULL )";
if( mysql_real_query( Connection, QCreate1.c_str( ), QCreate1.size( ) ) != 0 )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
if( mysql_real_query( Connection, QCreate2.c_str( ), QCreate2.size( ) ) != 0 )
{
cout << "error: " << mysql_error( Connection ) << endl;
return 1;
}
cout << "getting unscored games" << endl;
//.........这里部分代码省略.........
示例7: main
int main(int argc, char* argv[])
{
string cfgFile;
try{
namespace po = boost::program_options;
po::options_description generic("Generic options");
generic.add_options()
("version,v", "print version string")
("help,h", "help message")
("about,a", "about me")
;
po::options_description config("Configuration");
config.add_options()
("config,c",po::value<string>(&cfgFile)->default_value("moreobs.cfg"),"config file")
;
po::options_description cmdline_options;
cmdline_options.add(generic).add(config);
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, cmdline_options),vm);
po::notify(vm);
if (vm.count("help")) {
cout << cmdline_options << "\n";
return 1;
}
if (vm.count("version")) {
cout << "Version: " << "0.2.1079" << "\n";
return 1;
}
if (vm.count("about")) {
cout<< "Waaagh!TV Client Simulation Server (personal)"<<endl;
cout<< "Author: [email protected]" <<endl <<"Version: " <<"0.2.1079" <<endl
<< "Build: 2010-7-9"<<endl <<"This program is based on Waaagh!TV. All information about the protocol is guessing by looking at the network traffic. Thanks to guys for your useful programs."<<endl;
return 1;
}
if (cfgFile!="moreobs.cfg" && vm.count("config")) {
cout << "Using config file :" << cfgFile << endl;
}
} catch(boost::system::system_error& e) {
DEBUG_Print(string("[MAIN]") + e.what() , DEBUG_LEVEL_ERROR);
return 1;
}
//============================================================================================================
CConfig cfg;
cfg.Read(cfgFile);
debug_level = cfg.GetInt( "debug_level" , 99 );
gLogFile = cfg.GetString( "log", string( ) );
gLogMethod = cfg.GetInt( "logmethod", 1 );
if( !gLogFile.empty( ) )
{
if( gLogMethod == 1 )
{
// log method 1: open, append, and close the log for every message
// this works well on Linux but poorly on Windows, particularly as the log file grows in size
// the log file can be edited/moved/deleted while GHost++ is running
}
else if( gLogMethod == 2 )
{
// log method 2: open the log on startup, flush the log for every message, close the log on shutdown
// the log file CANNOT be edited/moved/deleted while GHost++ is running
gLog = new ofstream( );
gLog->open( gLogFile.c_str( ), ios :: app );
}
}
CONSOLE_Print( "[MAIN] starting up" );
if( !gLogFile.empty( ) )
{
if( gLogMethod == 1 )
CONSOLE_Print( "[MAIN] using log method 1, logging is enabled and [" + gLogFile + "] will not be locked" , DEBUG_LEVEL_MESSAGE );
else if( gLogMethod == 2 )
{
if( gLog->fail( ) )
CONSOLE_Print( "[MAIN] using log method 2 but unable to open [" + gLogFile + "] for appending, logging is disabled" , DEBUG_LEVEL_WARN );
else
CONSOLE_Print( "[MAIN] using log method 2, logging is enabled and [" + gLogFile + "] is now locked" , DEBUG_LEVEL_MESSAGE );
}
}
else
CONSOLE_Print( "[MAIN] no log file specified, logging is disabled" , DEBUG_LEVEL_WARN);
gMoreObs = new CMoreObs( &cfg );
//runing
gMoreObs->Run();
//shutdown
CONSOLE_Print( "[MAIN] shutting down", DEBUG_LEVEL_MESSAGE );
delete gMoreObs;
gMoreObs = NULL;
//.........这里部分代码省略.........