OpenDDS  Snapshot(2023/04/28-20:55)
ConfigUtils.cpp
Go to the documentation of this file.
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 
14 
15 namespace OpenDDS { namespace DCPS {
16 
19  ValueMap& values ) {
20  int index = 0;
23 
24  while (cf.enumerate_values( key, index, name, type ) == 0) {
25 
27  if (type == ACE_Configuration::STRING) {
28  cf.get_string_value( key, name.c_str(), value );
29  values[ACE_TEXT_ALWAYS_CHAR(name.c_str())] =
30  ACE_TEXT_ALWAYS_CHAR(value.c_str());
31  } else {
32  ACE_DEBUG((LM_WARNING, "Unexpected value type in config file (ignored): "
33  "name=%s, type=%d\n", name.c_str(), type));
34  }
35  index++;
36  }
37  return index;
38  }
39 
40 
43  KeyList& subsections ) {
44  int index = 0;
46  while (cf.enumerate_sections( key, index, name ) == 0) {
48  if (cf.open_section( key, name.c_str(), false, subkey ) != 0) {
49  return 1;
50  }
51  subsections.push_back( SubsectionPair( ACE_TEXT_ALWAYS_CHAR(name.c_str()),
52  subkey ) );
53  int subindex = 0;
54  ACE_TString subname;
55  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  return 1;
59  }
60  index++;
61  }
62  return 0;
63  }
64 
65 } }
66 
#define ACE_DEBUG(X)
const char * c_str(void) const
const LogLevel::Value value
Definition: debug.cpp:61
virtual int get_string_value(const ACE_Configuration_Section_Key &key, const ACE_TCHAR *name, ACE_TString &value)
sequence< octet > key
#define ACE_TEXT_ALWAYS_CHAR(STRING)
virtual int enumerate_values(const ACE_Configuration_Section_Key &key, int index, ACE_TString &name, VALUETYPE &type)
LM_WARNING
const char *const name
Definition: debug.cpp:60
std::pair< OPENDDS_STRING, ACE_Configuration_Section_Key > SubsectionPair
Definition: ConfigUtils.h:22
virtual int open_section(const ACE_Configuration_Section_Key &base, const ACE_TCHAR *sub_section, bool create, ACE_Configuration_Section_Key &result)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
int processSections(ACE_Configuration_Heap &cf, const ACE_Configuration_Section_Key &key, KeyList &subsections)
Definition: ConfigUtils.cpp:41
virtual int enumerate_sections(const ACE_Configuration_Section_Key &key, int index, ACE_TString &name)
int pullValues(ACE_Configuration_Heap &cf, const ACE_Configuration_Section_Key &key, ValueMap &values)
Definition: ConfigUtils.cpp:17
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28