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:
33  std::string value;
34  std::vector<Node> children;
36 
37  Node(): type(kRoot){}
38  std::string name() const;
39  std::string ToString() const;
40  std::string ToString(int indent) const;
41 };
42 // ============================================================================
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(
86  (std::string, value)
87  (std::vector<Gaudi::Parsers::Node>, children)
88 )
89 // ============================================================================
90 #endif // JOBOPTIONSVC_NODE_H_
void operator()(Node &node, Node::NodeType type) const
Definition: Node.h:53
void operator()(Node &node, bool val) const
Definition: Node.h:69
std::string name() const
Definition: Node.cpp:21
std::string ToString() const
Definition: Node.cpp:59
string type
Definition: gaudirun.py:126
void operator()(Node &node, Node &child) const
Definition: Node.h:57
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:19
void operator()(Node &node, const std::string &val) const
Definition: Node.h:61
void operator()(Node &node, const Iterator &iter) const
Definition: Node.h:73
This is a number of static methods for bootstrapping the Gaudi framework.
Definition: Bootstrap.h:14
NamedRange_< CONTAINER > range(const CONTAINER &cnt, const std::string &name)
simple function to create the named range form arbitrary container
Definition: NamedRange.h:133
std::string value
Definition: Node.h:33
boost::spirit::classic::file_position_base< std::string > IteratorPosition
Definition: Iterator.h:21
Position position
Definition: Node.h:35
NodeType type
Definition: Node.h:32
std::vector< Node > children
Definition: Node.h:34
void operator()(Node &node, boost::iterator_range< Iterator > range) const
Definition: Node.h:65