www.mooseframework.org
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
SyntaxTree Class Referenceabstract

#include <SyntaxTree.h>

Inheritance diagram for SyntaxTree:
[legend]

Classes

class  TreeNode
 This class represents a single node in our tree. More...
 

Public Member Functions

 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
 
virtual std::string preamble () const
 This method is called once at the beginning of the tree traversal and can be used to build up header information. More...
 
virtual std::string postscript () const
 This method is called once at the end of the tree traversal and can be used to add any necessary trailing information to the final formatted string. More...
 
virtual std::string preTraverse (short) const
 This method is called once at each node in the syntax tree before traversing child nodes. More...
 
virtual std::string printBlockOpen (const std::string &name, short depth, const std::string &doc)=0
 This method is called at the beginning of each Node in the tree. More...
 
virtual std::string printBlockClose (const std::string &name, short depth) const =0
 This method is called at the end of of each Node in the tree. More...
 
virtual std::string printParams (const std::string &prefix, const std::string &fully_qualified_name, InputParameters &params, short depth, const std::string &search_string, bool &found)=0
 This function is called for each InputParameters object stored at a particular node. More...
 

Protected Member Functions

bool isLongNames () const
 

Protected Attributes

TreeNode_root
 
bool _use_long_names
 

Private Attributes

std::set< std::string > _params_printed
 

Detailed Description

Definition at line 22 of file SyntaxTree.h.

Constructor & Destructor Documentation

◆ SyntaxTree()

SyntaxTree::SyntaxTree ( bool  use_long_names = false)

Definition at line 19 of file SyntaxTree.C.

20  : SyntaxFormatterInterface(), _root(NULL), _use_long_names(use_long_names)
21 {
22 }
TreeNode * _root
Definition: SyntaxTree.h:75
bool _use_long_names
Definition: SyntaxTree.h:76

◆ ~SyntaxTree()

SyntaxTree::~SyntaxTree ( )
virtual

Definition at line 24 of file SyntaxTree.C.

24 { delete (_root); }
TreeNode * _root
Definition: SyntaxTree.h:75

Member Function Documentation

◆ haveSeenIt()

bool SyntaxTree::haveSeenIt ( const std::string &  prefix,
const std::string &  item 
) const

Definition at line 63 of file SyntaxTree.C.

Referenced by InputFileFormatter::printParams(), and YAMLFormatter::printParams().

64 {
65  return _params_printed.find(prefix + item) != _params_printed.end();
66 }
std::set< std::string > _params_printed
Definition: SyntaxTree.h:79

◆ insertNode()

void SyntaxTree::insertNode ( std::string  syntax,
const std::string &  action,
bool  is_action_params = true,
InputParameters params = NULL 
)

Definition at line 27 of file SyntaxTree.C.

Referenced by ActionWarehouse::printInputFile().

31 {
32  if (_root == NULL)
33  _root = new TreeNode("", *this);
34 
35  _root->insertNode(syntax, action, is_action_params, params);
36 }
void insertNode(std::string &syntax, const std::string &action, bool is_action_params=true, InputParameters *params=NULL)
Definition: SyntaxTree.C:92
TreeNode * _root
Definition: SyntaxTree.h:75

◆ isLongNames()

bool SyntaxTree::isLongNames ( ) const
protected

Definition at line 236 of file SyntaxTree.C.

237 {
238  return _use_long_names;
239 }
bool _use_long_names
Definition: SyntaxTree.h:76

◆ postscript()

virtual std::string SyntaxFormatterInterface::postscript ( ) const
inlinevirtualinherited

This method is called once at the end of the tree traversal and can be used to add any necessary trailing information to the final formatted string.

Returns
- The formatted postscript string

Reimplemented in YAMLFormatter.

Definition at line 46 of file SyntaxFormatterInterface.h.

Referenced by print().

46 { return std::string(); }

◆ preamble()

virtual std::string SyntaxFormatterInterface::preamble ( ) const
inlinevirtualinherited

This method is called once at the beginning of the tree traversal and can be used to build up header information.

Returns
- The formatted preamble string

Reimplemented in YAMLFormatter.

Definition at line 38 of file SyntaxFormatterInterface.h.

Referenced by print().

38 { return std::string(); }

◆ preTraverse()

virtual std::string SyntaxFormatterInterface::preTraverse ( short  ) const
inlinevirtualinherited

This method is called once at each node in the syntax tree before traversing child nodes.

Returns
- The formatted pre-node traversal string

Reimplemented in YAMLFormatter.

Definition at line 52 of file SyntaxFormatterInterface.h.

52 { return std::string(); }

◆ print()

std::string SyntaxTree::print ( const std::string &  search_string)

Definition at line 39 of file SyntaxTree.C.

Referenced by ActionWarehouse::printInputFile().

40 {
41  bool found = false;
42  std::string output;
43 
44  // Clear the list of "seen" parameters before printing the tree
45  _params_printed.clear();
46 
47  if (_root)
48  output = _root->print(-1, search_string, found);
49 
50  if (found)
51  return preamble() + output + postscript();
52  else
53  return "";
54 }
TreeNode * _root
Definition: SyntaxTree.h:75
std::set< std::string > _params_printed
Definition: SyntaxTree.h:79
virtual std::string preamble() const
This method is called once at the beginning of the tree traversal and can be used to build up header ...
std::string print(short depth, const std::string &search_string, bool &found)
Definition: SyntaxTree.C:136
virtual std::string postscript() const
This method is called once at the end of the tree traversal and can be used to add any necessary trai...

◆ printBlockClose()

virtual std::string SyntaxFormatterInterface::printBlockClose ( const std::string &  name,
short  depth 
) const
pure virtualinherited

This method is called at the end of of each Node in the tree.

It is typically used to provide formatting necessary when closing blocks.

Returns
- The formatted block close string

Implemented in YAMLFormatter, and InputFileFormatter.

◆ printBlockOpen()

virtual std::string SyntaxFormatterInterface::printBlockOpen ( const std::string &  name,
short  depth,
const std::string &  doc 
)
pure virtualinherited

This method is called at the beginning of each Node in the tree.

It is typically used to provide formatting necessary when opening new blocks.

Returns
- The formatted block open string

Implemented in YAMLFormatter, and InputFileFormatter.

◆ printParams()

virtual std::string SyntaxFormatterInterface::printParams ( const std::string &  prefix,
const std::string &  fully_qualified_name,
InputParameters params,
short  depth,
const std::string &  search_string,
bool &  found 
)
pure virtualinherited

This function is called for each InputParameters object stored at a particular node.

It is responsible for formatting the parameters for the current node.

Returns
- The formatted parameters string for a Node.

Implemented in YAMLFormatter, and InputFileFormatter.

◆ seenIt()

void SyntaxTree::seenIt ( const std::string &  prefix,
const std::string &  item 
)

Definition at line 57 of file SyntaxTree.C.

Referenced by InputFileFormatter::printParams(), and YAMLFormatter::printParams().

58 {
59  _params_printed.insert(prefix + item);
60 }
std::set< std::string > _params_printed
Definition: SyntaxTree.h:79

Member Data Documentation

◆ _params_printed

std::set<std::string> SyntaxTree::_params_printed
private

Definition at line 79 of file SyntaxTree.h.

Referenced by haveSeenIt(), print(), and seenIt().

◆ _root

TreeNode* SyntaxTree::_root
protected

Definition at line 75 of file SyntaxTree.h.

Referenced by insertNode(), print(), and ~SyntaxTree().

◆ _use_long_names

bool SyntaxTree::_use_long_names
protected

Definition at line 76 of file SyntaxTree.h.

Referenced by isLongNames().


The documentation for this class was generated from the following files: