forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SyntaxTree.h
80 lines (64 loc) · 2.2 KB
/
SyntaxTree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#pragma once
#include "SyntaxFormatterInterface.h"
#include <string>
#include <map>
#include <set>
// Forward declarations
class InputParameters;
class SyntaxTree;
class SyntaxTree : public SyntaxFormatterInterface
{
public:
SyntaxTree(bool use_long_names = false);
virtual ~SyntaxTree();
void insertNode(std::string syntax,
const std::string & action,
bool is_action_params = true,
InputParameters * params = NULL);
std::string print(const std::string & search_string);
void seenIt(const std::string & prefix, const std::string & item);
bool haveSeenIt(const std::string & prefix, const std::string & item) const;
protected:
/**
* This class represents a single node in our tree
*/
class TreeNode
{
public:
TreeNode(const std::string & name,
SyntaxTree & syntax_tree,
const std::string * action = NULL,
InputParameters * params = NULL,
TreeNode * parent = NULL);
~TreeNode();
void insertNode(std::string & syntax,
const std::string & action,
bool is_action_params = true,
InputParameters * params = NULL);
std::string print(short depth, const std::string & search_string, bool & found);
std::string getLongName(const std::string & delim = "/") const;
protected:
void insertParams(const std::string & action,
bool is_action_params,
InputParameters * params = NULL);
std::map<std::string, TreeNode *> _children;
std::multimap<std::string, InputParameters *> _action_params;
std::multimap<std::string, InputParameters *> _moose_object_params;
std::string _name;
TreeNode * _parent;
SyntaxTree & _syntax_tree;
};
bool isLongNames() const;
TreeNode * _root;
bool _use_long_names;
private:
std::set<std::string> _params_printed;
};