The Gaudi Framework  v40r0 (475e45c1)
StringKey.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 \***********************************************************************************/
12 #include <GaudiKernel/StringKey.h>
13 #include <GaudiKernel/ToStream.h>
14 
23  : m_str( std::move( key ) )
24  , m_hash( std::hash<std::string>()( m_str ) ) // NB! hashing here!!!
25 {}
26 std::string Gaudi::StringKey::toString() const { return Gaudi::Utils::toString( m_str ); }
27 const std::string& Gaudi::StringKey::__str__() const { return m_str; }
28 std::string Gaudi::StringKey::__repr__() const { return toString(); }
29 bool Gaudi::StringKey::__eq__( const Gaudi::StringKey& right ) const { return *this == right; }
30 bool Gaudi::StringKey::__eq__( std::string_view right ) const { return *this == right; }
31 bool Gaudi::StringKey::__neq__( const Gaudi::StringKey& right ) const { return *this != right; }
32 bool Gaudi::StringKey::__neq__( std::string_view right ) const { return *this != right; }
33 std::ostream& Gaudi::Utils::toStream( const Gaudi::StringKey& key, std::ostream& s ) {
34  return Gaudi::Utils::toStream( key.str(), s );
35 }
36 StatusCode Gaudi::Parsers::parse( Gaudi::StringKey& result, std::string_view input ) {
37  std::string _result;
38  StatusCode sc = parse( _result, input );
39  result = Gaudi::StringKey( _result );
40  return sc;
41 }
42 StatusCode Gaudi::Parsers::parse( std::vector<Gaudi::StringKey>& result, std::string_view input ) {
43  result.clear();
44  typedef std::vector<std::string> Strings;
45  Strings _result;
46  StatusCode sc = parse( _result, input );
47  if ( sc.isFailure() ) { return sc; }
48  result.reserve( _result.size() );
49 
50  std::copy( _result.begin(), _result.end(), std::back_inserter( result ) );
51 
52  return StatusCode::SUCCESS;
53 }
GaudiPartProp.decorators.std
std
Definition: decorators.py:32
Gaudi::Parsers::parse
StatusCode parse(GaudiUtils::HashMap< K, V > &result, std::string_view input)
Basic parser for the types of HashMap used in DODBasicMapper.
Definition: DODBasicMapper.cpp:21
gaudirun.s
string s
Definition: gaudirun.py:346
StringKey.h
ToStream.h
Gaudi::StringKey
Definition: StringKey.h:35
Gaudi::StringKey::__str__
const std::string & __str__() const
the representation of the object
Definition: StringKey.cpp:27
StatusCode
Definition: StatusCode.h:64
Gaudi::StringKey::StringKey
StringKey(const char *key="")
constructor from plain C-string, perform hashing
Definition: StringKey.h:38
Gaudi::StringKey::__repr__
std::string __repr__() const
the representation of the object
Definition: StringKey.cpp:28
BoostArrayProperties.Strings
Strings
Definition: BoostArrayProperties.py:36
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:326
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:99
parse
StatusCode parse(DataObjID &dest, std::string_view src)
Definition: DataObjID.cpp:58
CommonParsers.h
Gaudi::Utils::toStream
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:304
Gaudi::StringKey::toString
std::string toString() const
string representation (for properties)
Definition: StringKey.cpp:26
Gaudi::StringKey::__eq__
bool __eq__(const StringKey &right) const
equality operator for python
Definition: StringKey.cpp:29
ProduceConsume.key
key
Definition: ProduceConsume.py:84
Gaudi::StringKey::__neq__
bool __neq__(const StringKey &right) const
non-equality operator for python
Definition: StringKey.cpp:31