encoding

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package encoding implements hdb field type en,- and decodings.

Index

Constants

View Source
const (
	BooleanFieldSize    = 1
	TinyintFieldSize    = 1
	SmallintFieldSize   = 2
	IntegerFieldSize    = 4
	BigintFieldSize     = 8
	RealFieldSize       = 4
	DoubleFieldSize     = 8
	DateFieldSize       = 4
	TimeFieldSize       = 4
	TimestampFieldSize  = DateFieldSize + TimeFieldSize
	LongdateFieldSize   = 8
	SeconddateFieldSize = 8
	DaydateFieldSize    = 4
	SecondtimeFieldSize = 4
	DecimalFieldSize    = 16
	Fixed8FieldSize     = 8
	Fixed12FieldSize    = 12
	Fixed16FieldSize    = 16
)

Filed size constants.

Variables

This section is empty.

Functions

func VarFieldSize

func VarFieldSize(size int) int

VarFieldSize returns the size of a varible field variable ([]byte, string and unicode variants).

Types

type Decoder

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

Decoder decodes hdb protocol datatypes on basis of an io.Reader.

func NewDecoder

func NewDecoder(rd io.Reader, decoder func() transform.Transformer) *Decoder

NewDecoder creates a new Decoder instance based on an io.Reader.

func (*Decoder) Bool

func (d *Decoder) Bool() bool

Bool decodes a boolean.

func (*Decoder) Byte

func (d *Decoder) Byte() byte

Byte decodes a byte.

func (*Decoder) Bytes

func (d *Decoder) Bytes(p []byte)

Bytes decodes bytes.

func (*Decoder) CESU8Bytes

func (d *Decoder) CESU8Bytes(size int) ([]byte, error)

CESU8Bytes decodes CESU-8 into UTF-8 bytes. - error is only returned in case of conversion errors.

func (*Decoder) CESU8LIBytes

func (d *Decoder) CESU8LIBytes() (int, []byte, error)

CESU8LIBytes decodes CESU-8 into UTF-8 bytes with length indicator.

func (*Decoder) CESU8LIString

func (d *Decoder) CESU8LIString() (int, string, error)

CESU8LIString decodes a CESU-8 into a UTF-8 string with length indicator.

func (*Decoder) Cnt

func (d *Decoder) Cnt() int

Cnt returns the value of the byte read counter.

func (*Decoder) Decimal

func (d *Decoder) Decimal() (*big.Int, int, error)

Decimal decodes a decimal. - error is only returned in case of conversion errors.

func (*Decoder) Error

func (d *Decoder) Error() error

Error returns the last decoder error.

func (*Decoder) Fixed

func (d *Decoder) Fixed(size int) *big.Int

Fixed decodes a fixed decimal.

func (*Decoder) Float32

func (d *Decoder) Float32() float32

Float32 decodes a float32.

func (*Decoder) Float64

func (d *Decoder) Float64() float64

Float64 decodes a float64.

func (*Decoder) Int16

func (d *Decoder) Int16() int16

Int16 decodes an int16.

func (*Decoder) Int32

func (d *Decoder) Int32() int32

Int32 decodes an int32.

func (*Decoder) Int64

func (d *Decoder) Int64() int64

Int64 decodes an int64.

func (*Decoder) Int8

func (d *Decoder) Int8() int8

Int8 decodes an int8.

func (*Decoder) LIBytes

func (d *Decoder) LIBytes() (n int, b []byte)

LIBytes decodes bytes with length indicator.

func (*Decoder) LIString

func (d *Decoder) LIString() (n int, s string)

LIString decodes a string with length indicator.

func (*Decoder) ResetCnt

func (d *Decoder) ResetCnt()

ResetCnt resets the byte read counter.

func (*Decoder) ResetError

func (d *Decoder) ResetError() error

ResetError return and resets reader error.

func (*Decoder) Skip

func (d *Decoder) Skip(cnt int)

Skip skips cnt bytes from reading.

func (*Decoder) Uint16

func (d *Decoder) Uint16() uint16

Uint16 decodes an uint16.

func (*Decoder) Uint16ByteOrder

func (d *Decoder) Uint16ByteOrder(byteOrder binary.ByteOrder) uint16

Uint16ByteOrder decodes an uint16 in given byte order.

func (*Decoder) Uint32

func (d *Decoder) Uint32() uint32

Uint32 decodes an uint32.

func (*Decoder) Uint32ByteOrder

func (d *Decoder) Uint32ByteOrder(byteOrder binary.ByteOrder) uint32

Uint32ByteOrder decodes an uint32 in given byte order.

func (*Decoder) Uint64

func (d *Decoder) Uint64() uint64

Uint64 decodes an uint64.

type Encoder

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

Encoder encodes hdb protocol datatypes on basis of an io.Writer.

func NewEncoder

func NewEncoder(wr io.Writer, encoder func() transform.Transformer) *Encoder

NewEncoder creates a new Encoder instance.

func (*Encoder) Bool

func (e *Encoder) Bool(v bool)

Bool encodes a boolean.

func (*Encoder) Byte

func (e *Encoder) Byte(b byte)

Byte encodes a byte.

func (*Encoder) Bytes

func (e *Encoder) Bytes(p []byte)

Bytes encodes bytes.

func (*Encoder) CESU8Bytes

func (e *Encoder) CESU8Bytes(p []byte) (int, error)

CESU8Bytes encodes UTF-8 bytes into CESU-8 and returns the CESU-8 bytes written.

func (*Encoder) CESU8LIBytes

func (e *Encoder) CESU8LIBytes(p []byte) error

CESU8LIBytes encodes UTF-8 into CESU-8 bytes with length indicator.

func (*Encoder) CESU8LIString

func (e *Encoder) CESU8LIString(s string) error

CESU8LIString encodes an UTF-8 into a CESU-8 string with length indicator.

func (*Encoder) CESU8String

func (e *Encoder) CESU8String(s string) (int, error)

CESU8String encodes an UTF-8 string into CESU-8 and returns the CESU-8 bytes written.

func (*Encoder) Decimal

func (e *Encoder) Decimal(m *big.Int, exp int)

Decimal encodes a decimal value.

func (*Encoder) Fixed

func (e *Encoder) Fixed(m *big.Int, size int)

Fixed encodes a fixed decimal value.

func (*Encoder) Float32

func (e *Encoder) Float32(f float32)

Float32 encodes a float32.

func (*Encoder) Float64

func (e *Encoder) Float64(f float64)

Float64 encodes a float64.

func (*Encoder) Int16

func (e *Encoder) Int16(i int16)

Int16 encodes an int16.

func (*Encoder) Int32

func (e *Encoder) Int32(i int32)

Int32 encodes an int32.

func (*Encoder) Int64

func (e *Encoder) Int64(i int64)

Int64 encodes an int64.

func (*Encoder) Int8

func (e *Encoder) Int8(i int8)

Int8 encodes an int8.

func (*Encoder) LIBytes

func (e *Encoder) LIBytes(p []byte) error

LIBytes encodes bytes with length indicator.

func (*Encoder) LIString

func (e *Encoder) LIString(s string) error

LIString encodes a string with length indicator.

func (*Encoder) String

func (e *Encoder) String(s string)

String encodes a string.

func (*Encoder) Uint16

func (e *Encoder) Uint16(i uint16)

Uint16 encodes an uint16.

func (*Encoder) Uint16ByteOrder

func (e *Encoder) Uint16ByteOrder(i uint16, byteOrder binary.ByteOrder)

Uint16ByteOrder encodes an uint16 in given byte order.

func (*Encoder) Uint32

func (e *Encoder) Uint32(i uint32)

Uint32 encodes an uint32.

func (*Encoder) Uint64

func (e *Encoder) Uint64(i uint64)

Uint64 encodes an uint64.

func (*Encoder) Zeroes

func (e *Encoder) Zeroes(cnt int)

Zeroes encodes cnt zero byte values.

Jump to

Keyboard shortcuts

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