tree

package
v0.0.0-...-c19ee7d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2021 License: BSD-3-Clause, MPL-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package tree is an nary tree that stores operational mode templates using maps of strings to nodes as the linkage mechanism.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PathErrorf

func PathErrorf(etype PErr, p Path, eelem string, matches []*OpTree) error

PathErrorf Takes an error type, a path, the element the path failed, and a list of matches then it generates an appropriate error message coresponding to the current CLI style.

Types

type ChildIterator

type ChildIterator struct {
	// contains filtered or unexported fields
}

ChildIterator allows interating over a map of child nodes.

func NewChildIterator

func NewChildIterator(t *OpTree) *ChildIterator

NewChildIterator creates a child iterator for the provided tree.

func (*ChildIterator) HasNext

func (i *ChildIterator) HasNext() bool

HasNext checks if there is another available element for the iterator.

func (*ChildIterator) Next

func (i *ChildIterator) Next()

Next increments the iterator.

func (*ChildIterator) Value

func (i *ChildIterator) Value() *OpTree

Value allows accessing the child at the current iterator position.

type OpTree

type OpTree struct {
	// contains filtered or unexported fields
}

OpTree is a representation of the operational mode template tree.

func BuildOpTree

func BuildOpTree(path string) (*OpTree, error)

func NewOpTree

func NewOpTree(name string, val *tmpl.OpTmpl) *OpTree

NewOpTree creates a new OpTree with the given name and value.

func (*OpTree) AddChild

func (t *OpTree) AddChild(child *OpTree) error

AddChild adds a new child to this node's child map.

func (*OpTree) Child

func (t *OpTree) Child(name string) (*OpTree, error)

Child returns a node's child of the given name.

func (*OpTree) ChildOrTag

func (t *OpTree) ChildOrTag(name string) (*OpTree, error)

ChildOrTag returns a nodes child for a given name or the tag node

func (*OpTree) DelChild

func (t *OpTree) DelChild(name string) error

DelChild removes the child with the given name from the child map.

func (*OpTree) Descendant

func (t *OpTree) Descendant(p Path) (*OpTree, error)

Descendant walks a given path returning the node if it is found.

func (*OpTree) Include

func (t *OpTree) Include() *OpTree

Include returns the node's current include tree.

func (*OpTree) Name

func (t *OpTree) Name() string

Name returns the tree node's name.

func (*OpTree) Parent

func (t *OpTree) Parent() (*OpTree, error)

Parent returns the node's current parent.

func (*OpTree) Print

func (t *OpTree) Print(depth int)

Print prints out the template tree, this is useful for debugging but not much else.

func (*OpTree) SetInclude

func (t *OpTree) SetInclude(i *OpTree) error

SetInclude overwrites the include value for the node.

func (*OpTree) SetName

func (t *OpTree) SetName(name string)

SetName overwrites the node's name.

func (*OpTree) SetParent

func (t *OpTree) SetParent(p *OpTree) error

SetParent overwrites the parent value for the node.

func (*OpTree) SetValue

func (t *OpTree) SetValue(template *tmpl.OpTmpl) error

SetValue overwrites the node's value.

func (*OpTree) Value

func (t *OpTree) Value() *tmpl.OpTmpl

Value returns the node's value; which is an OpTmpl.

type PErr

type PErr uint

PErr allows for an appropriate error message to be generated when accessing an invalid path

const (
	PErrInval  PErr = iota
	PErrIncomp PErr = iota
	PErrAmbig
)

type Path

type Path []string

Path is a representation of an operational path

func (Path) String

func (p Path) String() string

String generates a pretty representation of a path

func (Path) StringByAttrs

func (p Path) StringByAttrs(attrs *pathutil.PathAttrs) string

String generates a pretty representation of a path, based upon PathAttrs metadata. Specifically, elements of the path which are marked as secret will appear as **** in the returned string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL