Table of Contents

Class BaseKeyValueParser

Namespace
Tlumach.Base
Assembly
Tlumach.Base.dll

The base parser for key-value configuration and translation files (ini and toml).

public abstract class BaseKeyValueParser : BaseParser
Inheritance
BaseKeyValueParser
Derived
Inherited Members

Properties

LineCommentChar

protected virtual char LineCommentChar { get; }

Property Value

char

LocaleSeparatorChar

Gets or sets the character that is used to separate the locale name from the base name in the names of locale-specific translation files.

public static char LocaleSeparatorChar { get; set; }

Property Value

char

Methods

AcceptUnquotedEmptyValues()

protected abstract bool AcceptUnquotedEmptyValues()

Returns

bool

GetLocaleSeparatorChar()

Used for internal needs.

public override char GetLocaleSeparatorChar()

Returns

char

The character, used to separate the base file name and the locale.

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 abstract 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 abstract 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.

IsEscapedEOLInValue(string, int)

protected virtual bool IsEscapedEOLInValue(string content, int offset)

Parameters

content string
offset int

Returns

bool

IsSeparatorChar(char)

protected abstract bool IsSeparatorChar(char candidate)

Parameters

candidate char

Returns

bool

IsStartOfKey(string, int)

protected abstract bool IsStartOfKey(string content, int offset)

Parameters

content string
offset int

Returns

bool

IsStartOfValue(string, int, out int)

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

Parameters

content string
offset int
posAfterStart int

Returns

bool

IsValidKeyChar(string, int)

protected virtual bool IsValidKeyChar(string content, int offset)

Parameters

content string
offset int

Returns

bool

IsValidSectionNameChar(string, int)

protected virtual bool IsValidSectionNameChar(string content, int offset)

Parameters

content string
offset int

Returns

bool

LoadTranslation(string, CultureInfo?, TextFormat?)

Loads the translation information from the file and returns a translation.

public override Translation? LoadTranslation(string translationText, CultureInfo? culture, TextFormat? textProcessingMode)

Parameters

translationText string

The text of the file to load.

culture CultureInfo

An optional reference to the locale, whose translation is to be loaded. Makes sense for CSV and TSV formats that may contain multiple translations in one file.

textProcessingMode TextFormat?

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

Returns

Translation

The loaded translation or null if loading failed.

ParseConfiguration(string, Assembly?)

public override TranslationConfiguration? ParseConfiguration(string fileContent, Assembly? assembly)

Parameters

fileContent string
assembly Assembly

Returns

TranslationConfiguration

UnwrapKey(string)

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

protected abstract 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 abstract (string? escaped, string unescaped) UnwrapValue(string value)

Parameters

value string

The value to strip.

Returns

(string escaped, string unescaped)

The text inside the markers.