...

Package rw

Overview ▾

func PopRightUI32

func PopRightUI32(v uint32) (bool, uint32)

PopRightUI32 takes the rightmost bit from an uint32, shifts the uint32 to the right and returns both the bit and the modified uint32.

func PopRightUI64

func PopRightUI64(v uint64) (bool, uint64)

PopRightUI64 takes the rightmost bit from an uint64, shifts the uint64 to the right and returns both the bit and the modified uint64.

func PushLeftUI32

func PushLeftUI32(v uint32, flag bool) uint32

PushLeftUI32 shifts a given uint32, shifts it to the right, sets the leftmost bit as a given flag and returns the modified uint32.

func PushLeftUI64

func PushLeftUI64(v uint64, flag bool) uint64

PushLeftUI64 shifts a given uint64, shifts it to the right, sets the leftmost bit as a given flag and returns the modified uint64.

type Reader

Reader is composed from bytes.Reader with methods for handy write to MSCFB files added.

type Reader struct {
    *bytes.Reader
}

func NewReader

func NewReader(b []byte) (*Reader, error)

NewReader makes a Reader from a byte array.

func (*Reader) ReadPairProperty

func (r *Reader) ReadPairProperty(p interface{}) error

ReadProperty reads a property to the interface which can be represented as a 16-bit integer.

func (*Reader) ReadProperty

func (r *Reader) ReadProperty(a interface{}) error

ReadProperty reads a property to the interface which can be represented as an integer.

func (*Reader) ReadStringProperty

func (r *Reader) ReadStringProperty(n uint32) (string, error)

ReadStringProperty reads a property to a string with a given length and returns it.

type Writer

Writer is a copy of bytes.Buffer with all read functionality removed and methods for handy write to MSCFB files added.

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

func NewWriter

func NewWriter() *Writer

NewWriter returns a Writer with an empty underlying buffer.

func (*Writer) AlignLength

func (w *Writer) AlignLength(alignTo int) error

AlignLength makes the Writer length multiple to alignTo by filling it with zeroes at the end.

func (*Writer) Bytes

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

Bytes returns the whole Writer bytes as a byte array.

func (*Writer) Cap

func (w *Writer) Cap() int

Cap returns the capacity of the buffer's underlying byte slice, that is, the total space allocated for the buffer's data.

func (*Writer) FillWithByte

func (w *Writer) FillWithByte(fillSize int, b byte) error

FillWithByte records fillSize bytes with a value b to the end of the Writer.

func (*Writer) Len

func (w *Writer) Len() int

Len returns the number of bytes of the unread portion of the buffer; w.Len() == len(w.Bytes()).

func (*Writer) Skip

func (w *Writer) Skip(n int) error

Skip writes n zero bytes to the writer.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will return errTooLarge.

func (*Writer) WriteByteAt

func (w *Writer) WriteByteAt(b byte, off int) error

WriteByteAt writes a byte to the given location of the Writer's underlying buffer. It does not affect the current Writer offset.

func (*Writer) WriteProperty

func (w *Writer) WriteProperty(a interface{}) error

WriteProperty writes a given property to the writer with preceeding padding bytes as pointed in [MS-OFORMS] - v20210817 Office Forms Binary File Formats.

func (*Writer) WritePropertyNoAlign

func (w *Writer) WritePropertyNoAlign(a interface{}) error

WritePropertyNoAlign writes a given property to the writer without preceeding padding bytes.

func (*Writer) WriteStringProperty

func (w *Writer) WriteStringProperty(s string) error

WriteStringProperty writes a given string property to the writer with preceeding padding bytes as pointed in [MS-OFORMS] - v20210817 Office Forms Binary File Formats.

func (*Writer) WriteTo

func (w *Writer) WriteTo(wTo io.Writer) (n int64, err error)

WriteTo writes data to w until the buffer is drained or an error occurs. The return value n is the number of bytes written; it always fits into an int, but it is int64 to match the io.WriterTo interface. Any error encountered during the write is also returned.