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 "json/json.h"
12 #include <map>
13 #include <string>
14 #include <vector>
15 
16 typedef moosecontrib::Json::Value JsonVal;
17 
24 {
25 
26 public:
28 
33  std::string toString(const JsonVal & root);
34 
35 protected:
40  void addLine(const std::string & line);
41 
50  void addBlock(const std::string & block_name,
51  const JsonVal & block,
52  bool is_typeblock = false,
53  const std::string & parent_name = "",
54  const JsonVal & parameters_in = JsonVal::null,
55  const JsonVal & subblocks_in = JsonVal::null);
56 
61  void addParameters(const JsonVal & params);
62 
63  const int _spaces;
64  int _level;
65  std::ostringstream _stream;
66  std::map<std::string, std::vector<std::string>> _assoc_types_map;
68 };
69 
void addParameters(const JsonVal &params)
adds all parameters from a given block
moosecontrib::Json::Value JsonVal
This class produces a dump of the InputFileParameters in the Standard Object Notation (SON) format fo...
std::string toString(const JsonVal &root)
returns a string representation of the tree in input file format
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
void addBlock(const std::string &block_name, const JsonVal &block, bool is_typeblock=false, const std::string &parent_name="", const JsonVal &parameters_in=JsonVal::null, const JsonVal &subblocks_in=JsonVal::null)
adds a new block to the output