module watt.toml.event

Event driven TOML parser, a la SAX.

Code Map

//! Event driven TOML parser, a la SAX.
module watt.toml.event;


//! Interface for toml string consumers.
interface EventSink
{
public:
	//! Signals the start of content.
	fn start();
	//! Signals the end of content.
	fn end();
	//! Signals the start of a comment. Comment value is sent via 
	//! stringContent.
	fn commentStart();
	//! Signals the end of a comment.
	fn commentEnd();
	//! Signals the start of a key/value pair.
	fn keyValueStart(key: string);
	//! Signals the end of a key/value pair.
	fn keyValueEnd(key: string);
	//! Signals the start of a table.
	fn tableStart(name: string);
	//! Signals the end of a table.
	fn tableEnd(name: string);
	//! Signals a table array.
	fn tableArray(name: string);
	//! Signals an inline table value start.
	fn inlineTableStart();
	//! Signals the end of an inline table value.
	fn inlineTableEnd();
	//! Signals the start of an array.
	fn arrayStart();
	//! Signals the end of an array.
	fn arrayEnd();
	//! Regular text content, used by multiple events.
	fn stringContent(str: string);
	//! Signed integer content.
	fn integerContent(i: i64);
	//! Boolean content.
	fn boolContent(b: bool);
	//! Floating point content.
	fn floatContent(n: f64);
}

//! A class that implements all the methods of EventSink by doing nothing.
class NullEventSink : EventSink
{
public:
	this() { }
	fn start() { }
	fn end() { }
	fn commentStart() { }
	fn commentEnd() { }
	fn keyValueStart(key: string) { }
	fn keyValueEnd(key: string) { }
	fn tableStart(name: string) { }
	fn tableEnd(name: string) { }
	fn tableArray(name: string) { }
	fn inlineTableStart() { }
	fn inlineTableEnd() { }
	fn arrayStart() { }
	fn arrayEnd() { }
	fn stringContent(str: string) { }
	fn integerContent(i: i64) { }
	fn boolContent(b: bool) { }
	fn floatContent(n: f64) { }
}

//! Given a TOML string input, call the appropriate methods on the given 
//! EventSink.
fn runEventSink(txt: string, esink: EventSink) { }
fn runEventSink(txt: string, esink: EventSink)

Given a TOML string input, call the appropriate methods on the given EventSink.

interface EventSink

Interface for toml string consumers.

Implement this class, and pass an instance of your implementation to the watt.toml.event.parse function.

fn start()

Signals the start of content.

fn end()

Signals the end of content.

fn commentStart()

Signals the start of a comment. Comment value is sent via stringContent.

fn commentEnd()

Signals the end of a comment.

fn keyValueStart(key: string)

Signals the start of a key/value pair.

fn keyValueEnd(key: string)

Signals the end of a key/value pair.

fn tableStart(name: string)

Signals the start of a table.

fn tableEnd(name: string)

Signals the end of a table.

fn tableArray(name: string)

Signals a table array.

fn inlineTableStart()

Signals an inline table value start.

fn inlineTableEnd()

Signals the end of an inline table value.

fn arrayStart()

Signals the start of an array.

fn arrayEnd()

Signals the end of an array.

fn stringContent(str: string)

Regular text content, used by multiple events.

fn integerContent(i: i64)

Signed integer content.

fn boolContent(b: bool)

Boolean content.

fn floatContent(n: f64)

Floating point content.

class NullEventSink : EventSink

A class that implements all the methods of EventSink by doing nothing.