INIReader

Splits source into tokens.

This struct requires token delimeters to be ASCII-characters, Unicode is not supported **only** for token delimeters.

Unless you want to modify INIReader behaviour prefer using one of available preconfigured variants:

- StrictINIReader - UniversalINIReader

More...

Constructors

this
this(string source)

Creates new instance of INIReader from source.

Members

Aliases

BoxType
alias BoxType = BoxerType!Boxer

Reader's Box type (boxer return type).

CurrentBoxer
alias CurrentBoxer = Boxer

Reader's boxer.

CurrentFlags
alias CurrentFlags = Flags

Reader's flags.

CurrentFormat
alias CurrentFormat = Format

Reader's format descriptor.

KeyType
alias KeyType = INIReaderKey!BoxType

Alias for INIReaderKey!(BoxType).

TokenValue
alias TokenValue = Algebraic!(string, KeyType)

Type of value property.

Functions

findPair
bool findPair(int pairIndex)
Undocumented in source. Be warned that the author may not have intended to support it.
key
KeyType key()

Returns key token.

next
bool next()

Reads next token.

readComment
void readComment(int pairIndex)
Undocumented in source. Be warned that the author may not have intended to support it.
readEntry
void readEntry()
Undocumented in source. Be warned that the author may not have intended to support it.
readKey
void readKey(KeyType key)
Undocumented in source. Be warned that the author may not have intended to support it.
readSection
void readSection()
Undocumented in source. Be warned that the author may not have intended to support it.
readValue
BoxType readValue()
Undocumented in source. Be warned that the author may not have intended to support it.
sectionName
string sectionName()

Returns section name.

skipWhitespaces
void skipWhitespaces()
Undocumented in source. Be warned that the author may not have intended to support it.
tryReadQuote
bool tryReadQuote(string result)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

empty
bool empty;

Indicates whenever source has been exhausted.

isQuoted
bool isQuoted;

Used only with Key tokens.

source
immutable(ubyte)[] source;

INI source bytes.

sourceOffset
size_t sourceOffset;

INI source offset in bytes.

type
INIToken type;

Type of current token.

value
TokenValue value;

Current token's value.

Detailed Description

INIReader expects three template arguments:

- Format

Instance of INIFormatDescriptor, defines quote and comment sequences.

- Flags

INIReaderFlags (can be OR-ed)

- Boxer

Name of a function that takes (string value, INIReader reader) and returns a value. By default all readers just proxy values, doing nothing, but this can be used to e.g. store token values as JSONValue or other Algebraic-like type.

INIReader.BoxType is always return type of boxer function. So if you passed a boxer that returns SomeAlgebraic then typeof(reader.key.value) is SomeAlgebraic.

Examples

auto reader = UniversalINIReader("key=value\n");

while (reader.next) {
   writeln(reader.value);
}

Meta