tango.io.stream.Map

License:
BSD style:

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);
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:



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);
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.

Examples:
auto buf = new Array(200);
auto input = new MapInput!(char)(buf);
auto output = new MapOutput!(char)(buf);

const(char)[][char[]] map;
map["foo"] = "bar";
map["foo2"] = "bar2";
output.append(map).flush();

map = map.init;
input.load (map);
assert (map["foo"] == "bar");
assert (map["foo2"] == "bar2");


this(OutputStream stream, const(T)[] newline = NL);
Propagate ctor to superclass.

MapOutput newline();
Append a newline to the provided stream.

MapOutput comment(const(T)[] text);
Append a comment to the provided stream.

MapOutput append(const(T)[] name, const(T)[] value);
Append name & value to the provided stream.

MapOutput append(const(T)[][T[]] properties);
Append AA properties to the provided stream.


Page generated by Ddoc. Copyright (c) 2007 Kris Bell. All rights reserved