cprover
irep_serialization.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: binary irep conversions with hashing
4 
5 Author: CM Wintersteiger
6 
7 Date: May 2007
8 
9 \*******************************************************************/
10 
13 
14 #ifndef CPROVER_UTIL_IREP_SERIALIZATION_H
15 #define CPROVER_UTIL_IREP_SERIALIZATION_H
16 
17 #include <map>
18 #include <iosfwd>
19 #include <string>
20 #include <vector>
21 
22 #include "irep_hash_container.h"
23 #include "irep.h"
24 
25 void write_gb_word(std::ostream &, std::size_t);
26 void write_gb_string(std::ostream &, const std::string &);
27 
29 {
30 public:
32  {
33  public:
34  typedef std::vector<std::pair<bool, irept> > ireps_on_readt;
36 
38  typedef std::map<unsigned, size_t> ireps_on_writet;
40 
41  typedef std::vector<bool> string_mapt;
43 
44  typedef std::vector<std::pair<bool, irep_idt> > string_rev_mapt;
46 
47  void clear()
48  {
50  ireps_on_write.clear();
51  ireps_on_read.clear();
52  string_map.clear();
53  string_rev_map.clear();
54  }
55  };
56 
58  ireps_container(ic)
59  {
60  read_buffer.resize(1, 0);
61  clear();
62  };
63 
64  std::size_t insert_on_write(std::size_t h);
65  std::size_t insert_on_read(std::size_t id, const irept &);
66 
67  void reference_convert(std::istream &, irept &irep);
68  void reference_convert(const irept &irep, std::ostream &);
69 
70  irep_idt read_string_ref(std::istream &);
71  void write_string_ref(std::ostream &, const irep_idt &);
72 
73  void clear() { ireps_container.clear(); }
74 
75  static std::size_t read_gb_word(std::istream &);
76  irep_idt read_gb_string(std::istream &);
77 
78 private:
80  std::vector<char> read_buffer;
81 
82  void write_irep(std::ostream &, const irept &irep);
83  void read_irep(std::istream &, irept &irep);
84 };
85 
86 #endif // CPROVER_UTIL_IREP_SERIALIZATION_H
irep_serializationt(ireps_containert &ic)
IREP Hash Container.
std::vector< char > read_buffer
irep_idt read_string_ref(std::istream &)
reads a string reference from the stream
std::size_t insert_on_write(std::size_t h)
inserts an irep into the hashtable
void reference_convert(std::istream &, irept &irep)
irep_full_hash_containert irep_full_hash_container
Base class for tree-like data structures with sharing.
Definition: irep.h:86
void write_irep(std::ostream &, const irept &irep)
ireps_containert & ireps_container
void write_gb_word(std::ostream &, std::size_t)
outputs 4 characters for a long, most-significant byte first
irep_idt read_gb_string(std::istream &)
reads a string from the stream
std::map< unsigned, size_t > ireps_on_writet
std::vector< std::pair< bool, irep_idt > > string_rev_mapt
void write_string_ref(std::ostream &, const irep_idt &)
outputs the string reference
static std::size_t read_gb_word(std::istream &)
reads 4 characters and builds a long int from them
std::size_t insert_on_read(std::size_t id, const irept &)
inserts an irep into the hashtable, but only the id-hashtable (only to be used upon reading ireps fro...
void read_irep(std::istream &, irept &irep)
void write_gb_string(std::ostream &, const std::string &)
outputs the string and then a zero byte.
std::vector< std::pair< bool, irept > > ireps_on_readt