schema

package
v0.0.0-...-3a072fe Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Atom

type Atom struct {
	Name    string   // who
	Type    AtomType // what
	Locator Locator  // where
	// contains filtered or unexported fields
}

Atom represents a single element of an input document that can be mutated.

func (Atom) IsScalar

func (a Atom) IsScalar() bool

func (Atom) Prepare

func (a Atom) Prepare(raw []byte) error

type AtomType

type AtomType string
const (
	Buffer  AtomType = "buffer"
	String  AtomType = "string"
	Integer AtomType = "int"
	Float   AtomType = "float"
	Bool    AtomType = "bool"
)

TODO: define and implement more atom types (?)

type ByteSlice

type ByteSlice []byte

func (ByteSlice) Len

func (s ByteSlice) Len() int

func (ByteSlice) Less

func (s ByteSlice) Less(i, j int) bool

func (ByteSlice) Swap

func (s ByteSlice) Swap(i, j int)

type Descriptor

type Descriptor struct {
	Name  string // name of this schema descriptor (pdf, zip, websocket, whatever)
	Atoms []Atom // what the document with this schema is made of
}

Descriptor describes the structure of an input document in terms of atoms, their types, how to locate them, and optional mutation constraints.

func LoadDescriptor

func LoadDescriptor(path string) (d Descriptor, err error)

func (Descriptor) Prepare

func (d Descriptor) Prepare(doc Document) error

type Document

type Document struct {
	Path string
	Data []byte // aren't we all just a pointless array of bytes in this entropic universe after all?
	Size uint
	Gen  uint // generation number
}

func LoadDocument

func LoadDocument(path string) (doc Document, err error)

type Locator

type Locator struct {
	sync.Mutex

	Type LocatorType
	Data string
	// contains filtered or unexported fields
}

Locator represents a strategy to locate a single atom inside a document, by its offset, a XPath expression, etc.

func (Locator) Find

func (l Locator) Find(doc Document) (offset uint, size uint, err error)

type LocatorType

type LocatorType string
const (
	ByOffset LocatorType = "offset"
	ByExact  LocatorType = "exact"
	ByRE     LocatorType = "re"
)

TODO: define and implement more locator types (?)

Jump to

Keyboard shortcuts

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