rbytes

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package rbytes contains the definitions of types useful for serializing and deserializing ROOT data buffers.

rbytes also defines the interfaces to interact with ROOT's metadata classes such as StreamerInfo and StreamerElements.

Index

Constants

View Source
const (
	BypassStreamer                  uint32 = 1 << 12
	CannotHandleMemberWiseStreaming uint32 = 1 << 17
)
View Source
const (

	//baskets
	DisplacementMask = 0xFF000000
)
View Source
const (
	StreamedMemberWise = 0x4000
)

Variables

This section is empty.

Functions

func ResizeBool added in v0.27.0

func ResizeBool(sli []bool, n int) []bool

func ResizeD32 added in v0.27.0

func ResizeD32(sli []root.Double32, n int) []root.Double32

func ResizeF16 added in v0.27.0

func ResizeF16(sli []root.Float16, n int) []root.Float16

func ResizeF32 added in v0.27.0

func ResizeF32(sli []float32, n int) []float32

func ResizeF64 added in v0.27.0

func ResizeF64(sli []float64, n int) []float64

func ResizeI16 added in v0.27.0

func ResizeI16(sli []int16, n int) []int16

func ResizeI32 added in v0.27.0

func ResizeI32(sli []int32, n int) []int32

func ResizeI64 added in v0.27.0

func ResizeI64(sli []int64, n int) []int64

func ResizeI8 added in v0.27.0

func ResizeI8(sli []int8, n int) []int8

func ResizeStr added in v0.27.0

func ResizeStr(sli []string, n int) []string

func ResizeU16 added in v0.27.0

func ResizeU16(sli []uint16, n int) []uint16

func ResizeU32 added in v0.27.0

func ResizeU32(sli []uint32, n int) []uint32

func ResizeU64 added in v0.27.0

func ResizeU64(sli []uint64, n int) []uint64

func ResizeU8 added in v0.27.0

func ResizeU8(sli []uint8, n int) []uint8

Types

type Binder added in v0.28.0

type Binder interface {
	Bind(ptr interface{}) error
}

Binder wraps the Bind method.

type Counter added in v0.28.0

type Counter interface {
	Count(f func() int) error
}

Counter wraps the Count method.

type Decoder added in v0.28.0

type Decoder interface {
	DecodeROOT(ptr interface{}) error
}

Decoder is the interface that wraps the basic DecodeROOT method.

type Encoder added in v0.28.0

type Encoder interface {
	EncodeROOT(ptr interface{}) error
}

Encoder is the interface that wraps the basic EncodeROOT method.

type Header struct {
	Name string // name of the type being guarded by this header.
	Vers int16  // version of the type being guarded by this header.
	Pos  int64  // position of the type in the ROOT buffer.
	Len  int32  // length of the value in the ROOT buffer.

	MemberWise bool // whether the value has been written member-wise.
}

Header represents a type header in a ROOT buffer.

type Marshaler

type Marshaler interface {
	MarshalROOT(w *WBuffer) (int, error)
}

Marshaler is the interface implemented by an object that can marshal itself into a ROOT buffer

type Member added in v0.34.0

type Member struct {
	Name  string
	Value any
}

Member is a ROOT member of a ROOT class.

type RBuffer

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

RBuffer is a read-only ROOT buffer for streaming.

func NewRBuffer

func NewRBuffer(data []byte, refs map[int64]interface{}, offset uint32, ctx StreamerInfoContext) *RBuffer

func (*RBuffer) CheckHeader added in v0.31.0

func (r *RBuffer) CheckHeader(hdr Header)

func (*RBuffer) DumpHex added in v0.17.0

func (r *RBuffer) DumpHex(n int)

func (*RBuffer) Err

func (r *RBuffer) Err() error

func (*RBuffer) Len

func (r *RBuffer) Len() int64

func (*RBuffer) Pos

func (r *RBuffer) Pos() int64

func (*RBuffer) RStream added in v0.28.0

func (r *RBuffer) RStream(si StreamerInfo, ptr interface{}) error

func (*RBuffer) Read

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

func (*RBuffer) ReadArrayBool added in v0.27.0

func (r *RBuffer) ReadArrayBool(arr []bool)

func (*RBuffer) ReadArrayD32 added in v0.27.0

func (r *RBuffer) ReadArrayD32(arr []root.Double32, elm StreamerElement)

func (*RBuffer) ReadArrayF16 added in v0.27.0

func (r *RBuffer) ReadArrayF16(arr []root.Float16, elm StreamerElement)

func (*RBuffer) ReadArrayF32 added in v0.27.0

func (r *RBuffer) ReadArrayF32(sli []float32)

func (*RBuffer) ReadArrayF64 added in v0.27.0

func (r *RBuffer) ReadArrayF64(sli []float64)

func (*RBuffer) ReadArrayI16 added in v0.27.0

func (r *RBuffer) ReadArrayI16(sli []int16)

func (*RBuffer) ReadArrayI32 added in v0.27.0

func (r *RBuffer) ReadArrayI32(sli []int32)

func (*RBuffer) ReadArrayI64 added in v0.27.0

func (r *RBuffer) ReadArrayI64(sli []int64)

func (*RBuffer) ReadArrayI8 added in v0.27.0

func (r *RBuffer) ReadArrayI8(arr []int8)

func (*RBuffer) ReadArrayString added in v0.27.0

func (r *RBuffer) ReadArrayString(arr []string)

func (*RBuffer) ReadArrayU16 added in v0.27.0

func (r *RBuffer) ReadArrayU16(sli []uint16)

func (*RBuffer) ReadArrayU32 added in v0.27.0

func (r *RBuffer) ReadArrayU32(sli []uint32)

func (*RBuffer) ReadArrayU64 added in v0.27.0

func (r *RBuffer) ReadArrayU64(sli []uint64)

func (*RBuffer) ReadArrayU8 added in v0.27.0

func (r *RBuffer) ReadArrayU8(arr []uint8)

func (*RBuffer) ReadBool

func (r *RBuffer) ReadBool() bool

func (*RBuffer) ReadCString

func (r *RBuffer) ReadCString(n int) string

func (*RBuffer) ReadD32 added in v0.23.0

func (r *RBuffer) ReadD32(elm StreamerElement) root.Double32

func (*RBuffer) ReadF16 added in v0.23.0

func (r *RBuffer) ReadF16(elm StreamerElement) root.Float16

func (*RBuffer) ReadF32

func (r *RBuffer) ReadF32() float32

func (*RBuffer) ReadF64

func (r *RBuffer) ReadF64() float64

func (*RBuffer) ReadHeader added in v0.31.0

func (r *RBuffer) ReadHeader(class string, vmax int16) Header

ReadHeader reads the serialization header for the given class and its known maximum version.

func (*RBuffer) ReadI16

func (r *RBuffer) ReadI16() int16

func (*RBuffer) ReadI32

func (r *RBuffer) ReadI32() int32

func (*RBuffer) ReadI64

func (r *RBuffer) ReadI64() int64

func (*RBuffer) ReadI8

func (r *RBuffer) ReadI8() int8

func (*RBuffer) ReadObject

func (r *RBuffer) ReadObject(obj Unmarshaler)

func (*RBuffer) ReadObjectAny

func (r *RBuffer) ReadObjectAny() (obj root.Object)

func (*RBuffer) ReadStaticArrayI32

func (r *RBuffer) ReadStaticArrayI32() []int32

func (*RBuffer) ReadStdBitset added in v0.28.0

func (r *RBuffer) ReadStdBitset(v []uint8)

func (*RBuffer) ReadStdString added in v0.31.0

func (r *RBuffer) ReadStdString() string

func (*RBuffer) ReadStdVectorF32 added in v0.31.0

func (r *RBuffer) ReadStdVectorF32(sli *[]float32)

func (*RBuffer) ReadStdVectorF64 added in v0.31.0

func (r *RBuffer) ReadStdVectorF64(sli *[]float64)

func (*RBuffer) ReadStdVectorI16 added in v0.31.0

func (r *RBuffer) ReadStdVectorI16(sli *[]int16)

func (*RBuffer) ReadStdVectorI32 added in v0.31.0

func (r *RBuffer) ReadStdVectorI32(sli *[]int32)

func (*RBuffer) ReadStdVectorI64 added in v0.31.0

func (r *RBuffer) ReadStdVectorI64(sli *[]int64)

func (*RBuffer) ReadStdVectorStrs added in v0.28.0

func (r *RBuffer) ReadStdVectorStrs(sli *[]string)

func (*RBuffer) ReadStdVectorU16 added in v0.31.0

func (r *RBuffer) ReadStdVectorU16(sli *[]uint16)

func (*RBuffer) ReadStdVectorU32 added in v0.31.0

func (r *RBuffer) ReadStdVectorU32(sli *[]uint32)

func (*RBuffer) ReadStdVectorU64 added in v0.31.0

func (r *RBuffer) ReadStdVectorU64(sli *[]uint64)

func (*RBuffer) ReadString

func (r *RBuffer) ReadString() string

func (*RBuffer) ReadU16

func (r *RBuffer) ReadU16() uint16

func (*RBuffer) ReadU32

func (r *RBuffer) ReadU32() uint32

func (*RBuffer) ReadU64

func (r *RBuffer) ReadU64() uint64

func (*RBuffer) ReadU8

func (r *RBuffer) ReadU8() uint8

func (*RBuffer) Reset added in v0.27.0

func (r *RBuffer) Reset(data []byte, refs map[int64]interface{}, offset uint32, ctx StreamerInfoContext) *RBuffer

func (*RBuffer) SetErr

func (r *RBuffer) SetErr(err error)

func (*RBuffer) SetPos

func (r *RBuffer) SetPos(pos int64)

func (*RBuffer) SkipObject

func (r *RBuffer) SkipObject()

func (*RBuffer) SkipVersion

func (r *RBuffer) SkipVersion(class string)

func (*RBuffer) StreamerInfo

func (r *RBuffer) StreamerInfo(name string, version int) (StreamerInfo, error)

StreamerInfo returns the named StreamerInfo. If version is negative, the latest version should be returned.

type RSlicer added in v0.34.0

type RSlicer interface {
	// RMembers returns the list of (pointers to) members of a given ROOT value.
	RMembers() []Member
}

RSlicer wraps the RMembers method.

type RStreamer added in v0.17.0

type RStreamer interface {
	RStreamROOT(*RBuffer) error
}

RStreamer is the interface implemented by types that can stream themselves from a ROOT buffer.

type RVersioner added in v0.17.0

type RVersioner interface {
	RVersion() int16
}

RVersioner is the interface implemented by an object that can tell the ROOT system what is its current version.

type StreamKind added in v0.28.0

type StreamKind byte

StreamKind describes whether a composite ROOT value was encoded member-wise or object-wise.

const (
	ObjectWise StreamKind = iota
	MemberWise
)

func (StreamKind) String added in v0.28.0

func (k StreamKind) String() string

type Streamer added in v0.17.0

type Streamer interface {
	WStreamer
	RStreamer
}

Streamer is the interface implemented by types that can stream themselves to and from a ROOT buffer.

type StreamerElement

type StreamerElement interface {
	root.Named

	ArrayDim() int
	ArrayDims() []int32
	ArrayLen() int
	Type() rmeta.Enum
	Offset() uintptr
	Size() uintptr
	TypeName() string
	XMin() float64
	XMax() float64
	Factor() float64
}

StreamerElement describes a ROOT StreamerElement

type StreamerInfo

type StreamerInfo interface {
	root.Named

	CheckSum() int
	ClassVersion() int
	Elements() []StreamerElement

	// BuildStreamers builds the r/w streamers.
	BuildStreamers() error

	NewDecoder(kind StreamKind, r *RBuffer) (Decoder, error)
	NewEncoder(kind StreamKind, w *WBuffer) (Encoder, error)

	NewRStreamer(kind StreamKind) (RStreamer, error)
	NewWStreamer(kind StreamKind) (WStreamer, error)
}

StreamerInfo describes a ROOT Streamer.

type StreamerInfoContext

type StreamerInfoContext interface {
	// StreamerInfo returns the named StreamerInfo.
	// If version is negative, the latest version should be returned.
	StreamerInfo(name string, version int) (StreamerInfo, error)
}

StreamerInfoContext defines the protocol to retrieve a ROOT StreamerInfo metadata type by name.

Implementations should make sure the protocol is goroutine safe.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalROOT(r *RBuffer) error
}

Unmarshaler is the interface implemented by an object that can unmarshal itself from a ROOT buffer

type WBuffer

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

WBuffer is a write-only ROOT buffer for streaming.

func NewWBuffer

func NewWBuffer(data []byte, refs map[interface{}]int64, offset uint32, ctx StreamerInfoContext) *WBuffer

func (*WBuffer) Bytes

func (w *WBuffer) Bytes() []byte

func (*WBuffer) DumpHex added in v0.20.0

func (w *WBuffer) DumpHex(n int)

func (*WBuffer) Err

func (w *WBuffer) Err() error

func (*WBuffer) Grow

func (w *WBuffer) Grow(n int)

func (*WBuffer) Len added in v0.20.0

func (w *WBuffer) Len() int64

func (*WBuffer) Pos

func (w *WBuffer) Pos() int64

func (*WBuffer) SetErr

func (w *WBuffer) SetErr(err error)

func (*WBuffer) SetHeader added in v0.31.0

func (w *WBuffer) SetHeader(hdr Header) (int, error)

func (*WBuffer) SetPos

func (w *WBuffer) SetPos(pos int64)

func (*WBuffer) StreamerInfo added in v0.18.0

func (w *WBuffer) StreamerInfo(name string, version int) (StreamerInfo, error)

StreamerInfo returns the named StreamerInfo. If version is negative, the latest version should be returned.

func (*WBuffer) Write

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

func (*WBuffer) WriteArrayBool added in v0.31.0

func (w *WBuffer) WriteArrayBool(v []bool)

func (*WBuffer) WriteArrayD32 added in v0.31.0

func (w *WBuffer) WriteArrayD32(v []root.Double32, elm StreamerElement)

func (*WBuffer) WriteArrayF16 added in v0.31.0

func (w *WBuffer) WriteArrayF16(v []root.Float16, elm StreamerElement)

func (*WBuffer) WriteArrayF32 added in v0.31.0

func (w *WBuffer) WriteArrayF32(sli []float32)

func (*WBuffer) WriteArrayF64 added in v0.31.0

func (w *WBuffer) WriteArrayF64(sli []float64)

func (*WBuffer) WriteArrayI16 added in v0.31.0

func (w *WBuffer) WriteArrayI16(sli []int16)

func (*WBuffer) WriteArrayI32 added in v0.31.0

func (w *WBuffer) WriteArrayI32(sli []int32)

func (*WBuffer) WriteArrayI64 added in v0.31.0

func (w *WBuffer) WriteArrayI64(sli []int64)

func (*WBuffer) WriteArrayI8 added in v0.31.0

func (w *WBuffer) WriteArrayI8(v []int8)

func (*WBuffer) WriteArrayString added in v0.31.0

func (w *WBuffer) WriteArrayString(v []string)

func (*WBuffer) WriteArrayU16 added in v0.31.0

func (w *WBuffer) WriteArrayU16(sli []uint16)

func (*WBuffer) WriteArrayU32 added in v0.31.0

func (w *WBuffer) WriteArrayU32(sli []uint32)

func (*WBuffer) WriteArrayU64 added in v0.31.0

func (w *WBuffer) WriteArrayU64(sli []uint64)

func (*WBuffer) WriteArrayU8 added in v0.31.0

func (w *WBuffer) WriteArrayU8(v []uint8)

func (*WBuffer) WriteBool

func (w *WBuffer) WriteBool(v bool)

func (*WBuffer) WriteCString

func (w *WBuffer) WriteCString(v string)

func (*WBuffer) WriteClass

func (w *WBuffer) WriteClass(beg int64, obj root.Object) uint32

func (*WBuffer) WriteD32 added in v0.23.0

func (w *WBuffer) WriteD32(v root.Double32, elm StreamerElement)

func (*WBuffer) WriteF16 added in v0.23.0

func (w *WBuffer) WriteF16(v root.Float16, elm StreamerElement)

func (*WBuffer) WriteF32

func (w *WBuffer) WriteF32(v float32)

func (*WBuffer) WriteF64

func (w *WBuffer) WriteF64(v float64)

func (*WBuffer) WriteHeader added in v0.31.0

func (w *WBuffer) WriteHeader(typename string, vers int16) Header

func (*WBuffer) WriteI16

func (w *WBuffer) WriteI16(v int16)

func (*WBuffer) WriteI32

func (w *WBuffer) WriteI32(v int32)

func (*WBuffer) WriteI64

func (w *WBuffer) WriteI64(v int64)

func (*WBuffer) WriteI8

func (w *WBuffer) WriteI8(v int8)

func (*WBuffer) WriteObject added in v0.31.0

func (w *WBuffer) WriteObject(obj Marshaler)

func (*WBuffer) WriteObjectAny

func (w *WBuffer) WriteObjectAny(obj root.Object)

func (*WBuffer) WriteStaticArrayI32

func (w *WBuffer) WriteStaticArrayI32(v []int32)

func (*WBuffer) WriteStdBitset added in v0.28.0

func (w *WBuffer) WriteStdBitset(v []uint8)

func (*WBuffer) WriteStdString added in v0.31.0

func (w *WBuffer) WriteStdString(v string)

func (*WBuffer) WriteStdVectorF32 added in v0.31.0

func (w *WBuffer) WriteStdVectorF32(sli []float32)

func (*WBuffer) WriteStdVectorF64 added in v0.31.0

func (w *WBuffer) WriteStdVectorF64(sli []float64)

func (*WBuffer) WriteStdVectorI16 added in v0.31.0

func (w *WBuffer) WriteStdVectorI16(sli []int16)

func (*WBuffer) WriteStdVectorI32 added in v0.31.0

func (w *WBuffer) WriteStdVectorI32(sli []int32)

func (*WBuffer) WriteStdVectorI64 added in v0.31.0

func (w *WBuffer) WriteStdVectorI64(sli []int64)

func (*WBuffer) WriteStdVectorStrs added in v0.28.0

func (w *WBuffer) WriteStdVectorStrs(v []string)

func (*WBuffer) WriteStdVectorU16 added in v0.31.0

func (w *WBuffer) WriteStdVectorU16(sli []uint16)

func (*WBuffer) WriteStdVectorU32 added in v0.31.0

func (w *WBuffer) WriteStdVectorU32(sli []uint32)

func (*WBuffer) WriteStdVectorU64 added in v0.31.0

func (w *WBuffer) WriteStdVectorU64(sli []uint64)

func (*WBuffer) WriteString

func (w *WBuffer) WriteString(v string)

func (*WBuffer) WriteU16

func (w *WBuffer) WriteU16(v uint16)

func (*WBuffer) WriteU32

func (w *WBuffer) WriteU32(v uint32)

func (*WBuffer) WriteU64

func (w *WBuffer) WriteU64(v uint64)

func (*WBuffer) WriteU8

func (w *WBuffer) WriteU8(v uint8)

type WStreamer added in v0.17.0

type WStreamer interface {
	WStreamROOT(*WBuffer) error
}

WStreamer is the interface implemented by types that can stream themselves to a ROOT buffer.

Jump to

Keyboard shortcuts

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