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 27 of file SyntaxTree.h.

Constructor & Destructor Documentation

SyntaxTree::SyntaxTree ( bool  use_long_names = false)

Definition at line 24 of file SyntaxTree.C.

25  : SyntaxFormatterInterface(), _root(NULL), _use_long_names(use_long_names)
26 {
27 }
TreeNode * _root
Definition: SyntaxTree.h:80
bool _use_long_names
Definition: SyntaxTree.h:81
SyntaxTree::~SyntaxTree ( )
virtual

Definition at line 29 of file SyntaxTree.C.

29 { delete (_root); }
TreeNode * _root
Definition: SyntaxTree.h:80

Member Function Documentation

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

Definition at line 68 of file SyntaxTree.C.

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

69 {
70  return _params_printed.find(prefix + item) != _params_printed.end();
71 }
std::set< std::string > _params_printed
Definition: SyntaxTree.h:84
void SyntaxTree::insertNode ( std::string  syntax,
const std::string &  action,
bool  is_action_params = true,
InputParameters params = NULL 
)

Definition at line 32 of file SyntaxTree.C.

Referenced by ActionWarehouse::printInputFile().

36 {
37  if (_root == NULL)
38  _root = new TreeNode("", *this);
39 
40  _root->insertNode(syntax, action, is_action_params, params);
41 }
void insertNode(std::string &syntax, const std::string &action, bool is_action_params=true, InputParameters *params=NULL)
Definition: SyntaxTree.C:97
TreeNode * _root
Definition: SyntaxTree.h:80
bool SyntaxTree::isLongNames ( ) const
protected

Definition at line 241 of file SyntaxTree.C.

Referenced by SyntaxTree::TreeNode::print().

242 {
243  return _use_long_names;
244 }
bool _use_long_names
Definition: SyntaxTree.h:81
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 51 of file SyntaxFormatterInterface.h.

Referenced by print().

51 { return std::string(); }
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 43 of file SyntaxFormatterInterface.h.

Referenced by print().

43 { return std::string(); }
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 57 of file SyntaxFormatterInterface.h.

Referenced by SyntaxTree::TreeNode::print().

57 { return std::string(); }
std::string SyntaxTree::print ( const std::string &  search_string)

Definition at line 44 of file SyntaxTree.C.

Referenced by ActionWarehouse::printInputFile().

45 {
46  bool found = false;
47  std::string output;
48 
49  // Clear the list of "seen" parameters before printing the tree
50  _params_printed.clear();
51 
52  if (_root)
53  output = _root->print(-1, search_string, found);
54 
55  if (found)
56  return preamble() + output + postscript();
57  else
58  return "";
59 }
TreeNode * _root
Definition: SyntaxTree.h:80
std::set< std::string > _params_printed
Definition: SyntaxTree.h:84
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 ...
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...
std::string print(short depth, const std::string &search_string, bool &found)
Definition: SyntaxTree.C:141
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.

Referenced by SyntaxFormatterInterface::preTraverse(), and SyntaxTree::TreeNode::print().

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.

Referenced by SyntaxFormatterInterface::preTraverse(), and SyntaxTree::TreeNode::print().

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.

Referenced by SyntaxFormatterInterface::preTraverse(), and SyntaxTree::TreeNode::print().

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

Definition at line 62 of file SyntaxTree.C.

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

63 {
64  _params_printed.insert(prefix + item);
65 }
std::set< std::string > _params_printed
Definition: SyntaxTree.h:84

Member Data Documentation

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

Definition at line 84 of file SyntaxTree.h.

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

TreeNode* SyntaxTree::_root
protected

Definition at line 80 of file SyntaxTree.h.

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

bool SyntaxTree::_use_long_names
protected

Definition at line 81 of file SyntaxTree.h.

Referenced by isLongNames().


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