The Gaudi Framework  master (e3184c44)
BoostArrayAsProperty.h
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 \***********************************************************************************/
11 #pragma once
12 
14 #include <algorithm>
15 #include <boost/array.hpp>
16 
26 // ============================================================================
27 // 1) Streamers : value -> string
28 // ============================================================================
29 namespace Gaudi {
30  namespace Utils {
31  template <class ITERATOR>
32  inline std::ostream& toStream( ITERATOR first, // begin of the sequence
33  ITERATOR last, // end of the sequence
34  std::ostream& s, // the stream
35  const std::string& open, // opening
36  const std::string& close, // closing
37  const std::string& delim ); // delimiter
46  template <class TYPE, std::size_t N>
47  inline std::ostream& toStream( const boost::array<TYPE, N>& obj, std::ostream& s ) {
48  return toStream( obj.begin(), obj.end(), s, "( ", " )", " , " );
49  }
50  } // namespace Utils
51 } // namespace Gaudi
52 // ============================================================================
53 // 2) Parsers: string -> value
54 // ============================================================================
55 namespace Gaudi {
56  namespace Parsers {
64  template <class TYPE, std::size_t N>
65  StatusCode parse( boost::array<TYPE, N>& result, std::string_view input ) {
66  typedef std::vector<TYPE> _Vct;
67  // create the temporaty vector
68  _Vct tmp;
69  // parse the string
70  StatusCode sc = parse( tmp, input );
71  if ( sc.isFailure() ) { return sc; }
72  if ( N != tmp.size() ) { return StatusCode::FAILURE; }
73  // copy vector into array
74  std::copy( tmp.begin(), tmp.end(), result.begin() );
75  //
76  return StatusCode::SUCCESS;
77  }
78  } // namespace Parsers
79 } // namespace Gaudi
IOTest.N
N
Definition: IOTest.py:112
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
StatusCode
Definition: StatusCode.h:64
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:99
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
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:100