CatapultServer  v0.5.0.1 (Elephant)
utils/ConfigurationUtils.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "ConfigurationBag.h"
23 #include <unordered_set>
24 #include <vector>
25 
26 namespace catapult { namespace utils {
27 
29  std::string GetIniPropertyName(const char* cppVariableName);
30 
33  template<typename T>
34  void LoadIniProperty(const ConfigurationBag& bag, const char* section, const char* cppVariableName, T& value) {
35  value = bag.get<T>(ConfigurationKey(section, GetIniPropertyName(cppVariableName).c_str()));
36  }
37 
39  void VerifyBagSizeLte(const ConfigurationBag& bag, size_t expectedSize);
40 
42  ConfigurationBag ExtractSectionAsBag(const ConfigurationBag& bag, const char* section);
43 
46  std::pair<std::unordered_set<std::string>, size_t> ExtractSectionAsUnorderedSet(const ConfigurationBag& bag, const char* section);
47 
50  std::pair<std::vector<std::string>, size_t> ExtractSectionAsOrderedVector(const ConfigurationBag& bag, const char* section);
51 }}
catapult::utils::GetIniPropertyName
std::string GetIniPropertyName(const char *cppVariableName)
Gets the ini property name corresponding to the cpp variable name (cppVariableName).
Definition: utils/ConfigurationUtils.cpp:26
catapult::utils::VerifyBagSizeLte
void VerifyBagSizeLte(const ConfigurationBag &bag, size_t expectedSize)
Verifies that the number of properties in bag is no greater than expectedSize.
Definition: utils/ConfigurationUtils.cpp:38
catapult::utils::ExtractSectionAsOrderedVector
std::pair< std::vector< std::string >, size_t > ExtractSectionAsOrderedVector(const ConfigurationBag &bag, const char *section)
Definition: utils/ConfigurationUtils.cpp:54
catapult::utils::ExtractSectionAsBag
ConfigurationBag ExtractSectionAsBag(const ConfigurationBag &bag, const char *section)
Extracts all section properties from bag into a new bag with a single section with a default (empty s...
Definition: utils/ConfigurationUtils.cpp:43
catapult::utils::ConfigurationBag
A simple bag of properties.
Definition: ConfigurationBag.h:57
catapult::utils::ConfigurationKey
A configuration key.
Definition: ConfigurationBag.h:44
catapult::utils::ConfigurationBag::get
T get(const ConfigurationKey &key) const
Gets the property identified by key from this bag.
Definition: ConfigurationBag.h:130
catapult::utils::LoadIniProperty
void LoadIniProperty(const ConfigurationBag &bag, const char *section, const char *cppVariableName, T &value)
Definition: utils/ConfigurationUtils.h:34
ConfigurationBag.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::utils::ExtractSectionAsUnorderedSet
std::pair< std::unordered_set< std::string >, size_t > ExtractSectionAsUnorderedSet(const ConfigurationBag &bag, const char *section)
Definition: utils/ConfigurationUtils.cpp:49