URIVariable

Tagged union for template URI variables. Implementation tags the length of the arrays for the type.

Constructors

this
this(string value)

Initializes this variable to a string value.

this
this(string[] array)

Initializes this variable to an array value. All items are assumed to be defined, so null strings are equivalent to empty strings.

this
this(Tuple!(string, string)[] map)
this(string[string] map)

Initializes this variable to a map value. All items are assumed to be defined, so null strings are equivalent to empty strings.

Members

Enums

Type
enum Type

Describes the possible types a variable can have.

Functions

array
inout(string[]) array()
array
string[] array(string[] array)

Sets the type of this variable to array and sets the data.

clear
void clear()

Clears this variable back to being undefined.

isEmpty
bool isEmpty()
isUndefined
bool isUndefined()
length
size_t length()

The length of a value, count of an array or count of a map.

map
inout(Tuple!(string, string)[]) map()
map
Tuple!(string, string)[] map(Tuple!(string, string)[] map)
Tuple!(string, string)[] map(string[string] map)

Sets the type of this variable to map and sets the data.

type
Type type()
value
string value()
value
string value(string value)

Sets the type of this variable to value and sets the data.

Manifest constants

TagBitLength
enum TagBitLength;
Undocumented in source.
TagBitMask
enum TagBitMask;
Undocumented in source.
undefined
enum undefined;
Undocumented in source.

Variables

ptr
void* ptr;
Undocumented in source.
rawLength
size_t rawLength;
Undocumented in source.

Examples

URIVariable value = URIVariable("hello");
URIVariable array = URIVariable(["hello", "world"]);
URIVariable map = URIVariable([tuple("foo", "bar")]);
// AA converts to tuple list at unspecified order
URIVariable mapAA = URIVariable(["foo": "baz"]);

assert(!value.isUndefined);
assert(!value.isEmpty);

assert(!array.isUndefined);
assert(!array.isEmpty);

assert(!map.isUndefined);
assert(!map.isEmpty);

assert(!mapAA.isUndefined);
assert(!mapAA.isEmpty);

assert(value.type == URIVariable.Type.value);
assert(array.type == URIVariable.Type.array);
assert(map.type == URIVariable.Type.map);
assert(mapAA.type == URIVariable.Type.map);

assert(value.value == "hello");
assert(array.array == ["hello", "world"]);
assert(map.map == [tuple("foo", "bar")]);
assert(mapAA.map == [tuple("foo", "baz")]);

URIVariable undefined;
assert(undefined.isUndefined);
assert(undefined.isEmpty);

URIVariable empty = URIVariable(cast(string) null);
assert(!empty.isUndefined);
assert(empty.isEmpty);

URIVariable emptyList = URIVariable(cast(string[]) null);
assert(emptyList.isUndefined);
assert(emptyList.isEmpty);

value.clear();
assert(value.isUndefined);
assert(value.isEmpty);

Meta