text

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// EOF denotes the end of a file.
	EOF token = iota
	// EOL denotes the end of a Line.
	EOL
	// WS denotes any whitespace except EOF and EOL.
	WS

	// CRC denotes a crc24 checksum.
	CRC
	// DATA denotes the zbase32 encoded payload data.
	DATA
	// LINO denotes a Line number.
	LINO
	// DESC denotes any other type of text.
	DESC
)
View Source
const Name = "text"

Name holds the name of the format.

Variables

This section is empty.

Functions

func NewReader

func NewReader(r io.Reader) io.Reader

NewReader returns an text format reader instance.

func NewWriter

func NewWriter(w io.Writer, f *Format) (io.WriteCloser, error)

NewWriter returns an text format writer instance.

Types

type Format

type Format struct {
	LineLength uint8
	// contains filtered or unexported fields
}

Format represents the text type format.

func New

func New(input input.Input) *Format

New creates a new format of type Text.

func (*Format) Name

func (f *Format) Name() string

Name returns the formats name.

func (*Format) OutputFileName

func (f *Format) OutputFileName(x byte) string

OutputFileName returns the file name for the given x.

func (*Format) Reader

func (f *Format) Reader(r io.Reader) (io.Reader, error)

Reader creates a new format reader using the given reader as input.

func (*Format) Writer

func (f *Format) Writer(x byte) (io.Writer, []io.Closer, error)

Writer creates a new text format writer for the part identified by x.

type Line

type Line struct {
	// N holds the line number.
	N uint64
	// Data holds the data payload part of the line.
	Data string
	// CRC holds the lines checksum or if data is nil, for the whole document.
	CRC uint32
}

Line represents a parsed data Line.

type Parser

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

Parser represents the text parser.

func NewParser

func NewParser(r io.Reader) *Parser

NewParser returns a instance of Parser.

func (*Parser) Parse

func (p *Parser) Parse() (*Line, error)

Parse parses a data Line.

type Scanner

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

Scanner represents the lexical text scanner.

func NewScanner

func NewScanner(r io.Reader) *Scanner

NewScanner returns a new instance of Scanner.

func (*Scanner) Scan

func (s *Scanner) Scan() (tok token, lit string)

Scan returns the next token and literal value.

Jump to

Keyboard shortcuts

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