On 09/25/2016 06:12 PM, Nick Sabalausky wrote:

-----------------------------
// A few basic values
first "Joe"
last "Coder"
ip "127.0.0.1" port=80

// Supports child tags
folder "myFiles" color="yellow" protection=on {
     folder "my documents" {
         document "resume.pdf"
     }
}
-----------------------------

Example of using some of the new API features:

---------------------------------------------
import sdlang;

Tag root = parseFile("the-above.sdl");

string first = root.expectTagValue!string("first"); // Required
string last  = root.getTagValue!string("last");     // Optional

// Custom default values (if omitted, default value is T.init):
string ip = root.getTagValue!string("ip", "192.168.1.1");
int port = root.getTagAttribute!int("ip", "port", 8080);

Tag folder = root.expectTag("folder");
string folderName = folder.expectValue!string();
assert(folderName == "myFiles");
bool folderProtection = folder.getAttribute!bool("protection");

string subfolderName = folder.getTagValue!string("folder");
assert(subfolderName == "my documents");
---------------------------------------------

Reply via email to