Documentation ¶
Index ¶
- func ParseLocation(strval string) (uo.Location, error)
- func ParseTagLine(line string) (string, string, error)
- func RangeExpression(e string, rng RandomSource) int
- type ListFileReader
- func (f *ListFileReader) Errors() []error
- func (f *ListFileReader) HasErrors() bool
- func (f *ListFileReader) ReadNextSegment() *ListFileSegment
- func (f *ListFileReader) ReadSegments(r io.Reader) []*ListFileSegment
- func (f *ListFileReader) SkipCurrentSegment() bool
- func (f *ListFileReader) StartReading(r io.Reader)
- func (f *ListFileReader) StreamNextEntry() string
- func (f *ListFileReader) StreamNextSegmentHeader() string
- type ListFileSegment
- type Queue
- type RNG
- type RandomSource
- type Registry
- type Slice
- type SliceElement
- type TagFileObject
- func (o *TagFileObject) Errors() []error
- func (o *TagFileObject) GetBool(name string, def bool) bool
- func (o *TagFileObject) GetBounds(name string, def uo.Bounds) uo.Bounds
- func (o *TagFileObject) GetFloat(name string, def float32) float32
- func (o *TagFileObject) GetHex(name string, def uint32) uint32
- func (o *TagFileObject) GetLocation(name string, def uo.Location) uo.Location
- func (o *TagFileObject) GetNumber(name string, def int) int
- func (o *TagFileObject) GetObjectReferences(name string) []uo.Serial
- func (o *TagFileObject) GetString(name, def string) string
- func (o *TagFileObject) GetULong(name string, def uint64) uint64
- func (o *TagFileObject) HandlePropertyLine(line string) error
- func (o *TagFileObject) HasErrors() bool
- func (o *TagFileObject) InjectError(err error)
- func (o *TagFileObject) Map(fn func(name, value string) error) []error
- func (o *TagFileObject) Set(name, value string)
- func (o *TagFileObject) TypeName() string
- type TagFileReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RangeExpression ¶
func RangeExpression(e string, rng RandomSource) int
RangeExpression parses a string expression and returns a number, possibly randomly selected from a set or range.
Types ¶
type ListFileReader ¶
type ListFileReader struct {
// contains filtered or unexported fields
}
ListFileReader reads ini-like list files
func (*ListFileReader) Errors ¶
func (f *ListFileReader) Errors() []error
Errors returns the slice of all accumulated errors
func (*ListFileReader) HasErrors ¶
func (f *ListFileReader) HasErrors() bool
HasErrors returns true if there are any errors
func (*ListFileReader) ReadNextSegment ¶
func (f *ListFileReader) ReadNextSegment() *ListFileSegment
ReadNextSegment returns the next segment in the current reader stream or nil if the end of the stream has been reached. Use HasErrors and Errors to see if there were errors in execution.
func (*ListFileReader) ReadSegments ¶
func (f *ListFileReader) ReadSegments(r io.Reader) []*ListFileSegment
ReadSegments returns all of the list segments from the reader. Use HasErrors and Errors to look for error conditions found within the file.
func (*ListFileReader) SkipCurrentSegment ¶
func (f *ListFileReader) SkipCurrentSegment() bool
SkipCurrentSegment runs the file forward to the start of the next segment header. StreamNextSegment and ReadNextSegment are both sane to call after a call to SkipCurrentSegment. On error or end of file this function returns false. The error state can be inspected after this call with HasErrors and Errors.
func (*ListFileReader) StartReading ¶
func (f *ListFileReader) StartReading(r io.Reader)
StartReading should be called to begin reading from a new reader
func (*ListFileReader) StreamNextEntry ¶
func (f *ListFileReader) StreamNextEntry() string
StreamNextEntry continues reading the list file until the next non-empty, non-comment line. It expects this line to be an entry line (not a segment header). The empty string return value means no more entries in this segment, or an error condition. Use HasErrors and Errors to inspect the error state.
func (*ListFileReader) StreamNextSegmentHeader ¶
func (f *ListFileReader) StreamNextSegmentHeader() string
StreamNextSegmentHeader continues reading the list file until the next non- empty, non-comment line. It expects this line to be a segment header in the form [SEGMENT_NAME] . The name of the segment is returned. The empty string means end of file or error. Use HasErrors and Errors to inspect the error state.
type ListFileSegment ¶
ListFileSegment represents one segment of the list file
type Queue ¶
type Queue[V any] struct { // contains filtered or unexported fields }
Queue manages a queue of values with a maximum capacity.
func (*Queue[V]) Dequeue ¶
func (q *Queue[V]) Dequeue() V
Dequeue removes and returns the first element of the queue.
type RNG ¶
type RNG struct {
// contains filtered or unexported fields
}
RNG is a statefull, NON-thread-safe random number generator
func NewRNG ¶
func NewRNG() *RNG
NewRNG returns a new RNG object seeded with the current millisecond time.
type RandomSource ¶
type RandomSource interface { // Random returns a random int value between min and max inclusive Random(int, int) int }
RandomSource is the interface sources of psuedo-random numbers that the Random* functions expect.
type Registry ¶
type Registry[K comparable, V any] struct { // contains filtered or unexported fields }
Registry is a managed map that only supports Add and Get operations. This is used in the factory pattern as well as a few other things.
func NewRegistry ¶
func NewRegistry[K comparable, V any](name string) *Registry[K, V]
NewRegistry returns a new Registry ready for use.
func (*Registry[K, V]) Add ¶
func (r *Registry[K, V]) Add(k K, v V)
Add adds a value to the registry
func (*Registry[K, V]) Get ¶
Get returns the value associated with key and has the same semantics as looking up a map key
type Slice ¶
type Slice[T SliceElement] []T
Slice is a generic wrapper around slices of objects
type SliceElement ¶
type TagFileObject ¶
type TagFileObject struct {
// contains filtered or unexported fields
}
TagFileObject is the intermediate representation of an object in tag file format.
func NewTagFileObject ¶
func NewTagFileObject() *TagFileObject
NewTagFileObject creates a new TagFileObject for the given tag file reader.
func (*TagFileObject) Errors ¶
func (o *TagFileObject) Errors() []error
Errors returns a slice of all of the errors encountered by this object.
func (*TagFileObject) GetBool ¶
func (o *TagFileObject) GetBool(name string, def bool) bool
GetBool returns the named property as a boolean value or the default if not found. This function may add errors to the internal error slice.
func (*TagFileObject) GetBounds ¶
GetBounds returns a uo.Bounds value. The default value is returned if the named tag is not found.
func (*TagFileObject) GetFloat ¶
func (o *TagFileObject) GetFloat(name string, def float32) float32
GetFloat returns the named property as a float32 or the default if not found. This function may add errors to the internal error slice.
func (*TagFileObject) GetHex ¶
func (o *TagFileObject) GetHex(name string, def uint32) uint32
GetHex returns the named property as an unsigned number or the default if not found. This function may add errors to the internal error slice.
func (*TagFileObject) GetLocation ¶
GetLocation returns a uo.Location value. The default value is returned if the named tag is not found.
func (*TagFileObject) GetNumber ¶
func (o *TagFileObject) GetNumber(name string, def int) int
GetNumber returns the named property as a number or the default if not found. This function may add errors to the internal error slice.
func (*TagFileObject) GetObjectReferences ¶
func (o *TagFileObject) GetObjectReferences(name string) []uo.Serial
GetObjectReferences returns a slice of uo.Serial values. nil is the default value. This function may add errors to the internal error slice.
func (*TagFileObject) GetString ¶
func (o *TagFileObject) GetString(name, def string) string
GetString returns the named property as a string or the default if not found.
func (*TagFileObject) GetULong ¶
func (o *TagFileObject) GetULong(name string, def uint64) uint64
GetULong returns the named property as a uint64 or the default if not found. This function may add errors to the internal error slice. Only use this for actual 64-bit values, like uo.Time.
func (*TagFileObject) HandlePropertyLine ¶
func (o *TagFileObject) HandlePropertyLine(line string) error
HandlePropertyLine attempts to handle a single property line in the file.
func (*TagFileObject) HasErrors ¶
func (o *TagFileObject) HasErrors() bool
HasErrors returns true if the object has encountered any errors.
func (*TagFileObject) InjectError ¶
func (o *TagFileObject) InjectError(err error)
InjectError injects the error into this object's error slice. This is used by higher-level data loading functions to report out errors without panicing.
func (*TagFileObject) Map ¶
func (o *TagFileObject) Map(fn func(name, value string) error) []error
Map executes fn for every key/value pair in the object.
func (*TagFileObject) Set ¶
func (o *TagFileObject) Set(name, value string)
Set adds or overwrites the raw string associated with the name
func (*TagFileObject) TypeName ¶
func (o *TagFileObject) TypeName() string
TypeName returns the type name of the object described
type TagFileReader ¶
type TagFileReader struct {
ListFileReader
}
TagFileReader reads objects from tag files.
func (*TagFileReader) ReadObject ¶
func (f *TagFileReader) ReadObject() *TagFileObject
ReadObject returns the next object in the file, or nil if no more objects are in the current file. Use HasErrors and Errors to see if there were errors.