bs_open {bitstreamio}R Documentation

Open/close a bitstream

Description

Open/close a bitstream

Usage

bs_open(con, mode, msb_first = TRUE, flush_threshold = 1024 * 8)

bs_close(bs, verbosity = 0)

Arguments

con

A vector of raw values or an R connection (e.g. file(), url(), etc)

mode

Bitstream mode set to read or write? One of 'r', 'w', 'rb', 'wb'.

msb_first

Should the output mode be Most Signficant Bit first? Default: TRUE

flush_threshold

Threshold number of bits at which the buffered data will be automatically written to the connection. Default: 8192 bits (1024 bytes). Note: Use bs_flush() to write out the buffer at any time. All bits are automatically written out when bs_close() is called.

bs

Bistream connection object created with bs_open()

verbosity

Verbosity level. Default: 0

Value

bs_open() returns a bitstream connection object. When the connection is a raw vector and mode = 'w', bs_close() returns the final state of the raw vector; in all other cases bs_close() does not return a value.

Examples

raw_vec <- as.raw(1:3)
bs  <- bs_open(raw_vec, 'r')
assert_bs(bs)
bs_close(bs)


[Package bitstreamio version 0.1.0 Index]