byteptr

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: MIT Imports: 2 Imported by: 2

README

Byteptr

Byteptr is a solution to manipulate with bytes/strings (and their parts) without using pointers. It's a part of the reducing pointer policy.

Byteptr is similar of refrect.SliceHeader and refrecl.StringHeader structs, but provides extra methods to manipulate with data in raw memory.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Byteptr

type Byteptr struct {
	// contains filtered or unexported fields
}

Byteptr is a pointer-free representation of bytes/string types.

Similar to reflect.SliceHeader/reflect.StringHeader structs.

func (*Byteptr) Bytes

func (p *Byteptr) Bytes() []byte

Bytes returns byte sub-slice using offset from previously take address with length len.

func (*Byteptr) Init

func (p *Byteptr) Init(s []byte, offset, len int) *Byteptr

Init ptr with address of the byte array s and offset/length.

func (*Byteptr) InitStr

func (p *Byteptr) InitStr(s string, offset, len int) *Byteptr

InitStr ptr with address of the string s and offset/length.

func (Byteptr) Len

func (p Byteptr) Len() int

func (Byteptr) Offset

func (p Byteptr) Offset() int

Offset returns offset.

func (*Byteptr) Reset

func (p *Byteptr) Reset() *Byteptr

Reset all fields.

Made to use with pools.

func (*Byteptr) SetLen

func (p *Byteptr) SetLen(len int) *Byteptr

SetLen sets length of sub-slice.

func (*Byteptr) SetOffset

func (p *Byteptr) SetOffset(offset int) *Byteptr

SetOffset sets offset from previously taken address.

func (*Byteptr) String

func (p *Byteptr) String() string

Get substring.

See Bytes().

func (*Byteptr) TakeAddr

func (p *Byteptr) TakeAddr(s []byte) *Byteptr

TakeAddr takes address of underlying byte array of bytes s.

func (*Byteptr) TakeStrAddr

func (p *Byteptr) TakeStrAddr(s string) *Byteptr

TakeStrAddr takes address of underlying byte array of string s.

Jump to

Keyboard shortcuts

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