本文整理汇总了C++中CConfig::GetInt方法的典型用法代码示例。如果您正苦于以下问题:C++ CConfig::GetInt方法的具体用法?C++ CConfig::GetInt怎么用?C++ CConfig::GetInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CConfig
的用法示例。
在下文中一共展示了CConfig::GetInt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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))));
}
示例2: 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( );
//.........这里部分代码省略.........
示例3: main
int main( )
{
// seed the RNG
srand( (unsigned int) time( NULL ) );
// check if the log folder exists
if( !UTIL_FileExists( "log" ) )
{
#ifdef WIN32
CreateDirectoryA( "log", NULL );
#else
system( "mkdir log" );
system( "chmod 777 log" );
#endif
}
// check if the cfg folder exists
if( !UTIL_FileExists( "cfg" ) )
{
#ifdef WIN32
CreateDirectoryA( "cfg", NULL );
#else
system( "mkdir cfg" );
system( "chmod 777 cfg" );
#endif
}
// read config file
CConfig CFG;
CFG.Read( CFGFile );
gLog = CFG.GetInt( "bot_log", 1 ) == 0 ? false : true;
// catch SIGABRT and SIGINT
signal( SIGABRT, SignalCatcher );
signal( SIGINT, SignalCatcher );
#ifndef WIN32
// disable SIGPIPE since some systems like OS X don't define MSG_NOSIGNAL
signal( SIGPIPE, SIG_IGN );
#endif
// initialize curses
gCurses = true;
initscr( );
#ifdef WIN32
resize_term( 28, 97 );
#endif
clear( );
noecho( );
cbreak( );
gMainWindow = newwin( LINES - 3, COLS - 17, 0, 0 );
gBottomBorder = newwin( 1, COLS, LINES - 3, 0 );
gRightBorder = newwin( LINES - 3, 1, 0, COLS - 17 );
gInputWindow = newwin( 2, COLS, LINES - 2, 0 );
gChannelWindow = newwin( LINES - 3, 16, 0, COLS - 16 );
mvwhline( gBottomBorder, 0, 0, 0, COLS );
mvwvline( gRightBorder, 0, 0, 0, LINES );
wrefresh( gBottomBorder );
wrefresh( gRightBorder );
scrollok( gMainWindow, TRUE );
keypad( gInputWindow, TRUE );
scrollok( gInputWindow, TRUE );
CONSOLE_Draw( );
nodelay( gInputWindow, TRUE );
// print something for logging purposes
CONSOLE_Print( "[CCBOT] starting up" );
#ifdef WIN32
// increase process priority
CONSOLE_Print( "[CCBOT] setting process priority to \"high\"" );
SetPriorityClass( GetCurrentProcess( ), HIGH_PRIORITY_CLASS );
// initialize winsock
CONSOLE_Print( "[CCBOT] starting winsock" );
WSADATA wsadata;
if( WSAStartup( MAKEWORD( 2, 2 ), &wsadata ) != 0 )
{
CONSOLE_Print( "[CCBOT] error starting winsock" );
return 1;
}
#endif
// initialize ccbot
gCCBot = new CCCBot( &CFG );
while( true )
//.........这里部分代码省略.........
示例4: 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 );
//.........这里部分代码省略.........
示例5: 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;
//.........这里部分代码省略.........
示例6: 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;
//.........这里部分代码省略.........