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 
12 #include "json/json.h"
13 
20 {
21 public:
23 
28  std::string toString(const moosecontrib::Json::Value & root);
29 
30 protected:
38  void addLine(const std::string & line, size_t max_line_len = 0, const std::string & comment = "");
39 
46  void
47  addBlock(const std::string & name, const moosecontrib::Json::Value & block, bool top = false);
48 
53  void addParameters(const moosecontrib::Json::Value & params);
54 
60  void addTypes(const std::string & key, const moosecontrib::Json::Value & block);
61 
62  const int _spaces;
63  int _level;
64  std::ostringstream _stream;
65 };
66 
std::string toString(const moosecontrib::Json::Value &root)
Returns a string representation of the tree in input file format.
This class produces produces a dump of the InputFileParameters that appears like the normal input fil...
void addLine(const std::string &line, size_t max_line_len=0, const std::string &comment="")
Adds a line to the output.
void addBlock(const std::string &name, const moosecontrib::Json::Value &block, bool top=false)
Adds a new block to the output.
void addParameters(const moosecontrib::Json::Value &params)
Add a comment to the block.
void addTypes(const std::string &key, const moosecontrib::Json::Value &block)
Add a dictionary of type blocks to the output.