amath  1.6.2
Simple command line calculator
AbsoluteNode Class Reference

#include <operators.h>

Inheritance diagram for AbsoluteNode:
Collaboration diagram for AbsoluteNode:

Public Member Functions

 AbsoluteNode (ExpressionNode *expression)
 
 ~AbsoluteNode ()
 
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 ()
 
SyntaxNodeGetParent ()
 
void SetParent (SyntaxNode *node)
 
virtual ReductionType GetReductionType ()
 
virtual void ResetIterator ()
 

Protected Member Functions

char * GetNodeText ()
 

Private Attributes

ExpressionNodeexpression
 

Additional Inherited Members

- Protected Attributes inherited from ExpressionNode
Numberresult
 
- Protected Attributes inherited from SyntaxNode
CharBufferoutput
 
SyntaxNodeparent
 
SyntaxNodeiterator
 
bool leftBottom
 

Detailed Description

Definition at line 60 of file operators.h.

Constructor & Destructor Documentation

AbsoluteNode::AbsoluteNode ( ExpressionNode expression)

Definition at line 125 of file operators.cpp.

References expression, and ExpressionNode::ExpressionNode().

Referenced by Parser::ParseAtomic().

125  :
126  ExpressionNode(), expression(expression) { }
ExpressionNode * expression
Definition: operators.h:77

Here is the call graph for this function:

Here is the caller graph for this function:

AbsoluteNode::~AbsoluteNode ( )

Definition at line 128 of file operators.cpp.

References expression.

129 {
130  if (expression != NOMEM) {
131  delete expression;
132  }
133 }
#define NOMEM
Definition: platform.h:43
ExpressionNode * expression
Definition: operators.h:77

Member Function Documentation

void AbsoluteNode::Attach ( SyntaxNode node)
virtual

Implements SyntaxNode.

Definition at line 175 of file operators.cpp.

References expression, and SyntaxNode::SetParent().

176 {
177  if (expression == NOMEM) {
178  expression = (ExpressionNode*)node;
179  node->SetParent(this);
180  }
181 }
#define NOMEM
Definition: platform.h:43
void SetParent(SyntaxNode *node)
Definition: nodes.cpp:71
ExpressionNode * expression
Definition: operators.h:77
Base class for all nodes related to mathematical expressions.
Definition: nodes.h:88

Here is the call graph for this function:

void AbsoluteNode::Detach ( SyntaxNode node)
virtual

Implements SyntaxNode.

Definition at line 183 of file operators.cpp.

References expression.

184 {
185  if (expression == node) {
186  expression = NOMEM;
187  }
188 }
#define NOMEM
Definition: platform.h:43
ExpressionNode * expression
Definition: operators.h:77
Number * AbsoluteNode::Evaluate ( )
virtual

Implements ExpressionNode.

Definition at line 154 of file operators.cpp.

References Number::Absolute(), ExpressionNode::Evaluate(), expression, and ExpressionNode::result.

155 {
157  return result;
158 }
virtual Number * Absolute()=0
virtual Number * Evaluate()=0
Number * result
Definition: nodes.h:104
ExpressionNode * expression
Definition: operators.h:77

Here is the call graph for this function:

SyntaxNode * AbsoluteNode::GetNext ( )
virtual

Implements SyntaxNode.

Definition at line 165 of file operators.cpp.

References expression, and SyntaxNode::iterator.

166 {
167  if (iterator == NOMEM) {
169  return iterator;
170  }
171 
172  return NOMEM;
173 }
#define NOMEM
Definition: platform.h:43
ExpressionNode * expression
Definition: operators.h:77
SyntaxNode * iterator
Definition: nodes.h:76
char * AbsoluteNode::GetNodeText ( )
protectedvirtual

Implements ExpressionNode.

Definition at line 160 of file operators.cpp.

Referenced by GetText().

161 {
162  return (char*)"|";
163 }

Here is the caller graph for this function:

int AbsoluteNode::GetPrecedence ( )
virtual

Implements ExpressionNode.

Definition at line 149 of file operators.cpp.

150 {
151  return 8;
152 }
char * AbsoluteNode::GetText ( )
virtual

Implements ExpressionNode.

Definition at line 135 of file operators.cpp.

References CharBuffer::Append(), CharBuffer::Empty(), CharBuffer::EnsureSize(), expression, GetNodeText(), CharBuffer::GetString(), ExpressionNode::GetText(), SyntaxNode::output, and StrLen().

136 {
137  const char *expText = expression->GetText();
138  const char *nodeText = GetNodeText();
139 
140  output->Empty();
141  output->EnsureSize(StrLen(expText) + StrLen(nodeText) * 2 + 1);
142  output->Append(nodeText);
143  output->Append(expText);
144  output->Append(nodeText);
145 
146  return output->GetString();
147 }
void Empty()
Definition: charbuf.cpp:168
void Append(const char *source)
Definition: charbuf.cpp:211
char * GetNodeText()
Definition: operators.cpp:160
char * GetString()
Definition: charbuf.cpp:250
int StrLen(const char *string)
Get the length of a null terminated string.
Definition: strlen.c:31
virtual char * GetText()=0
CharBuffer * output
Definition: nodes.h:74
ExpressionNode * expression
Definition: operators.h:77
void EnsureSize(unsigned int size)
Ensure a memory block of speficied size is allocated.
Definition: charbuf.cpp:112

Here is the call graph for this function:

void AbsoluteNode::Replace ( SyntaxNode n,
SyntaxNode x 
)
virtual

Implements SyntaxNode.

Definition at line 190 of file operators.cpp.

References expression.

191 {
192  if (expression == n) {
193  delete expression;
195  }
196 }
ExpressionNode * expression
Definition: operators.h:77
Base class for all nodes related to mathematical expressions.
Definition: nodes.h:88

Member Data Documentation

ExpressionNode* AbsoluteNode::expression
private

Definition at line 77 of file operators.h.

Referenced by AbsoluteNode(), Attach(), Detach(), Evaluate(), GetNext(), GetText(), Replace(), and ~AbsoluteNode().


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