The Gaudi Framework  master (37c0b60a)
Dictionary.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #include <GaudiKernel/System.h>
12 namespace GaudiDict {
13  std::string typeName( const std::type_info& typ );
15  std::string vectorName( const std::string& typ );
16  std::string pairName( const std::type_info& typ1, const std::type_info& typ2 );
17  std::string relationName( const std::string& prefix, const std::type_info& typ1, const std::type_info& typ2 );
19  std::string templateName1( std::string templ, const std::string& typ );
20  std::string templateName2( std::string templ, const std::type_info& typ1, const std::type_info& typ2 );
21  std::string templateName3( std::string templ, const std::type_info& typ1, const std::type_info& typ2,
22  const std::type_info& typ3 );
24 } // namespace GaudiDict
25 
26 static std::string clean( std::string c ) {
27  for ( size_t occ = c.find( " *" ); occ != std::string::npos; occ = c.find( " *" ) ) c.replace( occ, 2, "*" );
28  return c;
29 }
30 
32  std::string r = clean( System::typeinfoName( typ ) );
33  // if ( r.compare(0,4,"enum") == 0 ) {
34  // r = "int";
35  //}
36  return r;
37 }
38 
40  return templateName1( std::move( templ ), typeName( typ ) );
41 }
42 
44  s += "<";
45  s += typ;
46  s += ( s.back() == '>' ) ? " >" : ">"; // with C++11, we can have <somename<T>>...
47  return clean( s );
48 }
49 
51  s += "<";
52  s += typeName( typ1 );
53  s += ",";
54  s += typeName( typ2 );
55  s += ( s.back() == '>' ) ? " >" : ">";
56  return clean( s );
57 }
58 
60  const std::type_info& typ3 ) {
61  s += "<";
62  s += typeName( typ1 );
63  s += ",";
64  s += typeName( typ2 );
65  s += ",";
66  s += typeName( typ3 );
67  s += ( s.back() == '>' ) ? " >" : ">";
68  return clean( s );
69 }
70 
71 std::string GaudiDict::vectorName( const std::type_info& typ ) { return templateName1( "std::vector", typ ); }
72 
73 std::string GaudiDict::vectorName( const std::string& typ ) { return templateName1( "std::vector", typ ); }
74 
76  return templateName2( "std::pair", typ1, typ2 );
77 }
78 
80  std::string s = "KeyedContainer<";
81  s += typeName( typ1 );
82  s += ",";
83  s += mgr_typ;
84  if ( mgr_typ[mgr_typ.length() - 1] == '>' ) s += " ";
85  s += ">";
86  return clean( s );
87 }
88 
89 std::string GaudiDict::relationName( const std::string& /* prefix */, const std::type_info& /* typ1 */,
90  const std::type_info& /* typ2 */ ) {
91  return "";
92 }
GaudiDict::templateName2
std::string templateName2(std::string templ, const std::type_info &typ1, const std::type_info &typ2)
Definition: Dictionary.cpp:50
std::string
STL class.
std::move
T move(T... args)
System.h
GaudiDict::templateName1
std::string templateName1(std::string templ, const std::string &typ)
Definition: Dictionary.cpp:43
GaudiDict::templateName3
std::string templateName3(std::string templ, const std::type_info &typ1, const std::type_info &typ2, const std::type_info &typ3)
Definition: Dictionary.cpp:59
gaudirun.s
string s
Definition: gaudirun.py:346
std::string::length
T length(T... args)
std::type_info
gaudirun.prefix
string prefix
Definition: gaudirun.py:361
gaudirun.c
c
Definition: gaudirun.py:525
GaudiDict::vectorName
std::string vectorName(const std::type_info &typ)
Definition: Dictionary.cpp:71
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:315
GaudiDict::keyedContainerName
std::string keyedContainerName(const std::string &prefix, const std::type_info &typ1)
Definition: Dictionary.cpp:79
GaudiDict::pairName
std::string pairName(const std::type_info &typ1, const std::type_info &typ2)
Definition: Dictionary.cpp:75
GaudiDict::templateName1
std::string templateName1(std::string templ, const std::type_info &typ)
Definition: Dictionary.cpp:39
GaudiDict::relationName
std::string relationName(const std::string &prefix, const std::type_info &typ1, const std::type_info &typ2)
Definition: Dictionary.cpp:89
GaudiDict::typeName
std::string typeName(const std::type_info &typ)
Definition: Dictionary.cpp:31
GaudiDict
Definition: KeyedContainer.h:18