23 #include "libmesh/vector_value.h" 34 for (
auto & entry : actmap)
35 for (
auto & act : entry.second)
39 for (
auto & entry : objmap)
40 for (
auto & obj : entry.second)
44 std::vector<std::string>
48 std::istringstream f(path);
49 std::vector<std::string> paths;
50 while (std::getline(f, s,
'/'))
60 mooseAssert(paths.size() > 0,
"path is empty");
61 auto * next = &(
_root[
"blocks"][paths[0]]);
63 for (
auto pit = paths.begin() + 1; pit != paths.end(); ++pit)
67 next = &(*next)[
"star"];
68 else if (*pit ==
"<type>")
69 next = &(*next)[
"types"];
71 next = &(*next)[
"subblocks"][*pit];
82 if (path.back() ==
'*' && !j.contains(
"subblock_types"))
83 j[
"subblock_types"] = nlohmann::json();
84 else if (path.back() !=
'*' && !j.contains(
"types"))
85 j[
"types"] = nlohmann::json();
89 auto & parent_json =
getJson(parent);
91 std::string key =
"subblock_types";
94 auto & val = parent_json[key][paths.back()];
102 for (
auto & iter : *params)
106 if (params->isPrivate(iter.first) || (!
_search.empty() && !search_match && !param_match))
110 nlohmann::json param_json;
112 param_json[
"required"] = params->isParamRequired(iter.first);
115 if (params->isParamValid(iter.first))
117 else if (params->hasDefaultCoupledValue(iter.first))
118 param_json[
"default"] = params->defaultCoupledValue(iter.first);
120 bool out_of_range_allowed =
false;
121 std::map<MooseEnumItem, std::string> docs;
122 param_json[
"options"] =
buildOptions(iter, out_of_range_allowed, docs);
123 if (!nlohmann::to_string(param_json[
"options"]).empty())
125 param_json[
"out_of_range_allowed"] = out_of_range_allowed;
128 nlohmann::json jdocs;
129 for (
const auto & doc : docs)
130 jdocs[doc.first.name()] = doc.second;
131 param_json[
"option_docs"] = jdocs;
134 auto reserved_values = params->reservedValues(iter.first);
135 for (
const auto & reserved : reserved_values)
136 param_json[
"reserved_values"].push_back(reserved);
139 param_json[
"cpp_type"] = t;
141 param_json[
"group_name"] = params->getGroupName(iter.first);
142 param_json[
"name"] = iter.first;
144 std::string doc = params->getDocString(iter.first);
146 param_json[
"description"] = doc;
148 param_json[
"doc_unit"] = params->getDocUnit(iter.first);
149 param_json[
"doc_range"] =
150 params->isRangeChecked(iter.first) ? params->rangeCheckedFunction(iter.first) :
"";
152 param_json[
"controllable"] = params->isControllable(iter.first);
153 param_json[
"deprecated"] = params->isParamDeprecated(iter.first);
154 all_params[iter.first] = param_json;
166 nlohmann::json jparams;
168 _root[
"global"][
"parameters"] = jparams;
173 for (
const auto & name_bi_pair : factory.registeredObjects())
174 apps.push_back(name_bi_pair.first);
176 _root[
"global"][
"registered_apps"] = apps;
182 const std::string & path,
184 const std::string & action,
188 const std::string & classname)
190 if (action ==
"EmptyAction")
193 nlohmann::json all_params;
197 auto count =
setParams(params, search_match, all_params);
198 if (!
_search.empty() && count == 0)
202 nlohmann::json & json =
getJson(parent, path, is_type);
206 json[action][
"parameters"] = all_params;
208 json[action][
"action_path"] = path;
210 json[action][
"label"] = label_pair.first;
211 json[action][
"register_file"] = label_pair.second;
213 json[action][
"file_info"][lineinfo.
file()] = lineinfo.
line();
218 json[
"moose_base"] = params->
getBase();
220 json[
"parameters"] = all_params;
221 json[
"syntax_path"] = path;
222 json[
"parent_syntax"] = parent;
226 if (params->
hasBase() && json[
"moose_base"] ==
"Action")
229 json[
"label"] = label_pair.first;
230 json[
"register_file"] = label_pair.second;
235 json[
"label"] = label_pair.first;
236 json[
"register_file"] = label_pair.second;
240 json[
"file_info"][lineinfo.
file()] = lineinfo.
line();
241 if (!classname.empty())
242 json[
"class"] = classname;
250 bool & out_of_range_allowed,
251 std::map<MooseEnumItem, std::string> & docs)
257 auto * enum_type =
dynamic_cast<InputParameters::Parameter<MooseEnum> *
>(val);
260 out_of_range_allowed = enum_type->get().isOutOfRangeAllowed();
261 options = enum_type->get().getRawNames();
262 docs = enum_type->get().getItemDocumentation();
266 auto * enum_type =
dynamic_cast<InputParameters::Parameter<MultiMooseEnum> *
>(val);
269 out_of_range_allowed = enum_type->get().isOutOfRangeAllowed();
270 options = enum_type->get().getRawNames();
271 docs = enum_type->get().getItemDocumentation();
275 auto * enum_type =
dynamic_cast<InputParameters::Parameter<ExecFlagEnum> *
>(val);
278 out_of_range_allowed = enum_type->get().isOutOfRangeAllowed();
279 options = enum_type->get().getRawNames();
280 docs = enum_type->get().getItemDocumentation();
284 auto * enum_type =
dynamic_cast<InputParameters::Parameter<std::vector<MooseEnum>
> *>(val);
287 out_of_range_allowed = (enum_type->get())[0].isOutOfRangeAllowed();
288 options = (enum_type->get())[0].getRawNames();
289 docs = enum_type->get()[0].getItemDocumentation();
293 auto * enum_type =
dynamic_cast<InputParameters::Parameter<std::vector<MultiMooseEnum>
> *>(val);
296 out_of_range_allowed = (enum_type->get())[0].isOutOfRangeAllowed();
297 options = (enum_type->get())[0].getRawNames();
298 docs = enum_type->get()[0].getItemDocumentation();
306 const std::iterator_traits<InputParameters::iterator>::value_type & p)
311 std::stringstream str;
312 InputParameters::Parameter<Point> * ptr0 =
dynamic_cast<InputParameters::Parameter<Point> *
>(val);
315 InputParameters::Parameter<RealVectorValue> * ptr1 =
316 dynamic_cast<InputParameters::Parameter<RealVectorValue> *
>(val);
320 str << ptr0->get().operator()(0) <<
" " << ptr0->get().operator()(1) <<
" " 321 << ptr0->get().operator()(2);
325 str << ptr1->get().operator()(0) <<
" " << ptr1->get().operator()(1) <<
" " 326 << ptr1->get().operator()(2);
333 std::string tmp_str = str.str();
334 for (
auto & ch : tmp_str)
338 return tmp_str.substr(0, tmp_str.find(
"<RESIDUAL>"));
347 j[
"associated_types"].push_back(type);
352 _root[
"global"][
"associated_types"][type].push_back(path);
358 const std::string & action,
359 const std::string & task_name,
362 nlohmann::json & json =
getJson(
"", path,
false);
364 json[action][
"tasks"][task_name][
"file_info"][lineinfo.
file()] = lineinfo.
line();
370 std::string s =
"String";
371 if (cpp_type.find(
"std::vector") != std::string::npos ||
372 cpp_type.find(
"libMesh::VectorValue") != std::string::npos ||
373 cpp_type.find(
"libMesh::TensorValue") != std::string::npos ||
374 cpp_type.find(
"Eigen::Matrix") != std::string::npos)
377 pcrecpp::RE r(
"^[^<]+<\\s*(.*)\\s*>$");
379 r.FullMatch(cpp_type, &t);
382 if (cpp_type.find(
"Eigen::Matrix") != std::string::npos)
383 t = t.substr(0, t.find(
","));
387 else if (cpp_type.find(
"std::map") != std::string::npos ||
388 cpp_type.find(
"std::unordered_map") != std::string::npos)
394 "^(?:std::)?(?:unordered_)?map\\s*<\\s*([^,>]+)\\s*,\\s*([^,>]+)(?:\\s*,.*)?\\s*>$");
398 r_map.FullMatch(cpp_type, &k, &v);
400 s =
"Map:" + k +
"->" + v;
402 else if (cpp_type.find(
"MultiMooseEnum") != std::string::npos ||
403 cpp_type.find(
"ExecFlagEnum") != std::string::npos ||
404 cpp_type.find(
"VectorPostprocessorName") != std::string::npos)
406 else if (cpp_type.find(
"libMesh::Point") != std::string::npos)
408 else if (cpp_type ==
"int" || cpp_type ==
"unsigned int" || cpp_type ==
"short" ||
409 cpp_type ==
"unsigned short" || cpp_type ==
"char" || cpp_type ==
"unsigned char" ||
410 cpp_type ==
"long" || cpp_type ==
"unsigned long" || cpp_type ==
"long long" ||
411 cpp_type ==
"unsigned long long")
413 else if (cpp_type ==
"double" || cpp_type ==
"float")
415 else if (cpp_type ==
"bool")
421 std::pair<std::string, std::string>
429 return std::make_pair(
"",
"");
432 std::pair<std::string, std::string>
439 return std::make_pair(
"",
"");
void addSyntaxType(const std::string &path, const std::string type)
Add an associated type to a block.
virtual void print(std::ostream &) const=0
std::string buildOptions(const std::iterator_traits< InputParameters::iterator >::value_type &p, bool &out_of_range_allowed, std::map< MooseEnumItem, std::string > &docs)
void addActionTask(const std::string &path, const std::string &action, const std::string &task, const FileLineInfo &lineinfo)
Add a task to the tree.
nlohmann::json & getJson(const std::string &parent, const std::string &path, bool is_type)
static const std::map< std::string, std::vector< std::shared_ptr< RegistryEntryBase > > > & allActions()
Returns a per-label keyed map of all Actions in the registry.
size_t setParams(InputParameters *params, bool search_match, nlohmann::json &all_params)
static std::vector< std::string > splitPath(const std::string &path)
static InputParameters validParams()
Parameters that are processed directly by the Parser and are valid anywhere in the input...
static const std::map< std::string, std::vector< std::shared_ptr< RegistryEntryBase > > > & allObjects()
Returns a per-label keyed map of all MooseObjects in the registry.
static std::string buildOutputString(const std::iterator_traits< InputParameters::iterator >::value_type &p)
JsonSyntaxTree(const std::string &search_string)
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.
std::map< std::string, std::pair< std::string, std::string > > _action_label_map
static std::string basicCppType(const std::string &cpp_type)
Utilities for making sense of c++ types.
Holds file and line information.
static AppFactory & instance()
Get the instance of the AppFactory.
std::pair< std::string, std::string > getActionLabel(const std::string &action) const
std::pair< std::string, std::string > getObjectLabel(const std::string &obj) const
bool wildCardMatch(std::string name, std::string search_string)
void addGlobal()
Add the global section to the output.
std::map< std::string, std::pair< std::string, std::string > > _object_label_map
void escape(std::string &str)
std::string prettyCppType(const std::string &cpp_type)