www.mooseframework.org
SyntaxTree.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 
13 
14 #include <string>
15 #include <map>
16 
17 // Forward declarations
18 class InputParameters;
19 class SyntaxTree;
20 
22 {
23 public:
24  SyntaxTree(bool use_long_names = false);
25  virtual ~SyntaxTree();
26 
27  void insertNode(std::string syntax,
28  const std::string & action,
29  bool is_action_params = true,
30  InputParameters * params = NULL);
31 
32  std::string print(const std::string & search_string);
33 
34  void seenIt(const std::string & prefix, const std::string & item);
35  bool haveSeenIt(const std::string & prefix, const std::string & item) const;
36 
37 protected:
41  class TreeNode
42  {
43  public:
44  TreeNode(const std::string & name,
45  SyntaxTree & syntax_tree,
46  const std::string * action = NULL,
47  InputParameters * params = NULL,
48  TreeNode * parent = NULL);
49  ~TreeNode();
50 
51  void insertNode(std::string & syntax,
52  const std::string & action,
53  bool is_action_params = true,
54  InputParameters * params = NULL);
55  std::string print(short depth, const std::string & search_string, bool & found);
56 
57  std::string getLongName(const std::string & delim = "/") const;
58 
59  protected:
60  void insertParams(const std::string & action,
61  bool is_action_params,
62  InputParameters * params = NULL);
63 
64  std::map<std::string, TreeNode *> _children;
65  std::multimap<std::string, InputParameters *> _action_params;
66  std::multimap<std::string, InputParameters *> _moose_object_params;
67  std::string _name;
70  };
71 
72  bool isLongNames() const;
73 
76 
77 private:
78  std::set<std::string> _params_printed;
79 };
80 
TreeNode * _parent
Definition: SyntaxTree.h:68
This interface is for classes that want to be called to format InputFileParameters.
void insertNode(std::string &syntax, const std::string &action, bool is_action_params=true, InputParameters *params=NULL)
Definition: SyntaxTree.C:92
std::string getLongName(const std::string &delim="/") const
Definition: SyntaxTree.C:227
std::map< std::string, TreeNode * > _children
Definition: SyntaxTree.h:64
void insertParams(const std::string &action, bool is_action_params, InputParameters *params=NULL)
Definition: SyntaxTree.C:125
TreeNode * _root
Definition: SyntaxTree.h:74
std::set< std::string > _params_printed
Definition: SyntaxTree.h:78
SyntaxTree(bool use_long_names=false)
Definition: SyntaxTree.C:19
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
TreeNode(const std::string &name, SyntaxTree &syntax_tree, const std::string *action=NULL, InputParameters *params=NULL, TreeNode *parent=NULL)
Definition: SyntaxTree.C:68
std::string _name
Definition: SyntaxTree.h:67
SyntaxTree & _syntax_tree
Definition: SyntaxTree.h:69
virtual ~SyntaxTree()
Definition: SyntaxTree.C:24
std::multimap< std::string, InputParameters * > _moose_object_params
Definition: SyntaxTree.h:66
std::multimap< std::string, InputParameters * > _action_params
Definition: SyntaxTree.h:65
bool _use_long_names
Definition: SyntaxTree.h:75
void insertNode(std::string syntax, const std::string &action, bool is_action_params=true, InputParameters *params=NULL)
Definition: SyntaxTree.C:27
std::string print(const std::string &search_string)
Definition: SyntaxTree.C:39
std::string print(short depth, const std::string &search_string, bool &found)
Definition: SyntaxTree.C:136
bool isLongNames() const
Definition: SyntaxTree.C:236
bool haveSeenIt(const std::string &prefix, const std::string &item) const
Definition: SyntaxTree.C:63
This class represents a single node in our tree.
Definition: SyntaxTree.h:41
void seenIt(const std::string &prefix, const std::string &item)
Definition: SyntaxTree.C:57