21#include "StringTools.hpp"
41 std::vector<std::string> tmp =
parents;
42 tmp.emplace_back(
name);
43 return detail::join(tmp,
".");
51 std::vector<ConfigItem> items{};
55 virtual std::string
to_config(
const App *,
bool,
bool, std::string)
const = 0;
58 virtual std::vector<ConfigItem>
from_config(std::istream &)
const = 0;
62 if(item.inputs.size() == 1) {
63 return item.inputs.at(0);
65 if(item.inputs.empty()) {
68 throw ConversionError::TooManyInputsFlag(item.fullname());
72 CLI11_NODISCARD std::vector<ConfigItem>
from_file(
const std::string &name)
const {
73 std::ifstream input{name};
75 throw FileError::Missing(name);
116 to_config(
const App * ,
bool default_also,
bool write_description, std::string prefix)
const override;
118 std::vector<ConfigItem>
from_config(std::istream &input)
const override;
188using ConfigTOML = ConfigBase;
Creates a command line program, with very few defaults.
Definition App.hpp:90
This converter works with INI/TOML files; to write INI files use ConfigINI.
Definition ConfigFwd.hpp:85
std::vector< ConfigItem > from_config(std::istream &input) const override
Convert a configuration into an app.
std::string configSection
Specify the configuration section that should be used.
Definition ConfigFwd.hpp:112
ConfigBase * comment(char cchar)
Specify the configuration for comment characters.
Definition ConfigFwd.hpp:120
ConfigBase * arrayDelimiter(char aSep)
Specify the delimiter character for an array.
Definition ConfigFwd.hpp:131
ConfigBase * quoteCharacter(char qString, char literalChar)
Specify the quote characters used around strings and literal strings.
Definition ConfigFwd.hpp:141
char arraySeparator
the character used to separate elements in an array
Definition ConfigFwd.hpp:94
std::string & sectionRef()
get a reference to the configuration section
Definition ConfigFwd.hpp:162
ConfigBase * arrayBounds(char aStart, char aEnd)
Specify the start and end characters for an array.
Definition ConfigFwd.hpp:125
std::string to_config(const App *, bool default_also, bool write_description, std::string prefix) const override
Convert an app into a configuration.
ConfigBase * maxLayers(uint8_t layers)
Specify the maximum number of parents.
Definition ConfigFwd.hpp:147
ConfigBase * allowDuplicateFields(bool value=true)
specify that multiple duplicate arguments should be merged even if not sequential
Definition ConfigFwd.hpp:181
CLI11_NODISCARD const std::string & section() const
get the section
Definition ConfigFwd.hpp:164
ConfigBase * commentDefaults(bool comDef=true)
comment default value options
Definition ConfigFwd.hpp:157
char stringQuote
the character to use around strings
Definition ConfigFwd.hpp:98
ConfigBase * section(const std::string §ionName)
specify a particular section of the configuration file to use
Definition ConfigFwd.hpp:166
ConfigBase * valueSeparator(char vSep)
Specify the delimiter between a name and value.
Definition ConfigFwd.hpp:136
uint8_t maximumLayers
the maximum number of layers to allow
Definition ConfigFwd.hpp:102
char valueDelimiter
the character used separate the name from the value
Definition ConfigFwd.hpp:96
char arrayStart
the character used to start an array '\0' is a default to not use
Definition ConfigFwd.hpp:90
char parentSeparatorChar
the separator used to separator parent layers
Definition ConfigFwd.hpp:104
bool allowMultipleDuplicateFields
specify the config reader should collapse repeated field names to a single vector
Definition ConfigFwd.hpp:108
CLI11_NODISCARD int16_t index() const
get the section index
Definition ConfigFwd.hpp:174
char literalQuote
the character to use around single characters and literal strings
Definition ConfigFwd.hpp:100
ConfigBase * index(int16_t sectionIndex)
specify a particular index in the section to use (-1) for all sections to use
Definition ConfigFwd.hpp:176
int16_t & indexRef()
get a reference to the configuration index
Definition ConfigFwd.hpp:172
char arrayEnd
the character used to end an array '\0' is a default to not use
Definition ConfigFwd.hpp:92
ConfigBase * parentSeparator(char sep)
Specify the separator to use for parent layers.
Definition ConfigFwd.hpp:152
bool commentDefaultsBool
comment default values
Definition ConfigFwd.hpp:106
int16_t configIndex
Specify the configuration index to use for arrayed sections.
Definition ConfigFwd.hpp:110
char commentChar
the character used for comments
Definition ConfigFwd.hpp:88
This class provides a converter for configuration files.
Definition ConfigFwd.hpp:49
virtual CLI11_NODISCARD std::string to_flag(const ConfigItem &item) const
Get a flag value.
Definition ConfigFwd.hpp:61
virtual std::string to_config(const App *, bool, bool, std::string) const =0
Convert an app into a configuration.
CLI11_NODISCARD std::vector< ConfigItem > from_file(const std::string &name) const
Parse a config file, throw an error (ParseError:ConfigParseError or FileError) on failure.
Definition ConfigFwd.hpp:72
virtual ~Config()=default
Virtual destructor.
virtual std::vector< ConfigItem > from_config(std::istream &) const =0
Convert a configuration into an app.
ConfigINI generates a "standard" INI compliant output.
Definition ConfigFwd.hpp:191
Holds values to load into Options.
Definition ConfigFwd.hpp:29
std::vector< std::string > inputs
Listing of inputs.
Definition ConfigFwd.hpp:36
std::string name
This is the name.
Definition ConfigFwd.hpp:34
CLI11_NODISCARD std::string fullname() const
The list of parents and name joined by ".".
Definition ConfigFwd.hpp:40
bool multiline
indicator if a multiline vector separator was inserted
Definition ConfigFwd.hpp:38
std::vector< std::string > parents
This is the list of parents.
Definition ConfigFwd.hpp:31