Line data Source code
1 : /* 2 : * 3 : * 4 : * Distributed under the OpenDDS License. 5 : * See: http://www.opendds.org/license.html 6 : */ 7 : 8 : #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/ 9 : 10 : #include "ConfigUtils.h" 11 : #include "ace/SString.h" 12 : 13 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 14 : 15 : namespace OpenDDS { namespace DCPS { 16 : 17 0 : int pullValues( ACE_Configuration_Heap& cf, 18 : const ACE_Configuration_Section_Key& key, 19 : ValueMap& values ) { 20 0 : int index = 0; 21 0 : ACE_TString name; 22 : ACE_Configuration::VALUETYPE type; 23 : 24 0 : while (cf.enumerate_values( key, index, name, type ) == 0) { 25 : 26 0 : ACE_TString value; 27 0 : if (type == ACE_Configuration::STRING) { 28 0 : cf.get_string_value( key, name.c_str(), value ); 29 0 : values[ACE_TEXT_ALWAYS_CHAR(name.c_str())] = 30 0 : ACE_TEXT_ALWAYS_CHAR(value.c_str()); 31 : } else { 32 0 : ACE_DEBUG((LM_WARNING, "Unexpected value type in config file (ignored): " 33 : "name=%s, type=%d\n", name.c_str(), type)); 34 : } 35 0 : index++; 36 0 : } 37 0 : return index; 38 0 : } 39 : 40 : 41 0 : int processSections( ACE_Configuration_Heap& cf, 42 : const ACE_Configuration_Section_Key& key, 43 : KeyList& subsections ) { 44 0 : int index = 0; 45 0 : ACE_TString name; 46 0 : while (cf.enumerate_sections( key, index, name ) == 0) { 47 0 : ACE_Configuration_Section_Key subkey; 48 0 : if (cf.open_section( key, name.c_str(), false, subkey ) != 0) { 49 0 : return 1; 50 : } 51 0 : subsections.push_back( SubsectionPair( ACE_TEXT_ALWAYS_CHAR(name.c_str()), 52 : subkey ) ); 53 0 : int subindex = 0; 54 0 : ACE_TString subname; 55 0 : if (cf.enumerate_sections( subkey, subindex, subname ) == 0) { 56 : // Found additional nesting of subsections that we don't care 57 : // to allow (e.g. [transport/my/yours]), so return an error. 58 0 : return 1; 59 : } 60 0 : index++; 61 0 : } 62 0 : return 0; 63 0 : } 64 : 65 : } } 66 : 67 : OPENDDS_END_VERSIONED_NAMESPACE_DECL