common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const NumberValueMagic uint32 = 0x6E6D6276

NumberValueMagic is vbmn in little endian ascii ==> nmbv

Variables

This section is empty.

Functions

func ParseLengthAndMagic

func ParseLengthAndMagic(bytes []byte, exptectedMagic uint32) (int, []byte, error)

ParseLengthAndMagic checks if if the given byte array is longer or equal the uint32 in the first 4 bytes, and if the magic value in the second 4 bytes equals the supplied magic and returns the length, a slice of the bytes without length and magic or an error.

func WriteLengthAndMagic

func WriteLengthAndMagic(bytes []byte, length int, magic uint32)

WriteLengthAndMagic just writes length and magic as uint32 4 byte values into the given array.

Types

type NSNumber

type NSNumber struct {

	//not certain if these are really unsigned
	IntValue   uint32
	LongValue  uint64
	FloatValue float64
	// contains filtered or unexported fields
}

NSNumber represents a type in the binary protocol used. Type 6 seems to be a float64, type 4 a int64, type 3 a int32. I am not sure whether signed or unsigned. They are all in LittleEndian

func NewNSNumber

func NewNSNumber(bytes []byte) (NSNumber, error)

NewNSNumber reads a NSNumber from bytes.

func NewNSNumberFromUFloat64

func NewNSNumberFromUFloat64(floatValue float64) NSNumber

NewNSNumberFromUFloat64 create NSNumber of type 0x06 with a 8 byte int as value

func NewNSNumberFromUInt32

func NewNSNumberFromUInt32(intValue uint32) NSNumber

NewNSNumberFromUInt32 create NSNumber of type 0x03 with a 4 byte int as value

func NewNSNumberFromUInt64

func NewNSNumberFromUInt64(longValue uint64) NSNumber

NewNSNumberFromUInt64 create NSNumber of type 0x04 with a 8 byte int as value

func (NSNumber) String

func (n NSNumber) String() string

func (NSNumber) ToBytes

func (n NSNumber) ToBytes() []byte

ToBytes serializes a NSNumber into a []byte. FIXME: remove allocation of array and use one that is passed in instead

Jump to

Keyboard shortcuts

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