mCRL2
Loading...
Searching...
No Matches
atermpp::binary_aterm_ostream Class Referencefinal

Writes terms in a streamable binary aterm format to an output stream. More...

#include <aterm_io_binary.h>

Inheritance diagram for atermpp::binary_aterm_ostream:
atermpp::aterm_ostream atermpp::aterm_stream

Public Member Functions

 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)
 
 ~binary_aterm_ostream () override
 
void put (const aterm &term) override
 Writes an aterm in a compact binary format where subterms are shared. The term that is written itself is not shared whenever it occurs as the argument of another term.
 
- Public Member Functions inherited from atermpp::aterm_ostream
virtual ~aterm_ostream ()
 
virtual void put (const aterm &term)=0
 Write the given term to the stream.
 
- Public Member Functions inherited from atermpp::aterm_stream
virtual ~aterm_stream ()
 
void set_transformer (aterm_transformer transformer)
 Sets the given transformer to be applied to following writes.
 
aterm_transformerget_transformer () const
 

Private Member Functions

std::size_t write_function_symbol (const function_symbol &symbol)
 Write a function symbol to the output stream.
 
unsigned int term_index_width ()
 
unsigned int function_symbol_index_width ()
 

Private Attributes

std::shared_ptr< mcrl2::utilities::obitstreamm_stream
 
unsigned int m_term_index_width
 caches the result of term_index_width().
 
unsigned int m_function_symbol_index_width
 caches the result of function_symbol_index_width().
 
atermpp::indexed_set< atermm_terms
 An index of already written terms.
 
mcrl2::utilities::indexed_set< function_symbolm_function_symbols
 An index of already written function symbols.
 

Additional Inherited Members

- Protected Attributes inherited from atermpp::aterm_stream
aterm_transformerm_transformer = identity
 

Detailed Description

Writes terms in a streamable binary aterm format to an output stream.

The streamable aterm format:

     Aterms (and function symbols) are written as packets (with an identifier in the header) and their
     indices are derived from the number of aterms, resp. symbols, that occur before them in this stream. For each term
     we first ensure that its arguments and symbol are written to the stream (avoiding duplicates). Then its
     symbol index followed by a number of indices (depending on the arity) for its argments are written as integers.
     Packet headers also contain a special value to indicate that the read term should be visible as output as opposed to
     being only a subterm.
     The start of the stream is a zero followed by a header and a version and a term with function symbol index zero
     indicates the end of the stream.

Definition at line 34 of file aterm_io_binary.h.

Constructor & Destructor Documentation

◆ binary_aterm_ostream() [1/2]

atermpp::binary_aterm_ostream::binary_aterm_ostream ( std::ostream &  os)

Provide the output stream to which the terms are written.

Definition at line 67 of file aterm_io_binary.cpp.

◆ binary_aterm_ostream() [2/2]

atermpp::binary_aterm_ostream::binary_aterm_ostream ( std::shared_ptr< mcrl2::utilities::obitstream stream)

Definition at line 54 of file aterm_io_binary.cpp.

◆ ~binary_aterm_ostream()

atermpp::binary_aterm_ostream::~binary_aterm_ostream ( )
override

Definition at line 71 of file aterm_io_binary.cpp.

Member Function Documentation

◆ function_symbol_index_width()

unsigned int atermpp::binary_aterm_ostream::function_symbol_index_width ( )
private
Returns
The number of bits needed to index function symbols.

Definition at line 186 of file aterm_io_binary.cpp.

◆ put()

void atermpp::binary_aterm_ostream::put ( const aterm term)
overridevirtual

Writes an aterm in a compact binary format where subterms are shared. The term that is written itself is not shared whenever it occurs as the argument of another term.

Implements atermpp::aterm_ostream.

Definition at line 94 of file aterm_io_binary.cpp.

◆ term_index_width()

unsigned int atermpp::binary_aterm_ostream::term_index_width ( )
private
Returns
The number of bits needed to index terms.

Definition at line 180 of file aterm_io_binary.cpp.

◆ write_function_symbol()

std::size_t atermpp::binary_aterm_ostream::write_function_symbol ( const function_symbol symbol)
private

Write a function symbol to the output stream.

Definition at line 217 of file aterm_io_binary.cpp.

Member Data Documentation

◆ m_function_symbol_index_width

unsigned int atermpp::binary_aterm_ostream::m_function_symbol_index_width
private

caches the result of function_symbol_index_width().

Definition at line 60 of file aterm_io_binary.h.

◆ m_function_symbols

mcrl2::utilities::indexed_set<function_symbol> atermpp::binary_aterm_ostream::m_function_symbols
private

An index of already written function symbols.

Definition at line 63 of file aterm_io_binary.h.

◆ m_stream

std::shared_ptr<mcrl2::utilities::obitstream> atermpp::binary_aterm_ostream::m_stream
private

Definition at line 57 of file aterm_io_binary.h.

◆ m_term_index_width

unsigned int atermpp::binary_aterm_ostream::m_term_index_width
private

caches the result of term_index_width().

Definition at line 59 of file aterm_io_binary.h.

◆ m_terms

atermpp::indexed_set<aterm> atermpp::binary_aterm_ostream::m_terms
private

An index of already written terms.

Definition at line 62 of file aterm_io_binary.h.


The documentation for this class was generated from the following files: