amath  1.8.5
Simple command line calculator
OutputStatement Class Reference

Change numeral output system. More...

#include <output.h>

Inheritance diagram for OutputStatement:
Collaboration diagram for OutputStatement:

Public Member Functions

 OutputStatement ()
 Constructor used to show number of active digits. More...
 
 OutputStatement (unsigned int base)
 Constructor used to set number of active digits. More...
 
 ~OutputStatement ()
 
char * Execute ()
 
- Public Member Functions inherited from StatementNode
 StatementNode ()
 
 StatementNode (const char *text)
 
virtual ~StatementNode ()
 
NodeType GetNodeType ()
 
virtual SyntaxNodeGetNext ()
 
virtual char * GetTextCode ()
 
void Attach (SyntaxNode *node)
 
void Detach (SyntaxNode *node)
 
void Replace (SyntaxNode *n, SyntaxNode *x)
 
- 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 ()
 

Private Attributes

unsigned int base
 

Additional Inherited Members

- Protected Attributes inherited from StatementNode
char * statementText
 
- Protected Attributes inherited from SyntaxNode
CharBufferoutput
 
SyntaxNodeparent
 
SyntaxNodeiterator
 
bool leftBottom
 

Detailed Description

Change numeral output system.

Definition at line 39 of file output.h.

Constructor & Destructor Documentation

◆ OutputStatement() [1/2]

OutputStatement::OutputStatement ( )

Constructor used to show number of active digits.

Definition at line 38 of file output.cpp.

References base, and StatementNode::StatementNode().

Referenced by Parser::ParseNumeralStatement().

38  :
39  StatementNode(), base(0)
40 {
41 }
unsigned int base
Definition: output.h:48
StatementNode()
Definition: node.cpp:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OutputStatement() [2/2]

OutputStatement::OutputStatement ( unsigned int  base)
explicit

Constructor used to set number of active digits.

Definition at line 47 of file output.cpp.

References base, and StatementNode::StatementNode().

Referenced by Parser::ParseNumeralStatement().

47  :
49 {
50 }
unsigned int base
Definition: output.h:48
StatementNode()
Definition: node.cpp:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~OutputStatement()

OutputStatement::~OutputStatement ( )

Definition at line 52 of file output.cpp.

53 {
54 }

Member Function Documentation

◆ Execute()

char * OutputStatement::Execute ( )
virtual

Implements StatementNode.

Definition at line 56 of file output.cpp.

References CharBuffer::Append(), base, CharBuffer::Empty(), CharBuffer::EnsureSize(), NumeralSystem::GetDigits(), NumeralSystem::GetName(), CharBuffer::GetString(), Program::NewPositionalOutput(), Program::Output, SyntaxNode::output, and StrLen().

57 {
58  const char* text;
59 
60  if (base != 0)
61  {
62  int digits = Program->Output->GetDigits();
64  text = HELPOUTPSETT;
65  }
66  else
67  {
68  text = HELPOUTPSHOW;
69  }
70 
71  const char* desc = Program->Output->GetName();
72 
73  output->Empty();
74  output->EnsureSize(StrLen(text) + StrLen(desc) + StrLen(NEWLINE) + 1);
75  output->Append(text);
76  output->Append(desc);
78  return output->GetString();
79 }
#define NEWLINE
Definition: amath.h:222
Master control class.
Definition: program.h:55
void NewPositionalOutput(short unsigned int base, short unsigned int digits)
Definition: program.cpp:97
#define HELPOUTPSETT
Definition: text.h:88
void Empty()
Definition: charbuf.cpp:218
char * GetString() const
Definition: charbuf.cpp:306
void Append(const char *source)
Definition: charbuf.cpp:262
unsigned int base
Definition: output.h:48
#define HELPOUTPSHOW
Definition: text.h:86
virtual const char * GetName()=0
virtual unsigned int GetDigits()=0
int StrLen(const char *string)
Get the length of a null terminated string.
Definition: strlen.c:34
CharBuffer * output
Definition: nodes.h:85
void EnsureSize(unsigned int size)
Ensure a memory block of specified size is allocated.
Definition: charbuf.cpp:114
class NumeralSystem * Output
Definition: program.h:76
Here is the call graph for this function:

Member Data Documentation

◆ base

unsigned int OutputStatement::base
private

Definition at line 48 of file output.h.

Referenced by Execute(), and OutputStatement().


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