| The Gaudi Framework v32r1 (f65d50dc)

Node.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Includes:
3 // ============================================================================
4 #include "Node.h"
5 #include <algorithm>
6 #include <numeric>
7 // ============================================================================
8 namespace gp = Gaudi::Parsers;
9 // ============================================================================
10
11 std::vector<std::string> init_names() {
12 std::vector<std::string> n( gp::Node::NodeType::number_of_node_types );
13 n[gp::Node::NodeType::kRoot] = "root";
14 n[gp::Node::NodeType::kInclude] = "include";
15 n[gp::Node::NodeType::kIdentifier] = "identifier";
16 n[gp::Node::NodeType::kProperty] = "property";
17 n[gp::Node::NodeType::kOperation] = "operation";
18 n[gp::Node::NodeType::kValue] = "value";
19 n[gp::Node::NodeType::kAssign] = "assign";
20 n[gp::Node::NodeType::kEqual] = "equal";
21 n[gp::Node::NodeType::kPlusEqual] = "plus_equal";
22 n[gp::Node::NodeType::kMinusEqual] = "minus_equal";
23 n[gp::Node::NodeType::kVector] = "vector";
24 n[gp::Node::NodeType::kMap] = "map";
25 n[gp::Node::NodeType::kPair] = "pair";
26 n[gp::Node::NodeType::kSimple] = "simple";
27 n[gp::Node::NodeType::kString] = "string";
28 n[gp::Node::NodeType::kReal] = "real";
29 n[gp::Node::NodeType::kBool] = "bool";
30 n[gp::Node::NodeType::kUnits] = "units";
31 n[gp::Node::NodeType::kUnit] = "unit";
32 n[gp::Node::NodeType::kCondition] = "condition";
33 n[gp::Node::NodeType::kIfdef] = "ifdef";
34 n[gp::Node::NodeType::kIfndef] = "ifndef";
35 n[gp::Node::NodeType::kElse] = "else";
36 n[gp::Node::NodeType::kPrintOptions] = "print_options";
37 n[gp::Node::NodeType::kPrintOn] = "print_on";
38 n[gp::Node::NodeType::kPrintOff] = "print_off";
39 n[gp::Node::NodeType::kShell] = "shell";
40 n[gp::Node::NodeType::kPrintTree] = "print_tree";
41 n[gp::Node::NodeType::kDumpFile] = "dump_file";
42 n[gp::Node::NodeType::kPropertyRef] = "property_ref";
43 return n;
44 }
45
46 // ============================================================================
47 std::string gp::Node::name() const {
48 static const auto names = init_names();
49 return names[type];
50 }
51
52 // ============================================================================
53 std::string gp::Node::ToString( int indent ) const {
54
55 std::string result( indent, ' ' );
56 result += "<" + name();
57 if ( !value.empty() ) result += " value=\"" + value + "\"";
58 if ( position.line() != 0 ) result += " line=\"" + std::to_string( position.line() ) + "\"";
59 if ( position.column() != 0 ) result += " column=\"" + std::to_string( position.column() ) + "\"";
60 if ( children.empty() ) {
61 result += "/>\n";
62 } else {
63 result = std::accumulate( std::begin( children ), std::end( children ), result + ">\n",
64 [&]( std::string s, const gp::Node& node ) { return s + node.ToString( indent + 2 ); } )
65 .append( ' ', indent ) +
66 "</" + name() + ">\n";
67 }
68 return result;
69 }
70 // ============================================================================
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
init_names
std::vector< std::string > init_names()
Definition: Node.cpp:11
std::to_string
T to_string(T... args)
std::end
T end(T... args)
std::string
STL class.
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:210
gaudirun.type
type
Definition: gaudirun.py:142
Node.h
std::vector< std::string >
std::begin
T begin(T... args)
Gaudi::Parsers
Definition: DODBasicMapper.cpp:7
gaudirun.s
string s
Definition: gaudirun.py:316
std::accumulate
T accumulate(T... args)