| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Node.h
Go to the documentation of this file.
1 // $Id:$
2 #ifndef JOBOPTIONSVC_NODE_H_
3 #define JOBOPTIONSVC_NODE_H_
4 // ============================================================================
5 // Includes:
6 // ============================================================================
7 // STD & STL:
8 // ============================================================================
9 #include <iostream>
10 #include <string>
11 #include <vector>
12 // ============================================================================
13 // BOOST:
14 // ============================================================================
15
16 #include <boost/fusion/include/adapt_struct.hpp>
17 #include <boost/fusion/include/unused.hpp>
18 #include <boost/range/iterator_range.hpp>
19 // ============================================================================
20 #include "Position.h"
21 #include "Iterator.h"
22 // ============================================================================
23 namespace Gaudi { namespace Parsers {
24 // ============================================================================
25 class Node {
26 public:
27 enum NodeType {kRoot,kInclude, kIdentifier, kProperty, kOperation,
28 kValue, kAssign, kEqual, kPlusEqual, kMinusEqual, kVector, kMap, kPair,
29 kSimple, kString, kReal, kBool, kUnits, kUnit, kCondition, kIfdef, kIfndef,
30 kElse, kPrintOptions, kPrintOn, kPrintOff, kShell, kPrintTree, kDumpFile,
31 kPropertyRef};
32 NodeType type;
33 std::string value;
34 std::vector<Node> children;
35 Position position;
36
37 Node(): type(kRoot){}
38 std::string name() const;
39 std::string ToString() const;
40 std::string ToString(int indent) const;
41 };
42 // ============================================================================
43 class NodeOperations {
44 public:
45 struct value {};
46 template<typename A, typename B = boost::fusion::unused_type,
47 typename C = boost::fusion::unused_type,
48 typename D = boost::fusion::unused_type>
49 struct result {
50 typedef void type;
51 };
52 //---------------------------------------------------------------------------
53 void operator()(Node& node, Node::NodeType type) const {
54 node.type = type;
55 }
56
57 void operator()(Node& node, Node& child) const {
58 node.children.push_back(child);
59 }
60
61 void operator()(Node& node, const std::string& val) const {
62 node.value = val;
63 }
64
65 void operator()(Node& node, boost::iterator_range<Iterator> range) const {
66 node.value = boost::copy_range<std::string>(range);
67 }
68
69 void operator()(Node& node, bool val) const {
70 node.value = val?"1":"0";
71 }
72
73 void operator()(Node& node, const Iterator& iter) const {
74 const IteratorPosition& pos = iter.get_position();
75 node.position = Position(pos.file, pos.line, pos.column);
76 }
77
78 //---------------------------------------------------------------------------
79 };
80 // ============================================================================
81 } /* Gaudi */ } /* Parsers */
82 // ============================================================================
83 BOOST_FUSION_ADAPT_STRUCT(
84 Gaudi::Parsers::Node,
85 (Gaudi::Parsers::Node::NodeType, type)
86 (std::string, value)
87 (std::vector<Gaudi::Parsers::Node>, children)
88 )
89 // ============================================================================
90 #endif // JOBOPTIONSVC_NODE_H_