stringtab

package standard library
go1.26.11 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

Reader is a helper for reading a string table previously serialized by a Writer.Write call.

func NewReader

func NewReader(r *slicereader.Reader) *Reader

NewReader creates a stringtab.Reader to read the contents of a string table from 'r'.

func (*Reader) Entries

func (str *Reader) Entries() int

Entries returns the number of decoded entries in a string table.

func (*Reader) Get

func (str *Reader) Get(idx uint32) string

Get returns string 'idx' within the string table.

func (*Reader) Read

func (str *Reader) Read()

Read reads/decodes a string table using the reader provided.

type Writer

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

Writer implements a string table writing utility.

func (*Writer) Freeze

func (stw *Writer) Freeze()

Freeze sends a signal to the writer that no more additions are allowed, only lookups of existing strings (if a lookup triggers addition, a panic will result). Useful as a mechanism for "finalizing" a string table prior to writing it out.

func (*Writer) InitWriter

func (stw *Writer) InitWriter()

InitWriter initializes a stringtab.Writer.

func (*Writer) Lookup

func (stw *Writer) Lookup(s string) uint32

Lookup looks up string 's' in the writer's table, adding a new entry if need be, and returning an index into the table.

func (*Writer) Nentries

func (stw *Writer) Nentries() uint32

Nentries returns the number of strings interned so far.

func (*Writer) Size

func (stw *Writer) Size() uint32

Size computes the memory in bytes needed for the serialized version of a stringtab.Writer.

func (*Writer) Write

func (stw *Writer) Write(w io.Writer) error

Write writes the string table in serialized form to the specified io.Writer.

Jump to

Keyboard shortcuts

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