view tango/example/text/properties.d @ 358:051f5b550d9c trunk

[svn r379] Fix slice assigns of the form T[] = T when T is a typedef. Fixes run/a/array_initialization_20_B, D, F, H.
author ChristianK
date Mon, 14 Jul 2008 12:39:23 +0200
parents 1700239cab2e
children
line wrap: on
line source

private import  tango.io.Buffer,
                tango.io.Console;

private import  tango.text.Properties;

/*******************************************************************************

        Illustrates simple usage of tango.text.Properties

*******************************************************************************/

void main() 
{
        char[][char[]] aa;
        aa ["foo"] = "something";
        aa ["bar"] = "something else";
        aa ["wumpus"] = "";

        // write associative-array to a buffer; could use a file
        auto props = new Properties!(char);
        auto buffer = new Buffer (256);
        props.save (buffer, aa);

        // reset and repopulate AA from the buffer
        aa = null;
        props.load (buffer, (char[] name, char[] value){aa[name] = value;});

        // display result
        foreach (name, value; aa)
                 Cout (name) (" = ") (value).newline;
}