| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 // ============================================================================
48 std::string gp::Node::name() const {
49 static const auto names = init_names();
50 return names[type];
51 }
52
53 // ============================================================================
54 std::string gp::Node::ToString(int indent) const {
55
56 std::string result( indent, ' ');
57 result += "<" + name();
58 if (!value.empty())
59 result += " value=\"" + value + "\"";
60 if (position.line() != 0)
61 result += " line=\"" + std::to_string(position.line()) + "\"";
62 if (position.column() != 0)
63 result += " column=\"" + std::to_string(position.column()) + "\"";
64 if (children.empty()) {
65 result += "/>\n";
66 } else {
67 result = std::accumulate( std::begin(children), std::end(children),
68 result + ">\n" , [&](std::string s, const gp::Node& node) {
69 return s + node.ToString(indent+2);
70 }).append( ' ', indent ) + "</" + name() + ">\n";
71 }
72 return result;
73 }
74 // ============================================================================
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
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:217
gaudirun.type
type
Definition: gaudirun.py:125
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:245
std::accumulate
T accumulate(T...args)