| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 {
24 namespace Parsers
25 {
26 // ============================================================================
27 class Node final
28 {
29 public:
30 enum NodeType {
31 kRoot,
32 kInclude,
33 kIdentifier,
34 kProperty,
35 kOperation,
36 kValue,
37 kAssign,
38 kEqual,
39 kPlusEqual,
40 kMinusEqual,
41 kVector,
42 kMap,
43 kPair,
44 kSimple,
45 kString,
46 kReal,
47 kBool,
48 kUnits,
49 kUnit,
50 kCondition,
51 kIfdef,
52 kIfndef,
53 kElse,
54 kPrintOptions,
55 kPrintOn,
56 kPrintOff,
57 kShell,
58 kPrintTree,
59 kDumpFile,
60 kPropertyRef,
61 number_of_node_types
62 };
63 NodeType type = kRoot;
64 std::string value;
65 std::vector<Node> children;
66 Position position;
67
68 Node() = default;
69 std::string name() const;
70 std::string ToString( int indent = 0 ) const;
71 };
72 // ============================================================================
73 class NodeOperations final
74 {
75 public:
76 struct value {
77 };
78 template <typename A, typename B = boost::fusion::unused_type, typename C = boost::fusion::unused_type,
79 typename D = boost::fusion::unused_type>
80 struct result {
81 typedef void type;
82 };
83 //---------------------------------------------------------------------------
84 void operator()( Node& node, Node::NodeType type ) const { node.type = type; }
85
86 void operator()( Node& node, Node child ) const { node.children.push_back( std::move( child ) ); }
87
88 void operator()( Node& node, std::string val ) const { node.value = std::move( val ); }
89
90 void operator()( Node& node, boost::iterator_range<Iterator> range ) const
91 {
92 node.value = boost::copy_range<std::string>( range );
93 }
94
95 void operator()( Node& node, bool val ) const { node.value = val ? "1" : "0"; }
96
97 void operator()( Node& node, const Iterator& iter ) const
98 {
99 const IteratorPosition& pos = iter.get_position();
100 node.position = Position( pos.file, pos.line, pos.column );
101 }
102
103 //---------------------------------------------------------------------------
104 };
105 // ============================================================================
106 } /* Gaudi */
107 } /* Parsers */
108 // ============================================================================
109 BOOST_FUSION_ADAPT_STRUCT( Gaudi::Parsers::Node,
110 ( Gaudi::Parsers::Node::NodeType,
111 type )( std::string, value )( std::vector<Gaudi::Parsers::Node>, children ) )
112 // ============================================================================
113 #endif // JOBOPTIONSVC_NODE_H_
Gaudi::Parsers::Node::kString
Definition: Node.h:45
Gaudi::Parsers::Node::kRoot
Definition: Node.h:31
Gaudi::Parsers::Node::kMap
Definition: Node.h:42
Gaudi::Parsers::NodeOperations::operator()
void operator()(Node &node, Node::NodeType type) const
Definition: Node.h:84
Gaudi::Parsers::NodeOperations::operator()
void operator()(Node &node, Node child) const
Definition: Node.h:86
Gaudi::Parsers::Node::kPlusEqual
Definition: Node.h:39
Gaudi::Parsers::NodeOperations::operator()
void operator()(Node &node, bool val) const
Definition: Node.h:95
Gaudi::Parsers::Node::name
std::string name() const
Definition: Node.cpp:48
Gaudi::Parsers::NodeOperations::result
Definition: Node.h:80
Gaudi::Parsers::Node::kShell
Definition: Node.h:57
Gaudi::Parsers::Node::kPair
Definition: Node.h:43
Gaudi::Parsers::Node::kOperation
Definition: Node.h:35
Gaudi::Parsers::Node::kUnit
Definition: Node.h:49
Gaudi::Parsers::Node::kValue
Definition: Node.h:36
Gaudi::Parsers::Node::kIdentifier
Definition: Node.h:33
Gaudi::Parsers::Node::NodeType
NodeType
Definition: Node.h:30
Gaudi::Parsers::NodeOperations::value
Definition: Node.h:76
Gaudi::Parsers::Node::kIfdef
Definition: Node.h:51
Gaudi::Parsers::Node::kMinusEqual
Definition: Node.h:40
Gaudi::Parsers::Node::kElse
Definition: Node.h:53
Gaudi::Parsers::Node::kVector
Definition: Node.h:41
Gaudi::Parsers::Node::kEqual
Definition: Node.h:38
Gaudi::Parsers::Node::kPrintOff
Definition: Node.h:56
std::string
STL class.
Gaudi::Parsers::Node::kAssign
Definition: Node.h:37
Gaudi::Parsers::Node
Definition: Node.h:27
Gaudi::range
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range from arbitrary container
Definition: NamedRange.h:121
Gaudi::Parsers::Node::kCondition
Definition: Node.h:50
Gaudi::Parsers::Position
Definition: Position.h:15
std::move
T move(T...args)
Gaudi::Parsers::Node::kBool
Definition: Node.h:47
Iterator.h
Gaudi::Parsers::Node::ToString
std::string ToString(int indent=0) const
Definition: Node.cpp:55
std::vector
STL class.
Gaudi::Parsers::Node::kPrintOptions
Definition: Node.h:54
Gaudi::Parsers::Node::kSimple
Definition: Node.h:44
Iterator
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18
Position.h
Gaudi::Parsers::Node::Node
Node()=default
Gaudi::Parsers::Node::kPrintTree
Definition: Node.h:58
Gaudi::Parsers::NodeOperations
Definition: Node.h:73
Gaudi::Parsers::Node::kInclude
Definition: Node.h:32
Gaudi::Parsers::Node::kPrintOn
Definition: Node.h:55
Gaudi::Parsers::NodeOperations::operator()
void operator()(Node &node, const Iterator &iter) const
Definition: Node.h:97
Gaudi::Parsers::Node::kUnits
Definition: Node.h:48
Gaudi::Parsers::Node::value
std::string value
Definition: Node.h:64
Gaudi::Parsers::Node::kIfndef
Definition: Node.h:52
IteratorPosition
boost::spirit::classic::file_position_base< std::string > IteratorPosition
Definition: Iterator.h:19
Gaudi::Parsers::Node::number_of_node_types
Definition: Node.h:61
Gaudi::Parsers::Node::kDumpFile
Definition: Node.h:59
Gaudi::Parsers::Node::position
Position position
Definition: Node.h:66
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::Parsers::NodeOperations::operator()
void operator()(Node &node, std::string val) const
Definition: Node.h:88
Gaudi::Parsers::Node::kProperty
Definition: Node.h:34
Gaudi::Parsers::Node::type
NodeType type
Definition: Node.h:63
Gaudi::Parsers::Node::kPropertyRef
Definition: Node.h:60
Gaudi::Parsers::NodeOperations::result::type
void type
Definition: Node.h:81
Gaudi::Parsers::Node::children
std::vector< Node > children
Definition: Node.h:65
Gaudi::Parsers::Node::kReal
Definition: Node.h:46
Gaudi::Parsers::NodeOperations::operator()
void operator()(Node &node, boost::iterator_range< Iterator > range) const
Definition: Node.h:90