10#ifndef MCRL2_UTILITIES_BITSTREAM_H
11#define MCRL2_UTILITIES_BITSTREAM_H
26 return ((
sizeof(T) + 1) * 8) / 7;
57 void write(
const std::uint8_t* buffer,
std::size_t size);
90 void read(
std::size_t size,
std::uint8_t* buffer);
bool is_a_binary_aterm(std::istream &is)
An integer term stores a single std::size_t value. It carries no arguments.
The interface for a class that reads aterm from a stream. The default constructed term aterm() indica...
The interface for a class that writes aterm to a stream. Every written term is retrieved by the corre...
aterm()
Default constructor.
aterm & operator=(const aterm &other) noexcept=default
aterm & operator=(aterm &&other) noexcept=default
std::shared_ptr< mcrl2::utilities::ibitstream > m_stream
unsigned int m_function_symbol_index_width
caches the result of function_symbol_index_width().
unsigned int function_symbol_index_width()
atermpp::deque< aterm > m_terms
An index of read terms.
unsigned int term_index_width()
binary_aterm_istream(std::istream &is)
Provide the input stream from which terms are read.
unsigned int m_term_index_width
caches the result of term_index_width().
void get(aterm &t) override
Reads an aterm from this stream.
std::deque< function_symbol > m_function_symbols
An index of read function symbols.
binary_aterm_istream(std::shared_ptr< mcrl2::utilities::ibitstream > stream)
unsigned int m_term_index_width
caches the result of term_index_width().
~binary_aterm_ostream() override
std::size_t write_function_symbol(const function_symbol &symbol)
Write a function symbol to the output stream.
binary_aterm_ostream(std::ostream &os)
Provide the output stream to which the terms are written.
binary_aterm_ostream(std::shared_ptr< mcrl2::utilities::obitstream > stream)
std::shared_ptr< mcrl2::utilities::obitstream > m_stream
unsigned int m_function_symbol_index_width
caches the result of function_symbol_index_width().
unsigned int term_index_width()
atermpp::indexed_set< aterm > m_terms
An index of already written terms.
void put(const aterm &term) override
Writes an aterm in a compact binary format where subterms are shared. The term that is written itself...
unsigned int function_symbol_index_width()
mcrl2::utilities::indexed_set< function_symbol > m_function_symbols
An index of already written function symbols.
bool operator==(const function_symbol &f) const
Equality test.
std::size_t arity() const
Return the arity (number of arguments) of the function symbol (function_symbol).
Standard exception class for reporting runtime errors.
The counterpart of obitstream, guarantees that the same data is read as has been written when calling...
std::size_t read_integer()
unsigned int bits_in_buffer
how many bits in the buffer are used.
std::size_t read_bits(unsigned int num_of_bits)
Reads an num_of_bits bits from the input stream and stores them in the least significant part (in des...
void read(std::size_t size, std::uint8_t *buffer)
Read size bytes into the provided buffer.
std::vector< char > m_text_buffer
A temporary buffer to store char array strings.
const char * read_string()
std::bitset< 128 > read_buffer
Buffer that is filled starting from bit 127 when reading.
ibitstream(std::istream &stream)
Provides the stream on which the read function operate.
A bitstream provides per bit writing of data to any stream (including stdout).
void flush()
Flush the remaining bits in the buffer to the output stream.
std::bitset< 128 > write_buffer
Buffer that is filled starting from bit 127 when writing.
unsigned int bits_in_buffer
how many bits in are used in the buffer.
std::uint8_t integer_buffer[integer_encoding_size< std::size_t >()]
Reserved space to store an n byte integer.
void write_bits(std::size_t value, unsigned int num_of_bits)
Write the num_of_bits least significant bits in descending order from value.
void write(const std::uint8_t *buffer, std::size_t size)
Writes size bytes from the given buffer.
void write_string(const std::string &string)
Write the given string to the output stream.
void write_integer(std::size_t value)
Write the given value to the output stream.
obitstream(std::ostream &stream)
Provides the stream on which the write function operate.
function_symbol g_as_int
These function symbols are used to indicate integer, list and empty list terms.
The main namespace for the aterm++ library.
static constexpr unsigned int packet_bits
The number of bits needed to store an element of packet_type.
void write_term_to_binary_stream(const aterm &t, std::ostream &os)
Writes term t to a stream in binary aterm format.
static constexpr std::uint16_t BAF_MAGIC
The magic value for a binary aterm format stream.
void read_term_from_binary_stream(std::istream &is, aterm &t)
Reads a term from a stream in binary aterm format.
packet_type
Each packet has a header consisting of a type.
void make_aterm_int(aterm_int &target, std::size_t value)
Constructs an integer term from a value.
static constexpr std::uint16_t BAF_VERSION
The BAF_VERSION constant is the version number of the ATerms written in BAF format....
constexpr std::size_t integer_encoding_size()
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Keep track of whether the term can be written to the stream.
void mark(std::stack< std::reference_wrapper< detail::_aterm > > &todo) const
detail::reference_aterm< aterm > term
write_todo(const aterm &term)
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const