dom

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(w io.Writer, doc *Document, fm FmtMode) error

Write document to a writer with specified formatting

Types

type BlanksBlock

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

Sequence of blank lines

func (*BlanksBlock) LinesCount

func (blk *BlanksBlock) LinesCount() int

func (*BlanksBlock) Type

func (blk *BlanksBlock) Type() BlockType

type Block

type Block interface {
	Type() BlockType
	// contains filtered or unexported methods
}

type BlockType

type BlockType int
const (
	Unknown BlockType = iota
	Comments
	Blanks
	IPList
)

type CommentsBlock

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

Sequence of comments

func NewCommentsBlock

func NewCommentsBlock(commentsText string) *CommentsBlock

Creates new comments block

func (*CommentsBlock) CommentsText

func (blk *CommentsBlock) CommentsText() string

func (*CommentsBlock) SetCommentsText

func (blk *CommentsBlock) SetCommentsText(commentsText string)

func (*CommentsBlock) Type

func (blk *CommentsBlock) Type() BlockType

type Document

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

Container object for dom blocks found during parsing of the original document

func NewDocument

func NewDocument(doc *syntax.Document) *Document

func NewEmptyDocument

func NewEmptyDocument() *Document

func Read

func Read(r io.Reader) (*Document, error)

Read and parse document from a reader

func (*Document) AddBlock

func (doc *Document) AddBlock(block Block)

func (*Document) Blocks

func (doc *Document) Blocks() []Block

func (*Document) BlocksCount

func (doc *Document) BlocksCount() int

func (*Document) DeleteBlock

func (doc *Document) DeleteBlock(block Block)

func (*Document) IPBlocks

func (doc *Document) IPBlocks() []*IPAliasesBlock

func (*Document) IPBlocksByIdentifiers

func (doc *Document) IPBlocksByIdentifiers(id int, name string) []*IPAliasesBlock

func (*Document) IPsBlockById

func (doc *Document) IPsBlockById(id int) *IPAliasesBlock

Finds IPs block by ID

func (*Document) IPsBlockByIdOrName

func (doc *Document) IPsBlockByIdOrName(idOrName string) *IPAliasesBlock

func (*Document) IPsBlockByName

func (doc *Document) IPsBlockByName(name string) *IPAliasesBlock

Finds IPs block by name

func (*Document) Normalize

func (doc *Document) Normalize() bool

type FmtMode

type FmtMode int

Documet formatting mode

const (
	FmtKeep     FmtMode = iota    // keep original formatting where possible
	FmtReFormat FmtMode = iota    // re-format document
	FmtDefault          = FmtKeep // default pormatting (Keep)
)

type IPAliasesBlock

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

Block of IPs

func NewIPAliasesBlock

func NewIPAliasesBlock() *IPAliasesBlock

func (*IPAliasesBlock) AddEntry

func (blk *IPAliasesBlock) AddEntry(entry IPAliasesBlockElement)

func (*IPAliasesBlock) AliasEntries

func (blk *IPAliasesBlock) AliasEntries() []*IPAliasesEntry

func (*IPAliasesBlock) AliasEntriesByAlias

func (blk *IPAliasesBlock) AliasEntriesByAlias(alias string) []*IPAliasesEntry

func (*IPAliasesBlock) AliasEntriesByIP

func (blk *IPAliasesBlock) AliasEntriesByIP(ip string) []*IPAliasesEntry

func (*IPAliasesBlock) AliasEntriesByIPOrAlias

func (blk *IPAliasesBlock) AliasEntriesByIPOrAlias(ipOrAlias string) []*IPAliasesEntry

func (*IPAliasesBlock) ClearFormatting

func (blk *IPAliasesBlock) ClearFormatting()

func (*IPAliasesBlock) Entries

func (blk *IPAliasesBlock) Entries() []IPAliasesBlockElement

func (*IPAliasesBlock) Id

func (blk *IPAliasesBlock) Id() int

func (*IPAliasesBlock) IdSet

func (blk *IPAliasesBlock) IdSet() bool

Returns true if real ID value is set, otherwise if ID is auto generated, then returns false

func (*IPAliasesBlock) Name

func (blk *IPAliasesBlock) Name() string

func (*IPAliasesBlock) Note

func (blk *IPAliasesBlock) Note() string

func (*IPAliasesBlock) RemoveEntry

func (blk *IPAliasesBlock) RemoveEntry(entry IPAliasesBlockElement) bool

func (*IPAliasesBlock) SetId

func (blk *IPAliasesBlock) SetId(id int)

func (*IPAliasesBlock) SetName

func (blk *IPAliasesBlock) SetName(name string)

func (*IPAliasesBlock) SetNote

func (blk *IPAliasesBlock) SetNote(comment string)

func (*IPAliasesBlock) Type

func (blk *IPAliasesBlock) Type() BlockType

type IPAliasesBlockElement

type IPAliasesBlockElement interface {
	Type() IPAliasesBlockElementType
	ClearFormatting()
	// contains filtered or unexported methods
}

type IPAliasesBlockElementType

type IPAliasesBlockElementType int
const (
	Alias IPAliasesBlockElementType = iota
	Placeholder
)

type IPAliasesEntry

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

func NewIPAliasesEntry

func NewIPAliasesEntry(ip string) *IPAliasesEntry

func (*IPAliasesEntry) AddAlias

func (blk *IPAliasesEntry) AddAlias(alias string) bool

func (*IPAliasesEntry) Aliases

func (blk *IPAliasesEntry) Aliases() []string

func (*IPAliasesEntry) ClearFormatting

func (blk *IPAliasesEntry) ClearFormatting()

func (*IPAliasesEntry) Disabled

func (blk *IPAliasesEntry) Disabled() bool

func (*IPAliasesEntry) IP

func (blk *IPAliasesEntry) IP() string

func (*IPAliasesEntry) Note

func (blk *IPAliasesEntry) Note() string

func (*IPAliasesEntry) RemoveAlias

func (blk *IPAliasesEntry) RemoveAlias(alias string) bool

func (*IPAliasesEntry) SetDisabled

func (blk *IPAliasesEntry) SetDisabled(disabled bool)

func (*IPAliasesEntry) SetIP

func (blk *IPAliasesEntry) SetIP(ip string)

func (*IPAliasesEntry) SetNote

func (blk *IPAliasesEntry) SetNote(comment string)

func (*IPAliasesEntry) Type

type IPAliasesPlaceholder

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

func NewIPAliasesPlaceholder

func NewIPAliasesPlaceholder() *IPAliasesPlaceholder

func (*IPAliasesPlaceholder) ClearFormatting

func (blk *IPAliasesPlaceholder) ClearFormatting()

func (*IPAliasesPlaceholder) Type

type UnrecognizedBlock

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

Block of unrecognized lines

func (*UnrecognizedBlock) BodyElements

func (blk *UnrecognizedBlock) BodyElements() []syntax.Element

func (*UnrecognizedBlock) Type

func (blk *UnrecognizedBlock) Type() BlockType

Jump to

Keyboard shortcuts

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