27#include <Ice/Initialize.h>
37 Ice::StringSeq strSeq;
49 armarxIceProperties->parseCommandLineOptions(std::string(), propertySeq);
51 return armarxIceProperties;
60 Ice::StringSeq propertySeq = Ice::argsToStringSeq(argn, argv);
63 armarxIceProperties->parseCommandLineOptions(std::string(), propertySeq);
65 return armarxIceProperties;
69 internalProperties(iceProperties), modified(true)
76 internalProperties = source.internalProperties->clone();
77 modified = source.modified;
78 if (source.inheritanceSolver)
80 inheritanceSolver = new InheritanceSolver(*source.inheritanceSolver);
93 return internalProperties->getProperty(name);
98 const ::std::string& defaultValue) ICE_NOEXCEPT
102 return internalProperties->getPropertyWithDefault(name, defaultValue);
110 return internalProperties->getPropertyAsInt(name);
115 ::Ice::Int defaultValue) ICE_NOEXCEPT
119 return internalProperties->getPropertyAsIntWithDefault(name, defaultValue);
127 return internalProperties->getPropertyAsList(name);
132 const ::Ice::StringSeq& defaultValue) ICE_NOEXCEPT
136 return internalProperties->getPropertyAsListWithDefault(name, defaultValue);
144 return internalProperties->getPropertiesForPrefix(prefix);
150 internalProperties->setProperty(name, value);
159 return internalProperties->getCommandLineOptions();
164 const ::Ice::StringSeq& options)
166 Ice::StringSeq optionSeq = internalProperties->parseCommandLineOptions(prefix, options);
177 Ice::StringSeq optionSeq = internalProperties->parseIceCommandLineOptions(options);
188 internalProperties->load(fileName);
197 return internalProperties->clone();
201 IceProperties::setModified(
bool mod)
203 this->modified = mod;
207 IceProperties::isModified()
213 IceProperties::update()
217 if (inheritanceSolver.get() !=
nullptr)
219 inheritanceSolver->resolveInheritance(internalProperties);
229 return inheritanceSolver;
235 this->inheritanceSolver = solver;
249 NamespaceMap::const_iterator namespacesIter = namespaces.begin();
251 while (namespacesIter != namespaces.end())
265 Ice::PropertyDict propertyDict = properties->getPropertiesForPrefix(std::string());
268 Ice::PropertyDict::iterator dictIter = propertyDict.begin();
270 while (dictIter != propertyDict.end())
272 std::string propertyFullName = dictIter->first;
274 unsigned nameDelimiter = propertyFullName.find_last_of(
".");
275 std::string propertyNamespace = propertyFullName.substr(0, nameDelimiter);
276 namespaces[propertyNamespace] =
true;
288 if (properties->getPropertyWithDefault(inheritanceProperty,
"::NOT-SET::")
289 .compare(
"::NOT-SET::") == 0)
303 return properties->getProperty(inheritanceProperty);
308 const std::string& namespace_)
310 std::vector<std::string>::const_iterator heritageLineIter = heritageLine.begin();
312 while (heritageLineIter != heritageLine.end())
314 if ((*heritageLineIter).compare(namespace_) == 0)
327 const std::string& namespace_)
329 return propertyName.substr(namespace_.length() + 1);
336 std::vector<std::string> heritageLine;
338 if (
hasParent(childNamespace, properties))
341 childNamespace,
getParent(childNamespace, properties), properties, heritageLine);
347 const std::string& parentNamespace,
349 std::vector<std::string> heritageLine)
351 heritageLine.push_back(childNamespace);
354 if (
hasParent(parentNamespace, properties))
358 heritageLine.push_back(parentNamespace);
363 parentNamespace,
getParent(parentNamespace, properties), properties, heritageLine);
367 Ice::PropertyDict parentProperties = properties->getPropertiesForPrefix(parentNamespace);
369 Ice::PropertyDict::iterator parentPropIter = parentProperties.begin();
371 while (parentPropIter != parentProperties.end())
377 for (
auto property : properties->getPropertiesForPrefix(childNamespace))
379 std::string propertyVariable =
380 "{" +
stripNamespace(parentPropIter->first, parentNamespace) +
"}";
381 auto index =
property.second.find(propertyVariable);
382 if (
index != std::string::npos)
384 std::string newValue =
property.second.replace(
385 index, propertyVariable.size(), parentPropIter->second);
386 properties->setProperty(property.first, newValue);
392 std::string newPropertyName =
393 childNamespace +
"." +
stripNamespace(parentPropIter->first, parentNamespace);
396 if (properties->getProperty(newPropertyName).empty())
398 properties->setProperty(newPropertyName, parentPropIter->second);
#define STRINGREPLACEMENT_NAMESPACE
#define INHERITANCE_KEYWORD
void extractNamespaces(const Ice::PropertiesPtr &properties, NamespaceMap &namespaces)
Extracts all existing namespace within the passed property container.
void inherit(const std::string &childNamespace, const std::string &parentNamespace, Ice::PropertiesPtr &properties, std::vector< std::string > heritageLine)
Performs the inheritance of properties from parentNamespace to childNamespace.
bool isInHeritageLine(const std::vector< std::string > &heritageLine, const std::string &namespace_)
Checks whether the specified namespace exists already in the heritageLine.
void resolveNamespaceInheritance(const std::string &childNamespace, Ice::PropertiesPtr &properties)
Resolves namespace inheritance for a specific namespace.
std::string stripNamespace(const std::string &propertyName, const std::string &namespace_)
Removes the namespace of the property name.
bool hasParent(const std::string &childNamespace, const Ice::PropertiesPtr &properties)
Checks whether the specified namespace has a parent which it inherits from.
std::map< std::string, bool > NamespaceMap
void resolveInheritance(Ice::PropertiesPtr &properties)
Resolves all inheritance specifications made using the config notation "<namespace>....
std::string getParent(const std::string &childNamespace, const Ice::PropertiesPtr &properties)
Returns the parent namespace of a child namespace.
~InheritanceSolver() override
::std::string getPropertyWithDefault(const ::std::string &name, const ::std::string &defaultValue) ICE_NOEXCEPT override
IceUtil::Handle< InheritanceSolver > InheritanceSolverPtr
void setProperty(const ::std::string &name, const ::std::string &value) override
IceProperties(const Ice::PropertiesPtr iceProperties)
Ice property container constructor.
::Ice::PropertyDict getPropertiesForPrefix(const ::std::string &prefix) ICE_NOEXCEPT override
::Ice::PropertiesPtr clone() ICE_NOEXCEPT override
virtual void setInheritanceSolver(const InheritanceSolverPtr &inheritanceSolver)
Sets an inheritance solver in case of testing or using a non-default solver.
::Ice::Int getPropertyAsIntWithDefault(const ::std::string &name, ::Ice::Int defaultValue) ICE_NOEXCEPT override
::Ice::StringSeq parseCommandLineOptions(const ::std::string &prefix, const ::Ice::StringSeq &options) override
~IceProperties() override
Ice property container desctructor.
::std::string getProperty(const ::std::string &name) ICE_NOEXCEPT override
::Ice::StringSeq getPropertyAsList(const ::std::string &name) ICE_NOEXCEPT override
::Ice::StringSeq parseIceCommandLineOptions(const ::Ice::StringSeq &options) override
void load(const ::std::string &fileName) override
::Ice::Int getPropertyAsInt(const ::std::string &name) ICE_NOEXCEPT override
::Ice::StringSeq getPropertyAsListWithDefault(const ::std::string &name, const ::Ice::StringSeq &defaultValue) ICE_NOEXCEPT override
::Ice::StringSeq getCommandLineOptions() ICE_NOEXCEPT override
static Ice::PropertiesPtr create(const Ice::PropertiesPtr &iceProperties=nullptr)
virtual InheritanceSolverPtr getInheritanceSolver()
Returns the currently used inheritance solver.
This exception is thrown if a property inheritance cycle has been encountered.
Ice::PropertiesPtr createProperties()
::IceInternal::Handle<::Ice::Properties > PropertiesPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.