The Gaudi Framework  master (37c0b60a)
Node.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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 #ifndef JOBOPTIONSVC_NODE_H_
12 #define JOBOPTIONSVC_NODE_H_
13 // ============================================================================
14 // Includes:
15 // ============================================================================
16 // STD & STL:
17 // ============================================================================
18 #include <iostream>
19 #include <string>
20 #include <vector>
21 // ============================================================================
22 // BOOST:
23 // ============================================================================
24 
25 #include <boost/fusion/include/adapt_struct.hpp>
26 #include <boost/fusion/include/unused.hpp>
27 #include <boost/range/iterator_range.hpp>
28 // ============================================================================
29 #include "Iterator.h"
30 #include "Position.h"
31 // ============================================================================
32 namespace Gaudi {
33  namespace Parsers {
34  // ============================================================================
35  struct Node final {
36  enum NodeType {
68  };
73 
74  Node() = default;
75  std::string name() const;
76  std::string ToString( int indent = 0 ) const;
77  };
78  // ============================================================================
79  struct NodeOperations final {
80  struct value {};
81  //---------------------------------------------------------------------------
82  void operator()( Node& node, Node::NodeType type ) const { node.type = type; }
83 
84  void operator()( Node& node, Node child ) const { node.children.push_back( std::move( child ) ); }
85 
86  void operator()( Node& node, std::string val ) const { node.value = std::move( val ); }
87 
88  void operator()( Node& node, boost::iterator_range<Iterator> range ) const {
89  node.value = boost::copy_range<std::string>( range );
90  }
91 
92  void operator()( Node& node, bool val ) const { node.value = val ? "1" : "0"; }
93 
94  void operator()( Node& node, const Iterator& iter ) const {
95  const IteratorPosition& pos = iter.get_position();
96  node.position = Position( pos.file, pos.line, pos.column );
97  }
98 
99  //---------------------------------------------------------------------------
100  };
101  // ============================================================================
102  } // namespace Parsers
103 } // namespace Gaudi
104 // ============================================================================
105 BOOST_FUSION_ADAPT_STRUCT( Gaudi::Parsers::Node,
107  type )( std::string, value )( std::vector<Gaudi::Parsers::Node>, children ) )
108 // ============================================================================
109 #endif // JOBOPTIONSVC_NODE_H_
Gaudi::Parsers::Node::value
std::string value
Definition: Node.h:70
Gaudi::Parsers::Node::kOperation
@ kOperation
Definition: Node.h:41
Gaudi::Parsers::Node::kPrintOptions
@ kPrintOptions
Definition: Node.h:60
Gaudi::Parsers::Node::children
std::vector< Node > children
Definition: Node.h:71
Gaudi::Parsers::Node::kBool
@ kBool
Definition: Node.h:53
std::string
STL class.
std::move
T move(T... args)
Gaudi::Parsers::Node::kEqual
@ kEqual
Definition: Node.h:44
Gaudi::Parsers::Node::NodeType
NodeType
Definition: Node.h:36
Gaudi::Parsers::Node::kInclude
@ kInclude
Definition: Node.h:38
Gaudi::Parsers::Node::kIdentifier
@ kIdentifier
Definition: Node.h:39
Gaudi::Parsers::Node::kMinusEqual
@ kMinusEqual
Definition: Node.h:46
Gaudi::Parsers::Node::kCondition
@ kCondition
Definition: Node.h:56
std::vector
STL class.
Gaudi::Parsers::NodeOperations::operator()
void operator()(Node &node, boost::iterator_range< Iterator > range) const
Definition: Node.h:88
IteratorPosition
boost::spirit::classic::file_position_base< std::string > IteratorPosition
Definition: Iterator.h:29
Gaudi::Parsers::Node::kAssign
@ kAssign
Definition: Node.h:43
Gaudi::Parsers::Node
Definition: Node.h:35
Gaudi::Parsers::Node::kPropertyRef
@ kPropertyRef
Definition: Node.h:66
Gaudi::Parsers::Node::kSimple
@ kSimple
Definition: Node.h:50
Gaudi::Parsers::NodeOperations::operator()
void operator()(Node &node, bool val) const
Definition: Node.h:92
Gaudi::Parsers::Node::kProperty
@ kProperty
Definition: Node.h:40
Gaudi::Parsers::Node::kPrintOn
@ kPrintOn
Definition: Node.h:61
Gaudi::Parsers::NodeOperations::operator()
void operator()(Node &node, Node child) const
Definition: Node.h:84
Gaudi::Parsers::Node::kIfdef
@ kIfdef
Definition: Node.h:57
Gaudi::Parsers::Node::kString
@ kString
Definition: Node.h:51
Gaudi::Parsers::Node::name
std::string name() const
Definition: Node.cpp:57
Gaudi::Parsers::Node::kShell
@ kShell
Definition: Node.h:63
Gaudi::range
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range from arbitrary container
Definition: NamedRange.h:128
Gaudi::Parsers::Node::kPlusEqual
@ kPlusEqual
Definition: Node.h:45
Gaudi::Parsers::Node::ToString
std::string ToString(int indent=0) const
Definition: Node.cpp:63
Gaudi::Parsers::Position
Definition: Position.h:23
Gaudi::Parsers::Node::kValue
@ kValue
Definition: Node.h:42
Gaudi::Parsers::Node::type
NodeType type
Definition: Node.h:69
Gaudi::Parsers::Node::kUnit
@ kUnit
Definition: Node.h:55
Gaudi::Parsers::NodeOperations
Definition: Node.h:79
Gaudi::Parsers::Node::position
Position position
Definition: Node.h:72
Iterator.h
Gaudi::Parsers::NodeOperations::operator()
void operator()(Node &node, Node::NodeType type) const
Definition: Node.h:82
Gaudi::Parsers::Node::kDumpFile
@ kDumpFile
Definition: Node.h:65
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Gaudi::Parsers::Node::kVector
@ kVector
Definition: Node.h:47
Gaudi::Parsers::Node::kRoot
@ kRoot
Definition: Node.h:37
Gaudi::Parsers::Node::kElse
@ kElse
Definition: Node.h:59
Gaudi::Parsers::Node::kUnits
@ kUnits
Definition: Node.h:54
Gaudi::Parsers::NodeOperations::value
Definition: Node.h:80
Position.h
Gaudi::Parsers::NodeOperations::operator()
void operator()(Node &node, std::string val) const
Definition: Node.h:86
Gaudi::Parsers::Node::kPrintTree
@ kPrintTree
Definition: Node.h:64
gaudirun.type
type
Definition: gaudirun.py:160
Gaudi::Parsers::Node::number_of_node_types
@ number_of_node_types
Definition: Node.h:67
Gaudi::Parsers::Node::kPair
@ kPair
Definition: Node.h:49
Gaudi::Parsers::Node::kIfndef
@ kIfndef
Definition: Node.h:58
Gaudi::Parsers::Node::kMap
@ kMap
Definition: Node.h:48
Gaudi::Parsers::Node::kReal
@ kReal
Definition: Node.h:52
Gaudi::Parsers::NodeOperations::operator()
void operator()(Node &node, const Iterator &iter) const
Definition: Node.h:94
Gaudi::Parsers::Node::Node
Node()=default
Iterator
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:28
Gaudi::Parsers::Node::kPrintOff
@ kPrintOff
Definition: Node.h:62