Gaudi Framework, version v21r7p1

Home   Generated: 15 Feb 2010

StringKey.cpp

Go to the documentation of this file.
00001 // $Id: $
00002 // ============================================================================
00003 // Include files 
00004 // ============================================================================
00005 // GaudiKernel
00006 // ============================================================================
00007 #include "GaudiKernel/Parsers.h"
00008 #include "GaudiKernel/ToStream.h"
00009 #include "GaudiKernel/StringKey.h"
00010 // ============================================================================
00011 // Boost
00012 // ============================================================================
00013 #include "boost/functional/hash.hpp"
00014 #include "boost/bind.hpp"
00015 // ============================================================================
00022 // ============================================================================
00023 // constructor from the string: perform hashing
00024 // ============================================================================
00025 Gaudi::StringKey::StringKey ( const std::string& key ) 
00026   : m_str  ( key )
00027   , m_hash ( boost::hash_value( key ) )  // NB! hashing here!!!
00028 {}
00029 // ============================================================================
00030 // the representation of the object
00031 // ============================================================================
00032 std::string Gaudi::StringKey::toString() const 
00033 { return Gaudi::Utils::toString ( m_str ) ; }
00034 // ============================================================================
00035 // the representation of the object
00036 // ============================================================================
00037 std::string Gaudi::StringKey:: __str__ () const { return toString() ; }
00038 // ============================================================================
00039 // the representation of the object
00040 // ============================================================================
00041 std::string Gaudi::StringKey:: __repr__() const { return toString() ; }
00042 // ============================================================================
00043 // equality operator for python 
00044 bool Gaudi::StringKey::__eq__    ( const Gaudi::StringKey&   right ) const 
00045 { return this == &right || *this == right ; }
00046 // ============================================================================
00047 // equality operators for python 
00048 // ============================================================================
00049 bool Gaudi::StringKey::__eq__    ( const std::string&        right ) const 
00050 { return *this == right ; }
00051 // ============================================================================
00052 // non-equality operator for python 
00053 // ============================================================================
00054 bool Gaudi::StringKey::__neq__   ( const Gaudi::StringKey&   right ) const 
00055 { return this != &right && *this != right ; }
00056 // ============================================================================
00057 // non-equality operator for python 
00058 // ============================================================================
00059 bool Gaudi::StringKey::__neq__   ( const std::string&        right ) const 
00060 { return *this != right ; }
00061 // ============================================================================
00062 /*  send the object to stream (needed to use it as property)
00063  *  @see Gaudi::Utils::toString
00064  *  @see Gaudi::Utils::toStream
00065  */
00066 // ============================================================================
00067 std::ostream& Gaudi::Utils::toStream 
00068 ( const Gaudi::StringKey& key , std::ostream& s ) 
00069 { return Gaudi::Utils::toStream ( key.str() , s ) ; }
00070 // ============================================================================
00071 /*  parse the key from the string
00072  *  @attention: this function is needed to use it as property
00073  *  @param result (OUTPUT) the parsing result
00074  *  @param input the input string
00075  *  @return status code 
00076  */
00077 // ============================================================================
00078 StatusCode Gaudi::Parsers::parse 
00079 ( Gaudi::StringKey&   result , 
00080   const std::string&  input  ) 
00081 {
00082   std::string _result ;
00083   StatusCode sc = parse ( _result , input ) ;
00084   result = Gaudi::StringKey ( _result ) ;
00085   return sc ;
00086 }
00087 // ============================================================================
00088 /*  parse the vector of keys from the string
00089  *  @see Gaudi::Parsers
00090  *  @see Gaudi::Parsers::parse
00091  *  @see Gaudi::StringKey
00092  *  @attention: this function is needed to use it as property
00093  *  @param result (OUTPUT) the parsing result
00094  *  @param input the input string
00095  *  @return status code 
00096  */
00097 // ============================================================================
00098 StatusCode Gaudi::Parsers::parse 
00099 ( std::vector<Gaudi::StringKey>&  result , 
00100   const std::string&              input  ) 
00101 {
00102   result.clear() ;
00103   typedef std::vector<std::string> Strings ;
00104   Strings _result ;
00105   StatusCode sc = parse ( _result , input ) ;
00106   if ( sc.isFailure() ) { return sc ; }                              // RETURN 
00107   result.reserve ( _result.size() ) ;
00108   //
00109   std::copy ( _result.begin() , 
00110               _result.end  () , std::back_inserter ( result ) ) ;
00111   //
00112   return StatusCode::SUCCESS ;
00113 }
00114 
00115   
00116 
00117 
00118 // ============================================================================
00119 // The END 
00120 // ============================================================================
00121 

Generated at Mon Feb 15 17:27:25 2010 for Gaudi Framework, version v21r7p1 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004