www.mooseframework.org
JsonInputFileFormatter.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 #include <sstream>
12 #include "nlohmann/json.h"
13 
20 {
21 public:
23 
28  std::string toString(const nlohmann::json & root);
29 
30 protected:
38  void addLine(const std::string & line, size_t max_line_len = 0, const std::string & comment = "");
39 
46  void addBlock(const std::string & name, const nlohmann::json & block, bool top = false);
47 
52  void addParameters(const nlohmann::json & params);
53 
59  void addTypes(const std::string & key, const nlohmann::json & block);
60 
61  const int _spaces;
62  int _level;
63  std::ostringstream _stream;
64 };
std::string name(const ElemQuality q)
void addBlock(const std::string &name, const nlohmann::json &block, bool top=false)
Adds a new block to the output.
void addTypes(const std::string &key, const nlohmann::json &block)
Add a dictionary of type blocks to the output.
This class produces produces a dump of the InputParameters that appears like the normal input file sy...
void addLine(const std::string &line, size_t max_line_len=0, const std::string &comment="")
Adds a line to the output.
std::string toString(const nlohmann::json &root)
Returns a string representation of the tree in input file format.
void addParameters(const nlohmann::json &params)
Add a comment to the block.