lu.serialisation

Various functions related to serialising and deserialising structs into/from .ini-like files.

Members

Classes

DeserialisationException
class DeserialisationException

Exception, to be thrown when the specified serialised text could not be parsed, for whatever reason.

Functions

deserialise
void deserialise(Range range, string[][string] missingEntries, string[][string] invalidEntries, Things things)

Takes an input range containing serialised entry-value text and applies the contents therein to one or more passed struct/class objects.

justifiedEntryValueText
string justifiedEntryValueText(string origLines)

Takes an unformatted string of serialised entry-value text and justifies it into two neat columns.

serialise
void serialise(Sink sink, Things things)

Convenience function to call serialise on several objects.

serialise
void serialise(Sink sink, QualThing thing)

Serialises the fields of an object into an .ini file-like format.

splitEntryValue
auto splitEntryValue(string line)

Splits a line into an entry and a value component.

Examples

 struct FooSettings
 {
     string fooasdf;
     string bar;
     string bazzzzzzz;
     @Quoted flerrp;
     double pi;
 }

 FooSettings f;

 f.fooasdf = "foo";
 f.bar = "bar";
 f.bazzzzzzz = "baz";
 f.flerrp = "hirr steff  ";
 f.pi = 3.14159;

 enum fooSerialised =
`[Foo]
 fooasdf foo
 bar bar
 bazzzzzzz baz
 flerrp "hirr steff  "
 pi 3.14159`;

 enum fooJustified =
 `[Foo]
 fooasdf                 foo
 bar                     bar
 bazzzzzzz               baz
 flerrp                  "hirr steff  "
 pi                      3.14159`;

 Appender!(char[]) sink;

 sink.serialise(f);
 assert(sink.data.justifiedEntryValueText == fooJustified);

 FooSettings mirror;
 deserialise(fooSerialised, mirror);
 assert(mirror == f);

 FooSettings mirror2;
 deserialise(fooJustified, mirror2);
 assert(mirror2 == mirror);

Meta