| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Dictionary.cpp
Go to the documentation of this file.
1 #include "GaudiKernel/System.h"
2 namespace GaudiDict {
3 std::string typeName(const std::type_info& typ);
4 std::string vectorName(const std::type_info& typ);
5 std::string vectorName(const std::string& typ);
6 std::string pairName(const std::type_info& typ1, const std::type_info& typ2);
7 std::string relationName(const std::string& prefix, const std::type_info& typ1, const std::type_info& typ2);
8 std::string templateName1(const std::string& templ, const std::type_info& typ);
9 std::string templateName1(const std::string& templ, const std::string& typ);
10 std::string templateName2(const std::string& templ, const std::type_info& typ1, const std::type_info& typ2);
11 std::string templateName3(const std::string& templ, const std::type_info& typ1, const std::type_info& typ2, const std::type_info& typ3);
12 std::string keyedContainerName(const std::string& prefix, const std::type_info& typ1);
13 }
14
15 static std::string clean(const std::string& s) {
16 std::string c = s;
17 for(size_t occ=c.find(" *"); occ != std::string::npos; occ=c.find(" *"))
18 c.replace(occ,2,"*");
19 return c;
20 }
21
22 std::string GaudiDict::typeName(const std::type_info& typ) {
23 std::string r = clean(System::typeinfoName(typ));
24 //if ( r.substr(0,4) == "enum" ) {
25 // r = "int";
26 //}
27 return r;
28 }
29
30 std::string GaudiDict::templateName1(const std::string& templ, const std::type_info& typ) {
31 return templateName1(templ, typeName(typ));
32 }
33
34 std::string GaudiDict::templateName1(const std::string& templ, const std::string& typ) {
35 std::string s = templ + "<";
36 s += typ;
37 s += (s[s.length()-1] == '>') ? " >" : ">";
38 return clean(s);
39 }
40
41 std::string GaudiDict::templateName2(const std::string& templ, const std::type_info& typ1, const std::type_info& typ2) {
42 std::string s = templ + "<";
43 s += typeName(typ1);
44 s += ",";
45 s += typeName(typ2);
46 s += (s[s.length()-1] == '>') ? " >" : ">";
47 return clean(s);
48 }
49
50 std::string GaudiDict::templateName3(const std::string& templ, const std::type_info& typ1, const std::type_info& typ2, const std::type_info& typ3) {
51 std::string s = templ + "<";
52 s += typeName(typ1);
53 s += ",";
54 s += typeName(typ2);
55 s += ",";
56 s += typeName(typ3);
57 s += (s[s.length()-1] == '>') ? " >" : ">";
58 return clean(s);
59 }
60
61 std::string GaudiDict::vectorName(const std::type_info& typ) {
62 return templateName1("std::vector", typ);
63 }
64
65 std::string GaudiDict::vectorName(const std::string& typ) {
66 return templateName1("std::vector", typ);
67 }
68
69 std::string GaudiDict::pairName(const std::type_info& typ1, const std::type_info& typ2) {
70 return templateName2("std::pair", typ1, typ2);
71 }
72
73 std::string GaudiDict::keyedContainerName(const std::string& mgr_typ, const std::type_info& typ1) {
74 std::string s = "KeyedContainer<";
75 s += typeName(typ1);
76 s += ",";
77 s += mgr_typ;
78 if ( mgr_typ[mgr_typ.length()-1]=='>' ) s += " ";
79 s += ">";
80 return clean(s);
81 }
82
83 std::string GaudiDict::relationName(const std::string& /* prefix */, const std::type_info& /* typ1 */, const std::type_info& /* typ2 */) {
84 return "";
85 }