https://mooseframework.inl.gov
Loading...
Searching...
No Matches
JsonSyntaxTree.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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 "nlohmann/json.h"
15#include <string>
16#include <vector>
17#include <utility>
18
23{
24public:
25 JsonSyntaxTree(const std::string & search_string);
26 virtual ~JsonSyntaxTree() {}
27
40 bool addParameters(const std::string & parent_path,
41 const std::string & path,
42 bool is_type,
43 const std::string & action,
44 bool is_action,
45 InputParameters * params,
46 const FileLineInfo & lineinfo,
47 const std::string & classname);
48
56 void addActionTask(const std::string & path,
57 const std::string & action,
58 const std::string & task,
59 const FileLineInfo & lineinfo);
64 const nlohmann::json & getRoot() const { return _root; }
65
71 void addSyntaxType(const std::string & path, const std::string type);
72
76 void addGlobal();
77
81 static std::string documentationCppType(const std::string & cpp_type);
82 static std::string basicCppType(const std::string & cpp_type);
83
84protected:
85 std::string buildOptions(const std::iterator_traits<InputParameters::iterator>::value_type & p,
86 bool & out_of_range_allowed,
87 std::map<MooseEnumItem, std::string> & docs);
88
89 size_t setParams(InputParameters * params, bool search_match, nlohmann::json & all_params);
90
91 static std::string
92 buildOutputString(const std::iterator_traits<InputParameters::iterator>::value_type & p);
93 static std::vector<std::string> splitPath(const std::string & path);
94 nlohmann::json & getJson(const std::string & parent, const std::string & path, bool is_type);
95 nlohmann::json & getJson(const std::string & path);
96 std::pair<std::string, std::string> getObjectLabel(const std::string & obj) const;
97 std::pair<std::string, std::string> getActionLabel(const std::string & action) const;
98
99 nlohmann::json _root;
100 std::string _search;
101
104 std::map<std::string, std::pair<std::string, std::string>> _action_label_map;
105 std::map<std::string, std::pair<std::string, std::string>> _object_label_map;
107
108 // Allow the MooseServer class to use protected static convenience methods
109 friend class MooseServer;
110};
Holds file and line information.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Holds the syntax in a Json::Value tree.
const nlohmann::json & getRoot() const
Get the root of the tree.
std::string _search
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.
void addSyntaxType(const std::string &path, const std::string type)
Add an associated type to a block.
static std::string documentationCppType(const std::string &cpp_type)
Utilities for making sense of c++ types.
void addActionTask(const std::string &path, const std::string &action, const std::string &task, const FileLineInfo &lineinfo)
Add a task to the tree.
static std::string basicCppType(const std::string &cpp_type)
nlohmann::json & getJson(const std::string &parent, const std::string &path, bool is_type)
std::pair< std::string, std::string > getObjectLabel(const std::string &obj) const
std::map< std::string, std::pair< std::string, std::string > > _action_label_map
nlohmann::json _root
std::pair< std::string, std::string > getActionLabel(const std::string &action) const
std::map< std::string, std::pair< std::string, std::string > > _object_label_map
static std::string buildOutputString(const std::iterator_traits< InputParameters::iterator >::value_type &p)
size_t setParams(InputParameters *params, bool search_match, nlohmann::json &all_params)
virtual ~JsonSyntaxTree()
void addGlobal()
Add the global section to the output.
static std::vector< std::string > splitPath(const std::string &path)
std::string buildOptions(const std::iterator_traits< InputParameters::iterator >::value_type &p, bool &out_of_range_allowed, std::map< MooseEnumItem, std::string > &docs)