Alexandria
2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Pyston
src
lib
GraphvizGenerator.cpp
Go to the documentation of this file.
1
19
#include "
Pyston/Util/GraphvizGenerator.h
"
20
#include <boost/algorithm/string.hpp>
21
22
namespace
Pyston
{
23
24
static
std::string
escape
(
const
std::string
& str) {
25
return
boost::replace_all_copy(str,
"\""
,
"\\\""
);
26
}
27
28
GraphvizGenerator::GraphvizGenerator
(
const
std::string
& label) : m_unique_id(0) {
29
m_stream
<<
"digraph G {"
<<
std::endl
<<
"\tlabel=\""
<<
escape
(label) <<
"\""
<<
std::endl
;
30
}
31
32
void
GraphvizGenerator::enter
(
const
NodeBase
* node) {
33
m_stream
<<
"\t"
<<
'"'
<<
m_unique_id
<<
'"'
<<
" [label=\""
<<
escape
(node->
repr
()) <<
"\"];"
<<
std::endl
;
34
if
(!
m_stack
.
empty
()) {
35
m_stream
<<
"\t\""
<<
m_stack
.
back
() <<
'"'
<<
" -> \""
<<
m_unique_id
<<
"\""
<<
std::endl
;
36
}
37
m_stack
.
push_back
(
m_unique_id
);
38
++
m_unique_id
;
39
}
40
41
void
GraphvizGenerator::exit
(
const
NodeBase
*) {
42
m_stack
.
pop_back
();
43
}
44
45
std::string
GraphvizGenerator::str
()
const
{
46
return
m_stream
.
str
() +
"}"
;
47
}
48
49
}
// end of namespace Pyston
GraphvizGenerator.h
std::list::back
T back(T... args)
std::string
Pyston::GraphvizGenerator::exit
void exit(const NodeBase *) override
Definition
GraphvizGenerator.cpp:41
Pyston::GraphvizGenerator::str
std::string str() const
Definition
GraphvizGenerator.cpp:45
Pyston::GraphvizGenerator::m_unique_id
int64_t m_unique_id
Definition
GraphvizGenerator.h:58
Pyston::GraphvizGenerator::m_stack
std::list< int64_t > m_stack
Definition
GraphvizGenerator.h:60
Pyston::GraphvizGenerator::m_stream
std::stringstream m_stream
Definition
GraphvizGenerator.h:59
Pyston::GraphvizGenerator::GraphvizGenerator
GraphvizGenerator(const std::string &label)
Definition
GraphvizGenerator.cpp:28
Pyston::GraphvizGenerator::enter
void enter(const NodeBase *node) override
Definition
GraphvizGenerator.cpp:32
Pyston::NodeBase
Definition
Node.h:39
Pyston::NodeBase::repr
virtual std::string repr() const =0
std::list::empty
T empty(T... args)
std::endl
T endl(T... args)
Pyston
Definition
ExceptionRaiser.h:28
Pyston::escape
static std::string escape(const std::string &str)
Definition
GraphvizGenerator.cpp:24
std::list::pop_back
T pop_back(T... args)
std::list::push_back
T push_back(T... args)
std::stringstream::str
T str(T... args)
Generated by
1.9.8