Documentation
¶
Index ¶
- Constants
- type KeyValue
- func (node *KeyValue) AddChild(value *KeyValue) error
- func (node *KeyValue) AsFloat() (float32, error)
- func (node *KeyValue) AsInt() (int32, error)
- func (node *KeyValue) AsString() (string, error)
- func (node *KeyValue) Children() (children []*KeyValue, err error)
- func (node *KeyValue) Find(key string) (*KeyValue, error)
- func (node *KeyValue) FindAll(key string) (children []*KeyValue, err error)
- func (node *KeyValue) HasChildren() bool
- func (node *KeyValue) Key() string
- func (node *KeyValue) MergeInto(parent *KeyValue) (merged KeyValue, err error)
- func (node *KeyValue) Parent() *KeyValue
- func (node *KeyValue) Type() ValueType
- type Reader
- type ValueType
Constants ¶
const ValueArray = ValueType("array")
const ValueFloat = ValueType("float")
const ValueInt = ValueType("integer")
const ValuePtr = ValueType("ptr")
const ValueString = ValueType("string")
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyValue ¶
type KeyValue struct {
// contains filtered or unexported fields
}
A KeyValue object, that may hold multiple Values
func (*KeyValue) AddChild ¶
Add adds a new KeyValue pair to an existing Key Existing key's value must be an Array type
func (*KeyValue) Children ¶
GetChildren gets all node child values This is used for keys that contain 1 or more children as its value rather than a basic type
func (*KeyValue) Find ¶
Find returns a keyvalue pair where the key matches input It will return the first found KeyValue in cases where the key is defined multiple times
func (*KeyValue) FindAll ¶
FindAll returns all children of a given type for a node. This is different from properties, as a property is a string:<primitive> This will return an array of all KeyValues that match a given key, even though there should be only one.
func (*KeyValue) HasChildren ¶
HasChildren returns if this Key has KeyValues as its own value.
func (*KeyValue) MergeInto ¶ added in v1.2.0
MergeInto merges this KeyValue tree into another. The resultant tree will contain all nodes in the same tree from both this and the target. In the case where a key exists in both trees, this key's value will replace the parent's value
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is used for parsing a KeyValue format stream There are various KeyValue based formats (vmt, vmf, gameinfo.txt etc.) This should be able to parse all of them.