inilike.common

Common functions for dealing with entries in ini-like file.

Members

Aliases

chooseLocalizedValue
alias chooseLocalizedValue = selectLocalizedValue
Undocumented in source.

Functions

boolToString
string boolToString(bool b)

Convert bool to string. Can be used to set boolean values.

doUnescape
inout(char)[] doUnescape(inout(char)[] value, Tuple!(char, char)[] pairs)

Unescape value. If value does not need unescaping this function returns original value.

dropEncodingPart
String dropEncodingPart(String locale)

Drop encoding part from locale (it's not used in constructing localized keys).

escapeValue
String escapeValue(String value)

Escapes string by replacing special symbols with escaped sequences. These symbols are: '\\' (backslash), '\n' (newline), '\r' (carriage return) and '\t' (tab).

isBoolean
bool isBoolean(const(char)[] value)

Check if the entry value can be interpreted as boolean value.

isComment
bool isComment(const(char)[] s)

Test whether the string represents a comment.

isFalse
bool isFalse(const(char)[] value)

Test whether the entry value represents false.

isGroupHeader
bool isGroupHeader(const(char)[] s)

Test whether the string represents a group header. Note: "[]" is not considered to be a valid group header.

isTrue
bool isTrue(const(char)[] value)

Test whether the entry value represents true.

isValidDesktopFileKey
bool isValidDesktopFileKey(const(char)[] desktopKey)

Test whether the string is valid key in terms of Desktop File Specification.

isValidKey
bool isValidKey(const(char)[] key)

Test whether the string is valid key, i.e. does not need escaping, is not a comment and not empty string.

keyValueTuple
auto keyValueTuple(String key, String value)
Undocumented in source. Be warned that the author may not have intended to support it.
localizedKey
String localizedKey(String key, String locale)

Construct localized key name from key and locale.

localizedKey
String localizedKey(String key, String lang, String country, String modifier)

ditto, but constructs locale name from arguments.

makeLocaleName
String makeLocaleName(String lang, String country, String encoding, String modifier)

Make locale name based on language, country, encoding and modifier.

needEscaping
bool needEscaping(String value)

Check if value needs to be escaped. This function is currently tolerant to single slashes and tabs.

parseGroupHeader
auto parseGroupHeader(inout(char)[] s)

Retrieve group name from header entry.

parseKeyValue
auto parseKeyValue(String s)

Parse entry of kind Key=Value into pair of Key and Value.

parseLocaleName
auto parseLocaleName(String locale)

Parse locale name into the tuple of 4 values corresponding to language, country, encoding and modifier

selectKeyLocale
auto selectKeyLocale(String locale, String firstKeyLocale, String secondKeyLocale)

Between two key locales (i.e. locales found in keys of .ini-like file) select a better match for the provided locale. The "goodness" is determined using algorithm described in Localized values for keys.

selectLocalizedValue
auto selectLocalizedValue(String locale, String firstLocale, String firstValue, String secondLocale, String secondValue)

Same as selectKeyLocale, but returns a locale bundled with a value in one tuple.

separateFromLocale
auto separateFromLocale(String key)

Separate key name into non-localized key and locale name. If key is not localized returns original key and empty string.

unescapeValue
inout(char)[] unescapeValue(inout(char)[] value)

Unescapes string. You should unescape values returned by library before displaying until you want keep them as is (e.g., to allow user to edit values in escaped form).

See Also

Meta