本文整理汇总了C++中ACE_Configuration_Heap::get_string_value方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Configuration_Heap::get_string_value方法的具体用法?C++ ACE_Configuration_Heap::get_string_value怎么用?C++ ACE_Configuration_Heap::get_string_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Configuration_Heap
的用法示例。
在下文中一共展示了ACE_Configuration_Heap::get_string_value方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start_scheduler_algorithm
int KSGateway::start_scheduler_algorithm()
{
std::string config_path = KSGOSUtil::JoinPath(_configuration._basedir,KSG_CONFIG_FILENAME);
ACE_Configuration_Heap config;
if(config.open() == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_Ini_ImpExp config_importer(config);
if(config_importer.import_config(config_path.c_str()) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_Configuration_Section_Key section;
if(config.open_section(config.root_section(),ACE_TEXT(KSG_COMMON_SECT)
,0,section) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_TString v;
if(config.open_section(config.root_section(),ACE_TEXT(KSG_SCHEDULER_SECT)
,0,section) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
if(config.get_string_value(section,KSG_SCHD_ALG,v) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
std::string algs = v.c_str();
std::list<std::string> idstr;
std::back_insert_iterator<std::list<std::string> > iter(idstr);
// 从配置中读取需要启动的任务号
xutil::StringUtil::SpliteString(algs,",",iter);
int count = 0;
for(std::list<std::string>::iterator i = idstr.begin();i != idstr.end();++i,++count)
{
if(init_scheduler_algorithm(*i))
return -1;
}
ACE_DEBUG((LM_TRACE,"启动[%d]个调度算法",count));
return 0;
}
示例2: iniIO
int
Service_Monitor::import_svc_ini(const char* ini_file)
{
int rc = -1;
// load ini file
ACE_Configuration_Heap config;
config.open();
ACE_Ini_ImpExp iniIO(config);
rc = iniIO.import_config(ini_file);
if ( rc != 0 )
return rc;
// clear monitors
monitors_.clear();
ini_file_ = "";
// read ini
ACE_TString name;
for(int i = 0;
config.enumerate_sections(config.root_section(), i, name) == 0;
++i)
{
// not [service] section
if ( !ACE_OS::ace_isalnum(*(name.c_str())) )
continue;
ACE_Configuration_Section_Key sec;
config.open_section(config.root_section(), name.c_str(), 0, sec);
// read svm
ACE_TString str_svm;
config.get_string_value(sec, ACE_TEXT("svm"), str_svm);
// no svm value
if ( str_svm.is_empty() )
continue;
int monitor_sec = ACE_OS::atoi(str_svm.c_str());
if ( monitor_sec >= 0 )
monitors_.insert(std::make_pair(name.c_str(), monitor_sec));
}
return rc;
}
示例3: get_scheduler_alg_thr_count
int KSGateway::get_scheduler_alg_thr_count(const std::string &alg_name)
{
int count = 0;
std::string config_path = KSGOSUtil::JoinPath(_configuration._basedir,KSG_CONFIG_FILENAME);
ACE_Configuration_Heap config;
if(config.open() == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_Ini_ImpExp config_importer(config);
if(config_importer.import_config(config_path.c_str()) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_Configuration_Section_Key section;
if(config.open_section(config.root_section(),ACE_TEXT(KSG_COMMON_SECT)
,0,section) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_TString v;
if(config.open_section(config.root_section(),ACE_TEXT(KSG_SCHEDULER_SECT)
,0,section) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
std::string key_name = alg_name;
key_name += "_thr_count";
if(config.get_string_value(section,key_name.c_str(),v) == -1)
{
count = 5;
}
else
{
count = ACE_OS::atoi(v.c_str());
count = (count <= 0) ? 5 : count;
}
return count;
}
示例4: pullValues
int pullValues( ACE_Configuration_Heap& cf,
const ACE_Configuration_Section_Key& key,
ValueMap& values ) {
int index = 0;
ACE_TString name;
ACE_Configuration::VALUETYPE type;
while (cf.enumerate_values( key, index, name, type ) == 0) {
ACE_TString value;
if (type == ACE_Configuration::STRING) {
cf.get_string_value( key, name.c_str(), value );
values[ACE_TEXT_ALWAYS_CHAR(name.c_str())] =
ACE_TEXT_ALWAYS_CHAR(value.c_str());
} else {
ACE_DEBUG((LM_WARNING, "Unexpected value type in config file (ignored): "
"name=%s, type=%d\n", name.c_str(), type));
}
index++;
}
return index;
}
示例5: init
//---------------------------------------------------------------------------------------------
int HA_ccifs::init ( int argc , ACE_TCHAR *argv[] )
{
ACE_Trace _( ACE_TEXT( "%D HA_ccifs::init" ) , __LINE__ );
//command line
//-------------------------------------------------------------------------------
static const ACE_TCHAR options[] = ACE_TEXT (":f:");
ACE_Get_Opt cmd_opts (argc, argv, options, 0);
if (cmd_opts.long_option
(ACE_TEXT ( "config" ), 'f', ACE_Get_Opt::ARG_REQUIRED) == -1)
{ return -1; }
int option;
ACE_TCHAR config_file[MAXPATHLEN];
ACE_OS::strcpy ( config_file, ACE_TEXT ( conf_path.c_str() ) );
while ( ( option = cmd_opts ()) != EOF)
switch ( option )
{
case 'f' :
ACE_OS::strncpy (config_file , cmd_opts.opt_arg () , MAXPATHLEN );
break;
case ':':
ACE_ERROR_RETURN ( ( LM_ERROR , ACE_TEXT ( "-%c requires an argument\n" ) ,
cmd_opts.opt_opt ()) , -1 );
default:
ACE_ERROR_RETURN ( ( LM_ERROR , ACE_TEXT ( "parse error.\n" ) ) ,
- 1);
}
//configuration file
//-------------------------------------------------------------------------------
ACE_Configuration_Heap config;
config.open ();
ACE_Registry_ImpExp config_importer (config);
if ( config_importer.import_config (config_file) == -1 )
{ ACE_ERROR_RETURN ( ( LM_ERROR , ACE_TEXT ("%p\n") , config_file ) , -1 ); }
ACE_Configuration_Section_Key dispatcher_section;
if (config.open_section (config.root_section (),
ACE_TEXT ("HA_ccifs"),
0,
dispatcher_section) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ( "can't open HA_ccifs section" ) ) ,
-1 );
//fifo
u_int dispatcher_port;
if (config.get_integer_value ( dispatcher_section,
ACE_TEXT ( "fifo" ) ,
dispatcher_port ) == -1 )
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("HA_ccifs fifo")
ACE_TEXT (" does not exist\n") ) ,
-1 );
//ccifs
ACE_TString ccifs;
if (config.get_string_value ( dispatcher_section,
ACE_TEXT ( "ccifs_tmpfs_mount" ) ,
ccifs ) == -1 )
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("HA_ccifs ccifs_mount")
ACE_TEXT (" does not exist\n") ) ,
-1 );
if( ACE_Thread_Manager::instance()->spawn( ACE_THR_FUNC (ccifs_func) ,
(void*) this ,
THR_NEW_LWP ,
&m_thread_id ) )
{
ACE_DEBUG
((LM_DEBUG, ACE_TEXT ("(%t) ..spawned ccifs notify thread..\n")));
}
else
{
ACE_DEBUG
((LM_DEBUG, ACE_TEXT ("(%t) ..spawning ccifs notify failed..\n")));
}
return 0;
}
示例6: loadConfig
int KSGConfig::loadConfig(const std::string& file_name)
{
ACE_Configuration_Heap config;
if(config.open() == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_Ini_ImpExp config_importer(config);
if(config_importer.import_config(file_name.c_str()) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_Configuration_Section_Key section;
if(config.open_section(config.root_section(),ACE_TEXT(KSG_COMMON_SECT)
,0,section) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
ACE_TString v;
if(config.get_string_value(section,ACE_TEXT(KSG_MAJOR_VER),v) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
_majorVer = ACE_OS::atoi(v.c_str());
if(config.get_string_value(section,KSG_MINOR_VER,v) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
_minorVer = ACE_OS::atoi(v.c_str());
if(config.open_section(config.root_section(),ACE_TEXT(KSG_SERVER_SECT)
,0,section) == -1 )
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
if(config.get_string_value(section,KSG_SVR_IP,v) == -1)
{
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
}
_drtpSvrIP = v.c_str();
if(config.get_string_value(section,KSG_SVR_PORT,v) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
_drtpSvrPort = ACE_OS::atoi(v.c_str());
if(config.get_string_value(section,KSG_SVR_BRANCE_NO,v) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
_drtpNo = ACE_OS::atoi(v.c_str());
if(config.get_string_value(section,KSG_SVR_MAINFUNC,v) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
_drtpMainFunc = ACE_OS::atoi(v.c_str());
if(config.get_string_value(section,KSG_SVR_POOL_CONN,v) == -1)
_drtpPoolMaxCnt = 5;
else
_drtpPoolMaxCnt = ACE_OS::atoi(v.c_str());
if(_drtpPoolMaxCnt < 0)
_drtpPoolMaxCnt = 5;
if(_drtpPoolMaxCnt > 30)
_drtpPoolMaxCnt = 30;
if(config.get_string_value(section,KSG_SVR_BCC,v) == -1)
_start_bcc = 0;
else
_start_bcc = ACE_OS::atoi(v.c_str());
/// 是否加载卡状态
if(config.get_string_value(section,KSG_SVR_LOAD_CARD_STATE,v) == -1)
_loadCardState = 0;
else
_loadCardState = ACE_OS::atoi(v.c_str());
if(config.open_section(config.root_section(),ACE_TEXT(KSG_GATEWAY_SECT)
,0,section) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
if(config.get_string_value(section,KSG_GW_IP,v) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
_localIP = v.c_str();
if(config.open_section(config.root_section(),ACE_TEXT(KSG_SCHEDULER_SECT)
,0,section) == -1)
ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("读取前置机配置失败")),-1);
_runTaskIds = "";
if(config.get_string_value(section,KSG_SCHD_IDS,v) != -1)
{
_runTaskIds = v.c_str();
}
_listenerIds = "";
if(config.get_string_value(section,KSG_LISTENER_IDS,v) != -1)
{
_listenerIds = v.c_str();
}
if(config.get_string_value(section,"conn_interval",v)==-1)
_conn_interval = 100;
else
//.........这里部分代码省略.........