The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
Node.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 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#pragma once
12
13#include "Iterator.h"
14#include "Position.h"
15#include <boost/fusion/include/adapt_struct.hpp>
16#include <boost/fusion/include/unused.hpp>
17#include <boost/range/iterator_range.hpp>
18#include <string>
19#include <vector>
20
21namespace Gaudi {
22 namespace Parsers {
66
67 struct NodeOperations final {
68 struct value {};
69
70 void operator()( Node& node, Node::NodeType type ) const { node.type = type; }
71
72 void operator()( Node& node, Node child ) const { node.children.push_back( std::move( child ) ); }
73
74 void operator()( Node& node, std::string val ) const { node.value = std::move( val ); }
75
76 void operator()( Node& node, boost::iterator_range<Iterator> range ) const {
77 node.value = boost::copy_range<std::string>( range );
78 }
79
80 void operator()( Node& node, bool val ) const { node.value = val ? "1" : "0"; }
81
82 void operator()( Node& node, const Iterator& iter ) const {
83 const IteratorPosition& pos = iter.get_position();
84 node.position = Position( pos.file, pos.line, pos.column );
85 }
86 };
87 } // namespace Parsers
88} // namespace Gaudi
89// cppcheck-suppress unknownMacro
90BOOST_FUSION_ADAPT_STRUCT( Gaudi::Parsers::Node,
92 type )( std::string, value )( std::vector<Gaudi::Parsers::Node>, children ) )
boost::spirit::classic::file_position_base< std::string > IteratorPosition
Definition Iterator.h:19
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition Iterator.h:18
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range from arbitrary container
Definition NamedRange.h:111
std::string value
Definition Node.h:58
Position position
Definition Node.h:60
std::vector< Node > children
Definition Node.h:59
NodeType type
Definition Node.h:57
std::string ToString(int indent=0) const
Definition Node.cpp:56
std::string name() const
Definition Node.cpp:51
void operator()(Node &node, Node::NodeType type) const
Definition Node.h:70
void operator()(Node &node, Node child) const
Definition Node.h:72
void operator()(Node &node, bool val) const
Definition Node.h:80
void operator()(Node &node, boost::iterator_range< Iterator > range) const
Definition Node.h:76
void operator()(Node &node, std::string val) const
Definition Node.h:74
void operator()(Node &node, const Iterator &iter) const
Definition Node.h:82