Documentation ¶
Overview ¶
rw is the read-write package for reading and writing types from the OrientDB binary network protocol. Reading is done via io.Reader and writing is done to bytes.Buffer (since the extra functionality of byte.Buffer is desired). All the OrientDB types are represented here for non-encoded forms. For varint and zigzag encoding/decoding handling use the obinary/varint package instead.
Index ¶
- Constants
- Variables
- type ByteReader
- type ReadSeeker
- type Reader
- func (r *Reader) Err() error
- func (r *Reader) Read(p []byte) (int, error)
- func (r *Reader) ReadBool() bool
- func (r *Reader) ReadByte() byte
- func (r *Reader) ReadBytes() []byte
- func (r *Reader) ReadBytesVarint() []byte
- func (r *Reader) ReadDouble() (v float64)
- func (r *Reader) ReadFloat() (v float32)
- func (r *Reader) ReadInt() (v int32)
- func (r *Reader) ReadLong() (v int64)
- func (r *Reader) ReadRawBytes(buf []byte) error
- func (r *Reader) ReadShort() (v int16)
- func (r *Reader) ReadString() string
- func (r *Reader) ReadStringVarint() string
- func (r *Reader) ReadUvarint() uint64
- func (r *Reader) ReadVarint() int64
- type Writer
- func (w Writer) Err() error
- func (w *Writer) Write(p []byte) (int, error)
- func (w *Writer) WriteBool(b bool) error
- func (w *Writer) WriteByte(b byte) error
- func (w *Writer) WriteBytes(bs []byte) error
- func (w *Writer) WriteBytesVarint(bs []byte) (int, error)
- func (w *Writer) WriteDouble(f float64) error
- func (w *Writer) WriteFloat(f float32) error
- func (w *Writer) WriteInt(n int32) error
- func (w *Writer) WriteLong(n int64) error
- func (w *Writer) WriteNull() error
- func (w *Writer) WriteRawBytes(bs []byte) error
- func (w *Writer) WriteShort(n int16) error
- func (w *Writer) WriteString(s string) error
- func (w *Writer) WriteStringVarint(s string) (int, error)
- func (w *Writer) WriteStrings(ss ...string) error
- func (w *Writer) WriteVarint(v int64) (int, error)
Constants ¶
const ( SizeByte = 1 SizeShort = 2 SizeInt = 4 SizeLong = 8 SizeFloat = SizeInt SizeDouble = SizeLong )
Variables ¶
var Order = binary.BigEndian
Functions ¶
This section is empty.
Types ¶
type ByteReader ¶
type ByteReader interface { io.Reader io.ByteReader }
type ReadSeeker ¶
func NewReadSeeker ¶
func NewReadSeeker(r io.ReadSeeker) *ReadSeeker
type Reader ¶
func (*Reader) ReadBool ¶
Reads one byte from the Reader. If the byte is zero, then false is returned, otherwise true. If error is non-nil, then the bool value is undefined.
func (*Reader) ReadBytes ¶
ReadBytes reads in an OrientDB byte array. It reads the first 4 bytes from the Reader as an int to determine the length of the byte array to read in. If the specified size of the byte array is 0 (empty) or negative (null) nil is returned for the []byte.
func (*Reader) ReadBytesVarint ¶
varint.ReadBytes, like rw.ReadBytes, first reads a length from the input buffer and then that number of bytes into a []byte from the input buffer. The difference is that the integer indicating the length of the byte array to follow is a zigzag encoded varint.
func (*Reader) ReadDouble ¶
func (*Reader) ReadRawBytes ¶
func (*Reader) ReadString ¶
ReadString xxxx If the string size is 0 an empty string and nil error are returned
func (*Reader) ReadStringVarint ¶
varint.ReadString, like rw.ReadString, first reads a length from the input buffer and then that number of bytes (of ASCII chars) into a string from the input buffer. The difference is that the integer indicating the length of the byte array to follow is a zigzag encoded varint.
func (*Reader) ReadUvarint ¶
ReadVarIntToUint reads a variable length integer from the input buffer. The inflated integer is written is returned as a uint64 value. This method only "inflates" the varint into a uint64; it does NOT zigzag decode it.
func (*Reader) ReadVarint ¶
ReadVarIntAndDecode64 reads a varint from r to a uint64 and then zigzag decodes it to an int64 value.
type Writer ¶
func (*Writer) WriteBool ¶
WriteBool writes byte(1) for true and byte(0) for false to Writer, as specified by the OrientDB spec.
func (*Writer) WriteBytes ¶
WriteBytes is meant to be used for writing a structure that the OrientDB will interpret as a byte array, usually a serialized data structure. This means the first thing written to Writer is the size of the byte array. If you want to write bytes without the the size prefix, use WriteRawBytes instead.
func (*Writer) WriteDouble ¶
WriteDouble writes a float64 in big endian order to Writer
func (*Writer) WriteFloat ¶
WriteFloat writes a float32 in big endian order to Writer
func (*Writer) WriteRawBytes ¶
WriteRawBytes just writes the bytes, not prefixed by the size of the []byte
func (*Writer) WriteShort ¶
WriteShort writes a int16 in big endian order to Writer