mCRL2
Loading...
Searching...
No Matches
aterm_io_binary.h
Go to the documentation of this file.
1// Author(s): Jan Friso Groote
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9
10#ifndef MCRL2_ATERMPP_ATERM_IO_BINARY_H
11#define MCRL2_ATERMPP_ATERM_IO_BINARY_H
12
14
18
19namespace atermpp
20{
21
35{
36public:
38 binary_aterm_ostream(std::ostream& os);
39 binary_aterm_ostream(std::shared_ptr<mcrl2::utilities::obitstream> stream);
40
41 ~binary_aterm_ostream() override;
42
45 void put(const aterm &term) override;
46
47private:
49 std::size_t write_function_symbol(const function_symbol& symbol);
50
52 unsigned int term_index_width();
53
55 unsigned int function_symbol_index_width();
56
57 std::shared_ptr<mcrl2::utilities::obitstream> m_stream;
58
59 unsigned int m_term_index_width;
61
64};
65
68{
69public:
71 binary_aterm_istream(std::istream& is);
72 binary_aterm_istream(std::shared_ptr<mcrl2::utilities::ibitstream> stream);
73
74 void get(aterm& t) override;
75
76private:
78 unsigned int term_index_width();
79
81 unsigned int function_symbol_index_width();
82
83 std::shared_ptr<mcrl2::utilities::ibitstream> m_stream;
84
85 unsigned int m_term_index_width;
87
89 std::deque<function_symbol> m_function_symbols;
90};
91
92} // namespace atermpp
93
94bool is_a_binary_aterm(std::istream& is);
95
96#endif // MCRL2_ATERMPP_ATERM_IO_BINARY_H
bool is_a_binary_aterm(std::istream &is)
The interface for a class that reads aterm from a stream. The default constructed term aterm() indica...
Definition aterm_io.h:59
The interface for a class that writes aterm to a stream. Every written term is retrieved by the corre...
Definition aterm_io.h:48
Reads terms from a stream in the steamable binary aterm format.
std::shared_ptr< mcrl2::utilities::ibitstream > m_stream
unsigned int m_function_symbol_index_width
caches the result of function_symbol_index_width().
atermpp::deque< aterm > m_terms
An index of read terms.
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.
Writes terms in a streamable binary aterm format to an output stream.
unsigned int m_term_index_width
caches the result of term_index_width().
std::size_t write_function_symbol(const function_symbol &symbol)
Write a function symbol to the output stream.
std::shared_ptr< mcrl2::utilities::obitstream > m_stream
unsigned int m_function_symbol_index_width
caches the result of function_symbol_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...
mcrl2::utilities::indexed_set< function_symbol > m_function_symbols
An index of already written function symbols.
A deque class in which aterms can be stored.
Definition deque.h:34
A set that assigns each element an unique index, and protects its internal terms en masse.
Definition indexed_set.h:30
A set that assigns each element an unique index.
Definition indexed_set.h:33
The main namespace for the aterm++ library.
Definition algorithm.h:21