ConfigEntry

A configuration entry which acts as a typed union and supports certain fixed types

Constructors

this
this(EntryType value)
Undocumented in source.

Members

Functions

array
string[] array()

Obtains the textual array value of this entry

flag
bool flag()

Obtains the flag value of this entry

getType
ConfigType getType()

Returns the type of the entry's value

isFalse
bool isFalse()
isTrue
bool isTrue()
numeric
size_t numeric()

Obtains the numeric value of this entry

opCast
T opCast()

Obtains the value of this configuration entry dependant on the requested casting type and matching that to the supported types of the configuration entry

opSlice
string[] opSlice()
text
string text()

Obtains the text value of this entry

Static functions

ofArray
ConfigEntry ofArray(string[] array)

Creates a new configuration entry containing a textual array

ofFlag
ConfigEntry ofFlag(bool flag)

Creates a new configuration entry containing a flag

ofNumeric
ConfigEntry ofNumeric(size_t i)

Creates a new configuration entry containing an integer

ofText
ConfigEntry ofText(string text)

Creates a new configuration entry containing text

Examples

Tests out using the configuration entry and its various operator overloads

ConfigEntry entry = ConfigEntry.ofArray(["hello", "world"]);
assert(entry[] == ["hello", "world"]);

entry = ConfigEntry.ofNumeric(1);
assert(entry.numeric() == 1);

entry = ConfigEntry.ofText("hello");
assert(cast(string)entry == "hello");

entry = ConfigEntry.ofFlag(true);
assert(entry);

Tests out the erroneous usage of a configuration entry

ConfigEntry entry = ConfigEntry.ofText("hello");

try
{
    entry[];
    assert(false);
}
catch(ConfigException e)
{

}

Tests out the erroneous usage of a configuration entry

ConfigEntry entry;

try
{
    entry[];
    assert(false);
}
catch(ConfigException e)
{

}

Meta