Properties

Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Functions

opIndex
inout(Property) opIndex(string key)
Undocumented in source. Be warned that the author may not have intended to support it.
opIndexAssign
void opIndexAssign(T value, string key)
Undocumented in source. Be warned that the author may not have intended to support it.
prettyPrint
void prettyPrint()
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.
tryGet
inout(Property)* tryGet(string key, inout(Property)* otherwise)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

name
string name;
Undocumented in source.
props
Property[string] props;

Dynamic property storage. Note: This member is public on purpose.

Examples

set/get

import std.exception : assertThrown;

auto props = Properties("props");
props["name"] = "hello";
assert(props["name"].get!string() == "hello");
props["custom"] = 1337;
assert(props["custom"].get!int() == 1337);
props["asdfghjkl"] = 42;
assert(props["asdfghjkl"].convertsTo!int());
assert(props["asdfghjkl"].get!int() == 42);
//struct IntValue { int value; }
//assert(props["asdfghjkl"].coerce!IntValue().value == 42);

assertThrown!MissingKeyError(props["iDontExist"].get!float());
assert(props.tryGet("iDontExist", null) is null);
{
  Property fallback;
  assert(props.tryGet("iDontExist", &fallback) == &fallback);
}

// Overwrite.
props["name"] = "world";
assert(props["name"].get!string() == "world");

Meta