www.mooseframework.org
SONDefinitionFormatter.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef SONDEFINITIONFORMATTER_H
16 #define SONDEFINITIONFORMATTER_H
17 #include "json/json.h"
18 #include <map>
19 #include <string>
20 #include <vector>
21 
22 typedef moosecontrib::Json::Value JsonVal;
23 
30 {
31 
32 public:
34 
39  std::string toString(const JsonVal & root);
40 
41 protected:
46  void addLine(const std::string & line);
47 
56  void addBlock(const std::string & block_name,
57  const JsonVal & block,
58  bool is_typeblock = false,
59  const std::string & parent_name = "",
60  const JsonVal & parameters_in = JsonVal::null,
61  const JsonVal & subblocks_in = JsonVal::null);
62 
67  void addParameters(const JsonVal & params);
68 
69  const int _spaces;
70  int _level;
71  std::ostringstream _stream;
72  std::map<std::string, std::vector<std::string>> _assoc_types_map;
74 };
75 
76 #endif /* SONDEFINITIONFORMATTER_H */
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