3#ifndef ICE_PROPERTIES_H
4#define ICE_PROPERTIES_H
7#include "Ice/BuiltinSequences.h"
8#include "Ice/PropertyDict.h"
9#include "PropertiesF.h"
10#include "StringConverter.h"
25#if defined(_WIN32) || defined(ICE_DOXYGEN)
45#if defined(_WIN32) || defined(ICE_DOXYGEN)
96 template<
typename ArgvT>
108 template<
typename... T>
109 Properties(std::string firstOptInPrefix, T... remainingOptInPrefixes)
110 : _optInPrefixes{std::move(firstOptInPrefix), std::move(remainingOptInPrefixes)...}
128 template<
typename ArgvT,
typename... T>
129 Properties(
int& argc, ArgvT argv, std::string firstOptInPrefix, T... remainingOptInPrefixes)
130 : Properties{std::move(firstOptInPrefix), std::move(remainingOptInPrefixes)...}
132 StringSeq args = argsToStringSeq(argc, argv);
134 stringSeqToArgs(args, argc, argv);
251 void load(std::string_view file);
269 static std::optional<std::pair<std::string, std::string>>
279 PropertyValue() : used(false) {}
281 PropertyValue(std::string v,
bool u) : value(std::move(v)), used(u) {}
287 std::map<std::string, PropertyValue, std::less<>> _propertySet;
290 std::vector<std::string> _optInPrefixes;
291 mutable std::mutex _mutex;
301 return std::make_shared<Properties>(std::forward<T>(args)...);
std::string getPropertyWithDefault(std::string_view key, std::string_view value)
Gets a property by key.
StringSeq parseIceCommandLineOptions(const StringSeq &options)
Converts a sequence of command-line options into properties.
std::set< std::string > getUnusedProperties()
Gets the properties that were never read.
StringSeq getPropertyAsListWithDefault(std::string_view key, const StringSeq &value)
Gets a property as a list of strings.
std::string getProperty(std::string_view key)
Gets a property by key.
void load(std::string_view file)
Loads properties from a file.
Properties(StringSeq &args, const PropertiesPtr &defaults=nullptr)
Constructs a property set, loads the configuration files specified by the Ice.Config property or the ...
void setProperty(std::string_view key, std::string_view value)
Sets a property.
int getPropertyAsIntWithDefault(std::string_view key, int value)
Gets a property as an integer.
PropertyDict getPropertiesForPrefix(std::string_view prefix)
Gets all properties whose keys begins with prefix.
StringSeq getPropertyAsList(std::string_view key)
Gets a property as a list of strings.
std::string getIceProperty(std::string_view key)
Gets an Ice property by key.
int getIcePropertyAsInt(std::string_view key)
Gets an Ice property as an integer.
Properties(int &argc, ArgvT argv, const PropertiesPtr &defaults=nullptr)
Constructs a property set, loads the configuration files specified by the Ice.Config property or the ...
StringSeq parseCommandLineOptions(std::string_view prefix, const StringSeq &options)
Converts a sequence of command-line options into properties.
PropertiesPtr clone()
Creates a copy of this property set.
StringSeq getCommandLineOptions()
Gets a sequence of command-line options that is equivalent to this property set.
StringSeq getIcePropertyAsList(std::string_view key)
Gets an Ice property as a list of strings.
int getPropertyAsInt(std::string_view key)
Gets a property as an integer.
Properties(const Properties &source)
Copy constructor.
Properties()=default
Constructs an empty property set.
static std::pair< PropertyDict, StringSeq > parseOptions(std::string_view prefix, const StringSeq &options)
Parses a sequence of options into a map of key value pairs starting with a prefix.
Represents a set of properties used to configure Ice and Ice-based applications.
std::shared_ptr< Properties > PropertiesPtr
A shared pointer to a Properties.
std::shared_ptr< StringConverter > StringConverterPtr
A shared pointer to a StringConverter.
StringSeq argsToStringSeq(int argc, const char *const argv[])
Converts an argument vector into a string sequence.
std::vector< std::string > StringSeq
A sequence of strings.
void stringSeqToArgs(const StringSeq &seq, int &argc, const char *argv[])
Updates argv to match the contents of seq.
std::map< std::string, std::string, std::less<> > PropertyDict
A simple collection of properties, represented as a dictionary of key/value pairs.
PropertiesPtr createProperties(T &&... args)
Creates a new shared Properties object.