gocoding

package module
v0.0.0-...-59666ce Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2015 License: MIT Imports: 9 Imported by: 6

README

gocoding

v1.2.1

Gocoding is designed to provide a framework for creating flexible marshallers and unmarshallers. It is designed for flexibility and modularity, not scalability. It has not (yet) been optimized for speed and it can only handle string lengths up to 1022 characters (not including quotes).

Change log

v1.2.1

Fixed bugs

Fixed some decoding bugs

v1.2

HTML

Added an HTML renderer such that Golang variables can be marshalled into HTML. The project has no interest in supporting a conversion from HTML into Golang.

v1.1

Hotfix

Fixed bugs

v1.0

Initial version

Marshaller & unmarshaller framework for encoder caching Text encoders & decoders JSON renderer & scanner

Complete Golang <=> JSON conversion.

Documentation

Index

Constants

View Source
const EndOfText rune = '\u0003'

Variables

This section is empty.

Functions

func PeekCheck

func PeekCheck(scanner Scanner, expected ...ScannerCode) bool

Types

type BasicErrorable

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

func (*BasicErrorable) Error

func (s *BasicErrorable) Error(err *Error)

func (*BasicErrorable) Recover

func (s *BasicErrorable) Recover(err interface{}) error

func (*BasicErrorable) SetErrorHandler

func (s *BasicErrorable) SetErrorHandler(handler func(*Error))

func (*BasicErrorable) SetRecoverHandler

func (s *BasicErrorable) SetRecoverHandler(handler func(interface{}) error)

type Decodable1

type Decodable1 interface {
	Decoding(Unmarshaller, reflect.Type) Decoder
}

type Decodable2

type Decodable2 interface {
	DecodableFields() map[string]reflect.Value
}

type Decoder

type Decoder func([64]byte, Scanner, reflect.Value)

func Decodable2Decoding

func Decodable2Decoding(unmarshaller Unmarshaller, theType reflect.Type) Decoder

func ErrorDecoding

func ErrorDecoding(err *Error) Decoder

func TryIndirectDecoding

func TryIndirectDecoding(direct Decoder, indirect Decoder) Decoder

type Decoding

type Decoding func(Unmarshaller, reflect.Type) Decoder

type Encodable1

type Encodable1 interface {
	Encoding(Marshaller, reflect.Type) Encoder
}

type Encodable2

type Encodable2 interface {
	EncodableFields() map[string]reflect.Value
}

type Encoder

type Encoder func([64]byte, Renderer, reflect.Value)

type Encoding

type Encoding func(Marshaller, reflect.Type) Encoder

type Error

type Error struct {
	Class string
	Value interface{}
}

func ErrorPrint

func ErrorPrint(class string, args ...interface{}) *Error

func ErrorPrintf

func ErrorPrintf(class, format string, args ...interface{}) *Error

func ErrorScanning

func ErrorScanning(got ScannerCode, expected ...ScannerCode) *Error

func (*Error) Error

func (e *Error) Error() string

type Errorable

type Errorable interface {
	Error(*Error)
	SetErrorHandler(func(*Error))
	Recover(interface{}) error
	SetRecoverHandler(func(interface{}) error)
}

type Marshaller

type Marshaller interface {
	Marshal(Renderer, interface{}) error
	MarshalObject(Renderer, interface{})
	MarshalValue(Renderer, reflect.Value)
	FindEncoder(reflect.Type) Encoder
	IsCached(reflect.Type) bool
	CacheEncoder(reflect.Type, Encoder)
}

func NewMarshaller

func NewMarshaller(encoding Encoding) Marshaller

type Renderer

type Renderer interface {
	Errorable
	io.Writer

	Print(args ...interface{}) int
	Printf(format string, args ...interface{}) int
	WriteNil() int
	PrintString(string) int

	StartStruct() int
	StopStruct() int

	StartMap() int
	StopMap() int

	StartArray() int
	StopArray() int

	StartElement(id string) int
	StopElement(id string) int
}

type RuneReader

type RuneReader interface {
	Next() rune
	Peek() rune
	Backup() rune
	Done() bool
	String() string // optional
}

type Scanner

type Scanner interface {
	Errorable

	// get the code on the top of the stack
	Peek() ScannerCode

	// scan the next rune, returning the appropriate code
	//   this will step through the scanner's state
	NextCode() ScannerCode

	// continue scanning until NextValue() doesn't return Scanning
	Continue() ScannerCode

	// scan the next value
	//   this will scan the next complete value
	NextValue() reflect.Value

	// scan the next value as a string
	//   this will scan the next complete value, returning the data unparsed
	NextString() string
}

type ScannerCode

type ScannerCode uint8
const (
	Scanning ScannerCode = iota
	ScannedKeyBegin
	ScannedKeyEnd
	ScannedLiteralBegin
	ScannedLiteralEnd
	ScannedStructBegin
	ScannedStructEnd
	ScannedMapBegin
	ScannedMapEnd
	ScannedArrayBegin
	ScannedArrayEnd
	ScannerInitialized
	ScannedToEnd
	ScannerError
	ScannerBadCode
)

func (ScannerCode) Matches

func (sc ScannerCode) Matches(codes ...ScannerCode) bool

func (ScannerCode) Reflection

func (sc ScannerCode) Reflection() ScannerCode

func (ScannerCode) ScannedBegin

func (sc ScannerCode) ScannedBegin() bool

func (ScannerCode) ScannedEnd

func (sc ScannerCode) ScannedEnd() bool

func (ScannerCode) String

func (sc ScannerCode) String() string

type SliceableRuneReader

type SliceableRuneReader interface {
	RuneReader
	Mark()
	Slice() SliceableRuneReader
}

func Read

func Read(source io.Reader, maxcap int) SliceableRuneReader

func ReadBytes

func ReadBytes(slice []byte) SliceableRuneReader

func ReadSlice

func ReadSlice(slice []rune) SliceableRuneReader

func ReadString

func ReadString(data string) SliceableRuneReader

type Unmarshaller

type Unmarshaller interface {
	Unmarshal(Scanner, interface{}) error
	UnmarshalObject(Scanner, interface{})
	UnmarshalValue(Scanner, reflect.Value)
	FindDecoder(reflect.Type) Decoder
	CacheDecoder(reflect.Type, Decoder)
}

func NewUnmarshaller

func NewUnmarshaller(decoding Decoding) Unmarshaller

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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