Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
StringKey.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // GaudiKernel
5 // ============================================================================
7 #include "GaudiKernel/ToStream.h"
9 // ============================================================================
16 // ============================================================================
17 // constructor from the string: perform hashing
18 // ============================================================================
20  : m_str( std::move( key ) )
21  , m_hash( std::hash<std::string>()( m_str ) ) // NB! hashing here!!!
22 {}
23 // ============================================================================
24 // constructor from the string: perform hashing
25 // ============================================================================
26 Gaudi::StringKey::StringKey( const char* key )
27  : m_str( key )
28  , m_hash( std::hash<std::string>()( m_str ) ) // NB! hashing here!!!
29 {}
30 // ============================================================================
31 // the representation of the object
32 // ============================================================================
34 // ============================================================================
35 // the representation of the object
36 // ============================================================================
38 // ============================================================================
39 // the representation of the object
40 // ============================================================================
42 // ============================================================================
43 // equality operator for python
44 bool Gaudi::StringKey::__eq__( const Gaudi::StringKey& right ) const { return this == &right || *this == right; }
45 // ============================================================================
46 // equality operators for python
47 // ============================================================================
48 bool Gaudi::StringKey::__eq__( const std::string& right ) const { return *this == right; }
49 // ============================================================================
50 // non-equality operator for python
51 // ============================================================================
52 bool Gaudi::StringKey::__neq__( const Gaudi::StringKey& right ) const { return this != &right && *this != right; }
53 // ============================================================================
54 // non-equality operator for python
55 // ============================================================================
56 bool Gaudi::StringKey::__neq__( const std::string& right ) const { return *this != right; }
57 // ============================================================================
58 /* send the object to stream (needed to use it as property)
59  * @see Gaudi::Utils::toString
60  * @see Gaudi::Utils::toStream
61  */
62 // ============================================================================
64  return Gaudi::Utils::toStream( key.str(), s );
65 }
66 // ============================================================================
67 /* parse the key from the string
68  * @attention: this function is needed to use it as property
69  * @param result (OUTPUT) the parsing result
70  * @param input the input string
71  * @return status code
72  */
73 // ============================================================================
75  std::string _result;
76  StatusCode sc = parse( _result, input );
77  result = Gaudi::StringKey( _result );
78  return sc;
79 }
80 // ============================================================================
81 /* parse the vector of keys from the string
82  * @see Gaudi::Parsers
83  * @see Gaudi::Parsers::parse
84  * @see Gaudi::StringKey
85  * @attention: this function is needed to use it as property
86  * @param result (OUTPUT) the parsing result
87  * @param input the input string
88  * @return status code
89  */
90 // ============================================================================
92  result.clear();
93  typedef std::vector<std::string> Strings;
94  Strings _result;
95  StatusCode sc = parse( _result, input );
96  if ( sc.isFailure() ) { return sc; } // RETURN
97  result.reserve( _result.size() );
98  //
99  std::copy( _result.begin(), _result.end(), std::back_inserter( result ) );
100  //
101  return StatusCode::SUCCESS;
102 }
103 
104 // ============================================================================
105 // The END
106 // ============================================================================
T copy(T...args)
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
Definition: ToStream.h:284
bool __eq__(const StringKey &right) const
equality operator for python
Definition: StringKey.cpp:44
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:334
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
STL namespace.
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
std::size_t m_hash
the hash:
Definition: StringKey.h:139
std::string __repr__() const
the representation of the object
Definition: StringKey.cpp:41
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
bool isFailure() const
Definition: StatusCode.h:130
The helper class to represent the efficient "key" for access.
Definition: StringKey.h:34
std::string __str__() const
the representation of the object
Definition: StringKey.cpp:37
STL class.
StringKey(const char *key="")
constructor from plain C-string, perform hashing
Definition: StringKey.cpp:26
std::string m_str
the actual string:
Definition: StringKey.h:137
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
T clear(T...args)
StatusCode parse(DataObjID &dest, const std::string &src)
Definition: DataObjID.cpp:46
T back_inserter(T...args)
string s
Definition: gaudirun.py:312
implementation of various functions for streaming.
bool __neq__(const StringKey &right) const
non-equality operator for python
Definition: StringKey.cpp:52
STL class.
const std::string & str() const
the actual string
Definition: StringKey.h:45
std::string toString() const
string representation (for properties)
Definition: StringKey.cpp:33
T reserve(T...args)