amath  1.8.5 Simple command line calculator
FactorialNode Class Reference

`#include <operators.h>`

Inheritance diagram for FactorialNode:
Collaboration diagram for FactorialNode:

## Public Member Functions

FactorialNode (ExpressionNode *expression)

~FactorialNode ()

char * GetText ()

NumberEvaluate ()

int GetPrecedence ()

SyntaxNodeGetNext ()

void Attach (SyntaxNode *node)

void Detach (SyntaxNode *node)

void Replace (SyntaxNode *n, SyntaxNode *x)

Public Member Functions inherited from ExpressionNode
ExpressionNode ()

ExpressionNode (Number *value)

virtual ~ExpressionNode ()

NodeType GetNodeType ()

virtual bool IsSilent ()

char * GetTextCode ()

char * Execute ()

Public Member Functions inherited from SyntaxNode
SyntaxNode ()

virtual ~SyntaxNode ()

void SetFirstNode ()

bool GetFirstNode () const

SyntaxNodeGetParent () const

void SetParent (SyntaxNode *node)

virtual ReductionType GetReductionType ()

virtual void ResetIterator ()

## Protected Member Functions

char * GetNodeText ()

## Private Attributes

ExpressionNodeexpression

Protected Attributes inherited from ExpressionNode
Numberresult

Protected Attributes inherited from SyntaxNode
CharBufferoutput

SyntaxNodeparent

SyntaxNodeiterator

bool leftBottom

## Detailed Description

Definition at line 85 of file operators.h.

## ◆ FactorialNode()

 FactorialNode::FactorialNode ( ExpressionNode * expression )

Definition at line 224 of file operators.cpp.

References expression, and ExpressionNode::ExpressionNode().

Referenced by Parser::ParseAtomic().

224  :
225  ExpressionNode(), expression(expression)
226 {
227 }
ExpressionNode()
Definition: nodes.cpp:89
ExpressionNode * expression
Definition: operators.h:103
Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ ~FactorialNode()

 FactorialNode::~FactorialNode ( )

Definition at line 229 of file operators.cpp.

References expression.

230 {
231  if (expression != nullptr)
232  {
233  delete expression;
234  }
235 }
ExpressionNode * expression
Definition: operators.h:103

## ◆ Attach()

 void FactorialNode::Attach ( SyntaxNode * node )
virtual

Implements SyntaxNode.

Definition at line 278 of file operators.cpp.

References expression, and SyntaxNode::SetParent().

279 {
280  if (expression == nullptr)
281  {
282  expression = static_cast<ExpressionNode*>(node);
283  node->SetParent(this);
284  }
285 }
ExpressionNode * expression
Definition: operators.h:103
void SetParent(SyntaxNode *node)
Definition: nodes.cpp:75
Base class for all nodes related to mathematical expressions.
Definition: nodes.h:99
Here is the call graph for this function:

## ◆ Detach()

 void FactorialNode::Detach ( SyntaxNode * node )
virtual

Implements SyntaxNode.

Definition at line 287 of file operators.cpp.

References expression.

288 {
289  if (expression == node)
290  {
291  expression = nullptr;
292  }
293 }
ExpressionNode * expression
Definition: operators.h:103

## ◆ Evaluate()

 Number * FactorialNode::Evaluate ( )
virtual

Implements ExpressionNode.

Definition at line 255 of file operators.cpp.

256 {
258  return result;
259 }
virtual Number * Factorial()=0
ExpressionNode * expression
Definition: operators.h:103
virtual Number * Evaluate()=0
Number * result
Definition: nodes.h:116
Here is the call graph for this function:

## ◆ GetNext()

 SyntaxNode * FactorialNode::GetNext ( )
virtual

Implements SyntaxNode.

Definition at line 267 of file operators.cpp.

References expression, and SyntaxNode::iterator.

268 {
269  if (iterator == nullptr)
270  {
272  return iterator;
273  }
274
275  return nullptr;
276 }
ExpressionNode * expression
Definition: operators.h:103
SyntaxNode * iterator
Definition: nodes.h:87

## ◆ GetNodeText()

 char * FactorialNode::GetNodeText ( )
protectedvirtual

Implements ExpressionNode.

Definition at line 261 of file operators.cpp.

Referenced by GetText().

262 {
263  static char* ret = (char*)"!";
264  return ret;
265 }
Here is the caller graph for this function:

## ◆ GetPrecedence()

 int FactorialNode::GetPrecedence ( )
virtual

Implements ExpressionNode.

Definition at line 250 of file operators.cpp.

251 {
252  return 9;
253 }

## ◆ GetText()

 char * FactorialNode::GetText ( )
virtual

Implements ExpressionNode.

Definition at line 237 of file operators.cpp.

238 {
239  const char* expText = expression->GetText();
240  const char* nodeText = GetNodeText();
241
242  output->Empty();
243  output->EnsureSize(StrLen(expText) + StrLen(nodeText) + 1);
244  output->Append(expText);
245  output->Append(nodeText);
246
247  return output->GetString();
248 }
void Empty()
Definition: charbuf.cpp:218
char * GetString() const
Definition: charbuf.cpp:306
ExpressionNode * expression
Definition: operators.h:103
void Append(const char *source)
Definition: charbuf.cpp:262
char * GetNodeText()
Definition: operators.cpp:261
int StrLen(const char *string)
Get the length of a null terminated string.
Definition: strlen.c:34
virtual char * GetText()=0
CharBuffer * output
Definition: nodes.h:85
void EnsureSize(unsigned int size)
Ensure a memory block of specified size is allocated.
Definition: charbuf.cpp:114
Here is the call graph for this function:

## ◆ Replace()

 void FactorialNode::Replace ( SyntaxNode * n, SyntaxNode * x )
virtual

Implements SyntaxNode.

Definition at line 295 of file operators.cpp.

References expression.

296 {
297  if (expression == n)
298  {
299  delete expression;
300  expression = static_cast<ExpressionNode*>(x);
301  }
302 }
ExpressionNode * expression
Definition: operators.h:103
Base class for all nodes related to mathematical expressions.
Definition: nodes.h:99

## ◆ expression

 ExpressionNode* FactorialNode::expression
private

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