| The Gaudi Framework v27r1

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

- File List
- File Members

TypeNameString.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_TYPENAMESTRING_H
2 #define GAUDIKERNEL_TYPENAMESTRING_H
3 #include <string>
4 #include <ostream>
5
6 namespace Gaudi {
7 namespace Utils {
9 class TypeNameString {
10 std::string m_type, m_name;
11 bool m_haveType;
12 void init(const std::string& tn, const std::string& deftyp) {
13 const std::string::size_type slash_pos = tn.find_first_of("/");
14 m_haveType = slash_pos != std::string::npos;
15 m_name = (m_haveType) ? tn.substr( slash_pos + 1) : tn;
16 m_type = (m_haveType) ? tn.substr( 0, slash_pos ) : deftyp;
17 }
18 public:
19 TypeNameString(const char tn[]) : TypeNameString( std::string{tn} ) { }
20 TypeNameString(const std::string& tn) { init(tn, tn); }
21 TypeNameString(const std::string& tn, const std::string& deftyp) { init(tn, deftyp); m_haveType = true; }
22 const std::string& type() const { return m_type; }
23 const std::string& name() const { return m_name; }
24 bool haveType() const { return m_haveType; }
25 };
26
28 inline std::ostream& operator<< (std::ostream& s, const TypeNameString& tn) {
29 return s << tn.type() << '/' << tn.name();
30 }
31 }
32 }
33
34
35 #endif // GAUDIKERNEL_TYPENAMESTRING_H
Gaudi::Utils::operator<<
std::ostream & operator<<(std::ostream &s, const TypeNameString &tn)
Output stream operator for TypeNameString instances.
Definition: TypeNameString.h:28
std
STL namespace.
Gaudi::Utils::TypeNameString::m_haveType
bool m_haveType
Definition: TypeNameString.h:11
std::string
STL class.
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
Gaudi::Utils::TypeNameString::TypeNameString
TypeNameString(const char tn[])
Definition: TypeNameString.h:19
std::string::find_first_of
T find_first_of(T...args)
Gaudi::Utils::TypeNameString::TypeNameString
TypeNameString(const std::string &tn, const std::string &deftyp)
Definition: TypeNameString.h:21
Gaudi::Utils::TypeNameString::init
void init(const std::string &tn, const std::string &deftyp)
Definition: TypeNameString.h:12
Gaudi::Utils::TypeNameString::type
const std::string & type() const
Definition: TypeNameString.h:22
gaudirun.s
string s
Definition: gaudirun.py:245
std::string::substr
T substr(T...args)
Gaudi::Utils::TypeNameString::haveType
bool haveType() const
Definition: TypeNameString.h:24
Gaudi::Utils::TypeNameString::m_name
std::string m_name
Definition: TypeNameString.h:10
Gaudi::Utils::TypeNameString::TypeNameString
TypeNameString(const std::string &tn)
Definition: TypeNameString.h:20
Gaudi::Utils::TypeNameString::name
const std::string & name() const
Definition: TypeNameString.h:23
std::ostream
STL class.
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::Utils::TypeNameString::m_type
std::string m_type
Definition: TypeNameString.h:10