www.mooseframework.org
JsonSyntaxTree.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 "InputParameters.h"
13 #include "FileLineInfo.h"
14 #include "json/json.h"
15 #include <string>
16 #include <vector>
17 #include <utility>
18 
23 {
24 public:
25  JsonSyntaxTree(const std::string & search_string);
26  virtual ~JsonSyntaxTree() {}
27 
39  bool addParameters(const std::string & parent_path,
40  const std::string & path,
41  bool is_type,
42  const std::string & action,
43  bool is_action,
44  InputParameters * params,
45  const FileLineInfo & lineinfo,
46  const std::string & classname);
47 
55  void addActionTask(const std::string & path,
56  const std::string & action,
57  const std::string & task,
58  const FileLineInfo & lineinfo);
63  const moosecontrib::Json::Value & getRoot() const { return _root; }
64 
70  void addSyntaxType(const std::string & path, const std::string type);
71 
75  void addGlobal();
76 
77 protected:
78  std::string buildOptions(const std::iterator_traits<InputParameters::iterator>::value_type & p,
79  bool & out_of_range_allowed);
80 
81  std::string prettyCppType(const std::string & cpp_type);
82  std::string basicCppType(const std::string & cpp_type);
83  size_t
84  setParams(InputParameters * params, bool search_match, moosecontrib::Json::Value & all_params);
85 
86  std::string
87  buildOutputString(const std::iterator_traits<InputParameters::iterator>::value_type & p);
88  static std::vector<std::string> splitPath(const std::string & path);
89  moosecontrib::Json::Value &
90  getJson(const std::string & parent, const std::string & path, bool is_type);
91  moosecontrib::Json::Value & getJson(const std::string & path);
92  std::pair<std::string, std::string> getObjectLabel(const std::string & obj) const;
93  std::pair<std::string, std::string> getActionLabel(const std::string & action) const;
94 
95  moosecontrib::Json::Value _root;
96  std::string _search;
97 
100  std::map<std::string, std::pair<std::string, std::string>> _action_label_map;
101  std::map<std::string, std::pair<std::string, std::string>> _object_label_map;
103 };
104 
void addSyntaxType(const std::string &path, const std::string type)
Add an associated type to a block.
void addActionTask(const std::string &path, const std::string &action, const std::string &task, const FileLineInfo &lineinfo)
Add a task to the tree.
size_t setParams(InputParameters *params, bool search_match, moosecontrib::Json::Value &all_params)
static std::vector< std::string > splitPath(const std::string &path)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::string buildOptions(const std::iterator_traits< InputParameters::iterator >::value_type &p, bool &out_of_range_allowed)
std::string prettyCppType(const std::string &cpp_type)
Holds the syntax in a Json::Value tree.
std::string buildOutputString(const std::iterator_traits< InputParameters::iterator >::value_type &p)
JsonSyntaxTree(const std::string &search_string)
moosecontrib::Json::Value _root
bool addParameters(const std::string &parent_path, const std::string &path, bool is_type, const std::string &action, bool is_action, InputParameters *params, const FileLineInfo &lineinfo, const std::string &classname)
Add parameters to the tree.
const moosecontrib::Json::Value & getRoot() const
Get the root of the tree.
std::map< std::string, std::pair< std::string, std::string > > _action_label_map
std::string basicCppType(const std::string &cpp_type)
Holds file and line information.
Definition: FileLineInfo.h:18
virtual ~JsonSyntaxTree()
MatType type
std::pair< std::string, std::string > getActionLabel(const std::string &action) const
std::pair< std::string, std::string > getObjectLabel(const std::string &obj) const
std::string _search
void addGlobal()
Add the global section to the output.
std::map< std::string, std::pair< std::string, std::string > > _object_label_map
moosecontrib::Json::Value & getJson(const std::string &parent, const std::string &path, bool is_type)