 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package binfmt exposes utilities for formatting binary data with descriptive comments.
Index ¶
- func FHexDump(w io.Writer, data []byte, width int, includeOffsets bool)
- func HexDump(data []byte, width int, includeOffsets bool) string
- type Formatter
- func (f *Formatter) Byte(format string, args ...interface{}) int
- func (f *Formatter) Data() []byte
- func (f *Formatter) HexBytesln(n int, format string, args ...interface{}) int
- func (f *Formatter) HexTextln(n int) int
- func (f *Formatter) Line(n int) Line
- func (f *Formatter) LineWidth(width int) *Formatter
- func (f *Formatter) More() bool
- func (f *Formatter) Offset() int
- func (f *Formatter) PeekUint(w int) uint64
- func (f *Formatter) Pointer(off int) unsafe.Pointer
- func (f *Formatter) RelativeData() []byte
- func (f *Formatter) RelativeOffset() int
- func (f *Formatter) Remaining() int
- func (f *Formatter) SetAnchorOffset()
- func (f *Formatter) SetLinePrefix(prefix string)
- func (f *Formatter) String() string
- func (f *Formatter) ToTreePrinter(tp treeprinter.Node)
- func (f *Formatter) Uvarint(format string, args ...interface{})
 
- type Line
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Formatter ¶
type Formatter struct {
	// contains filtered or unexported fields
}
    Formatter is a utility for formatting binary data with descriptive comments.
func (*Formatter) Byte ¶
Byte formats a single byte in binary format, displaying each bit as a zero or one.
func (*Formatter) Data ¶
Data returns the original data slice. Offset may be used to retrieve the current offset within the slice.
func (*Formatter) HexBytesln ¶
HexBytesln formats the next n bytes in hexadecimal format, appending the formatted comment string to each line and ending on a newline.
func (*Formatter) HexTextln ¶
HexTextln formats the next n bytes in hexadecimal format, appending a comment to each line showing the ASCII equivalent characters for each byte for bytes that are human-readable.
func (*Formatter) Line ¶
Line prepares a single line of formatted output that will consume n bytes, but formatting those n bytes in multiple ways. The line will be prefixed with the offsets for the line's entire data.
func (*Formatter) More ¶
More returns true if there is more data in the byte slice that can be formatted.
func (*Formatter) PeekUint ¶
PeekUint reads a little-endian unsigned integer of the specified width at the current offset.
func (*Formatter) Pointer ¶
Pointer returns a pointer into the original data slice at the specified offset.
func (*Formatter) RelativeData ¶
RelativeData returns the subslice of the original data slice beginning at the offset at which SetAnchorOffset was last called. If SetAnchorOffset was never called, RelativeData is equivalent to Data.
func (*Formatter) RelativeOffset ¶
RelativeOffset retrieves the current offset relative to the offset at the last time SetAnchorOffset was called. If SetAnchorOffset was never called, RelativeOffset is equivalent to Offset.
func (*Formatter) Remaining ¶
Remaining returns the number of unformatted bytes remaining in the byte slice.
func (*Formatter) SetAnchorOffset ¶
func (f *Formatter) SetAnchorOffset()
SetAnchorOffset sets the reference point for relative offset calculations to the current offset. Future calls to RelativeOffset() will return an offset relative to the current offset.
func (*Formatter) SetLinePrefix ¶
SetLinePrefix sets a prefix for each line of formatted output.
func (*Formatter) ToTreePrinter ¶
func (f *Formatter) ToTreePrinter(tp treeprinter.Node)
ToTreePrinter formats the current output and creates a treeprinter child node for each line. The current output is reset; the position within the binary buffer is not.
type Line ¶
type Line struct {
	// contains filtered or unexported fields
}
    Line is a pending line of formatted binary output.
func (Line) Binary ¶
Binary formats the next n bytes in binary format, displaying each bit as a zero or one.