www.mooseframework.org
SONDefinitionFormatter.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 "nlohmann/json.h"
12 #include <map>
13 #include <string>
14 #include <vector>
15 #include <sstream>
16 
23 {
24 
25 public:
27 
32  std::string toString(const nlohmann::json & root);
33 
34 protected:
39  void addLine(const std::string & line);
40 
49  void addBlock(const std::string & block_name,
50  const nlohmann::json & block,
51  bool is_typeblock = false,
52  const std::string & parent_name = "",
53  const nlohmann::json & parameters_in = nlohmann::json(nullptr),
54  const nlohmann::json & subblocks_in = nlohmann::json(nullptr));
55 
60  void addParameters(const nlohmann::json & params);
61 
62  const int _spaces;
63  int _level;
64  std::ostringstream _stream;
65  std::map<std::string, std::vector<std::string>> _assoc_types_map;
66  nlohmann::json _global_params;
67 };
void addParameters(const nlohmann::json &params)
adds all parameters from a given block
This class produces a dump of the InputFileParameters in the Standard Object Notation (SON) format fo...
std::map< std::string, std::vector< std::string > > _assoc_types_map
void addLine(const std::string &line)
adds a line to the output with the proper indentation automatically
std::string toString(const nlohmann::json &root)
returns a string representation of the tree in input file format
void addBlock(const std::string &block_name, const nlohmann::json &block, bool is_typeblock=false, const std::string &parent_name="", const nlohmann::json &parameters_in=nlohmann::json(nullptr), const nlohmann::json &subblocks_in=nlohmann::json(nullptr))
adds a new block to the output