Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Node.cpp
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 #include "Node.h"
12 #include <numeric>
13 
14 namespace gp = Gaudi::Parsers;
15 
16 std::vector<std::string> init_names() {
17  std::vector<std::string> n( gp::Node::NodeType::number_of_node_types );
18  n[gp::Node::NodeType::kRoot] = "root";
19  n[gp::Node::NodeType::kInclude] = "include";
20  n[gp::Node::NodeType::kIdentifier] = "identifier";
21  n[gp::Node::NodeType::kProperty] = "property";
22  n[gp::Node::NodeType::kOperation] = "operation";
23  n[gp::Node::NodeType::kValue] = "value";
24  n[gp::Node::NodeType::kAssign] = "assign";
25  n[gp::Node::NodeType::kEqual] = "equal";
26  n[gp::Node::NodeType::kPlusEqual] = "plus_equal";
27  n[gp::Node::NodeType::kMinusEqual] = "minus_equal";
28  n[gp::Node::NodeType::kVector] = "vector";
29  n[gp::Node::NodeType::kMap] = "map";
30  n[gp::Node::NodeType::kPair] = "pair";
31  n[gp::Node::NodeType::kSimple] = "simple";
32  n[gp::Node::NodeType::kString] = "string";
33  n[gp::Node::NodeType::kReal] = "real";
34  n[gp::Node::NodeType::kBool] = "bool";
35  n[gp::Node::NodeType::kUnits] = "units";
36  n[gp::Node::NodeType::kUnit] = "unit";
37  n[gp::Node::NodeType::kCondition] = "condition";
38  n[gp::Node::NodeType::kIfdef] = "ifdef";
39  n[gp::Node::NodeType::kIfndef] = "ifndef";
40  n[gp::Node::NodeType::kElse] = "else";
41  n[gp::Node::NodeType::kPrintOptions] = "print_options";
42  n[gp::Node::NodeType::kPrintOn] = "print_on";
43  n[gp::Node::NodeType::kPrintOff] = "print_off";
44  n[gp::Node::NodeType::kShell] = "shell";
45  n[gp::Node::NodeType::kPrintTree] = "print_tree";
46  n[gp::Node::NodeType::kDumpFile] = "dump_file";
47  n[gp::Node::NodeType::kPropertyRef] = "property_ref";
48  return n;
49 }
50 
51 std::string gp::Node::name() const {
52  static const auto names = init_names();
53  return names[type];
54 }
55 
56 std::string gp::Node::ToString( int indent ) const {
57 
58  std::string result( indent, ' ' );
59  result += "<" + name();
60  if ( !value.empty() ) result += " value=\"" + value + "\"";
61  if ( position.line() != 0 ) result += " line=\"" + std::to_string( position.line() ) + "\"";
62  if ( position.column() != 0 ) result += " column=\"" + std::to_string( position.column() ) + "\"";
63  if ( children.empty() ) {
64  result += "/>\n";
65  } else {
66  result = std::accumulate( std::begin( children ), std::end( children ), result + ">\n",
67  [&]( std::string s, const gp::Node& node ) { return s + node.ToString( indent + 2 ); } )
68  .append( ' ', indent ) +
69  "</" + name() + ">\n";
70  }
71  return result;
72 }
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::Parsers::Node
Definition: Node.h:23
init_names
std::vector< std::string > init_names()
Definition: Node.cpp:16
Gaudi::Parsers::Node::name
std::string name() const
Definition: Node.cpp:51
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:135
Gaudi::Parsers::Node::ToString
std::string ToString(int indent=0) const
Definition: Node.cpp:56
Gaudi::Parsers::Node::type
NodeType type
Definition: Node.h:57
cpluginsvc.n
n
Definition: cpluginsvc.py:234
Node.h
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Gaudi::Parsers
Definition: DODBasicMapper.cpp:17
IOTest.end
end
Definition: IOTest.py:125
Gaudi::Accumulators::accumulate
void accumulate(Counter &counter, const Container &container, Fun f=Identity{})
A helper function for accumulating data from a container into a counter This is internally using buff...
Definition: Accumulators.h:1227