cursor

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cursor

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

Cursor allow to navigate and modify an XML [Document]

func NewCursor

func NewCursor(doc parser.Document) Cursor

NewCursor create a cursor to navigate the document doc the document

func (*Cursor) BeginElement

func (c *Cursor) BeginElement(name xml.Name)

BeginElement create a start and end token and place the cursor between

func (*Cursor) ClearBookmark

func (c *Cursor) ClearBookmark(bookmark interface{})

ClearBookmark remove a bookmark to current cursor location if already present.

func (*Cursor) ComparePosition

func (c *Cursor) ComparePosition(c2 Cursor) int

ComparePosition return a negative, null or positive number according to relative positions of c and c2.

  • > 0 : c is right of c2
  • = 0 : c is at same position than c2
  • < 0 : c is left of c2

func (*Cursor) CurrentToken

func (c *Cursor) CurrentToken() parser.Token

CurrentToken retrieve current token

func (*Cursor) InsertElement

func (c *Cursor) InsertElement(name xml.Name)

InsertElement create a start and end token and place the cursor after

func (*Cursor) InsertElementWithText

func (c *Cursor) InsertElementWithText(name xml.Name, text string)

InsertElementWithText create a start, text end token and place the cursor after

func (*Cursor) InsertText

func (c *Cursor) InsertText(text string)

InsertText create a text token and place the cursor after

func (*Cursor) IsAtSamePositionAs

func (c *Cursor) IsAtSamePositionAs(c2 Cursor) bool

IsAtSamePositionAs report if c and c2 are at the same position

func (*Cursor) IsLeftOf

func (c *Cursor) IsLeftOf(c2 Cursor) bool

IsLeftOf report if c is left of c2

func (*Cursor) IsRightOf

func (c *Cursor) IsRightOf(c2 Cursor) bool

IsRightOf report if c is right of c2

func (*Cursor) NewCursor

func (c *Cursor) NewCursor() Cursor

NewCursor create a new cursor from the Cursor at the same position and same document

func (*Cursor) Pop

func (c *Cursor) Pop()

Pop restore the current position of the Cursor

func (*Cursor) Push

func (c *Cursor) Push()

Push save the current position of the Cursor

func (*Cursor) SetBookmark

func (c *Cursor) SetBookmark(bookmark interface{})

SetBookmark add a bookmark to current cursor location if not already present.

func (*Cursor) ToEndToken

func (c *Cursor) ToEndToken() parser.Token

ToEndToken move to the end token matching the current start token Return parser.None if the cursor is not on a parser.Start token

func (*Cursor) ToFirstBookmark

func (c *Cursor) ToFirstBookmark(bookmark interface{}) bool

ToFirstBookmark move to first bookmark and report if the Cursor moved

func (*Cursor) ToFirstChild

func (c *Cursor) ToFirstChild() bool

ToFirstChild move to first child and report if the Cursor moved

func (*Cursor) ToFirstChildByName

func (c *Cursor) ToFirstChildByName(name xml.Name) bool

ToFirstChildByName move to first child with the given name and report if the Cursor moved

func (*Cursor) ToNextBookmark

func (c *Cursor) ToNextBookmark(bookmark interface{}) bool

ToNextBookmark move to next bookmark and report if the Cursor moved Technically, it moves to the first bookmark after the current cursor position.

func (*Cursor) ToNextSibling

func (c *Cursor) ToNextSibling() bool

ToNextSibling move to next sibling and report if the Cursor moved

func (*Cursor) ToNextSiblingByName

func (c *Cursor) ToNextSiblingByName(name xml.Name) bool

ToNextSiblingByName move to next sibling with the given name and report if the Cursor moved

func (*Cursor) ToNextToken

func (c *Cursor) ToNextToken() parser.Token

ToNextToken move to next token and return it

func (*Cursor) ToPreviousToken

func (c *Cursor) ToPreviousToken() parser.Token

ToPreviousToken move to previous token

func (*Cursor) ToStartDoc

func (c *Cursor) ToStartDoc()

ToStartDoc move cursor to start of document, NOT the first start element

func (*Cursor) ToStartToken

func (c *Cursor) ToStartToken() parser.Token

ToStartToken move to the start token, works anywhere between tokens

func (*Cursor) Xml

func (c *Cursor) Xml() string

Xml produces the textual representation of the XML document

Jump to

Keyboard shortcuts

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