ConfigUtils.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "DCPS/DdsDcps_pch.h"
00009
00010 #include "ConfigUtils.h"
00011 #include "ace/SString.h"
00012
00013 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00014
00015 namespace OpenDDS { namespace DCPS {
00016
00017 int pullValues( ACE_Configuration_Heap& cf,
00018 const ACE_Configuration_Section_Key& key,
00019 ValueMap& values ) {
00020 int index = 0;
00021 ACE_TString name;
00022 ACE_Configuration::VALUETYPE type;
00023
00024 while (cf.enumerate_values( key, index, name, type ) == 0) {
00025
00026 ACE_TString value;
00027 if (type == ACE_Configuration::STRING) {
00028 cf.get_string_value( key, name.c_str(), value );
00029 values[ACE_TEXT_ALWAYS_CHAR(name.c_str())] =
00030 ACE_TEXT_ALWAYS_CHAR(value.c_str());
00031 } else {
00032 ACE_DEBUG((LM_WARNING, "Unexpected value type in config file (ignored): "
00033 "name=%s, type=%d\n", name.c_str(), type));
00034 }
00035 index++;
00036 }
00037 return index;
00038 }
00039
00040
00041 int processSections( ACE_Configuration_Heap& cf,
00042 const ACE_Configuration_Section_Key& key,
00043 KeyList& subsections ) {
00044 int index = 0;
00045 ACE_TString name;
00046 while (cf.enumerate_sections( key, index, name ) == 0) {
00047 ACE_Configuration_Section_Key subkey;
00048 if (cf.open_section( key, name.c_str(), 0, subkey ) != 0) {
00049 return 1;
00050 }
00051 subsections.push_back( SubsectionPair( ACE_TEXT_ALWAYS_CHAR(name.c_str()),
00052 subkey ) );
00053 int subindex = 0;
00054 ACE_TString subname;
00055 if (cf.enumerate_sections( subkey, subindex, subname ) == 0) {
00056
00057
00058 return 1;
00059 }
00060 index++;
00061 }
00062 return 0;
00063 }
00064
00065 } }
00066
00067 OPENDDS_END_VERSIONED_NAMESPACE_DECL