forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
YAMLFormatter.h
51 lines (43 loc) · 1.74 KB
/
YAMLFormatter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#pragma once
#include "SyntaxTree.h"
#include "InputParameters.h"
#include <sstream>
#include <iterator>
/**
* This class produces produces a yaml dump of the InputParameters that is machine parsable by
* any YAML formatter.
*/
class YAMLFormatter : public SyntaxTree
{
public:
YAMLFormatter(bool dump_mode);
virtual std::string preamble() const override;
virtual std::string postscript() const override;
virtual std::string preTraverse(short depth) const override;
virtual std::string
printBlockOpen(const std::string & name, short depth, const std::string & doc) override;
virtual std::string printBlockClose(const std::string & name, short depth) const override;
virtual std::string printParams(const std::string & prefix,
const std::string & fully_qualified_name,
InputParameters & params,
short depth,
const std::string & search_string,
bool & found) override;
protected:
bool _dump_mode;
/**
* Method for building an output string that accounts for specific types (e.g., Point)
* @param output Reference to the output string
* @param iter InputParameters iterator that is being output
*/
void buildOutputString(std::ostringstream & output,
const std::iterator_traits<InputParameters::iterator>::value_type & p);
};