amath  1.8.5
Simple command line calculator
InputStatement Class Reference

Change numeral input system. More...

#include <input.h>

Inheritance diagram for InputStatement:
Collaboration diagram for InputStatement:

Public Member Functions

 InputStatement ()
 Constructor used to show number of active digits. More...
 
 InputStatement (unsigned int base)
 Constructor used to set number of active digits. More...
 
 ~InputStatement ()
 
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 input system.

Definition at line 39 of file input.h.

Constructor & Destructor Documentation

◆ InputStatement() [1/2]

InputStatement::InputStatement ( )

Constructor used to show number of active digits.

Definition at line 38 of file input.cpp.

References base, and StatementNode::StatementNode().

Referenced by Parser::ParseNumeralStatement().

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

◆ InputStatement() [2/2]

InputStatement::InputStatement ( unsigned int  base)
explicit

Constructor used to set number of active digits.

Definition at line 47 of file input.cpp.

References base, and StatementNode::StatementNode().

Referenced by Parser::ParseNumeralStatement().

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

◆ ~InputStatement()

InputStatement::~InputStatement ( )

Definition at line 52 of file input.cpp.

53 {
54 }

Member Function Documentation

◆ Execute()

char * InputStatement::Execute ( )
virtual

Implements StatementNode.

Definition at line 56 of file input.cpp.

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

57 {
58  const char* text;
59 
60  if (base != 0)
61  {
62  int digits = Program->Input->GetDigits();
64  text = HELPINPUSETT;
65  }
66  else
67  {
68  text = HELPINPUSHOW;
69  }
70 
71  const char* desc = Program->Input->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 }
void NewPositionalInput(short unsigned int base, short unsigned int digits)
Definition: program.cpp:81
#define NEWLINE
Definition: amath.h:222
Master control class.
Definition: program.h:55
void Empty()
Definition: charbuf.cpp:218
char * GetString() const
Definition: charbuf.cpp:306
#define HELPINPUSHOW
Definition: text.h:85
void Append(const char *source)
Definition: charbuf.cpp:262
unsigned int base
Definition: input.h:48
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
#define HELPINPUSETT
Definition: text.h:87
class NumeralSystem * Input
Definition: program.h:75
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:

Member Data Documentation

◆ base

unsigned int InputStatement::base
private

Definition at line 48 of file input.h.

Referenced by Execute(), and InputStatement().


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