hprose-golang: github.com/hprose/hprose-golang/io Index | Files

package io

import "github.com/hprose/hprose-golang/io"

Package io is the hprose serialization library for Golang.


Package Files

array_decoder.go bool_decoder.go byte_pool.go byte_reader.go byte_writer.go complex128_decoder.go complex64_decoder.go decoder.go doc.go encoder.go float32_decoder.go float64_decoder.go formatter.go int_decoder.go interface_decoder.go map_decoder.go map_encoder.go ptr_decoder.go raw_reader.go reader.go reader_pool.go slice_decoder.go slice_encoder.go string_decoder.go struct_decoder.go struct_encoder.go tags.go types.go uint_decoder.go writer.go


const (

    // Serialize Type
    TagInteger  byte = 'i'
    TagLong     byte = 'l'
    TagDouble   byte = 'd'
    TagNull     byte = 'n'
    TagEmpty    byte = 'e'
    TagTrue     byte = 't'
    TagFalse    byte = 'f'
    TagNaN      byte = 'N'
    TagInfinity byte = 'I'
    TagDate     byte = 'D'
    TagTime     byte = 'T'
    TagUTC      byte = 'Z'
    TagBytes    byte = 'b'
    TagUTF8Char byte = 'u'
    TagString   byte = 's'
    TagGUID     byte = 'g'
    TagList     byte = 'a'
    TagMap      byte = 'm'
    TagClass    byte = 'c'
    TagObject   byte = 'o'
    TagRef      byte = 'r'

    // Serialize Marks
    TagPos        byte = '+'
    TagNeg        byte = '-'
    TagSemicolon  byte = ';'
    TagOpenbrace  byte = '{'
    TagClosebrace byte = '}'
    TagQuote      byte = '"'
    TagPoint      byte = '.'

    // Protocol Tags
    TagFunctions byte = 'F'
    TagCall      byte = 'C'
    TagResult    byte = 'R'
    TagArgument  byte = 'A'
    TagError     byte = 'E'
    TagEnd       byte = 'z'

Hprose Tags

func AcquireBytes Uses

func AcquireBytes(size int) []byte

AcquireBytes from pool.

func GetAlias Uses

func GetAlias(structType reflect.Type) string

GetAlias of structType

func GetStructType Uses

func GetStructType(alias string) (structType reflect.Type)

GetStructType by alias.

func GetTag Uses

func GetTag(structType reflect.Type) string

GetTag by structType.

func Marshal Uses

func Marshal(v interface{}) []byte

Marshal data

func Register Uses

func Register(proto interface{}, alias string, tag ...string)

Register the type of the proto with alias & tag.

func RegisterMapEncoder Uses

func RegisterMapEncoder(m interface{}, encoder func(*Writer, interface{}))

RegisterMapEncoder for fast serialize custom map type. This function is usually used for code generators. This function should be called in package init function.

func RegisterSliceEncoder Uses

func RegisterSliceEncoder(s interface{}, encoder func(*Writer, interface{}))

RegisterSliceEncoder for fast serialize custom slice type. This function is usually used for code generators. This function should be called in package init function.

func ReleaseBytes Uses

func ReleaseBytes(bytes []byte) bool

ReleaseBytes to pool.

func ReleaseReader Uses

func ReleaseReader(reader *Reader)

ReleaseReader to pool.

func Serialize Uses

func Serialize(v interface{}, simple bool) []byte

Serialize data

func Unmarshal Uses

func Unmarshal(b []byte, p interface{})

Unmarshal data

func Unserialize Uses

func Unserialize(b []byte, p interface{}, simple bool)

Unserialize data

type ByteReader Uses

type ByteReader struct {
    // contains filtered or unexported fields

ByteReader implements the io.Reader and io.ByteReader interfaces by reading from a byte slice

func NewByteReader Uses

func NewByteReader(buf []byte) (reader *ByteReader)

NewByteReader is a constructor for ByteReader

func (*ByteReader) Init Uses

func (r *ByteReader) Init(buf []byte)

Init ByteReader

func (*ByteReader) Next Uses

func (r *ByteReader) Next(n int) (data []byte)

Next returns a slice containing the next n bytes from the buffer, advancing the buffer as if the bytes had been returned by Read. If there are fewer than n bytes, Next returns the entire buffer. The slice is only valid until the next call to a read or write method.

func (*ByteReader) Read Uses

func (r *ByteReader) Read(b []byte) (n int, err error)

Read reads the next len(b) bytes from the buffer or until the buffer is drained. The return value n is the number of bytes read. If the buffer has no data, err is io.EOF (unless len(b) is zero); otherwise it is nil.

func (*ByteReader) ReadByte Uses

func (r *ByteReader) ReadByte() (byte, error)

ReadByte reads and returns a single byte. If no byte is available, it returns error io.EOF.

func (*ByteReader) Unread Uses

func (r *ByteReader) Unread(n int)

Unread n bytes from the current position.

func (*ByteReader) UnreadByte Uses

func (r *ByteReader) UnreadByte() error

UnreadByte unreads 1 byte from the current position.

type ByteWriter Uses

type ByteWriter struct {
    // contains filtered or unexported fields

ByteWriter implements the io.Writer and io.ByteWriter interfaces by writing to a byte slice

func NewByteWriter Uses

func NewByteWriter(buf []byte) (w *ByteWriter)

NewByteWriter create a ByteWriter in append mode

func (*ByteWriter) Bytes Uses

func (w *ByteWriter) Bytes() []byte

Bytes returns the byte slice of this writer.

func (*ByteWriter) Clear Uses

func (w *ByteWriter) Clear()

Clear the byte slice of this writer.

func (*ByteWriter) Grow Uses

func (w *ByteWriter) Grow(n int)

Grow the the byte slice capacity of this writer.

func (*ByteWriter) Len Uses

func (w *ByteWriter) Len() int

Len return the number of byte of this writer.

func (*ByteWriter) String Uses

func (w *ByteWriter) String() string

String returns the contents of this writer as a string. If the ByteWriter is a nil pointer, it returns "<nil>".

func (*ByteWriter) Write Uses

func (w *ByteWriter) Write(b []byte) (int, error)

Write the contents of b to the byte slice of this writer.

func (*ByteWriter) WriteByte Uses

func (w *ByteWriter) WriteByte(c byte) error

WriteByte c to the byte slice of this writer.

type RawReader Uses

type RawReader struct {

RawReader is the hprose raw reader

func NewRawReader Uses

func NewRawReader(buf []byte) (reader *RawReader)

NewRawReader is a constructor for RawReader

func (*RawReader) ReadRaw Uses

func (r *RawReader) ReadRaw() (raw []byte)

ReadRaw from stream

func (*RawReader) ReadRawTo Uses

func (r *RawReader) ReadRawTo(w *ByteWriter)

ReadRawTo buffer from stream

type Reader Uses

type Reader struct {
    Simple bool

    JSONCompatible bool
    // contains filtered or unexported fields

Reader is a fine-grained operation struct for Hprose unserialization when JSONCompatible is true, the Map data will unserialize to map[string]interface as the default type

func AcquireReader Uses

func AcquireReader(buf []byte, simple bool) *Reader

AcquireReader from pool.

func NewReader Uses

func NewReader(buf []byte, simple bool) (reader *Reader)

NewReader is the constructor for Hprose Reader

func (*Reader) CheckTag Uses

func (r *Reader) CheckTag(expectTag byte) (tag byte)

CheckTag the next byte in reader is the expected tag or not

func (*Reader) CheckTags Uses

func (r *Reader) CheckTags(expectTags []byte) (tag byte)

CheckTags the next byte in reader in the expected tags

func (*Reader) ReadBigIntWithoutTag Uses

func (r *Reader) ReadBigIntWithoutTag() *big.Int

ReadBigIntWithoutTag from the reader

func (*Reader) ReadBool Uses

func (r *Reader) ReadBool() bool

ReadBool from the reader

func (*Reader) ReadBytes Uses

func (r *Reader) ReadBytes() (b []byte)

ReadBytes from the reader

func (*Reader) ReadBytesWithoutTag Uses

func (r *Reader) ReadBytesWithoutTag() (b []byte)

ReadBytesWithoutTag from the reader

func (*Reader) ReadComplex128 Uses

func (r *Reader) ReadComplex128() complex128

ReadComplex128 from the reader

func (*Reader) ReadComplex64 Uses

func (r *Reader) ReadComplex64() complex64

ReadComplex64 from the reader

func (*Reader) ReadCount Uses

func (r *Reader) ReadCount() int

ReadCount of array, slice, map or struct field

func (*Reader) ReadDateTimeWithoutTag Uses

func (r *Reader) ReadDateTimeWithoutTag() (dt time.Time)

ReadDateTimeWithoutTag from the reader

func (*Reader) ReadFloat32 Uses

func (r *Reader) ReadFloat32() float32

ReadFloat32 from the reader

func (*Reader) ReadFloat64 Uses

func (r *Reader) ReadFloat64() float64

ReadFloat64 from the reader

func (*Reader) ReadInt Uses

func (r *Reader) ReadInt() int64

ReadInt from the reader

func (*Reader) ReadIntWithoutTag Uses

func (r *Reader) ReadIntWithoutTag() int

ReadIntWithoutTag from the reader

func (*Reader) ReadInterface Uses

func (r *Reader) ReadInterface() (v interface{})

ReadInterface from the reader

func (*Reader) ReadSlice Uses

func (r *Reader) ReadSlice(v []reflect.Value)

ReadSlice from the reader

func (*Reader) ReadSliceWithoutTag Uses

func (r *Reader) ReadSliceWithoutTag() []reflect.Value

ReadSliceWithoutTag from the reader

func (*Reader) ReadString Uses

func (r *Reader) ReadString() string

ReadString from the reader

func (*Reader) ReadStringWithoutTag Uses

func (r *Reader) ReadStringWithoutTag() (str string)

ReadStringWithoutTag from the reader

func (*Reader) ReadTime Uses

func (r *Reader) ReadTime() time.Time

ReadTime from the reader

func (*Reader) ReadTimeWithoutTag Uses

func (r *Reader) ReadTimeWithoutTag() (t time.Time)

ReadTimeWithoutTag from the reader

func (*Reader) ReadUint Uses

func (r *Reader) ReadUint() uint64

ReadUint from the reader

func (*Reader) ReadValue Uses

func (r *Reader) ReadValue(v reflect.Value)

ReadValue from the reader

func (*Reader) Reset Uses

func (r *Reader) Reset()

Reset the reference counter

func (*Reader) Unserialize Uses

func (r *Reader) Unserialize(p interface{})

Unserialize a data from the reader

type ReaderPool Uses

type ReaderPool struct {

ReaderPool is a reader pool for hprose client & service

func (*ReaderPool) AcquireReader Uses

func (pool *ReaderPool) AcquireReader(buf []byte, simple bool) (reader *Reader)

AcquireReader from pool.

func (*ReaderPool) ReleaseReader Uses

func (pool *ReaderPool) ReleaseReader(reader *Reader)

ReleaseReader to pool.

type Writer Uses

type Writer struct {
    Simple bool
    // contains filtered or unexported fields

Writer is a fine-grained operation struct for Hprose serialization

func NewWriter Uses

func NewWriter(simple bool, buf ...byte) (w *Writer)

NewWriter is the constructor for Hprose Writer

func (*Writer) Reset Uses

func (w *Writer) Reset()

Reset the reference counter

func (*Writer) Serialize Uses

func (w *Writer) Serialize(v interface{}) *Writer

Serialize a data v to the writer

func (*Writer) WriteBigFloat Uses

func (w *Writer) WriteBigFloat(bf *big.Float)

WriteBigFloat to the writer

func (*Writer) WriteBigInt Uses

func (w *Writer) WriteBigInt(bi *big.Int)

WriteBigInt to the writer

func (*Writer) WriteBigRat Uses

func (w *Writer) WriteBigRat(br *big.Rat)

WriteBigRat to the writer

func (*Writer) WriteBool Uses

func (w *Writer) WriteBool(b bool)

WriteBool to the writer

func (*Writer) WriteBytes Uses

func (w *Writer) WriteBytes(bytes []byte)

WriteBytes to the writer

func (*Writer) WriteComplex128 Uses

func (w *Writer) WriteComplex128(c complex128)

WriteComplex128 to the writer

func (*Writer) WriteComplex64 Uses

func (w *Writer) WriteComplex64(c complex64)

WriteComplex64 to the writer

func (*Writer) WriteFloat Uses

func (w *Writer) WriteFloat(f float64, bitSize int)

WriteFloat to the writer

func (*Writer) WriteInt Uses

func (w *Writer) WriteInt(i int64)

WriteInt to the writer

func (*Writer) WriteList Uses

func (w *Writer) WriteList(lst *list.List)

WriteList to the writer

func (*Writer) WriteNil Uses

func (w *Writer) WriteNil()

WriteNil to the writer

func (*Writer) WriteSlice Uses

func (w *Writer) WriteSlice(slice []reflect.Value)

WriteSlice to the writer

func (*Writer) WriteString Uses

func (w *Writer) WriteString(str string)

WriteString to the writer

func (*Writer) WriteStringSlice Uses

func (w *Writer) WriteStringSlice(slice []string)

WriteStringSlice to the writer

func (*Writer) WriteTime Uses

func (w *Writer) WriteTime(t *time.Time)

WriteTime to the writer

func (*Writer) WriteTuple Uses

func (w *Writer) WriteTuple(tuple ...interface{})

WriteTuple to the writer

func (*Writer) WriteUint Uses

func (w *Writer) WriteUint(i uint64)

WriteUint to the writer

func (*Writer) WriteValue Uses

func (w *Writer) WriteValue(v reflect.Value)

WriteValue to the writer

Package io imports 13 packages (graph) and is imported by 2 packages. Updated 2018-05-22. Refresh now. Tools for package owners.