The Gaudi Framework  v30r3 (a5ef0a68)
BoostArrayAsProperty.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_BOOSTARRAYASPROPERTY_H
2 #define GAUDIKERNEL_BOOSTARRAYASPROPERTY_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <algorithm>
9 // ============================================================================
10 // Boost
11 // ============================================================================
12 #include "boost/array.hpp"
13 // ============================================================================
23 // ============================================================================
24 // 1) Streamers : value -> string
25 // ============================================================================
26 namespace Gaudi
27 {
28  // ==========================================================================
29  namespace Utils
30  {
31  // ========================================================================
32  template <class ITERATOR>
33  inline std::ostream& toStream( ITERATOR first, // begin of the sequence
34  ITERATOR last, // end of the sequence
35  std::ostream& s, // the stream
36  const std::string& open, // opening
37  const std::string& close, // closing
38  const std::string& delim ); // delimiter
39  // ========================================================================
48  template <class TYPE, std::size_t N>
49  inline std::ostream& toStream( const boost::array<TYPE, N>& obj, std::ostream& s )
50  {
51  return toStream( obj.begin(), obj.end(), s, "( ", " )", " , " );
52  }
53  // ========================================================================
54  } // end of namespace Gaudi::Utils
55  // ==========================================================================
56 } // end of namespace Gaudi
57 // ============================================================================
58 // 2) Parsers: string -> value
59 // ============================================================================
60 // GaudiKernel
61 // ============================================================================
62 #include "GaudiKernel/Parsers.h"
63 // ============================================================================
64 namespace Gaudi
65 {
66  // ==========================================================================
67  namespace Parsers
68  {
69  // ========================================================================
77  template <class TYPE, std::size_t N>
78  StatusCode parse( boost::array<TYPE, N>& result, const std::string& input )
79  {
80  typedef std::vector<TYPE> _Vct;
81  // create the temporaty vector
82  _Vct tmp;
83  // parse the string
84  StatusCode sc = parse( tmp, input );
85  if ( sc.isFailure() ) {
86  return sc;
87  } // RETURN
88  if ( N != tmp.size() ) {
89  return StatusCode( StatusCode::FAILURE, true );
90  } // RETURN
91  // copy vector into array
92  std::copy( tmp.begin(), tmp.end(), result.begin() );
93  //
94  return StatusCode::SUCCESS;
95  }
96  // ========================================================================
97  } // end of namespace Gaudi::Parsers
98  // ==========================================================================
99 } // end of namespace Gaudi
100 // ============================================================================
101 // The END
102 // ============================================================================
103 #endif // GAUDIKERNEL_BOOSTARRAYASPROPERTY_H
104 // ============================================================================
constexpr static const auto FAILURE
Definition: StatusCode.h:88
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:303
The declaration of major parsing functions used e.g for (re)implementation of new extended properties...
bool isFailure() const
Definition: StatusCode.h:139
STL class.
int N
Definition: IOTest.py:101
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
StatusCode parse(DataObjID &dest, const std::string &src)
Definition: DataObjID.cpp:52
STL class.
string s
Definition: gaudirun.py:253
STL class.
Helper functions to set/get the application return code.
Definition: __init__.py:1