The Gaudi Framework  master (69a68366)
Loading...
Searching...
No Matches
ParsersVct.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2026 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#include <format>
15
16namespace {
17 typedef std::map<std::string, double> MAP;
18
19 template <unsigned int N>
20 inline MAP::const_iterator find( const MAP& m, const std::string ( &keys )[N] ) {
21 for ( unsigned int i = 0; i < N; ++i ) {
22 auto found = m.find( keys[i] );
23 if ( m.end() != found ) { return found; }
24 }
25 return m.end();
26 }
27} // namespace
28namespace Gaudi {
29 namespace Parsers {
30 template <typename T1, typename T2>
31 inline StatusCode parse_( ROOT::Math::PositionVector3D<T1, T2>& result, std::string_view input ) {
32 Skipper skipper;
34 IteratorT iter = input.begin(), end = input.end();
35 if ( qi::phrase_parse( iter, end, g, skipper, result ) ) { return StatusCode::SUCCESS; }
36 //@attention always
38 }
39
40 StatusCode parse( Gaudi::XYZPoint& result, std::string_view input ) { return parse_( result, input ); }
41
42 /* parse 3D-vector
43 * @param result (output) the parsed vector
44 * @param input (input) the input string
45 * @return status code
46 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
47 * @date 2009-09-05
48 */
49 StatusCode parse( Gaudi::XYZVector& result, std::string_view input ) {
50
51 Gaudi::XYZPoint point;
52 StatusCode sc = parse( point, input );
53 if ( sc.isFailure() ) { return sc; }
54 result = point;
56 }
57
58 StatusCode parse( Gaudi::LorentzVector& result, std::string_view input ) { return parse_( result, input ); }
59
60 /* parse the vector of points
61 * @param resut (OUTPUT) the parser vector
62 * @param input (INPIUT) the string to be parsed
63 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
64 * @date 2009-09-05
65 */
66 StatusCode parse( std::vector<Gaudi::XYZPoint>& result, std::string_view input ) {
67 result.clear();
68 return parse_( result, input );
69 }
70 /* parse the vector of vectors
71 * @param resut (OUTPUT) the parser vector
72 * @param input (INPIUT) the string to be parsed
73 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
74 * @date 2009-09-05
75 */
76 StatusCode parse( std::vector<Gaudi::XYZVector>& result, std::string_view input ) {
77 result.clear();
78 return parse_( result, input );
79 }
80
81 /* parse the vector of vectors
82 * @param resut (OUTPUT) the parser vector
83 * @param input (INPIUT) the string to be parsed
84 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
85 * @date 2009-09-05
86 */
87 StatusCode parse( std::vector<Gaudi::LorentzVector>& result, std::string_view input ) {
88 return parse_( result, input );
89 }
90 } // namespace Parsers
91} // namespace Gaudi
92std::ostream& Gaudi::Utils::toStream( const Gaudi::XYZPoint& obj, std::ostream& s ) {
93 return s << std::format( "( {} , {} , {} )", obj.X(), obj.Y(), obj.Z() );
94}
95std::ostream& Gaudi::Utils::toStream( const Gaudi::XYZVector& obj, std::ostream& s ) {
96 return s << std::format( "( {} , {} , {} )", obj.X(), obj.Y(), obj.Z() );
97}
98std::ostream& Gaudi::Utils::toStream( const Gaudi::LorentzVector& obj, std::ostream& s ) {
99 return s << std::format( "( {} , {} , {} , {} )", obj.Px(), obj.Py(), obj.Pz(), obj.E() );
100}
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:20
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:19
StatusCode parse_(ResultT &result, std::string_view input)
Definition Factory.h:22
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:307
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