blob: fceaacb48d0806710d6eb544bdc2df642d450be7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#ifndef NODEDUMPER_H_
#define NODEDUMPER_H_
#include <string>
#include <map>
#include <list>
#include "visitor.h"
#include "nodecache.h"
using std::string;
using std::map;
using std::list;
class NodeDumper : public Visitor
{
public:
/*! If idPrefix is true, we will output "n<id>:" in front of each node,
which is useful for debugging. */
NodeDumper(NodeCache &cache, bool idPrefix = false) :
cache(cache), idprefix(idPrefix), root(NULL) { }
virtual ~NodeDumper() {}
virtual Response visit(const State &state, const AbstractNode &node);
private:
void handleVisitedChildren(const State &state, const AbstractNode &node);
bool isCached(const AbstractNode &node) const;
void handleIndent(const State &state);
string dumpChildren(const AbstractNode &node);
NodeCache &cache;
bool idprefix;
string currindent;
const AbstractNode *root;
typedef list<const AbstractNode *> ChildList;
map<int, ChildList> visitedchildren;
};
#endif
|