9 #ifndef NaluParsingHelper_h 10 #define NaluParsingHelper_h 13 #include <yaml-cpp/yaml.h> 28 YAML::NodeType::value type = node.Type();
33 out = node.as<std::string>();
36 case YAML::NodeType::Sequence:
37 emout << YAML::BeginSeq;
38 for (
unsigned int i = 0; i < node.size(); ++i) {
42 emout << YAML::EndSeq;
44 case YAML::NodeType::Map:
45 emout << YAML::BeginMap ;
46 for (YAML::const_iterator i = node.begin(); i != node.end(); ++i) {
49 out = key.as<std::string>() ;
50 emout << YAML::Key << out;
54 emout << YAML::EndMap ;
56 case YAML::NodeType::Null:
60 std::cerr <<
"Warning: emit: unknown/unsupported node type" << std::endl;
69 sout << out.c_str() << std::endl;
73 std::ostringstream sout;
74 sout <<
"(pos,line,column) = (" 75 << node.Mark().pos <<
", " 76 << node.Mark().line <<
", " 77 << node.Mark().column <<
")" ;
83 std::ostringstream sout;
84 sout <<
"Node at " <<
line_info(node) <<
" => \n" ;
94 YAML::NodeType::value type = node.Type();
95 string indent((
size_t)depth*2,
' ');
100 out = node.as<std::string>();
101 sout << indent <<
"Scalar: " << out << endl;
103 case YAML::NodeType::Sequence:
104 sout << indent <<
"Sequence:" << endl;
105 for (
unsigned int i = 0; i < node.size(); ++i) {
107 sout << indent <<
"[" << i <<
"]:" << endl;
111 case YAML::NodeType::Map:
112 sout << indent <<
"Map:" << endl;
113 for (YAML::const_iterator i = node.begin(); i != node.end(); ++i) {
116 out = key.as<std::string>();
117 sout << indent <<
"Key: " << out << endl;
118 sout << indent <<
"Value:" << endl;
122 case YAML::NodeType::Null:
123 sout << indent <<
"(empty)" << endl;
126 cerr <<
"Warning: traverse: unknown/unsupported node type" << endl;
135 YAML::NodeType::value type = node.Type();
138 result.push_back(&node);
144 case YAML::NodeType::Sequence:
145 for (
unsigned int i = 0; i < node.size(); ++i) {
150 case YAML::NodeType::Map:
151 for (YAML::const_iterator i = node.begin(); i != node.end(); ++i) {
157 case YAML::NodeType::Null:
Definition: ABLForcingAlgorithm.C:26
double Scalar
Definition: LinearSolver.h:28
static std::string info(const YAML::Node &node)
Definition: NaluParsingHelper.h:82
static void find_nodes_given_key(const std::string &key, const YAML::Node &node, std::vector< const YAML::Node * > &result)
returns a vector of nodes that match the given key (depth first traversal)
Definition: NaluParsingHelper.h:132
static void emit(YAML::Emitter &emout, const YAML::Node &node)
Definition: NaluParsingHelper.h:26
static void emit(std::ostream &sout, const YAML::Node &node)
uses Emitter to print node to stream
Definition: NaluParsingHelper.h:66
Definition: NaluParsingHelper.h:23
static std::string line_info(const YAML::Node &node)
Definition: NaluParsingHelper.h:72
static void traverse(std::ostream &sout, const YAML::Node &node, unsigned int depth=0)
just prints nodes depth-first
Definition: NaluParsingHelper.h:90
Tpetra::Map< LocalOrdinal, GlobalOrdinal >::node_type Node
Definition: LinearSolver.h:32