Documentation ¶
Overview ¶
Package dot implements a container of named stringmaps.
Yes, it's just a tree of strings and Stringers - free of duplicate names.
And, yes, it's recursive. And, yes it's concurrency-safe. And, yes it carries stuff as You name it. And, yes it can also carry arbitrary Stringers - things which can name themselves. And, yes it supports concurrency via generic piping functions - found elsewhere.
Children can be obtained as map[string]string, and as sorted slice []string
Thus, it can be used as an iterated map "map[string]map[string]...map[string]string" or as an iterated slice "[]...[]string"
Any of it's elements has a name (=string) and (optionally) a map of named elements, the key's of which are strings, and the values are elements, which are strings which are the name of an (optional) map of named elements, the key's of which are strings, and the values are elements, which are strings which are the name of an (optional) map of named elements, the key's of which are strings, and the values are elements, which are strings which are the name of an (optional) map of named elements, the key's of which are strings, and the values are elements, ...
Such structure can be useful when information is acquired recursivlely such as by parsing some object (directory, template, URL, ...), which contains and 'reveals' additional information when being parsed/inspected.
Information, which 'reveals' additional information when being parsed/inspected.
...
Such can be used e.g. in selfdefining template structures Such may be extended to all kind's of types which are suitable as both key and value of a map.
This prototype has it's focus on type "string", as this is helpful in dynamic handling of template-driven processes.
Index ¶
- Constants
- type AssignFriendly
- type ChildFriendly
- type DeleteFriendly
- type Dot
- func (d *Dot) A(vals ...string) string
- func (d *Dot) AddMap(key string, val ...map[string]string) *Dot
- func (d *Dot) AddStringS(key string, val ...[]string) *Dot
- func (d *Dot) AddStrings(key string, val ...string) *Dot
- func (d *Dot) AssignMs(val ...map[string]string) *Dot
- func (d *Dot) AssignSs(val ...[]string) *Dot
- func (d *Dot) Assignss(vals ...string) *Dot
- func (d *Dot) Back() *Dot
- func (d *Dot) Clone() *Dot
- func (d *Dot) DeleteMs(vals ...map[string]string) *Dot
- func (d *Dot) DeleteSs(vals ...[]string) *Dot
- func (d *Dot) Deletess(vals ...string) *Dot
- func (d *Dot) Dot() interface{}
- func (d *Dot) DotDot(key, val string) *Dot
- func (d *Dot) DotDotDots() []*Dot
- func (d *Dot) DownS() []*Dot
- func (d *Dot) FprintTree(w io.Writer, pfx ...string) *Dot
- func (d *Dot) G(keys ...string) *Dot
- func (d *Dot) Home() *Dot
- func (d *Dot) Level() int
- func (d *Dot) Path() []*Dot
- func (d *Dot) PathBase() string
- func (d *Dot) PathClean() string
- func (d *Dot) PathDir() string
- func (d *Dot) PathDown() string
- func (d *Dot) PathExt() string
- func (d *Dot) PathIsAbs() bool
- func (d *Dot) PathJoin(elem ...string) string
- func (d *Dot) PathJoinThese(elem ...string) string
- func (d *Dot) PathMatch(pattern string) (matched bool, err error)
- func (d *Dot) PrintTree(prefix ...string) *Dot
- func (d *Dot) PutOut(msg ...interface{}) *Dot
- func (d *Dot) Root() *Dot
- func (d *Dot) SeeError(sender, place string, err error) bool
- func (d *Dot) SeeNotOk(sender, place string, ok bool, complain string) bool
- func (d *Dot) Set(vals ...string) *Dot
- func (d *Dot) SetM(val ...map[string]string) *Dot
- func (d *Dot) SetOutput(output io.Writer) *Dot
- func (d *Dot) SetS(val ...[]string) *Dot
- func (d *Dot) UnlockedAdd(key string, val ...string) (interface{}, bool)
- func (d *Dot) UnlockedGet(key string) (interface{}, bool)
- func (d *Dot) Up() *Dot
- func (d *Dot) WalkBreadth1st(wf WalkFunc) *Dot
- func (d *Dot) WalkDepth1st(wf WalkFunc) *Dot
- type DotS
- type ErrorFriendly
- type Friendly
- type GoFriendly
- type NavigatorFriendly
- type OutputFriendly
- type PrinterFriendly
- type PrivacyFriendly
- type SetableFriendly
- type StringFriendly
- type UserFriendly
- type WalkFunc
Constants ¶
const ErrorID = ":" + ErrorName + ":"
ErrorID is the ID of of a node of type error
const ErrorName = "Error"
ErrorName is the name of a node-type error
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssignFriendly ¶
type AssignFriendly interface { Assignss(vals ...string) *Dot // Assign/overwrite Content with val - given as strings AssignSs(val ...[]string) *Dot // Assign/overwrite Content with val - given as slices of strings AssignMs(val ...map[string]string) *Dot // Assign/overwrite Content with val - given as maps of strings }
AssignFriendly - interface exposed for go doc only
type ChildFriendly ¶
type ChildFriendly interface {
// contains filtered or unexported methods
}
ChildFriendly - interface exposed for go doc only
type DeleteFriendly ¶
type DeleteFriendly interface { Deletess(vals ...string) *Dot // Delete/remove vals from Content - given as strings DeleteSs(vals ...[]string) *Dot // Delete/remove val from Content - given as slices of strings DeleteMs(vals ...map[string]string) *Dot // Delete/remove val from Content - given as maps of strings }
DeleteFriendly - interface exposed for go doc only
type Dot ¶
type Dot struct { *tag.TagAny // key - a Key Value Pair *lsm.LazyStringerMap // value(s) - an 'Anything' StringMap *sync.RWMutex // public lock - concurency enabled! // contains filtered or unexported fields }
Dot - a tree of named anythings - useful for agnostic template-driven text generation
"Templates are executed by applying them to a data structure. Annotations in the template refer to elements of the data structure (typically a field of a struct or a key in a map) to control execution and derive values to be displayed.
Execution of the template walks the structure and sets the cursor, represented by a period '.' and called "dot", to the value at the current location in the structure as execution proceeds."
quoted from `text/template/doc.go`
func (*Dot) AddMap ¶
AddMap adds key to current dot d and adds content below this key using given variadic string-maps
func (*Dot) AddStringS ¶
AddStringS adds key to current dot d and adds content below this key using given variadic string-slices
func (*Dot) AddStrings ¶
AddStrings adds key to current dot d and adds content below this key using given variadic strings
func (*Dot) AssignMs ¶
AssignMs adds to (or replaces with) content below current dot d using given variadic string-maps
func (*Dot) AssignSs ¶
AssignSs adds to (or replaces with) content below current dot d using given variadic string-slices
func (*Dot) Assignss ¶
Assignss adds to (or replaces with) content below current dot d using given variadic strings
func (*Dot) DeleteMs ¶
DeleteMs deletes / removes content below current dot d using given variadic string-maps
func (*Dot) DeleteSs ¶
DeleteSs deletes / removes content below current dot d using given variadic string-slices
func (*Dot) Deletess ¶
Deletess deletes / removes content below current dot d using given variadic strings
func (*Dot) Dot ¶
func (d *Dot) Dot() interface{}
Dot is a helper method for templates: Dot returns the value of the current dot.
func (*Dot) DotDotDots ¶
DotDotDots is a helper method for templates: Returns the entire subtree, depth first.
func (*Dot) FprintTree ¶
FprintTree prints the tree to io.Writer, one line per node, each prefixed by prefix and indented with tab "\t"
func (*Dot) G ¶
G is a helper method for templates: Go down into (eventually new!) key(s) and return the final child dot (key).
func (*Dot) Path ¶
Path returns a slice from here up to the root Note: as the slice is returned bottom-up, may like to reverse it :-)
func (*Dot) PathDown ¶
PathDown returns the path from Root to here as a path.Join'ed string. Note: Intentionally, path.Clean is neither applied to components nor to the result, as this might make components such as ".." 'disappear'; but path.Clean is applied to empty nodes in order to gain a "." being joined!
func (*Dot) PathJoinThese ¶
PathJoinThese - func path.Join(elem ...string) string
Note: joins elem... - does not consider Dot
func (*Dot) PrintTree ¶
PrintTree prints the tree to os.Stdout, one line per node, each prefixed by prefix and indented with tab "\t"
func (*Dot) Root ¶
Root goes all the way Up() and returns the root - just in case You lost it :-)
Note: usually, Root == Home. Alas: operations (such as Remove subtree) may invalidate this.
func (*Dot) SeeNotOk ¶
SeeNotOk - If ok!=true, attach a not-ok complain below "Error:" of d, and return true
func (*Dot) SetM ¶
SetM adds (or replaces) content below current dot d using given variadic string-maps
func (*Dot) SetOutput ¶
SetOutput sets the destination for usage and error messages. If output is nil, os.Stderr is used.
func (*Dot) SetS ¶
SetS adds (or replaces) content below current dot d using given variadic string-slices
func (*Dot) UnlockedAdd ¶
UnlockedAdd is a helper method and is exported only for use by the function library "do/dot". It adds key to d, and adds variadic strings below key, and returns child "key"
Note: It's 2nd arg (bool) intentionally avoids usage from templates!
Other clients must behave as if this method is not exported!
func (*Dot) UnlockedGet ¶
UnlockedGet is a helper method and is exported only for use by the function library "do/dot". It returns the (eventually new!) child (key)
Note: It's 2nd arg (bool) intentionally avoids usage from templates!
Other clients must behave as if this method is not exported!
func (*Dot) WalkBreadth1st ¶
WalkBreadth1st applies a given WalkFunc wf in breadth-first order
func (*Dot) WalkDepth1st ¶
WalkDepth1st applies a given WalkFunc wf in depth-first order
type ErrorFriendly ¶
type ErrorFriendly interface { SeeError(sender, place string, err error) bool SeeNotOk(sender, place string, ok bool, complain string) bool }
ErrorFriendly - interface exposed for go doc only
type Friendly ¶
type Friendly interface { tag.Friendly // via "container/.../tag/..." lsm.Friendly // via "container/.../lsm" StringFriendly // dot.go: Set..., Assign..., Delete... ChildFriendly // children.go: lookupDot getChild NavigatorFriendly // navigate.go: Up Root Path DownS PrinterFriendly // print.go: PrintTree ErrorFriendly // => dot! error.go OutputFriendly // output.go GoFriendly // dot.go }
Friendly - interface exposed for go doc only shows the composition as interface
type GoFriendly ¶
type GoFriendly interface { // helper for templates: A(vals ...string) string // Add values, and return an empty string G(keys ...string) *Dot // Go into key(s) DotDot(key, val string) *Dot // Assign a Key Value Pair Dot() interface{} // The value of the current dot DotDotDots() []*Dot // The entire subtree, depth first // helper for "do/dot" UnlockedGet(key string) (interface{}, bool) UnlockedAdd(key string, val ...string) (interface{}, bool) }
GoFriendly - interface exposed for go doc only
type NavigatorFriendly ¶
type NavigatorFriendly interface { // contains filtered or unexported methods }
NavigatorFriendly - interface exposed for go doc only
type OutputFriendly ¶
type OutputFriendly interface { SetOutput(output io.Writer) *Dot // sets the destination for usage and error messages. If output is nil, os.Stderr is used. PutOut(msg ...interface{}) *Dot // prints msg's on a line to out() // contains filtered or unexported methods }
OutputFriendly - interface exposed for go doc only
type PrinterFriendly ¶
type PrinterFriendly interface {
PrintTree(prefix ...string) *Dot // prints the tree, one line per node, each prefixed by prefix and indented with tab "\t"
}
PrinterFriendly - interface exposed for go doc only
type PrivacyFriendly ¶
type PrivacyFriendly interface {
// contains filtered or unexported methods
}
PrivacyFriendly - interface exposed for go doc only
type SetableFriendly ¶
type SetableFriendly interface { Set(vals ...string) *Dot // Set/replace Content with val - given as strings SetS(val ...[]string) *Dot // Set/replace Content with val - given as slices of strings SetM(val ...map[string]string) *Dot // Set/replace Content with val - given as maps of strings }
SetableFriendly - interface exposed for go doc only
type StringFriendly ¶
type StringFriendly interface { SetableFriendly // set.go: Set/replace Content: Set SetS SetM AssignFriendly // assign.go: Add/overwrite Content: Assignss AssignSs AssignMs UserFriendly // add.go: AddMap AddStrings AddStringS DeleteFriendly // delete.go: Delete/remove vals from Content: Deletes, DeleteS, DeleteM PrivacyFriendly // content.go: add addM }
StringFriendly - interface exposed for go doc only
type UserFriendly ¶
type UserFriendly interface { AddStrings(key string, val ...string) *Dot // adds key to d, and adds variadic strings below key AddStringS(key string, val ...[]string) *Dot // adds key to d, and adds slices below key AddMap(key string, vals ...map[string]string) *Dot // adds key to d, and adds map(s) below key }
UserFriendly - interface exposed for go doc only