ArchiveObject

This class contains the data about an object in the archive.

Design: This class is modeled after sdlang-d, which feels mostly natural and comfortable to work with.

This class should be able to represent most kinds of objects, but will undoubtably be unsuitable for some.

Values: These are ArchiveValues that are directly attached to the object.

Attributes: These are named ArchiveValues that describe certain features of the object(e.g 'IsHidden=true', 'IsDirectory=false'). (You can of course, use your own meaning for these).

Children: These are ArchiveObjects that are children of the current object.

For example, there's the Archive.root object which is the root of all of the archive's data, and then children would be used to describe more complex objects from the root.

Issues: There is currently no tracking of parentship of objects, so it's possible to have circular references.

Constructors

this
this(string name)

Members

Functions

addChild
void addChild(ArchiveObject child)

Adds a child to this object, it's ArchiveObject.name can be used to retrieve it from ArchiveObject.getChild.

addValue
void addValue(ArchiveValue value)

Adds a value to this object.

addValueAs
void addValueAs(T value)

Helper function to add a Value without having to create an ArchiveValue.

addValues
void addValues(ArchiveValue[] values)

Helper function to add multiple ArchiveValues.

expectAttribute
ArchiveValue expectAttribute(string name)
expectAttributeAs
T expectAttributeAs(string name)

Helper function to get a attribute, or throw an exception if the attribute doesn't exist.

expectChild
ArchiveObject expectChild(string name)

Helper function to get a child, or throw an exception if the child doesn't exist.

expectValue
ArchiveValue expectValue(size_t index)
expectValueAs
T expectValueAs(size_t index)

Helper function to get a value, or throw an exception if the value doesn't exist.

getAttribute
ArchiveValue getAttribute(string name, ArchiveValue default_)

Gets an attribute by name.

getAttributeAs
T getAttributeAs(string name, T default_)

Helper function to get an attribute/value as a certain type.

getChild
ArchiveObject getChild(string name, ArchiveObject default_)

Gets an child by name.

getValue
ArchiveValue getValue(size_t index, ArchiveValue default_)

Gets a value by it's index.

getValueAs
T getValueAs(size_t index, T default_)

Helper function to get an attribute/value as a certain type.

opIndex
ArchiveObject opIndex(string childName)

An operator version of ArchiveObject.expectChild.

opIndex
ArchiveObject opIndex(Names childNames)

An operator version of ArchiveObject.expectChild that takes multiple child names.

setAttribute
void setAttribute(string name, ArchiveValue attrib)

Sets/Creates an attribute's value.

setAttributeAs
void setAttributeAs(string name, T attrib)

Helper function to set an attribute without having to create an ArchiveValue.

Structs

Attribute
struct Attribute

Describes an attribute.

Variables

attributes
Attribute[] attributes;

The attributes of this object.

children
ArchiveObject[] children;

The children of this object.

name
string name;

The name of this object.

values
ArchiveValue[] values;

The values of this object.

Meta