当前位置: 首页>>代码示例>>C++>>正文


C++ ACE_Configuration_Heap::enumerate_sections方法代码示例

本文整理汇总了C++中ACE_Configuration_Heap::enumerate_sections方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Configuration_Heap::enumerate_sections方法的具体用法?C++ ACE_Configuration_Heap::enumerate_sections怎么用?C++ ACE_Configuration_Heap::enumerate_sections使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ACE_Configuration_Heap的用法示例。


在下文中一共展示了ACE_Configuration_Heap::enumerate_sections方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: processSections

 int processSections( ACE_Configuration_Heap& cf,
                      const ACE_Configuration_Section_Key& key,
                      KeyList& subsections ) {
   int index = 0;
   ACE_TString name;
   while (cf.enumerate_sections( key, index, name ) == 0) {
     ACE_Configuration_Section_Key subkey;
     if (cf.open_section( key, name.c_str(), 0, subkey ) != 0) {
       return 1;
     }
     subsections.push_back( SubsectionPair( ACE_TEXT_ALWAYS_CHAR(name.c_str()),
                                            subkey ) );
     int subindex = 0;
     ACE_TString subname;
     if (cf.enumerate_sections( subkey, subindex, subname ) == 0) {
       // Found additional nesting of subsections that we don't care
       // to allow (e.g. [transport/my/yours]), so return an error.
       return 1;
     }
     index++;
   }
   return 0;
 }
开发者ID:shaominghaoo,项目名称:OpenDDS,代码行数:23,代码来源:ConfigUtils.cpp

示例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;
}
开发者ID:ancrux,项目名称:cpp-ex,代码行数:45,代码来源:Service_Monitor.cpp

示例3: if

int
TransportRegistry::load_transport_configuration(const OPENDDS_STRING& file_name,
                                                ACE_Configuration_Heap& cf)
{
  const ACE_Configuration_Section_Key &root = cf.root_section();

  // Create a vector to hold configuration information so we can populate
  // them after the transports instances are created.
  typedef std::pair<TransportConfig_rch, OPENDDS_VECTOR(OPENDDS_STRING) > ConfigInfo;
  OPENDDS_VECTOR(ConfigInfo) configInfoVec;

  // Record the transport instances created, so we can place them
  // in the implicit transport configuration for this file.
  OPENDDS_LIST(TransportInst_rch) instances;

  ACE_TString sect_name;

  for (int index = 0;
       cf.enumerate_sections(root, index, sect_name) == 0;
       ++index) {
    if (ACE_OS::strcmp(sect_name.c_str(), TRANSPORT_SECTION_NAME) == 0) {
      // found the [transport/*] section, now iterate through subsections...
      ACE_Configuration_Section_Key sect;
      if (cf.open_section(root, sect_name.c_str(), 0, sect) != 0) {
        ACE_ERROR_RETURN((LM_ERROR,
                          ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
                          ACE_TEXT("failed to open section %s\n"),
                          sect_name.c_str()),
                         -1);
      } else {
        // Ensure there are no properties in this section
        ValueMap vm;
        if (pullValues(cf, sect, vm) > 0) {
          // There are values inside [transport]
          ACE_ERROR_RETURN((LM_ERROR,
                            ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
                            ACE_TEXT("transport sections must have a section name\n"),
                            sect_name.c_str()),
                           -1);
        }
        // Process the subsections of this section (the individual transport
        // impls).
        KeyList keys;
        if (processSections( cf, sect, keys ) != 0) {
          ACE_ERROR_RETURN((LM_ERROR,
                            ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
                            ACE_TEXT("too many nesting layers in [%s] section.\n"),
                            sect_name.c_str()),
                           -1);
        }
        for (KeyList::const_iterator it=keys.begin(); it != keys.end(); ++it) {
          OPENDDS_STRING transport_id = (*it).first;
          ACE_Configuration_Section_Key inst_sect = (*it).second;

          ValueMap values;
          if (pullValues( cf, (*it).second, values ) != 0) {
            // Get the factory_id for the transport.
            OPENDDS_STRING transport_type;
            ValueMap::const_iterator vm_it = values.find("transport_type");
            if (vm_it != values.end()) {
              transport_type = (*vm_it).second;
            } else {
              ACE_ERROR_RETURN((LM_ERROR,
                                ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
                                ACE_TEXT("missing transport_type in [transport/%C] section.\n"),
                                transport_id.c_str()),
                               -1);
            }
            // Create the TransportInst object and load the transport
            // configuration in ACE_Configuration_Heap to the TransportInst
            // object.
            TransportInst_rch inst = this->create_inst(transport_id,
                                                       transport_type);
            if (inst == 0) {
              ACE_ERROR_RETURN((LM_ERROR,
                                ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
                                ACE_TEXT("Unable to create transport instance in [transport/%C] section.\n"),
                                transport_id.c_str()),
                               -1);
            }
            instances.push_back(inst);
            inst->load(cf, inst_sect);
          } else {
            ACE_ERROR_RETURN((LM_ERROR,
                              ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
                              ACE_TEXT("missing transport_type in [transport/%C] section.\n"),
                              transport_id.c_str()),
                             -1);
          }
        }
      }
    } else if (ACE_OS::strcmp(sect_name.c_str(), CONFIG_SECTION_NAME) == 0) {
      // found the [config/*] section, now iterate through subsections...
      ACE_Configuration_Section_Key sect;
      if (cf.open_section(root, sect_name.c_str(), 0, sect) != 0) {
        ACE_ERROR_RETURN((LM_ERROR,
                          ACE_TEXT("(%P|%t) TransportRegistry::load_transport_configuration: ")
                          ACE_TEXT("failed to open section [%s]\n"),
                          sect_name.c_str()),
                         -1);
//.........这里部分代码省略.........
开发者ID:tempbottle,项目名称:OpenDDS,代码行数:101,代码来源:TransportRegistry.cpp


注:本文中的ACE_Configuration_Heap::enumerate_sections方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。