Table of Contents

Class IniParser

Namespace
Tlumach.Base
Assembly
Tlumach.Base.dll

The parser for simple ini-style translation files.

public class IniParser : BaseKeyValueParser
Inheritance
IniParser
Inherited Members

Properties

LineCommentChar

protected override char LineCommentChar { get; }

Property Value

char

TextProcessingMode

Gets or sets the text processing mode to use when decoding potentially escaped strings and when recognizing template strings in translation entries.

public static TextFormat TextProcessingMode { get; set; }

Property Value

TextFormat

Methods

AcceptUnquotedEmptyValues()

protected override bool AcceptUnquotedEmptyValues()

Returns

bool

CanHandleExtension(string)

Checks whether this parser can handle a translation file with the given extension.

This method is not used for configuration files.

public override bool CanHandleExtension(string fileExtension)

Parameters

fileExtension string

The extension to check.

Returns

bool

true if the extension is supported and false otherwise.

GetTextProcessingMode()

Used for internal needs.

protected override TextFormat GetTextProcessingMode()

Returns

TextFormat

The effective text processing mode.

InternalLoadTranslationStructure(string, TextFormat?)

Loads the keys from the default translation file and builds a tree of keys.

protected override TranslationTree? InternalLoadTranslationStructure(string content, TextFormat? textProcessingMode)

Parameters

content string

The content to parse.

textProcessingMode TextFormat?

The mode of processing of the text of the default file.

Returns

TranslationTree

The constructed TranslationTree upon success or null otherwise.

Exceptions

TextParseException

Gets thrown when parsing of a default translation file fails.

IsEndOfKey(string, int, out int)

protected override bool? IsEndOfKey(string content, int offset, out int newPosition)

Parameters

content string
offset int
newPosition int

Returns

bool?

IsEndOfValue(string, int, out int)

Detects if the end of a value has been reached.

protected override bool? IsEndOfValue(string content, int offset, out int newPosition)

Parameters

content string

content to check.

offset int

current position within the content.

newPosition int

upon return is set to a position next to the end-of-value marker (indicates to which value the pointer must be set).

Returns

bool?

true if the end of the value has been reached, false if the end has not been reached, and null if the end of line was encountered and a single-line value was not closed.

Exceptions

TextParseException

thrown when an error occurs.

IsSeparatorChar(char)

protected override bool IsSeparatorChar(char candidate)

Parameters

candidate char

Returns

bool

IsStartOfKey(string, int)

protected override bool IsStartOfKey(string content, int offset)

Parameters

content string
offset int

Returns

bool

IsStartOfValue(string, int, out int)

protected override bool IsStartOfValue(string content, int offset, out int posAfterStart)

Parameters

content string
offset int
posAfterStart int

Returns

bool

IsValidKeyChar(string, int)

protected override bool IsValidKeyChar(string content, int offset)

Parameters

content string
offset int

Returns

bool

UnwrapKey(string)

Strips format-specific markers that denote the beginning and the end of a value.

protected override string UnwrapKey(string value)

Parameters

value string

The value to strip.

Returns

string

The text inside the markers.

UnwrapValue(string)

Strips format-specific markers that denote the beginning and the end of a value.

protected override (string? escaped, string unescaped) UnwrapValue(string value)

Parameters

value string

The value to strip.

Returns

(string escaped, string unescaped)

The text inside the markers.

Use()

Initializes the parser class, making it available for use.

public static void Use()