decoder

package
v0.11.10 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_DEPTH = 1000
View Source
const TERMINATION_CHAR = '\000'

In order to decode, you have to traverse the input buffer character by position. At that time, if you check whether the buffer has reached the end, it will be very slow. Therefore, by adding the NUL (\000) character to the end of the read buffer as shown below, it is possible to check the termination character at the same time as other characters.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

func RegisterDecoder

func RegisterDecoder[T any](fn DecoderFn)

Types

type Config

type Config struct {
	Scope scopes.Context
	// contains filtered or unexported fields
}

Config is a configuration for the decoder. It can be used to define the scope of the decoding ones and reuse it multiple times.

func (*Config) NewDecoder

func (c *Config) NewDecoder(data []byte) *Decoder

NewDecoder creates a new decoder with the given data.

func (*Config) Unmarshal

func (c *Config) Unmarshal(data []byte, v any) error

Unmarshal decodes the data into the given value.

func (*Config) UnmarshalCtx

func (c *Config) UnmarshalCtx(data []byte, v any, ctx *ctx.Ctx) error

UnmarshalCtx sets the *ctx.Ctx and decodes the data into the given value.

func (*Config) UnmarshalScoped

func (c *Config) UnmarshalScoped(data []byte, v any, operation scopes.Decoding) error

UnmarshalScoped decodes the data into the given value with the given scope.

func (*Config) UnmarshalScopedCtx

func (c *Config) UnmarshalScopedCtx(data []byte, v any, operation scopes.Decoding, ctx *ctx.Ctx) error

UnmarshalScopedCtx sets the *ctx.Ctx and decodes the data into the given value with the given scope.

func (*Config) UnmarshalScopedWithChanges

func (c *Config) UnmarshalScopedWithChanges(data []byte, v any, operation scopes.Decoding) ([]string, error)

UnmarshalScopedWithChanges decodes the data into the given value with the given scope and returns the changes. The changes are the paths of the fields that have been changed.

func (*Config) UnmarshalScopedWithChangesCtx

func (c *Config) UnmarshalScopedWithChangesCtx(data []byte, v any, operation scopes.Decoding, ctx *ctx.Ctx) ([]string, error)

UnmarshalScopedWithChangesCtx sets the *ctx.Ctx and decodes the data into the given value with the given scope and returns the changes. The changes are the paths of the fields that have been changed.

func (*Config) UnmarshalWithChanges

func (c *Config) UnmarshalWithChanges(data []byte, v any) ([]string, error)

UnmarshalWithChanges decodes the data into the given value and returns the changes. The changes are the paths of the fields that have been changed.

func (*Config) UnmarshalWithChangesCtx

func (c *Config) UnmarshalWithChangesCtx(data []byte, v any, ctx *ctx.Ctx) ([]string, error)

UnmarshalWithChangesCtx sets the *ctx.Ctx and decodes the data into the given value and returns the changes. The changes are the paths of the fields that have been changed.

type Decoder

type Decoder struct {
	*ctx.Ctx

	Buf []byte

	Changes       []string
	ChangesPrefix string
	// contains filtered or unexported fields
}

func (*Decoder) Context

func (d *Decoder) Context() scopes.Context

func (*Decoder) DecodeString

func (d *Decoder) DecodeString() (string, error)

func (*Decoder) Error

func (d *Decoder) Error(msg string) error

func (*Decoder) ErrorF

func (d *Decoder) ErrorF(format string, args ...any) error

func (*Decoder) Operation

func (d *Decoder) Operation() scopes.Decoding

func (*Decoder) ScanArray

func (d *Decoder) ScanArray() (int, error)

func (*Decoder) ScanNull

func (d *Decoder) ScanNull() error

func (*Decoder) ScanObject

func (d *Decoder) ScanObject() (int, error)

func (*Decoder) Skip

func (d *Decoder) Skip() error

func (*Decoder) SkipArray

func (d *Decoder) SkipArray() error

func (*Decoder) SkipExponent

func (d *Decoder) SkipExponent() error

func (*Decoder) SkipFalse

func (d *Decoder) SkipFalse() error

func (*Decoder) SkipFloat

func (d *Decoder) SkipFloat() error

func (*Decoder) SkipMinus

func (d *Decoder) SkipMinus(isFloat bool) error

func (*Decoder) SkipNumber

func (d *Decoder) SkipNumber(withDecimal, withExponent bool) error

func (*Decoder) SkipObject

func (d *Decoder) SkipObject() error

func (*Decoder) SkipString

func (d *Decoder) SkipString() error

func (*Decoder) SkipTrue

func (d *Decoder) SkipTrue() error

func (*Decoder) SkipWhitespace

func (d *Decoder) SkipWhitespace()

func (*Decoder) SkipZero

func (d *Decoder) SkipZero(isFloat bool) error

func (*Decoder) Unmarshal

func (d *Decoder) Unmarshal(data []byte, v any) error

func (*Decoder) UnmarshalScoped

func (d *Decoder) UnmarshalScoped(data []byte, v any, operation scopes.Decoding) error

func (*Decoder) UnmarshalScopedWithChanges

func (d *Decoder) UnmarshalScopedWithChanges(data []byte, v any, operation scopes.Decoding) ([]string, error)

func (*Decoder) UnmarshalWithChanges

func (d *Decoder) UnmarshalWithChanges(data []byte, v any) ([]string, error)

type DecoderFn

type DecoderFn func(*Decoder, reflect.Value) error

type Error

type Error struct {
	Message string
	Offset  int
	Area    []byte
	AreaPos int
}

func (*Error) Error

func (e *Error) Error() string

type Unmarshaler

type Unmarshaler interface {
	UnmarshalBlaze(e *Decoder, data []byte) error
}

Jump to

Keyboard shortcuts

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