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) Parent() *KeyValue
- func (node *KeyValue) Patch(parent *KeyValue) (merged KeyValue, err error)
- func (node *KeyValue) RemoveChild(key string) error
- func (node *KeyValue) Replace(parent *KeyValue) (merged KeyValue, err error)
- 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
}
KeyValue object, that may hold multiple Values
func NewKeyValuePair ¶ added in v1.4.0
NewKeyValuePair allows for manual creation of a single KeyValue pair.
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) Patch ¶ added in v1.3.0
Patch merges this KeyValue tree into another, adding KeyValues that don't exist in the parent.
func (*KeyValue) RemoveChild ¶ added in v1.2.3
RemoveChild removes a KeyValue from a parent 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.