Class BaseKeyValueParser
The base parser for key-value configuration and translation files (ini and toml).
Inheritance
BaseKeyValueParser
Assembly: Tlumach.Base.dll
Syntax
public abstract class BaseKeyValueParser : BaseParser
Properties
Declaration
protected virtual char LineCommentChar { get; }
Property Value
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.
Declaration
public static char LocaleSeparatorChar { get; set; }
Property Value
Methods
AcceptUnquotedEmptyValues()
Declaration
protected abstract bool AcceptUnquotedEmptyValues()
Returns
GetLocaleSeparatorChar()
Declaration
public override char GetLocaleSeparatorChar()
Returns
Overrides
InternalLoadTranslationStructure(string)
Loads the keys from the default translation file and builds a tree of keys.
Declaration
protected override TranslationTree? InternalLoadTranslationStructure(string content)
Parameters
| Type |
Name |
Description |
| string |
content |
The content to parse.
|
Returns
Overrides
Exceptions
| Type |
Condition |
| TextParseException |
Gets thrown when parsing of a default translation file fails.
|
IsEndOfKey(string, int, out int)
Declaration
protected abstract bool? IsEndOfKey(string content, int offset, out int newPosition)
Parameters
| Type |
Name |
Description |
| string |
content |
|
| int |
offset |
|
| int |
newPosition |
|
Returns
IsEndOfValue(string, int, out int)
Detects if the end of a value has been reached.
Declaration
protected abstract bool? IsEndOfValue(string content, int offset, out int newPosition)
Parameters
| Type |
Name |
Description |
| string |
content |
content to check.
|
| int |
offset |
current position within the content.
|
| int |
newPosition |
upon return is set to a position next to the end-of-value marker (indicates to which value the pointer must be set).
|
Returns
| Type |
Description |
| 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
IsEscapedEOLInValue(string, int)
Declaration
protected virtual bool IsEscapedEOLInValue(string content, int offset)
Parameters
| Type |
Name |
Description |
| string |
content |
|
| int |
offset |
|
Returns
IsSeparatorChar(char)
Declaration
protected abstract bool IsSeparatorChar(char candidate)
Parameters
| Type |
Name |
Description |
| char |
candidate |
|
Returns
IsStartOfKey(string, int)
Declaration
protected abstract bool IsStartOfKey(string content, int offset)
Parameters
| Type |
Name |
Description |
| string |
content |
|
| int |
offset |
|
Returns
IsStartOfValue(string, int, out int)
Declaration
protected abstract bool IsStartOfValue(string content, int offset, out int posAfterStart)
Parameters
| Type |
Name |
Description |
| string |
content |
|
| int |
offset |
|
| int |
posAfterStart |
|
Returns
IsValidKeyChar(string, int)
Declaration
protected virtual bool IsValidKeyChar(string content, int offset)
Parameters
| Type |
Name |
Description |
| string |
content |
|
| int |
offset |
|
Returns
IsValidSectionNameChar(string, int)
Declaration
protected virtual bool IsValidSectionNameChar(string content, int offset)
Parameters
| Type |
Name |
Description |
| string |
content |
|
| int |
offset |
|
Returns
LoadTranslation(string, CultureInfo?)
Loads the translation information from the file and returns a translation.
Declaration
public override Translation? LoadTranslation(string translationText, CultureInfo? culture)
Parameters
| Type |
Name |
Description |
| string |
translationText |
The text of the file to load.
|
| CultureInfo |
culture |
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.
|
Returns
| Type |
Description |
| Translation |
The loaded translation or null if loading failed.
|
Overrides
ParseConfiguration(string, Assembly?)
Declaration
public override TranslationConfiguration? ParseConfiguration(string fileContent, Assembly? assembly)
Parameters
Returns
Overrides
UnwrapKey(string)
Strips format-specific markers that denote the beginning and the end of a value.
Declaration
protected abstract string UnwrapKey(string value)
Parameters
| Type |
Name |
Description |
| string |
value |
The value to strip.
|
Returns
| Type |
Description |
| string |
The text inside the markers.
|
UnwrapValue(string)
Strips format-specific markers that denote the beginning and the end of a value.
Declaration
protected abstract (string? escaped, string unescaped) UnwrapValue(string value)
Parameters
| Type |
Name |
Description |
| string |
value |
The value to strip.
|
Returns