| The Gaudi Framework v27r1

- 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 // ============================================================================
7 namespace gp = Gaudi::Parsers;
8 // ============================================================================
9
10 std::vector<std::string> init_names() {
11 std::vector<std::string> n(gp::Node::NodeType::number_of_node_types);
12 n[gp::Node::NodeType::kRoot] = "root";
13 n[gp::Node::NodeType::kInclude] = "include";
14 n[gp::Node::NodeType::kIdentifier] = "identifier";
15 n[gp::Node::NodeType::kProperty] = "property";
16 n[gp::Node::NodeType::kOperation] = "operation";
17 n[gp::Node::NodeType::kValue] = "value";
18 n[gp::Node::NodeType::kAssign] = "assign";
19 n[gp::Node::NodeType::kEqual] = "equal";
20 n[gp::Node::NodeType::kPlusEqual] = "plus_equal";
21 n[gp::Node::NodeType::kMinusEqual] = "minus_equal";
22 n[gp::Node::NodeType::kVector] = "vector";
23 n[gp::Node::NodeType::kMap] = "map";
24 n[gp::Node::NodeType::kPair] = "pair";
25 n[gp::Node::NodeType::kSimple] = "simple";
26 n[gp::Node::NodeType::kString] = "string";
27 n[gp::Node::NodeType::kReal] = "real";
28 n[gp::Node::NodeType::kBool] = "bool";
29 n[gp::Node::NodeType::kUnits] = "units";
30 n[gp::Node::NodeType::kUnit] = "unit";
31 n[gp::Node::NodeType::kCondition] = "condition";
32 n[gp::Node::NodeType::kIfdef] = "ifdef";
33 n[gp::Node::NodeType::kIfndef] = "ifndef";
34 n[gp::Node::NodeType::kElse] = "else";
35 n[gp::Node::NodeType::kPrintOptions] = "print_options";
36 n[gp::Node::NodeType::kPrintOn] = "print_on";
37 n[gp::Node::NodeType::kPrintOff] = "print_off";
38 n[gp::Node::NodeType::kShell] = "shell";
39 n[gp::Node::NodeType::kPrintTree] = "print_tree";
40 n[gp::Node::NodeType::kDumpFile] = "dump_file";
41 n[gp::Node::NodeType::kPropertyRef] = "property_ref";
42 return n;
43 }
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())
58 result += " value=\"" + value + "\"";
59 if (position.line() != 0)
60 result += " line=\"" + std::to_string(position.line()) + "\"";
61 if (position.column() != 0)
62 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),
67 result + ">\n" , [&](std::string s, const gp::Node& node) {
68 return s + node.ToString(indent+2);
69 }).append( ' ', indent ) + "</" + name() + ">\n";
70 }
71 return result;
72 }
73 // ============================================================================
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
init_names
std::vector< std::string > init_names()
Definition: Node.cpp:10
std::to_string
T to_string(T...args)
std::end
T end(T...args)
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
std::string
STL class.
gaudirun.type
string type
Definition: gaudirun.py:151
Node.h
dump_component_properties.value
list value
Definition: dump_component_properties.py:12
std::vector< std::string >
std::begin
T begin(T...args)
project_manifest.indent
def indent
Definition: project_manifest.py:11
Gaudi::Parsers
Definition: DODBasicMapper.cpp:7
gaudirun.s
string s
Definition: gaudirun.py:245
std::accumulate
T accumulate(T...args)