tango.io.stream.Map

License:

BSD style: see license.txt

Version:

Initial release: Oct 2007

Author:

Kris

Simple serialization for text-based name/value pairs.
class MapInput(T) : Lines!(T)
Provides load facilities for a properties stream. That is, a file or other medium containing lines of text with a name=value layout.
this(InputStream stream)
Propagate ctor to superclass.
int opApply(scope int delegate(ref const(T)[] name, ref const(T)[] value) dg) [final]
Load properties from the provided stream, via a foreach.
We use an iterator to sweep text lines, and extract lValue and rValue pairs from each one, The expected file format is as follows:

x = y
abc = 123
x.y.z = this is a single property

# this is a comment line

Note that the provided name and value are actually slices and should be copied if you intend to retain them (using name.dup and value.dup where appropriate.)
MapInput load(ref const(T)[][T[]] properties) [final]
Load the input stream into an AA.
class MapOutput(T) : OutputFilter
Provides write facilities on a properties stream. That is, a file or other medium which will contain lines of text with a name=value layout.
this(OutputStream stream, const(T)[] newline = NL)
Propagate ctor to superclass.
MapOutput newline() [final]
Append a newline to the provided stream.
MapOutput comment(const(T)[] text) [final]
Append a comment to the provided stream.
MapOutput append(const(T)[] name, const(T)[] value) [final]
Append name & value to the provided stream.
MapOutput append(const(T)[][T[]] properties) [final]
Append AA properties to the provided stream.