https://mooseframework.inl.gov
YAMLFormatter.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "SyntaxTree.h"
13 #include "InputParameters.h"
14 
15 #include <sstream>
16 #include <iterator>
17 
22 class YAMLFormatter : public SyntaxTree
23 {
24 public:
25  YAMLFormatter(bool dump_mode);
26 
27  virtual std::string preamble() const override;
28  virtual std::string postscript() const override;
29 
30  virtual std::string preTraverse(short depth) const override;
31  virtual std::string
32  printBlockOpen(const std::string & name, short depth, const std::string & doc) override;
33  virtual std::string printBlockClose(const std::string & name, short depth) const override;
34  virtual std::string printParams(const std::string & prefix,
35  const std::string & fully_qualified_name,
36  InputParameters & params,
37  short depth,
38  const std::string & search_string,
39  bool & found) override;
40  template <typename T>
41  void addEnumOptionsAndDocs(std::ostringstream & oss, T & param, const std::string & indent);
42 
43 protected:
44  bool _dump_mode;
45 
51  void buildOutputString(std::ostringstream & output,
52  const std::iterator_traits<InputParameters::iterator>::value_type & p);
53 };
std::string name(const ElemQuality q)
std::string indent(unsigned int spaces)
Create empty string for indenting.
Definition: ConsoleUtils.C:41
virtual std::string postscript() const override
This method is called once at the end of the tree traversal and can be used to add any necessary trai...
Definition: YAMLFormatter.C:34
void buildOutputString(std::ostringstream &output, const std::iterator_traits< InputParameters::iterator >::value_type &p)
Method for building an output string that accounts for specific types (e.g., Point) ...
This class produces produces a yaml dump of the InputParameters that is machine parsable by any YAML ...
Definition: YAMLFormatter.h:22
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual std::string printBlockClose(const std::string &name, short depth) const override
This method is called at the end of of each Node in the tree.
void addEnumOptionsAndDocs(std::ostringstream &oss, T &param, const std::string &indent)
virtual std::string printBlockOpen(const std::string &name, short depth, const std::string &doc) override
This method is called at the beginning of each Node in the tree.
YAMLFormatter(bool dump_mode)
Definition: YAMLFormatter.C:24
virtual std::string preamble() const override
This method is called once at the beginning of the tree traversal and can be used to build up header ...
Definition: YAMLFormatter.C:27
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
This function is called for each InputParameters object stored at a particular node.
Definition: YAMLFormatter.C:40
virtual std::string preTraverse(short depth) const override
This method is called once at each node in the syntax tree before traversing child nodes...