| # Gaudi Framework, version v23r0 |

Home |  | Generated: Mon Jan 30 2012

# TypeNameString.h

Go to the documentation of this file.

    00001 #ifndef GAUDIKERNEL_TYPENAMESTRING_H
    00002 #define GAUDIKERNEL_TYPENAMESTRING_H
    00003 #include <string>
    00004
    00005 namespace Gaudi {
    00006   namespace Utils {
    00008     class TypeNameString {
    00009       std::string m_type, m_name;
    00010       bool m_haveType;
    00011       void init(const std::string& tn, const std::string& deftyp)    {
    00012         const std::string::size_type slash_pos = tn.find_first_of("/");
    00013         m_haveType = slash_pos != std::string::npos;
    00014         m_name = (m_haveType) ? tn.substr( slash_pos + 1) : tn;
    00015         m_type = (m_haveType) ? tn.substr( 0, slash_pos ) : deftyp;
    00016       }
    00017     public:
    00018       TypeNameString(const char tn[]): m_haveType(false) { init(tn, tn); }
    00019       TypeNameString(const std::string& tn): m_haveType(false) { init(tn, tn); }
    00020       TypeNameString(const std::string& tn, const std::string& deftyp) { init(tn, deftyp); m_haveType = true; }
    00021       const std::string& type() const { return m_type; }
    00022       const std::string& name() const { return m_name; }
    00023       bool haveType() const { return m_haveType; }
    00024     };
    00025
    00027     inline std::ostream& operator<< (std::ostream& s, const TypeNameString& tn) {
    00028       return s << tn.type() << '/' << tn.name();
    00029     }
    00030   }
    00031 }
    00032
    00033
    00034 #endif // GAUDIKERNEL_TYPENAMESTRING_H

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines