klee
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TreeStream.h
Go to the documentation of this file.
1 //===-- TreeStream.h --------------------------------------------*- C++ -*-===//
2 //
3 // The KLEE Symbolic Virtual Machine
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef __UTIL_TREESTREAM_H__
11 #define __UTIL_TREESTREAM_H__
12 
13 #include <string>
14 #include <vector>
15 
16 namespace klee {
17 
18  typedef unsigned TreeStreamID;
19  class TreeOStream;
20 
22  static const unsigned bufferSize = 4*4096;
23 
24  friend class TreeOStream;
25 
26  private:
28  unsigned lastID, bufferCount;
29 
30  std::string path;
31  std::ofstream *output;
32  unsigned ids;
33 
34  void write(TreeOStream &os, const char *s, unsigned size);
35  void flushBuffer();
36 
37  public:
38  TreeStreamWriter(const std::string &_path);
40 
41  bool good();
42 
43  TreeOStream open();
44  TreeOStream open(const TreeOStream &node);
45 
46  void flush();
47 
48  // hack, to be replace by proper stream capabilities
49  void readStream(TreeStreamID id,
50  std::vector<unsigned char> &out);
51  };
52 
53  class TreeOStream {
54  friend class TreeStreamWriter;
55 
56  private:
58  unsigned id;
59 
60  TreeOStream(TreeStreamWriter &_writer, unsigned _id);
61 
62  public:
63  TreeOStream();
64  ~TreeOStream();
65 
66  unsigned getID() const;
67 
68  void write(const char *buffer, unsigned size);
69 
70  TreeOStream &operator<<(const std::string &s);
71 
72  void flush();
73  };
74 }
75 
76 #endif
TreeStreamWriter(const std::string &_path)
Definition: TreeStream.cpp:26
TreeStreamWriter * writer
Definition: TreeStream.h:57
void write(TreeOStream &os, const char *s, unsigned size)
Definition: TreeStream.cpp:63
char buffer[bufferSize]
Definition: TreeStream.h:27
std::ofstream * output
Definition: TreeStream.h:31
unsigned TreeStreamID
Definition: TreeStream.h:18
void readStream(TreeStreamID id, std::vector< unsigned char > &out)
Definition: TreeStream.cpp:101
void write(const char *buffer, unsigned size)
Definition: TreeStream.cpp:187
unsigned getID() const
Definition: TreeStream.cpp:182
TreeOStream & operator<<(const std::string &s)
Definition: TreeStream.cpp:192
TreeOStream open()
Definition: TreeStream.cpp:49
static const unsigned bufferSize
Definition: TreeStream.h:22