The Gaudi Framework  v33r1 (b1225454)
Node.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef JOBOPTIONSVC_NODE_H_
12 #define JOBOPTIONSVC_NODE_H_
13 // ============================================================================
14 // Includes:
15 // ============================================================================
16 // STD & STL:
17 // ============================================================================
18 #include <iostream>
19 #include <string>
20 #include <vector>
21 // ============================================================================
22 // BOOST:
23 // ============================================================================
24 
25 #include <boost/fusion/include/adapt_struct.hpp>
26 #include <boost/fusion/include/unused.hpp>
27 #include <boost/range/iterator_range.hpp>
28 // ============================================================================
29 #include "Iterator.h"
30 #include "Position.h"
31 // ============================================================================
32 namespace Gaudi {
33  namespace Parsers {
34  // ============================================================================
35  struct Node final {
36  enum NodeType {
68  };
73 
74  Node() = default;
75  std::string name() const;
76  std::string ToString( int indent = 0 ) const;
77  };
78  // ============================================================================
79  struct NodeOperations final {
80  struct value {};
81  //---------------------------------------------------------------------------
82  void operator()( Node& node, Node::NodeType type ) const { node.type = type; }
83 
84  void operator()( Node& node, Node child ) const { node.children.push_back( std::move( child ) ); }
85 
86  void operator()( Node& node, std::string val ) const { node.value = std::move( val ); }
87 
88  void operator()( Node& node, boost::iterator_range<Iterator> range ) const {
89  node.value = boost::copy_range<std::string>( range );
90  }
91 
92  void operator()( Node& node, bool val ) const { node.value = val ? "1" : "0"; }
93 
94  void operator()( Node& node, const Iterator& iter ) const {
95  const IteratorPosition& pos = iter.get_position();
96  node.position = Position( pos.file, pos.line, pos.column );
97  }
98 
99  //---------------------------------------------------------------------------
100  };
101  // ============================================================================
102  } // namespace Parsers
103 } // namespace Gaudi
104 // ============================================================================
105 BOOST_FUSION_ADAPT_STRUCT( Gaudi::Parsers::Node,
107  type )( std::string, value )( std::vector<Gaudi::Parsers::Node>, children ) )
108 // ============================================================================
109 #endif // JOBOPTIONSVC_NODE_H_
void operator()(Node &node, Node child) const
Definition: Node.h:84
void operator()(Node &node, Node::NodeType type) const
Definition: Node.h:82
void operator()(Node &node, bool val) const
Definition: Node.h:92
std::string ToString(int indent=0) const
Definition: Node.cpp:63
STL class.
std::vector< Node > children
Definition: Node.h:71
void operator()(Node &node, const Iterator &iter) const
Definition: Node.h:94
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range from arbitrary container
Definition: NamedRange.h:126
NodeType type
Definition: Node.h:69
std::string name() const
Definition: Node.cpp:57
T move(T... args)
Position position
Definition: Node.h:72
void operator()(Node &node, std::string val) const
Definition: Node.h:86
STL class.
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:28
boost::spirit::classic::file_position_base< std::string > IteratorPosition
Definition: Iterator.h:29
std::string value
Definition: Node.h:70
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
void operator()(Node &node, boost::iterator_range< Iterator > range) const
Definition: Node.h:88