rw

package
v0.0.0-...-625dcbc Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2018 License: MIT Imports: 3 Imported by: 0

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

View Source
const (
	SizeByte   = 1
	SizeShort  = 2
	SizeInt    = 4
	SizeLong   = 8
	SizeFloat  = SizeInt
	SizeDouble = SizeLong
)

Variables

Functions

This section is empty.

Types

type ByteReader

type ByteReader interface {
	io.Reader
	io.ByteReader
}

type ReadSeeker

type ReadSeeker struct {
	*Reader
	S io.Seeker
}

func NewReadSeeker

func NewReadSeeker(r io.ReadSeeker) *ReadSeeker

func (*ReadSeeker) Seek

func (r *ReadSeeker) Seek(off int64, whence int) (int64, error)

type Reader

type Reader struct {
	R io.Reader
	// contains filtered or unexported fields
}

func NewReader

func NewReader(r io.Reader) *Reader

func (*Reader) Err

func (r *Reader) Err() error

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

func (*Reader) ReadBool

func (r *Reader) ReadBool() bool

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) ReadByte

func (r *Reader) ReadByte() byte

func (*Reader) ReadBytes

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

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

func (r *Reader) ReadBytesVarint() []byte

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 (r *Reader) ReadDouble() (v float64)

func (*Reader) ReadFloat

func (r *Reader) ReadFloat() (v float32)

func (*Reader) ReadInt

func (r *Reader) ReadInt() (v int32)

func (*Reader) ReadLong

func (r *Reader) ReadLong() (v int64)

func (*Reader) ReadRawBytes

func (r *Reader) ReadRawBytes(buf []byte) error

func (*Reader) ReadShort

func (r *Reader) ReadShort() (v int16)

func (*Reader) ReadString

func (r *Reader) ReadString() string

ReadString xxxx If the string size is 0 an empty string and nil error are returned

func (*Reader) ReadStringVarint

func (r *Reader) ReadStringVarint() string

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

func (r *Reader) ReadUvarint() uint64

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

func (r *Reader) ReadVarint() int64

ReadVarIntAndDecode64 reads a varint from r to a uint64 and then zigzag decodes it to an int64 value.

type Writer

type Writer struct {
	W io.Writer
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(w io.Writer) *Writer

func (Writer) Err

func (w Writer) Err() error

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

func (*Writer) WriteBool

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

WriteBool writes byte(1) for true and byte(0) for false to Writer, as specified by the OrientDB spec.

func (*Writer) WriteByte

func (w *Writer) WriteByte(b byte) error

func (*Writer) WriteBytes

func (w *Writer) WriteBytes(bs []byte) error

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) WriteBytesVarint

func (w *Writer) WriteBytesVarint(bs []byte) (int, error)

func (*Writer) WriteDouble

func (w *Writer) WriteDouble(f float64) error

WriteDouble writes a float64 in big endian order to Writer

func (*Writer) WriteFloat

func (w *Writer) WriteFloat(f float32) error

WriteFloat writes a float32 in big endian order to Writer

func (*Writer) WriteInt

func (w *Writer) WriteInt(n int32) error

WriteInt writes a int32 in big endian order to Writer

func (*Writer) WriteLong

func (w *Writer) WriteLong(n int64) error

WriteLong writes a int64 in big endian order to Writer

func (*Writer) WriteNull

func (w *Writer) WriteNull() error

func (*Writer) WriteRawBytes

func (w *Writer) WriteRawBytes(bs []byte) error

WriteRawBytes just writes the bytes, not prefixed by the size of the []byte

func (*Writer) WriteShort

func (w *Writer) WriteShort(n int16) error

WriteShort writes a int16 in big endian order to Writer

func (*Writer) WriteString

func (w *Writer) WriteString(s string) error

func (*Writer) WriteStringVarint

func (w *Writer) WriteStringVarint(s string) (int, error)

func (*Writer) WriteStrings

func (w *Writer) WriteStrings(ss ...string) error

func (*Writer) WriteVarint

func (w *Writer) WriteVarint(v int64) (int, error)

WriteVarint zigzag encodes the int64 passed in and then translates that number to a protobuf/OrientDB varint, writing the bytes of that varint to the io.Writer.

Jump to

Keyboard shortcuts

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