| The Gaudi Framework v28r2p1 (f1a77ff4)

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