Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
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 "Iterator.h"
20 #include "Position.h"
21 // ============================================================================
22 namespace Gaudi {
23  namespace Parsers {
24  // ============================================================================
25  struct Node final {
26  enum NodeType {
58  };
63 
64  Node() = default;
65  std::string name() const;
66  std::string ToString( int indent = 0 ) const;
67  };
68  // ============================================================================
69  struct NodeOperations final {
70  struct value {};
71  //---------------------------------------------------------------------------
72  void operator()( Node& node, Node::NodeType type ) const { node.type = type; }
73 
74  void operator()( Node& node, Node child ) const { node.children.push_back( std::move( child ) ); }
75 
76  void operator()( Node& node, std::string val ) const { node.value = std::move( val ); }
77 
78  void operator()( Node& node, boost::iterator_range<Iterator> range ) const {
79  node.value = boost::copy_range<std::string>( range );
80  }
81 
82  void operator()( Node& node, bool val ) const { node.value = val ? "1" : "0"; }
83 
84  void operator()( Node& node, const Iterator& iter ) const {
85  const IteratorPosition& pos = iter.get_position();
86  node.position = Position( pos.file, pos.line, pos.column );
87  }
88 
89  //---------------------------------------------------------------------------
90  };
91  // ============================================================================
92  } // namespace Parsers
93 } // namespace Gaudi
94 // ============================================================================
95 BOOST_FUSION_ADAPT_STRUCT( Gaudi::Parsers::Node,
98 // ============================================================================
99 #endif // JOBOPTIONSVC_NODE_H_
void operator()(Node &node, const Iterator &iter) const
Definition: Node.h:84
std::string name() const
Definition: Node.cpp:47
STL class.
std::string ToString(int indent=0) const
Definition: Node.cpp:53
void operator()(Node &node, Node::NodeType type) const
Definition: Node.h:72
std::vector< Node > children
Definition: Node.h:61
void operator()(Node &node, boost::iterator_range< Iterator > range) const
Definition: Node.h:78
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range from arbitrary container
Definition: NamedRange.h:118
NodeType type
Definition: Node.h:59
void operator()(Node &node, Node child) const
Definition: Node.h:74
void operator()(Node &node, std::string val) const
Definition: Node.h:76
T move(T...args)
Position position
Definition: Node.h:62
STL class.
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18
boost::spirit::classic::file_position_base< std::string > IteratorPosition
Definition: Iterator.h:19
std::string value
Definition: Node.h:60
Helper functions to set/get the application return code.
Definition: __init__.py:1
void operator()(Node &node, bool val) const
Definition: Node.h:82