File tree 4 files changed +29
-14
lines changed
4 files changed +29
-14
lines changed Original file line number Diff line number Diff line change 1
- #include < typeinfo>
2
1
#include < string>
3
2
#include < sstream>
4
3
5
4
#include " dump.hh"
5
+ #include " util.hh"
6
6
7
7
using namespace std ;
8
8
9
- std::string graphml_dumper::type (struct prod *p)
10
- {
11
- ostringstream os;
12
- os << typeid (*p).name ();
13
- string s = os.str ();
14
- while (s[0 ] <= ' 9' )
15
- s.erase (s.begin ());
16
- return s;
17
- }
18
-
19
9
std::string graphml_dumper::id (struct prod *p)
20
10
{
21
11
ostringstream os;
22
- os << type (p) << " _" << p;
12
+ os << pretty_type (p) << " _" << p;
23
13
return os.str ();
24
14
}
25
15
@@ -47,7 +37,7 @@ void graphml_dumper::visit(struct prod *p)
47
37
{
48
38
o << " <node id=\" " << id (p) << " \" >" ;
49
39
o << " <data key=\" retries\" >" << p->retries << " </data>" ;
50
- o << " <data key=\" label\" >" << type (p) << " </data>" ;
40
+ o << " <data key=\" label\" >" << pretty_type (p) << " </data>" ;
51
41
o << " <data key=\" scope\" >" << p->scope << " </data>" ;
52
42
o << " </node>" << endl;
53
43
if (p->pprod ) {
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ void report()
49
49
{
50
50
cerr << " impedance report: " << endl;
51
51
for (auto pair : occurances_in_failed_query) {
52
- cerr << " " << pair.first << " : " <<
52
+ cerr << " " << pretty_type ( pair.first ) << " : " <<
53
53
pair.second << " /" << occurances_in_ok_query[pair.first ]
54
54
<< " (bad/ok)" ;
55
55
if (!matched (pair.first ))
Original file line number Diff line number Diff line change 8
8
#include < typeinfo>
9
9
#include < map>
10
10
#include " prod.hh"
11
+ #include " util.hh"
11
12
#include " log.hh"
12
13
13
14
struct impedance_visitor : prod_visitor {
Original file line number Diff line number Diff line change
1
+ #ifndef UTIL_HH
2
+ #define UTIL_HH
3
+ #include < typeinfo>
4
+ #include < string>
5
+ #include < sstream>
6
+
7
+ using namespace std ;
8
+
9
+ inline std::string pretty_type (const char *raw)
10
+ {
11
+ ostringstream os;
12
+ os << raw;
13
+ string s = os.str ();
14
+ while (s[0 ] <= ' 9' )
15
+ s.erase (s.begin ());
16
+ return s;
17
+ }
18
+
19
+ inline std::string pretty_type (struct prod *p)
20
+ {
21
+ return pretty_type (typeid (*p).name ());
22
+ }
23
+
24
+ #endif
You can’t perform that action at this time.
0 commit comments