All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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:
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(
86 )
87 // ============================================================================
88 #endif // JOBOPTIONSVC_NODE_H_
void operator()(Node &node, Node::NodeType type) const
Definition: Node.h:51
void operator()(Node &node, Node child) const
Definition: Node.h:55
void operator()(Node &node, bool val) const
Definition: Node.h:67
std::string name() const
Definition: Node.cpp:48
STL class.
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range from arbitrary container
Definition: NamedRange.h:129
T move(T...args)
std::string ToString(int indent=0) const
Definition: Node.cpp:54
STL class.
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18
void operator()(Node &node, const Iterator &iter) const
Definition: Node.h:71
std::string value
Definition: Node.h:32
boost::spirit::classic::file_position_base< std::string > IteratorPosition
Definition: Iterator.h:20
Position position
Definition: Node.h:34
Helper functions to set/get the application return code.
Definition: __init__.py:1
void operator()(Node &node, std::string val) const
Definition: Node.h:59
NodeType type
Definition: Node.h:31
std::vector< Node > children
Definition: Node.h:33
void operator()(Node &node, boost::iterator_range< Iterator > range) const
Definition: Node.h:63