| The Gaudi Framework v32r1 (f65d50dc)

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