The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
ParsersVct.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\***********************************************************************************/
14
15namespace {
16 typedef std::map<std::string, double> MAP;
17
18 template <unsigned int N>
19 inline MAP::const_iterator find( const MAP& m, const std::string ( &keys )[N] ) {
20 for ( unsigned int i = 0; i < N; ++i ) {
21 auto found = m.find( keys[i] );
22 if ( m.end() != found ) { return found; }
23 }
24 return m.end();
25 }
26} // namespace
27namespace Gaudi {
28 namespace Parsers {
29 template <typename T1, typename T2>
30 inline StatusCode parse_( ROOT::Math::PositionVector3D<T1, T2>& result, std::string_view input ) {
31 Skipper skipper;
33 IteratorT iter = input.begin(), end = input.end();
34 if ( qi::phrase_parse( iter, end, g, skipper, result ) ) { return StatusCode::SUCCESS; }
35 //@attention always
37 }
38
39 StatusCode parse( Gaudi::XYZPoint& result, std::string_view input ) { return parse_( result, input ); }
40
41 /* parse 3D-vector
42 * @param result (output) the parsed vector
43 * @param input (input) the input string
44 * @return status code
45 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
46 * @date 2009-09-05
47 */
48 StatusCode parse( Gaudi::XYZVector& result, std::string_view input ) {
49
50 Gaudi::XYZPoint point;
51 StatusCode sc = parse( point, input );
52 if ( sc.isFailure() ) { return sc; }
53 result = point;
55 }
56
57 StatusCode parse( Gaudi::LorentzVector& result, std::string_view input ) { return parse_( result, input ); }
58
59 /* parse the vector of points
60 * @param resut (OUTPUT) the parser vector
61 * @param input (INPIUT) the string to be parsed
62 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
63 * @date 2009-09-05
64 */
65 StatusCode parse( std::vector<Gaudi::XYZPoint>& result, std::string_view input ) {
66 result.clear();
67 return parse_( result, input );
68 }
69 /* parse the vector of vectors
70 * @param resut (OUTPUT) the parser vector
71 * @param input (INPIUT) the string to be parsed
72 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
73 * @date 2009-09-05
74 */
75 StatusCode parse( std::vector<Gaudi::XYZVector>& result, std::string_view input ) {
76 result.clear();
77 return parse_( result, input );
78 }
79
80 /* parse the vector of vectors
81 * @param resut (OUTPUT) the parser vector
82 * @param input (INPIUT) the string to be parsed
83 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
84 * @date 2009-09-05
85 */
86 StatusCode parse( std::vector<Gaudi::LorentzVector>& result, std::string_view input ) {
87 return parse_( result, input );
88 }
89 } // namespace Parsers
90} // namespace Gaudi
91std::ostream& Gaudi::Utils::toStream( const Gaudi::XYZPoint& obj, std::ostream& s ) {
92 s << "( ";
93 toStream( obj.X(), s );
94 s << " , ";
95 toStream( obj.Y(), s );
96 s << " , ";
97 toStream( obj.Z(), s );
98 s << " )";
99 return s;
100}
101std::ostream& Gaudi::Utils::toStream( const Gaudi::XYZVector& obj, std::ostream& s ) {
102 s << "( ";
103 toStream( obj.X(), s );
104 s << " , ";
105 toStream( obj.Y(), s );
106 s << " , ";
107 toStream( obj.Z(), s );
108 s << " )";
109
110 return s;
111}
112std::ostream& Gaudi::Utils::toStream( const Gaudi::LorentzVector& obj, std::ostream& s ) {
113
114 s << "( ";
115 toStream( obj.Px(), s, 12 );
116 s << " , ";
117 toStream( obj.Py(), s, 12 );
118 s << " , ";
119 toStream( obj.Pz(), s, 13 );
120 s << " , ";
121 toStream( obj.E(), s, 14 );
122 s << " )";
123
124 return s;
125}
std::ostream & toStream(const DataObjID &d, std::ostream &os)
Definition DataObjID.cpp:84
implementation of various functions for streaming.
Declaration of parsing functions for various ROOT::Math objects to allow their usage as properties fo...
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isFailure() const
Definition StatusCode.h:129
constexpr static const auto SUCCESS
Definition StatusCode.h:99
SkipperGrammar< IteratorT > Skipper
Definition Factory.h:24
StatusCode parse(GaudiUtils::HashMap< K, V > &result, std::string_view input)
Basic parser for the types of HashMap used in DODBasicMapper.
std::string_view::const_iterator IteratorT
Definition Factory.h:23
StatusCode parse_(ResultT &result, std::string_view input)
Definition Factory.h:26
constexpr double m
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
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
int N
Definition IOTest.py:112