Documentation ¶
Overview ¶
Package encoding implements hdb field type en,- and decodings.
Index ¶
- Constants
- Variables
- func Cesu8FieldSize(v any) int
- func HexFieldSize(v any) int
- func VarFieldSize(v any) int
- type Decoder
- func (d *Decoder) AlphanumField() (any, error)
- func (d *Decoder) Bool() bool
- func (d *Decoder) BooleanField() (any, error)
- func (d *Decoder) Byte() byte
- func (d *Decoder) Bytes(p []byte)
- func (d *Decoder) CESU8Bytes(size int) ([]byte, error)
- func (d *Decoder) CESU8LIBytes() (int, []byte, error)
- func (d *Decoder) CESU8LIString() (int, string, error)
- func (d *Decoder) Cesu8Field() (any, error)
- func (d *Decoder) Cnt() int
- func (d *Decoder) DateField() (any, error)
- func (d *Decoder) DaydateField() (any, error)
- func (d *Decoder) Decimal() (*big.Int, int, error)
- func (d *Decoder) DecimalField() (any, error)
- func (d *Decoder) DoubleField() (any, error)
- func (d *Decoder) EmptyDateAsNull() bool
- func (d *Decoder) Error() error
- func (d *Decoder) Fixed(size int) *big.Int
- func (d *Decoder) Fixed12Field(scale int) (any, error)
- func (d *Decoder) Fixed16Field(scale int) (any, error)
- func (d *Decoder) Fixed8Field(scale int) (any, error)
- func (d *Decoder) Float32() float32
- func (d *Decoder) Float64() float64
- func (d *Decoder) HexField() (any, error)
- func (d *Decoder) Int16() int16
- func (d *Decoder) Int32() int32
- func (d *Decoder) Int64() int64
- func (d *Decoder) Int8() int8
- func (d *Decoder) LIBytes() (n int, b []byte)
- func (d *Decoder) LIString() (n int, s string)
- func (d *Decoder) LongdateField() (any, error)
- func (d *Decoder) RealField() (any, error)
- func (d *Decoder) ResetError()
- func (d *Decoder) SeconddateField() (any, error)
- func (d *Decoder) SecondtimeField() (any, error)
- func (d *Decoder) SetAlphanumDfv1(alphanumDfv1 bool)
- func (d *Decoder) SetEmptyDateAsNull(emptyDateAsNull bool)
- func (d *Decoder) Skip(cnt int)
- func (d *Decoder) TimeField() (any, error)
- func (d *Decoder) TimestampField() (any, error)
- func (d *Decoder) Transformer() transform.Transformer
- func (d *Decoder) Uint16() uint16
- func (d *Decoder) Uint16ByteOrder(byteOrder binary.ByteOrder) uint16
- func (d *Decoder) Uint32() uint32
- func (d *Decoder) Uint32ByteOrder(byteOrder binary.ByteOrder) uint32
- func (d *Decoder) Uint64() uint64
- func (d *Decoder) VarField() (any, error)
- type Encoder
- func (e *Encoder) BigintField(v any) error
- func (e *Encoder) Bool(v bool)
- func (e *Encoder) BooleanField(v any) error
- func (e *Encoder) Byte(b byte)
- func (e *Encoder) Bytes(p []byte)
- func (e *Encoder) CESU8Bytes(p []byte) (int, error)
- func (e *Encoder) CESU8LIBytes(p []byte) error
- func (e *Encoder) CESU8LIString(s string) error
- func (e *Encoder) CESU8String(s string) (int, error)
- func (e *Encoder) Cesu8Field(v any) error
- func (e *Encoder) DateField(v any) error
- func (e *Encoder) DaydateField(v any) error
- func (e *Encoder) Decimal(m *big.Int, exp int)
- func (e *Encoder) DecimalField(v any) error
- func (e *Encoder) DoubleField(v any) error
- func (e *Encoder) Fixed(m *big.Int, size int)
- func (e *Encoder) Fixed12Field(v any, prec, scale int) error
- func (e *Encoder) Fixed16Field(v any, prec, scale int) error
- func (e *Encoder) Fixed8Field(v any, prec, scale int) error
- func (e *Encoder) Float32(f float32)
- func (e *Encoder) Float64(f float64)
- func (e *Encoder) HexField(v any) error
- func (e *Encoder) Int16(i int16)
- func (e *Encoder) Int32(i int32)
- func (e *Encoder) Int64(i int64)
- func (e *Encoder) Int8(i int8)
- func (e *Encoder) IntegerField(v any) error
- func (e *Encoder) LIBytes(p []byte) error
- func (e *Encoder) LIString(s string) error
- func (e *Encoder) LongdateField(v any) error
- func (e *Encoder) RealField(v any) error
- func (e *Encoder) SeconddateField(v any) error
- func (e *Encoder) SecondtimeField(v any) error
- func (e *Encoder) SmallintField(v any) error
- func (e *Encoder) String(s string)
- func (e *Encoder) TimeField(v any) error
- func (e *Encoder) TimestampField(v any) error
- func (e *Encoder) TinyintField(v any) error
- func (e *Encoder) Uint16(i uint16)
- func (e *Encoder) Uint16ByteOrder(i uint16, byteOrder binary.ByteOrder)
- func (e *Encoder) Uint32(i uint32)
- func (e *Encoder) Uint64(i uint64)
- func (e *Encoder) VarField(v any) error
- func (e *Encoder) Zeroes(cnt int)
Constants ¶
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 LobInputParametersSize = 9 )
Field size constants.
Variables ¶
var ErrDecimalOutOfRange = errors.New("decimal out of range error")
ErrDecimalOutOfRange means that a big.Rat exceeds the size of hdb decimal fields.
Functions ¶
func Cesu8FieldSize ¶ added in v1.8.14
Cesu8FieldSize returns the size of a cesu8 field.
func HexFieldSize ¶ added in v1.8.14
HexFieldSize returns the size of a hex field.
func VarFieldSize ¶ added in v0.107.4
VarFieldSize returns the size of a var field.
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) AlphanumField ¶ added in v1.8.14
AlphanumField decodes a alphanum field.
func (*Decoder) BooleanField ¶ added in v1.8.14
BooleanField decodes a boolean field.
func (*Decoder) CESU8Bytes ¶
CESU8Bytes decodes CESU-8 into UTF-8 bytes. - error is only returned in case of conversion errors.
func (*Decoder) CESU8LIBytes ¶ added in v0.107.3
CESU8LIBytes decodes CESU-8 into UTF-8 bytes with length indicator.
func (*Decoder) CESU8LIString ¶ added in v0.107.3
CESU8LIString decodes a CESU-8 into a UTF-8 string with length indicator.
func (*Decoder) Cesu8Field ¶ added in v1.8.14
Cesu8Field decodes a cesu8 field.
func (*Decoder) DaydateField ¶ added in v1.8.14
DaydateField decodes a daydate field.
func (*Decoder) Decimal ¶
Decimal decodes a decimal. - error is only returned in case of conversion errors.
func (*Decoder) DecimalField ¶ added in v1.8.14
DecimalField decodes a decimal field.
func (*Decoder) DoubleField ¶ added in v1.8.14
DoubleField decodes a double field.
func (*Decoder) EmptyDateAsNull ¶ added in v1.8.14
EmptyDateAsNull returns the empty date as null flag.
func (*Decoder) Fixed12Field ¶ added in v1.8.14
Fixed12Field decodes a fixed12 field.
func (*Decoder) Fixed16Field ¶ added in v1.8.14
Fixed16Field decodes a fixed16 field.
func (*Decoder) Fixed8Field ¶ added in v1.8.14
Fixed8Field decodes a fixed8 field.
func (*Decoder) LongdateField ¶ added in v1.8.14
LongdateField decodes a longdate field.
func (*Decoder) SeconddateField ¶ added in v1.8.14
SeconddateField decodes a seconddate field.
func (*Decoder) SecondtimeField ¶ added in v1.8.14
SecondtimeField decodes a secondtime field.
func (*Decoder) SetAlphanumDfv1 ¶ added in v1.8.14
SetAlphanumDfv1 sets the alphanum dfv1 flag decoder.
func (*Decoder) SetEmptyDateAsNull ¶ added in v1.8.14
SetEmptyDateAsNull sets the empty date as null flag.
func (*Decoder) TimestampField ¶ added in v1.8.14
TimestampField decodes a timestamp field.
func (*Decoder) Transformer ¶ added in v1.8.21
func (d *Decoder) Transformer() transform.Transformer
Transformer returns the cesu8 transformer.
func (*Decoder) Uint16ByteOrder ¶ added in v0.107.0
Uint16ByteOrder decodes an uint16 in given byte order.
func (*Decoder) Uint32ByteOrder ¶
Uint32ByteOrder decodes an uint32 in given byte order.
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) BigintField ¶ added in v1.8.14
BigintField encodes a bigint field.
func (*Encoder) BooleanField ¶ added in v1.8.14
BooleanField encodes a boolean field.
func (*Encoder) CESU8Bytes ¶
CESU8Bytes encodes UTF-8 bytes into CESU-8 and returns the CESU-8 bytes written.
func (*Encoder) CESU8LIBytes ¶ added in v0.107.3
CESU8LIBytes encodes UTF-8 into CESU-8 bytes with length indicator.
func (*Encoder) CESU8LIString ¶ added in v0.107.3
CESU8LIString encodes an UTF-8 into a CESU-8 string with length indicator.
func (*Encoder) CESU8String ¶
CESU8String encodes an UTF-8 string into CESU-8 and returns the CESU-8 bytes written.
func (*Encoder) Cesu8Field ¶ added in v1.8.14
Cesu8Field encodes a cesu8 field.
func (*Encoder) DaydateField ¶ added in v1.8.14
DaydateField encodes a daydate field.
func (*Encoder) DecimalField ¶ added in v1.8.14
DecimalField encodes a decimal field.
func (*Encoder) DoubleField ¶ added in v1.8.14
DoubleField encodes a double field.
func (*Encoder) Fixed12Field ¶ added in v1.8.14
Fixed12Field encodes a fixed12 field.
func (*Encoder) Fixed16Field ¶ added in v1.8.14
Fixed16Field encodes a fixed16 field.
func (*Encoder) Fixed8Field ¶ added in v1.8.14
Fixed8Field encodes a fixed8 field.
func (*Encoder) IntegerField ¶ added in v1.8.14
IntegerField encodes a integer field.
func (*Encoder) LongdateField ¶ added in v1.8.14
LongdateField encodea a longdate field.
func (*Encoder) SeconddateField ¶ added in v1.8.14
SeconddateField encodes a seconddate field.
func (*Encoder) SecondtimeField ¶ added in v1.8.14
SecondtimeField encodes a secondtime field.
func (*Encoder) SmallintField ¶ added in v1.8.14
SmallintField encodes a smallint field.
func (*Encoder) TimestampField ¶ added in v1.8.14
TimestampField encodes a timestamp field.
func (*Encoder) TinyintField ¶ added in v1.8.14
TinyintField encodes a tinyint field.
func (*Encoder) Uint16ByteOrder ¶ added in v0.107.0
Uint16ByteOrder encodes an uint16 in given byte order.