Documentation
¶
Overview ¶
Package ini implements an INI file reader/writer with methods to read/write INI files from/to disc and methods to access the section's key/value pairs.
Copyright © 2019, 2024 M.Watermann, 10247 Berlin, Germany
All rights reserved
EMail : <support@mwat.de>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the GNU General Public License along with this program. If not, see the [GNU General Public License](http://www.gnu.org/licenses/gpl.html) for details.
Copyright © 2019, 2024 M.Watermann, 10247 Berlin, Germany
All rights reserved EMail : <support@mwat.de>
Copyright © 2019, 2024 M.Watermann, 10247 Berlin, Germany
All rights reserved EMail : <support@mwat.de>
Copyright © 2019, 2024 M.Watermann, 10247 Berlin, Germany
All rights reserved EMail : <support@mwat.de>
Copyright © 2019, 2024 M.Watermann, 10247 Berlin, Germany
All rights reserved EMail : <support@mwat.de>
Index ¶
- Constants
- type TIniWalker
- type TKeyVal
- func (kv *TKeyVal) AsBool() (rVal bool)
- func (kv *TKeyVal) AsFloat32() (float32, bool)
- func (kv *TKeyVal) AsFloat64() (float64, bool)
- func (kv *TKeyVal) AsInt() (int, bool)
- func (kv *TKeyVal) AsInt8() (int8, bool)
- func (kv *TKeyVal) AsInt16() (int16, bool)
- func (kv *TKeyVal) AsInt32() (int32, bool)
- func (kv *TKeyVal) AsInt64() (int64, bool)
- func (kv *TKeyVal) AsString() (string, bool)
- func (kv *TKeyVal) AsUInt() (uint, bool)
- func (kv *TKeyVal) AsUInt8() (uint8, bool)
- func (kv *TKeyVal) AsUInt16() (uint16, bool)
- func (kv *TKeyVal) AsUInt32() (uint32, bool)
- func (kv *TKeyVal) AsUInt64() (uint64, bool)
- func (kv *TKeyVal) String() string
- func (kv *TKeyVal) UpdateValue(aValue string) bool
- type TSection
- func (ks *TSection) AddKey(aKey, aValue string) bool
- func (ks *TSection) AsBool(aKey string) (bool, bool)
- func (ks *TSection) AsFloat32(aKey string) (float32, bool)
- func (ks *TSection) AsFloat64(aKey string) (float64, bool)
- func (ks *TSection) AsInt(aKey string) (int, bool)
- func (ks *TSection) AsInt8(aKey string) (int8, bool)
- func (ks *TSection) AsInt16(aKey string) (int16, bool)
- func (ks *TSection) AsInt32(aKey string) (int32, bool)
- func (ks *TSection) AsInt64(aKey string) (int64, bool)
- func (ks *TSection) AsString(aKey string) (string, bool)
- func (ks *TSection) AsUInt(aKey string) (uint, bool)
- func (ks *TSection) AsUInt8(aKey string) (uint8, bool)
- func (ks *TSection) AsUInt16(aKey string) (uint16, bool)
- func (ks *TSection) AsUInt32(aKey string) (uint32, bool)
- func (ks *TSection) AsUInt64(aKey string) (uint64, bool)
- func (ks *TSection) Clear() *TSection
- func (ks *TSection) HasKey(aKey string) bool
- func (ks *TSection) IndexOf(aKey string) int
- func (ks *TSection) Len() int
- func (ks *TSection) RemoveKey(aKey string) bool
- func (ks *TSection) String() (rString string)
- func (ks *TSection) UpdateKey(aKey, aValue string) bool
- type TSectionList
- func (sl *TSectionList) AUInt32(aSection, aKey string) (uint32, bool)
- func (sl *TSectionList) AddSectionKey(aSection, aKey, aValue string) bool
- func (sl *TSectionList) AsBool(aSection, aKey string) (bool, bool)
- func (sl *TSectionList) AsFloat32(aSection, aKey string) (rVal float32, rOK bool)
- func (sl *TSectionList) AsFloat64(aSection, aKey string) (rVal float64, rOK bool)
- func (sl *TSectionList) AsInt(aSection, aKey string) (int, bool)
- func (sl *TSectionList) AsInt8(aSection, aKey string) (int8, bool)
- func (sl *TSectionList) AsInt16(aSection, aKey string) (int16, bool)
- func (sl *TSectionList) AsInt32(aSection, aKey string) (int32, bool)
- func (sl *TSectionList) AsInt64(aSection, aKey string) (int64, bool)
- func (sl *TSectionList) AsString(aSection, aKey string) (string, bool)
- func (sl *TSectionList) AsUInt(aSection, aKey string) (uint, bool)
- func (sl *TSectionList) AsUInt8(aSection, aKey string) (uint8, bool)
- func (sl *TSectionList) AsUInt16(aSection, aKey string) (uint16, bool)
- func (sl *TSectionList) AsUInt64(aSection, aKey string) (uint64, bool)
- func (sl *TSectionList) Clear() *TSectionList
- func (sl *TSectionList) Filename() string
- func (sl *TSectionList) GetSection(aSection string) *TSection
- func (sl *TSectionList) HasSection(aSection string) (rOK bool)
- func (sl *TSectionList) HasSectionKey(aSection, aKey string) bool
- func (sl *TSectionList) Len() int
- func (sl *TSectionList) Load() (*TSectionList, error)
- func (sl *TSectionList) Merge(aINI *TSectionList) *TSectionList
- func (sl *TSectionList) RemoveSection(aSection string) bool
- func (sl *TSectionList) RemoveSectionKey(aSection, aKey string) bool
- func (sl *TSectionList) Sections() ([]string, int)
- func (sl *TSectionList) SetFilename(aFilename string) *TSectionList
- func (sl *TSectionList) Store() (int, error)
- func (sl *TSectionList) String() (rString string)
- func (sl *TSectionList) UpdateSectKeyBool(aSection, aKey string, aValue bool) bool
- func (sl *TSectionList) UpdateSectKeyFloat(aSection, aKey string, aValue float64) bool
- func (sl *TSectionList) UpdateSectKeyInt(aSection, aKey string, aValue int64) bool
- func (sl *TSectionList) UpdateSectKeyStr(aSection, aKey, aValue string) bool
- func (sl *TSectionList) UpdateSectKeyUInt(aSection, aKey string, aValue uint64) bool
- func (sl *TSectionList) Walk(aFunc TWalkFunc)
- func (sl *TSectionList) Walker(aWalker TIniWalker)
- type TWalkFunc
Constants ¶
const ( // `DefSection` is the name of the default section in the INI file // which is used when there are key/value pairs in the file // without a preceding section header like `[SectionName]`. DefSection = `Default` )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TIniWalker ¶
type TIniWalker interface {
Walk(aSection, aKey, aVal string)
}
A `TIniWalker` is used by `Walker()` when visiting an entry in the INI list.
see `Walker()`
type TKeyVal ¶
TKeyVal represents an INI key/value pair.
func (*TKeyVal) AsBool ¶ added in v1.5.4
`AsBool()` returns the value as a boolean value.
`0`, `f`, `F`, `n`, and `N` are considered `false` while `1`, `t`, `T`, `y`, and `Y` are considered `true`; these values will be given in the result value.
This method actually checks only the first character of the key's value so one can write e.g. "false" or "NO" (for a `false` result), or "True" or "yes" (for a `true` result).
func (*TKeyVal) AsFloat32 ¶ added in v1.5.4
`AsFloat32()` returns the value of the key/value pair as a 32bit floating point.
If the given `aKey` doesn't exist then the second (`rOK`) return value will be `false`.
If the string is well-formed and near a valid floating point number, `AsFloat32` returns the nearest floating point number rounded using IEEE754 unbiased rounding.
func (*TKeyVal) AsFloat64 ¶ added in v1.5.4
`AsFloat64` returns the value of the key/value pair as a 64bit floating point.
If the string is well-formed and near a valid floating point number, `AsFloat64` returns the nearest floating point number rounded using IEEE754 unbiased rounding.
func (*TKeyVal) AsInt ¶ added in v1.5.4
`AsInt()` returns the value of the key/value pair as an integer.
func (*TKeyVal) AsInt8 ¶ added in v1.6.0
`AsInt8()` returns the value of the key/value pair as an integer.
func (*TKeyVal) AsInt16 ¶ added in v1.5.4
`AsInt16()` returns the value of the key/value pair as a 16bit integer.
func (*TKeyVal) AsInt32 ¶ added in v1.5.4
`AsInt32()` returns the value of the key/value pair as a 32bit integer.
func (*TKeyVal) AsInt64 ¶ added in v1.5.4
`AsInt64()` returns the value of the key/value pair as a 64bit integer.
func (*TKeyVal) AsString ¶ added in v1.5.4
`AsString()` returns the value of the key's value as a string.
The second return value will be `true` (it exists for symmetry only).
func (*TKeyVal) AsUInt ¶ added in v1.6.0
`AsUInt()` returns the value of the key/value pair as an unsigned integer.
func (*TKeyVal) AsUInt8 ¶ added in v1.6.0
`AsUInt8()` returns the value of the key/value pair as an unsigned 8bit integer.
func (*TKeyVal) AsUInt16 ¶ added in v1.6.0
`AsUInt16()` returns the value of the key/value pair as an unsigned 16bit integer.
func (*TKeyVal) AsUInt32 ¶ added in v1.6.0
`AsUInt32()` returns the value of the key/value pair as an unsigned 32bit integer.
func (*TKeyVal) AsUInt64 ¶ added in v1.6.0
`AsUInt64()` returns the value of the key/value pair as an unsigned 64bit integer.
func (*TKeyVal) String ¶
`String()` returns a string representation of the key/value pair.
The returned string follows the pattern `Key = value`.
func (*TKeyVal) UpdateValue ¶ added in v1.5.4
`UpdateValue()` replaces the current value of the key/value pair by the provided new `aValue`.
`aValue` The value of the key/value pair to update.
type TSection ¶
type TSection []TKeyVal
`TSection` is a slice of key/value pairs.
func ReadIniData ¶ added in v1.5.0
func (*TSection) AddKey ¶
`AddKey()` appends a new key/value pair returning `true` on success or `false` otherwise.
If `aKey` is an empty string the method's result will be the result of `ks.RemoveKey(aKey)` i.e. usually `true`. If `aKey` already exist its value will be updated by `aValue`. If `aKey` doesn't exist in the section's list a new key/value pair will be appended.
`aKey` The key of the key/value pair to add. `aValue` The value of the key/value pair to add.
func (*TSection) AsBool ¶
`AsBool()` returns the value of `aKey` as a boolean value.
If the given `aKey` doesn't exist then the second (bool) return value will be `false`.
`0`, `f`, `F`, `n`, and `N` are considered `false` while `1`, `t`, `T`, `y`, and `Y` are considered `true`; these values will be given in the first result value. All other values will give `false` as the second result value.
This method actually checks only the first character of the key's value so one can write e.g. "false" or "NO" (for a `false` result), or "True" or "yes" (for a `true` result).
`aKey` The name of the key to lookup.
func (*TSection) AsFloat32 ¶
`AsFloat32()` returns the value of `aKey` as a 32bit floating point.
If the given `aKey` doesn't exist then the second return value will be `false`.
If the string is well-formed and near a valid floating point number, `AsFloat32` returns the nearest floating point number rounded using IEEE754 unbiased rounding.
`aKey` The name of the key to lookup.
func (*TSection) AsFloat64 ¶
`AsFloat64()` returns the value of `aKey` as a 64bit floating point.
If the given `aKey` doesn't exist then the second return value will be `false`.
If the string is well-formed and near a valid floating point number, `AsFloat64` returns the nearest floating point number rounded using IEEE754 unbiased rounding.
aKey` the name of the key to lookup.
func (*TSection) AsInt ¶
`AsInt()` returns the value of `aKey` as an integer.
If the given `aKey` doesn't exist then the second return value will be `false`.
`aKey` The name of the key to lookup.
func (*TSection) AsInt8 ¶ added in v1.6.0
`AsInt8()` returns the value of `aKey` as an 8bit integer.
If the given `aKey` doesn't exist then the second return value will be `false`.
`aKey` The name of the key to lookup.
func (*TSection) AsInt16 ¶
`AsInt16()` returns the value of `aKey` as a 16bit integer.
If the given `aKey` doesn't exist then the second return value will be `false`.
`aKey` The name of the key to lookup.
func (*TSection) AsInt32 ¶
`AsInt32()` returns the value of `aKey` as a 32bit integer.
If the given `aKey` doesn't exist then the second return value will be `false`.
`aKey` The name of the key to lookup.
func (*TSection) AsInt64 ¶
`AsInt64()` returns the value of `aKey` as a 64bit integer.
If the given `aKey` doesn't exist then the second return value will be `false`.
`aKey` The name of the key to lookup.
func (*TSection) AsString ¶
`AsString()` returns the value of `aKey` as a string.
If the given `aKey` doesn't exist then the second return value will be `false`.
`aKey` The name of the key to lookup.
func (*TSection) AsUInt ¶ added in v1.6.0
`AsUInt()` returns the value of `aKey` as an unsigned integer.
If the given `aKey` doesn't exist then the second return value will be `false`.
`aKey` The name of the key to lookup.
func (*TSection) AsUInt8 ¶ added in v1.6.0
`AsUInt8()` returns the value of `aKey` as an unsigned 8bit integer.
If the given `aKey` doesn't exist then the second return value will be `false`.
`aKey` The name of the key to lookup.
func (*TSection) AsUInt16 ¶ added in v1.6.0
`AsInt16()` returns the value of `aKey` as an unsigned 16bit integer.
If the given `aKey` doesn't exist then the second return value will be `false`.
`aKey` The name of the key to lookup.
func (*TSection) AsUInt32 ¶ added in v1.6.0
`AsInt32()` returns the value of `aKey` as an unsigned 32bit integer.
If the given `aKey` doesn't exist then the second return value will be `false`.
`aKey` The name of the key to lookup.
func (*TSection) AsUInt64 ¶ added in v1.6.0
`AsUInt64()` returns the value of `aKey` as an unsigned 64bit integer.
If the given `aKey` doesn't exist then the second return value will be `false`.
`aKey` The name of the key to lookup.
func (*TSection) Clear ¶
`Clear()` removes all entries in this INI section.
It returns a pointer to the same section, so that you can chain method calls like this:
ks.Clear().AddKey("key", "value")
This method does not return any error, because it does not perform any I/O operation.
func (*TSection) HasKey ¶
`HasKey()` returns whether `aKey` exists in this INI section.
`aKey` The key to lookup.
Returns:
`true` if aKey exists in the section, false otherwise.
func (*TSection) IndexOf ¶ added in v1.1.0
`IndexOf()` returns the index of `aKey` in this INI section or `-1` if not found.
`aKey` The key to lookup.
func (*TSection) Len ¶ added in v1.2.0
`Len()` returns the number of key/value pairs in this section.
func (*TSection) RemoveKey ¶
`RemoveKey()` removes `aKey` from this section.
This method returns 'true' if `aKey` doesn't exist at all, or if `aKey` was successfully removed, and `false` otherwise.
`aKey` The name of the key/value pair to remove.
func (*TSection) String ¶
`String()` returns a string representation of an INI section.
The single key/value pairs are delimited by a linefeed ('\n).
func (*TSection) UpdateKey ¶
`UpdateKey()` replaces the current value of `aKey` by the provided new `aValue`.
In case `aKey` doesn't already exist in the list (and therefore can't be updated) it will be added by calling the `AddKey()` method.
If `aKey` is an empty string the method's result will be `false`.
`aKey` The key of the key/value pair to update. `aValue` The value of the key/value pair to update.
type TSectionList ¶ added in v1.6.0
type TSectionList tIniSectionsList
`TSectionList` is a list of INI sections.
This opaque data structure is filled by e.g. `Load(…)`.
For accessing the sections and key/value pairs it provides the appropriate methods.
func New ¶ added in v1.3.0
func New(aFilename string) (*TSectionList, error)
`New()` reads the given `aFilename` returning the data structure read from that INI file and a possible error condition.
This function reads one line at a time of the INI file skipping both empty lines and comments (identified by '#' or ';' at line start).
`aFilename` The name of the INI file to read.
func (*TSectionList) AUInt32 ¶ added in v1.6.0
func (sl *TSectionList) AUInt32(aSection, aKey string) (uint32, bool)
`AsUInt32()` return the value of `aKey` in `aSection` as a 32bit integer.
If the given `aKey` in `aSection` doesn't exist then the second return value will be `false`.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AddSectionKey ¶ added in v1.6.0
func (sl *TSectionList) AddSectionKey(aSection, aKey, aValue string) bool
`AddSectionKey()` appends a new key/value pair to `aSection` returning `true` on success or `false` otherwise.
`aSection` The name of the INI section to use. `aKey` The key of the key/value pair to add. `aValue` The value of the key/value pair to add.
func (*TSectionList) AsBool ¶ added in v1.6.0
func (sl *TSectionList) AsBool(aSection, aKey string) (bool, bool)
`AsBool()` returns the value of `aKey` in `aSection` as a boolean value.
If the given aKey in `aSection` doesn't exist then the second (bool) return value will be `false`.
`0`, `f`, `F`, `n`, and `N` are considered `false` while `1`, `t`, `T`, `y`, `Y`, `j`, `J`, `o`, `O` are considered `true`; these values will be given in the first result value. All other values will give `false` as the second result value.
This method actually checks only the first character of the key's value so one can write e.g. "false" or "NO" (for a `false` result), or "True" or "yes" (for a `true` result).
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AsFloat32 ¶ added in v1.6.0
func (sl *TSectionList) AsFloat32(aSection, aKey string) (rVal float32, rOK bool)
`AsFloat32` returns the value of `aKey` in `aSection` as a 32bit floating point.
If the given `aKey` in `aSection` doesn't exist then the second (bool) return value will be `false`.
If the key's value is well-formed and near a valid floating point number, `AsFloat32` returns the nearest floating point number rounded using IEEE754 unbiased rounding.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AsFloat64 ¶ added in v1.6.0
func (sl *TSectionList) AsFloat64(aSection, aKey string) (rVal float64, rOK bool)
`AsFloat64` returns the value of `aKey` in `aSection` as a 64bit floating point.
If the given `aKey` in `aSection` doesn't exist then the second (`rOK`) return value will be `false`.
If the key's value is well-formed and near a valid floating point number, `AsFloat64` returns the nearest floating point number rounded using IEEE754 unbiased rounding.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AsInt ¶ added in v1.6.0
func (sl *TSectionList) AsInt(aSection, aKey string) (int, bool)
`AsInt()` returns the value of `aKey` in `aSection` as an integer.
If the given `aKey` in `aSection` doesn't exist then the second return value will be `false`.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AsInt8 ¶ added in v1.6.0
func (sl *TSectionList) AsInt8(aSection, aKey string) (int8, bool)
`AsInt8()` returns the value of `aKey` in `aSection` as a 8bit integer.
If the given `aKey` in `aSection` doesn't exist then the second return value will be `false`.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AsInt16 ¶ added in v1.6.0
func (sl *TSectionList) AsInt16(aSection, aKey string) (int16, bool)
`AsInt16()` return the value of `aKey` in `aSection` as a 16bit integer.
If the given `aKey` in `aSection` doesn't exist then the second return value will be `false`.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AsInt32 ¶ added in v1.6.0
func (sl *TSectionList) AsInt32(aSection, aKey string) (int32, bool)
`AsInt32()` return the value of `aKey` in `aSection` as a 32bit integer.
If the given `aKey` in `aSection` doesn't exist then the second return value will be `false`.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AsInt64 ¶ added in v1.6.0
func (sl *TSectionList) AsInt64(aSection, aKey string) (int64, bool)
`AsInt64()` return the value of `aKey` in `aSection` as a 64bit integer.
If the given `aKey` in `aSection` doesn't exist then the second return value will be `false`.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AsString ¶ added in v1.6.0
func (sl *TSectionList) AsString(aSection, aKey string) (string, bool)
`AsString()` returns the value of `aKey` in `aSection` as a string.
If the given `aKey` in `aSection` doesn't exist then the second return value will be `false`.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AsUInt ¶ added in v1.6.0
func (sl *TSectionList) AsUInt(aSection, aKey string) (uint, bool)
`AsUInt()` returns the value of `aKey` in `aSection` as an integer.
If the given `aKey` in `aSection` doesn't exist then the second return value will be `false`.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AsUInt8 ¶ added in v1.6.0
func (sl *TSectionList) AsUInt8(aSection, aKey string) (uint8, bool)
`AsUInt8()` returns the value of `aKey` in `aSection` as a 8bit integer.
If the given `aKey` in `aSection` doesn't exist then the second return value will be `false`.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AsUInt16 ¶ added in v1.6.0
func (sl *TSectionList) AsUInt16(aSection, aKey string) (uint16, bool)
`AsUInt16()` return the value of `aKey` in `aSection` as a 16bit integer.
If the given `aKey` in `aSection` doesn't exist then the second return value will be `false`.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) AsUInt64 ¶ added in v1.6.0
func (sl *TSectionList) AsUInt64(aSection, aKey string) (uint64, bool)
`AsUInt64()` return the value of `aKey` in `aSection` as an unsigned 64bit integer.
If the given `aKey` in `aSection` doesn't exist then the second return value will be `false`.
`aSection` the name of the INI section to lookup. `aKey` The name of the key to lookup.
func (*TSectionList) Clear ¶ added in v1.6.0
func (sl *TSectionList) Clear() *TSectionList
`Clear()` empties the internal data structures.
This method can be called once the program has used the config values stored in the INI file to setup the application. Emptying these data structures should help the garbage collector to release the data not needed anymore.
The return value is the cleared list.
func (*TSectionList) Filename ¶ added in v1.6.0
func (sl *TSectionList) Filename() string
`Filename()` returns the configured filename of the INI file.
func (*TSectionList) GetSection ¶ added in v1.6.0
func (sl *TSectionList) GetSection(aSection string) *TSection
`GetSection()` returns the INI section named `aSection`, or an empty list if not found.
`aSection` The name of the INI section to lookup.
func (*TSectionList) HasSection ¶ added in v1.6.0
func (sl *TSectionList) HasSection(aSection string) (rOK bool)
`HasSection()` checks whether the INI data contain `aSection`.
`aSection` is the name of the INI section to lookup.
func (*TSectionList) HasSectionKey ¶ added in v1.6.0
func (sl *TSectionList) HasSectionKey(aSection, aKey string) bool
`HasSectionKey()` checks whether the INI data contain `aSection` with `aKey` returning whether it exists at all.
`aSection` The INI section to lookup. `aKey` The key name to lookup in `aSection`.
func (*TSectionList) Len ¶ added in v1.6.0
func (sl *TSectionList) Len() int
`Len()` returns the number of INI sections.
It is used to determine the size of the list of sections.
Returns:
rOK: The number of sections in the INI file.
func (*TSectionList) Load ¶ added in v1.6.0
func (sl *TSectionList) Load() (*TSectionList, error)
`Load()` reads the configured filename returning the data structure read from the INI file and a possible error condition.
This method reads one line at a time of the INI file skipping both empty lines and comments (identified by '#' or ';' at line start).
Returns:
*TSectionList: The loaded INI list. error: A possible error condition.
func (*TSectionList) Merge ¶ added in v1.6.0
func (sl *TSectionList) Merge(aINI *TSectionList) *TSectionList
`Merge()` copies or merges all INI sections with all key/value pairs into this list.
Returns:
`aINI` The INI list to merge with this one.
func (*TSectionList) RemoveSection ¶ added in v1.6.0
func (sl *TSectionList) RemoveSection(aSection string) bool
`RemoveSection()` deletes `aSection` from the list of INI sections.
Parameters:
`aSection` The name of the INI section to remove.
Returns:
bool: `true` on success, `false` on failure.
func (*TSectionList) RemoveSectionKey ¶ added in v1.6.0
func (sl *TSectionList) RemoveSectionKey(aSection, aKey string) bool
`RemoveSectionKey()` removes aKey from aSection.
This method returns 'true' if either `aSection` or `aKey` doesn't exist or if `aKey` in `aSection` was successfully removed, or `false` otherwise.
Parameters:
`aSection` is the name of the INI section to use. `aKey` The name of the key/value pair to remove.
Returns:
bool: `true` on success, `false` on failure.
func (*TSectionList) Sections ¶ added in v1.6.0
func (sl *TSectionList) Sections() ([]string, int)
`Sections()` returns a list of section names in the order they appear in the INI file.
The returned list is a slice of strings. The length of the slice is the number of sections in the INI file.
Returns:
The number of sections in the returned list.
func (*TSectionList) SetFilename ¶ added in v1.6.0
func (sl *TSectionList) SetFilename(aFilename string) *TSectionList
`SetFilename()` sets the filename of the INI file to use.
Parameters:
`aFilename` The name to use for the INI file.
func (*TSectionList) Store ¶ added in v1.6.0
func (sl *TSectionList) Store() (int, error)
`Store()` writes all INI data to the configured filename returning the number of bytes written and a possible error.
func (*TSectionList) String ¶ added in v1.6.0
func (sl *TSectionList) String() (rString string)
String() returns a string representation of the INI section list.
func (*TSectionList) UpdateSectKeyBool ¶ added in v1.6.0
func (sl *TSectionList) UpdateSectKeyBool(aSection, aKey string, aValue bool) bool
`UpdateSectKeyBool()` replaces the current value of `aKey` in `aSection` by the provided new `aValue` boolean.
If the given `aValue` is `true` then the string "true" is used otherwise the string "false".
`aSection` The name of the INI section to lookup. `aKey` The name of the key/value pair to use. `aValue` The boolean value of the key/value pair to update.
func (*TSectionList) UpdateSectKeyFloat ¶ added in v1.6.0
func (sl *TSectionList) UpdateSectKeyFloat(aSection, aKey string, aValue float64) bool
`UpdateSectKeyFloat()` replaces the current value of aKey in `aSection` by the provided new `aValue` float.
`aSection` The name of the INI section to lookup. `aKey` The name of the key/value pair to use. `aValue` The float64 value of the key/value pair to update.
func (*TSectionList) UpdateSectKeyInt ¶ added in v1.6.0
func (sl *TSectionList) UpdateSectKeyInt(aSection, aKey string, aValue int64) bool
`UpdateSectKeyInt()` replaces the current value of `aKey` in `aSection` by the provided new `aValue` integer.
`aSection` The name of the INI section to lookup. `aKey` The name of the key/value pair to use. `aValue` The int64 value of the key/value pair to update.
func (*TSectionList) UpdateSectKeyStr ¶ added in v1.6.0
func (sl *TSectionList) UpdateSectKeyStr(aSection, aKey, aValue string) bool
`UpdateSectKeyStr` replaces the current value of `aKey` in `aSection` by the provided new `aValue` string.
`aSection` The name of the INI section to lookup. `aKey` The name of the key/value pair to use. `aValue` The string value of the key/value pair to update.
func (*TSectionList) UpdateSectKeyUInt ¶ added in v1.6.0
func (sl *TSectionList) UpdateSectKeyUInt(aSection, aKey string, aValue uint64) bool
`UpdateSectKeyUInt()` replaces the current value of `aKey` in `aSection` by the provided new `aValue` unsigned integer.
`aSection` The name of the INI section to lookup. `aKey` The name of the key/value pair to use. `aValue` The int64 value of the key/value pair to update.
func (*TSectionList) Walk ¶ added in v1.6.0
func (sl *TSectionList) Walk(aFunc TWalkFunc)
`Walk()` traverses through all entries in the INI list sections calling `aFunc` for each entry.
`aFunc` The function called for each key/value pair in all sections.
func (*TSectionList) Walker ¶ added in v1.6.0
func (sl *TSectionList) Walker(aWalker TIniWalker)
`Walker()` traverses through all entries in the INI list sections calling `aWalker` for each entry.
`aWalker` An object implementing the `TIniWalker` interface.