Documentation
¶
Index ¶
- Constants
- Variables
- type ByteBuffer
- func (buf *ByteBuffer) Buffer() []byte
- func (buf *ByteBuffer) Cap() int
- func (buf *ByteBuffer) Data() []byte
- func (buf *ByteBuffer) GetUInt16(offset int) (value uint16, err error)
- func (buf *ByteBuffer) GetUInt32(offset int) (value uint32, err error)
- func (buf *ByteBuffer) GetUInt64(offset int) (value uint64, err error)
- func (buf *ByteBuffer) Length() int
- func (buf *ByteBuffer) Position() int
- func (buf *ByteBuffer) PutUInt16(offset int, value uint16) error
- func (buf *ByteBuffer) PutUInt32(offset int, value uint32) error
- func (buf *ByteBuffer) PutUInt64(offset int, value uint64) error
- func (buf *ByteBuffer) ReadBoolean() (bool, error)
- func (buf *ByteBuffer) ReadBytes(value []byte, length int) (int, error)
- func (buf *ByteBuffer) ReadFloat32() (float32, error)
- func (buf *ByteBuffer) ReadFloat64() (float64, error)
- func (buf *ByteBuffer) ReadInt8() (byte, error)
- func (buf *ByteBuffer) ReadInt16() (int16, error)
- func (buf *ByteBuffer) ReadInt32() (int32, error)
- func (buf *ByteBuffer) ReadInt64() (int64, error)
- func (buf *ByteBuffer) ReadString(length int) (string, error)
- func (buf *ByteBuffer) ReadUInt16() (uint16, error)
- func (buf *ByteBuffer) ReadUInt32() (uint32, error)
- func (buf *ByteBuffer) ReadUInt64() (uint64, error)
- func (buf *ByteBuffer) Reset()
- func (buf *ByteBuffer) SetOrder(order binary.ByteOrder)
- func (buf *ByteBuffer) SetPosition(asbOffset int) error
- func (buf *ByteBuffer) WriteBoolean(value bool) error
- func (buf *ByteBuffer) WriteBytes(value []byte) (int, error)
- func (buf *ByteBuffer) WriteFloat32(value float32) error
- func (buf *ByteBuffer) WriteFloat64(value float64) error
- func (buf *ByteBuffer) WriteInt8(value byte) error
- func (buf *ByteBuffer) WriteInt16(value int16) error
- func (buf *ByteBuffer) WriteInt32(value int32) error
- func (buf *ByteBuffer) WriteInt64(value int64) error
- func (buf *ByteBuffer) WriteString(value string) (wlen int, err error)
- func (buf *ByteBuffer) WriteUInt16(value uint16) error
- func (buf *ByteBuffer) WriteUInt32(value uint32) error
- func (buf *ByteBuffer) WriteUInt64(value uint64) error
Constants ¶
const ( TRUE = 1 FALSE = 0 )
const ( SIZEOF_1_BYTE = 1 SIZEOF_2_BYTE = 2 SIZEOF_4_BYTE = 4 SIZEOF_8_BYTE = 8 )
Variables ¶
var ErrorPositionOverflow = errors.New("Invalid data access pointer “offset”")
ErrorPositionOverflow Invalid data access pointer “offset”
var ErrorReadOverflow = errors.New("The data read pointer is out of bounds")
ErrorReadOverflow The data read pointer is out of bounds
var ErrorWriteOverflow = errors.New("The data write pointer is out of bounds")
ErrorWriteOverflow The data write pointer is out of bounds
Functions ¶
This section is empty.
Types ¶
type ByteBuffer ¶
type ByteBuffer struct {
// contains filtered or unexported fields
}
ByteBuffer A fixed-size buffer of read-write data
func NewByteBuffer ¶
func NewByteBuffer(cap int, order binary.ByteOrder) *ByteBuffer
NewByteBuffer Create a fixed-size memory buffer order to determine how the data is written, should you use either binary.LittleEndian or binary.BigEndian
func (*ByteBuffer) Buffer ¶
func (buf *ByteBuffer) Buffer() []byte
Buffer Gets the buffer raw byte array
func (*ByteBuffer) GetUInt16 ¶
func (buf *ByteBuffer) GetUInt16(offset int) (value uint16, err error)
GetUInt16 Reads a uint16 value from the specified position offset This operation does not change the location of the read/write index
func (*ByteBuffer) GetUInt32 ¶
func (buf *ByteBuffer) GetUInt32(offset int) (value uint32, err error)
GetUInt32 Reads a uint32 type value from the specified position offset This operation does not change the location of the read/write index
func (*ByteBuffer) GetUInt64 ¶
func (buf *ByteBuffer) GetUInt64(offset int) (value uint64, err error)
GetUInt64 Reads a value of type uint64 from the specified position offset This operation does not change the location of the read/write index
func (*ByteBuffer) Length ¶
func (buf *ByteBuffer) Length() int
Length Gets the buffer effective data length
func (*ByteBuffer) Position ¶
func (buf *ByteBuffer) Position() int
Position Get the read/write offset
func (*ByteBuffer) PutUInt16 ¶
func (buf *ByteBuffer) PutUInt16(offset int, value uint16) error
PutUInt16 Fill in a uint16 value of type at the specified position offset This operation does not change the location of the read/write index
func (*ByteBuffer) PutUInt32 ¶
func (buf *ByteBuffer) PutUInt32(offset int, value uint32) error
PutUInt32 Enter a uint32 type value at the specified position offset This operation does not change the location of the read/write index
func (*ByteBuffer) PutUInt64 ¶
func (buf *ByteBuffer) PutUInt64(offset int, value uint64) error
PutUInt64 Enter a value of type uint64 at the specified position offset This operation does not change the location of the read/write index
func (*ByteBuffer) ReadBoolean ¶
func (buf *ByteBuffer) ReadBoolean() (bool, error)
ReadBoolean Reads a 1-byte Boolean variable from the current location
func (*ByteBuffer) ReadBytes ¶
func (buf *ByteBuffer) ReadBytes(value []byte, length int) (int, error)
ReadBytes Success is returned when length is 0, but not read Reads a byte array from the current location When length is less than 0, the length is the length of the array "value" Returns the length of the data actually read
func (*ByteBuffer) ReadFloat32 ¶
func (buf *ByteBuffer) ReadFloat32() (float32, error)
ReadFloat32 Reads a value of type Float32 from the current position
func (*ByteBuffer) ReadFloat64 ¶
func (buf *ByteBuffer) ReadFloat64() (float64, error)
ReadFloat64 Reads a value of type Float64 from the current position
func (*ByteBuffer) ReadInt8 ¶
func (buf *ByteBuffer) ReadInt8() (byte, error)
ReadInt8 Reads a value of type int8 from the current position
func (*ByteBuffer) ReadInt16 ¶
func (buf *ByteBuffer) ReadInt16() (int16, error)
ReadInt16 Reads a value of type int16 from the current position
func (*ByteBuffer) ReadInt32 ¶
func (buf *ByteBuffer) ReadInt32() (int32, error)
ReadInt32 Reads a value of type Int32 from the current position
func (*ByteBuffer) ReadInt64 ¶
func (buf *ByteBuffer) ReadInt64() (int64, error)
ReadInt64 Reads a value of type Int64 from the current position
func (*ByteBuffer) ReadString ¶
func (buf *ByteBuffer) ReadString(length int) (string, error)
ReadString Reads a String from the current position Success is returned when length is 0, but not read When length is less than 0, it reads from the current position until it reaches "0" and returns the result, otherwise all subsequent data is returned
func (*ByteBuffer) ReadUInt16 ¶
func (buf *ByteBuffer) ReadUInt16() (uint16, error)
ReadUInt16 Reads a value of type UInt16 from the current position
func (*ByteBuffer) ReadUInt32 ¶
func (buf *ByteBuffer) ReadUInt32() (uint32, error)
ReadUInt32 Reads a value of type UInt32 from the current position
func (*ByteBuffer) ReadUInt64 ¶
func (buf *ByteBuffer) ReadUInt64() (uint64, error)
ReadUInt64 Reads a value of type UInt64 from the current position
func (*ByteBuffer) Reset ¶
func (buf *ByteBuffer) Reset()
Reset Clear the read/write index and data in the buffer
func (*ByteBuffer) SetOrder ¶
func (buf *ByteBuffer) SetOrder(order binary.ByteOrder)
SetOrder Set the read and write mode of the buffer Used binary.LittleEndian or binary.BigEndian
func (*ByteBuffer) SetPosition ¶
func (buf *ByteBuffer) SetPosition(asbOffset int) error
SetPosition Set the read/write offset
func (*ByteBuffer) WriteBoolean ¶
func (buf *ByteBuffer) WriteBoolean(value bool) error
WriteBoolean Writes a 1-byte Boolean variable at the current location
func (*ByteBuffer) WriteBytes ¶
func (buf *ByteBuffer) WriteBytes(value []byte) (int, error)
WriteBytes Writes a byte array at the current location and returns the length of the data successfully written
func (*ByteBuffer) WriteFloat32 ¶
func (buf *ByteBuffer) WriteFloat32(value float32) error
WriteFloat32 Writes an Float32 type value to the current location
func (*ByteBuffer) WriteFloat64 ¶
func (buf *ByteBuffer) WriteFloat64(value float64) error
WriteFloat64 Writes an Float64 type value to the current location
func (*ByteBuffer) WriteInt8 ¶
func (buf *ByteBuffer) WriteInt8(value byte) error
WriteInt8 Writes an int8 type value to the current location
func (*ByteBuffer) WriteInt16 ¶
func (buf *ByteBuffer) WriteInt16(value int16) error
WriteInt16 Writes an int16 type value to the current location
func (*ByteBuffer) WriteInt32 ¶
func (buf *ByteBuffer) WriteInt32(value int32) error
WriteInt32 Writes an int32 type value to the current location
func (*ByteBuffer) WriteInt64 ¶
func (buf *ByteBuffer) WriteInt64(value int64) error
WriteInt64 Writes an int64 type value to the current location
func (*ByteBuffer) WriteString ¶
func (buf *ByteBuffer) WriteString(value string) (wlen int, err error)
WriteString Writes a String at the current location
func (*ByteBuffer) WriteUInt16 ¶
func (buf *ByteBuffer) WriteUInt16(value uint16) error
WriteUInt16 Writes a uint16 value at the current location
func (*ByteBuffer) WriteUInt32 ¶
func (buf *ByteBuffer) WriteUInt32(value uint32) error
WriteUInt32 Writes an UInt32 type value to the current location
func (*ByteBuffer) WriteUInt64 ¶
func (buf *ByteBuffer) WriteUInt64(value uint64) error
WriteUInt64 Writes an UInt64 type value to the current location