mana-core-gaudikernel / GaudiKernel / TypeNameString.h

// $Id: ListItem.h,v 1.2 2007/01/17 14:17:08 hmd Exp $
#ifndef GAUDIKERNEL_TYPENAMESTRING_H
#define GAUDIKERNEL_TYPENAMESTRING_H
#include <string>

namespace Gaudi {
  namespace Utils {
    /// Helper class to parse a string of format "type/name"
    class TypeNameString {
      std::string m_type, m_name;
      bool m_haveType;
      void init(const std::string& tn, const std::string& deftyp)    {
        const std::string::size_type slash_pos = tn.find_first_of("/");
        m_haveType = slash_pos != std::string::npos;
        m_name = (m_haveType) ? tn.substr( slash_pos + 1) : tn;
        m_type = (m_haveType) ? tn.substr( 0, slash_pos ) : deftyp;
      }
    public:
      TypeNameString(const char tn[]): m_haveType(false) { init(tn, tn); }
      TypeNameString(const std::string& tn): m_haveType(false) { init(tn, tn); }
      TypeNameString(const std::string& tn, const std::string& deftyp) { init(tn, deftyp); m_haveType = true; }
      const std::string& type() const { return m_type; }
      const std::string& name() const { return m_name; }
      bool haveType() const { return m_haveType; }
    };
  }
}

#endif // GAUDIKERNEL_TYPENAMESTRING_H
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.