hprose

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2015 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/* Serialize Tags */
	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'
)

Variables

View Source
var ClassManager = initClassManager()

ClassManager used to be register class with alias for hprose serialize/unserialize.

View Source
var ErrNil = errors.New("nil")

ErrNil is a error of nil

Functions

func Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal data

func Serialize

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

Serialize data

func Unmarshal

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

Unmarshal data

func Unserialize

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

Unserialize data

Types

type BufReader

type BufReader interface {
	Read(p []byte) (n int, err error)
	ReadByte() (c byte, err error)
	ReadRune() (r rune, size int, err error)
	ReadString(delim byte) (line string, err error)
}

BufReader is buffer reader interface, Hprose Reader use it as input stream.

type BufWriter

type BufWriter interface {
	Write(p []byte) (n int, err error)
	WriteByte(c byte) error
	WriteRune(r rune) (n int, err error)
	WriteString(s string) (n int, err error)
}

BufWriter is buffer writer interface, Hprose Writer use it as output stream.

type BytesReader

type BytesReader struct {
	Bytes []byte
	Pos   int
}

BytesReader is a bytes reader

func NewBytesReader

func NewBytesReader(b []byte) (reader *BytesReader)

NewBytesReader is the constructor of BytesReader

func (*BytesReader) Read

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

Read bytes from BytesReader

func (*BytesReader) ReadByte

func (r *BytesReader) ReadByte() (b byte, err error)

ReadByte from BytesReader

func (*BytesReader) ReadRune

func (r *BytesReader) ReadRune() (ch rune, size int, err error)

ReadRune from BytesReader

func (*BytesReader) ReadString

func (r *BytesReader) ReadString(delim byte) (line string, err error)

ReadString from BytesReader

type RawReader

type RawReader struct {
	Stream BufReader
}

RawReader is the hprose raw reader

func NewRawReader

func NewRawReader(stream BufReader) (reader *RawReader)

NewRawReader is a constructor for RawReader

func (*RawReader) ReadRaw

func (r *RawReader) ReadRaw() (raw []byte, err error)

ReadRaw from stream

func (*RawReader) ReadRawTo

func (r *RawReader) ReadRawTo(ostream BufWriter) (err error)

ReadRawTo ostream from stream

type Reader

type Reader struct {
	*RawReader

	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 NewReader

func NewReader(stream BufReader, simple bool) (reader *Reader)

NewReader is the constructor for Hprose Reader

func (*Reader) CheckTag

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

CheckTag the next byte in stream is the expected tag

func (*Reader) CheckTags

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

CheckTags the next byte in stream in the expected tags

func (*Reader) ReadArray

func (r *Reader) ReadArray(a []reflect.Value) error

ReadArray from stream

func (*Reader) ReadBigInt

func (r *Reader) ReadBigInt() (*big.Int, error)

ReadBigInt from stream

func (*Reader) ReadBigIntWithoutTag

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

ReadBigIntWithoutTag from stream

func (*Reader) ReadBool

func (r *Reader) ReadBool() (bool, error)

ReadBool from stream

func (*Reader) ReadBytes

func (r *Reader) ReadBytes() (*[]byte, error)

ReadBytes from stream

func (*Reader) ReadBytesWithoutTag

func (r *Reader) ReadBytesWithoutTag() (*[]byte, error)

ReadBytesWithoutTag from stream

func (*Reader) ReadDateTime

func (r *Reader) ReadDateTime() (time.Time, error)

ReadDateTime from stream

func (*Reader) ReadDateWithoutTag

func (r *Reader) ReadDateWithoutTag() (time.Time, error)

ReadDateWithoutTag from stream

func (*Reader) ReadFloat32

func (r *Reader) ReadFloat32() (float32, error)

ReadFloat32 from stream

func (*Reader) ReadFloat32WithoutTag

func (r *Reader) ReadFloat32WithoutTag() (float32, error)

ReadFloat32WithoutTag from stream

func (*Reader) ReadFloat64

func (r *Reader) ReadFloat64() (float64, error)

ReadFloat64 from stream

func (*Reader) ReadFloat64WithoutTag

func (r *Reader) ReadFloat64WithoutTag() (float64, error)

ReadFloat64WithoutTag from stream

func (*Reader) ReadInt

func (r *Reader) ReadInt() (int, error)

ReadInt from stream

func (*Reader) ReadInt16

func (r *Reader) ReadInt16() (int16, error)

ReadInt16 from stream

func (*Reader) ReadInt16WithoutTag

func (r *Reader) ReadInt16WithoutTag() (int16, error)

ReadInt16WithoutTag from stream

func (*Reader) ReadInt32

func (r *Reader) ReadInt32() (int32, error)

ReadInt32 from stream

func (*Reader) ReadInt32WithoutTag

func (r *Reader) ReadInt32WithoutTag() (int32, error)

ReadInt32WithoutTag from stream

func (*Reader) ReadInt64

func (r *Reader) ReadInt64() (int64, error)

ReadInt64 from stream

func (*Reader) ReadInt64WithoutTag

func (r *Reader) ReadInt64WithoutTag() (int64, error)

ReadInt64WithoutTag from stream

func (*Reader) ReadInt8

func (r *Reader) ReadInt8() (int8, error)

ReadInt8 from stream

func (*Reader) ReadInt8WithoutTag

func (r *Reader) ReadInt8WithoutTag() (int8, error)

ReadInt8WithoutTag from stream

func (*Reader) ReadIntWithoutTag

func (r *Reader) ReadIntWithoutTag() (int, error)

ReadIntWithoutTag from stream

func (*Reader) ReadInteger

func (r *Reader) ReadInteger(tag byte) (int, error)

ReadInteger from stream

func (*Reader) ReadList

func (r *Reader) ReadList() (*list.List, error)

ReadList from stream

func (*Reader) ReadListWithoutTag

func (r *Reader) ReadListWithoutTag() (*list.List, error)

ReadListWithoutTag from stream

func (*Reader) ReadMap

func (r *Reader) ReadMap(p interface{}) error

ReadMap from stream

func (*Reader) ReadMapWithoutTag

func (r *Reader) ReadMapWithoutTag(p interface{}) error

ReadMapWithoutTag from stream

func (*Reader) ReadObject

func (r *Reader) ReadObject(p interface{}) error

ReadObject from stream

func (*Reader) ReadObjectWithoutTag

func (r *Reader) ReadObjectWithoutTag(p interface{}) error

ReadObjectWithoutTag from stream

func (*Reader) ReadSlice

func (r *Reader) ReadSlice(p interface{}) error

ReadSlice from stream

func (*Reader) ReadSliceWithoutTag

func (r *Reader) ReadSliceWithoutTag(p interface{}) error

ReadSliceWithoutTag from stream

func (*Reader) ReadString

func (r *Reader) ReadString() (string, error)

ReadString from stream

func (*Reader) ReadStringWithoutTag

func (r *Reader) ReadStringWithoutTag() (str string, err error)

ReadStringWithoutTag from stream

func (*Reader) ReadTimeWithoutTag

func (r *Reader) ReadTimeWithoutTag() (time.Time, error)

ReadTimeWithoutTag from stream

func (*Reader) ReadUUID

func (r *Reader) ReadUUID() (*UUID, error)

ReadUUID from stream

func (*Reader) ReadUUIDWithoutTag

func (r *Reader) ReadUUIDWithoutTag() (*UUID, error)

ReadUUIDWithoutTag from stream

func (*Reader) ReadUint

func (r *Reader) ReadUint() (uint, error)

ReadUint from stream

func (*Reader) ReadUint16

func (r *Reader) ReadUint16() (uint16, error)

ReadUint16 from stream

func (*Reader) ReadUint16WithoutTag

func (r *Reader) ReadUint16WithoutTag() (uint16, error)

ReadUint16WithoutTag from stream

func (*Reader) ReadUint32

func (r *Reader) ReadUint32() (uint32, error)

ReadUint32 from stream

func (*Reader) ReadUint32WithoutTag

func (r *Reader) ReadUint32WithoutTag() (uint32, error)

ReadUint32WithoutTag from stream

func (*Reader) ReadUint64

func (r *Reader) ReadUint64() (uint64, error)

ReadUint64 from stream

func (*Reader) ReadUint64WithoutTag

func (r *Reader) ReadUint64WithoutTag() (uint64, error)

ReadUint64WithoutTag from stream

func (*Reader) ReadUint8

func (r *Reader) ReadUint8() (uint8, error)

ReadUint8 from stream

func (*Reader) ReadUint8WithoutTag

func (r *Reader) ReadUint8WithoutTag() (uint8, error)

ReadUint8WithoutTag from stream

func (*Reader) ReadUintWithoutTag

func (r *Reader) ReadUintWithoutTag() (uint, error)

ReadUintWithoutTag from stream

func (*Reader) ReadUinteger

func (r *Reader) ReadUinteger(tag byte) (uint, error)

ReadUinteger from stream

func (*Reader) ReadValue

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

ReadValue from stream

func (*Reader) Reset

func (r *Reader) Reset()

Reset the serialize reference count

func (*Reader) Unserialize

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

Unserialize a data from stream

type UUID

type UUID []byte

UUID type is only a UUID wrapper for hprose serialize/unserialize, If you want to generate UUIDs, you should use other UUID package.

func ToUUID

func ToUUID(s string) UUID

ToUUID decodes s into a UUID or returns nil. Both the UUID form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded.

func (UUID) String

func (uuid UUID) String() string

String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx , or "" if uuid is invalid.

type Writer

type Writer struct {
	Stream BufWriter
	// contains filtered or unexported fields
}

Writer is a fine-grained operation struct for Hprose serialization

func NewWriter

func NewWriter(stream BufWriter, simple bool) (writer *Writer)

NewWriter is the constructor for Hprose Writer

func (*Writer) Reset

func (w *Writer) Reset()

Reset the serialize reference count

func (*Writer) Serialize

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

Serialize a data to stream

func (*Writer) WriteArray

func (w *Writer) WriteArray(v []reflect.Value) (err error)

WriteArray to stream

func (*Writer) WriteBigInt

func (w *Writer) WriteBigInt(v *big.Int) (err error)

WriteBigInt to stream

func (*Writer) WriteBool

func (w *Writer) WriteBool(v bool) error

WriteBool to stream

func (*Writer) WriteBytes

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

WriteBytes to stream

func (*Writer) WriteBytesWithRef

func (w *Writer) WriteBytesWithRef(bytes []byte) (err error)

WriteBytesWithRef to stream

func (*Writer) WriteFloat64

func (w *Writer) WriteFloat64(v float64) (err error)

WriteFloat64 to stream

func (*Writer) WriteInt64

func (w *Writer) WriteInt64(v int64) (err error)

WriteInt64 to stream

func (*Writer) WriteNull

func (w *Writer) WriteNull() error

WriteNull to stream

func (*Writer) WriteString

func (w *Writer) WriteString(str string) (err error)

WriteString to stream

func (*Writer) WriteStringWithRef

func (w *Writer) WriteStringWithRef(str string) (err error)

WriteStringWithRef to stream

func (*Writer) WriteTime

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

WriteTime to stream

func (*Writer) WriteUint64

func (w *Writer) WriteUint64(v uint64) (err error)

WriteUint64 to stream

func (*Writer) WriteValue

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

WriteValue to stream

Jump to

Keyboard shortcuts

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