amath  1.8.5
Simple command line calculator
HelpStatement Class Reference

Logic related to the help statement. More...

#include <help.h>

Inheritance diagram for HelpStatement:
Collaboration diagram for HelpStatement:

Public Member Functions

 HelpStatement ()
 
 HelpStatement (Symbol argument)
 
 HelpStatement (const char *ident)
 
 ~HelpStatement ()
 
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 Member Functions

char * StatementHelp () const
 

Private Attributes

Symbol argument
 
char * ident
 

Additional Inherited Members

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

Detailed Description

Logic related to the help statement.

Definition at line 39 of file help.h.

Constructor & Destructor Documentation

◆ HelpStatement() [1/3]

HelpStatement::HelpStatement ( )

Definition at line 37 of file help.cpp.

References argument, ident, and StatementNode::StatementNode().

Referenced by Parser::ParseHelpStatement().

37  :
39 {
40  argument = static_cast<Symbol>(0);
41  ident = nullptr;
42 }
char * ident
Definition: help.h:52
Symbol argument
Definition: help.h:51
StatementNode()
Definition: node.cpp:34
Symbol
Symbols generated by the Lexer.
Definition: symbol.h:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HelpStatement() [2/3]

HelpStatement::HelpStatement ( Symbol  argument)
explicit

Definition at line 44 of file help.cpp.

References argument, ident, and StatementNode::StatementNode().

Referenced by Parser::ParseHelpStatement().

44  :
46 {
47  ident = nullptr;
48 }
char * ident
Definition: help.h:52
Symbol argument
Definition: help.h:51
StatementNode()
Definition: node.cpp:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HelpStatement() [3/3]

HelpStatement::HelpStatement ( const char *  ident)
explicit

Definition at line 50 of file help.cpp.

References AllocAndCopy(), argument, ident, and symident.

Referenced by Parser::ParseHelpStatement().

51 {
53  AllocAndCopy(&this->ident, ident);
54 }
char * ident
Definition: help.h:52
unsigned int AllocAndCopy(char **destination, const char *source)
Allocate memory and copy a string into the array.
Definition: alloccpy.c:40
Symbol argument
Definition: help.h:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~HelpStatement()

HelpStatement::~HelpStatement ( )

Definition at line 56 of file help.cpp.

References ident.

57 {
58  if (ident != nullptr)
59  {
60  delete [] ident;
61  }
62 }
char * ident
Definition: help.h:52

Member Function Documentation

◆ Execute()

char * HelpStatement::Execute ( )
virtual

Implements StatementNode.

Definition at line 64 of file help.cpp.

References argument, CharBuffer::ClearAndCopy(), Language::GetHelpText(), CharBuffer::GetString(), ident, SyntaxNode::output, StatementHelp(), symident, and symstatement.

65 {
66  if (argument == symstatement)
67  {
68  return StatementHelp();
69  }
70  else if (argument == symident)
71  {
72  char* text = Program->Language->GetHelpText(ident);
73  output->ClearAndCopy(text);
74  return output->GetString();
75  }
76 
77  char* text = Program->Language->GetHelpText(argument);
78  output->ClearAndCopy(text);
79  return output->GetString();
80 }
Master control class.
Definition: program.h:55
char * ident
Definition: help.h:52
char * GetString() const
Definition: charbuf.cpp:306
class Language * Language
Definition: program.h:71
char * StatementHelp() const
Definition: help.cpp:87
Symbol argument
Definition: help.h:51
char * GetHelpText(char *ident)
Definition: language.cpp:154
CharBuffer * output
Definition: nodes.h:85
void ClearAndCopy(const char *source)
Release memory, allocate and copy source.
Definition: charbuf.cpp:81
Here is the call graph for this function:

◆ StatementHelp()

char * HelpStatement::StatementHelp ( ) const
private

Definition at line 87 of file help.cpp.

References CharBuffer::ClearBuffer(), CharBuffer::GetString(), and SyntaxNode::output.

Referenced by Execute().

88 {
89  char* text;
91 
94 #if defined(AMIGA) || defined(TERMIOS) || defined(WINDOWS)
96 #endif
106 #if defined(UNIX) || defined(HAIKU) || defined(AMIGA)
108 #endif
119 
120  return output->GetString();
121 }
#define STATEMENTINPUT
Definition: text.h:57
#define STATEMENTFUNCS
Definition: text.h:56
#define STATEMENTVERSION
Definition: text.h:65
char * GetString() const
Definition: charbuf.cpp:306
#define STATEMENTLICENSE
Definition: text.h:66
#define STATEMENTSAVE
Definition: text.h:63
#define STATEMENTDEF
Definition: text.h:51
#define STATEMENTVARS
Definition: text.h:64
#define STATEMENTABOUT
Definition: text.h:49
void ClearBuffer()
Release memory in buffer.
Definition: charbuf.cpp:65
#define STATEMENTLINE
Definition: text.h:48
#define STATEMENTMEMORY
Definition: text.h:67
#define STATEMENTDELETE
Definition: text.h:52
#define STATEMENTDIGITS
Definition: text.h:53
#define STATEMENTSHOW
Definition: text.h:61
#define STATEMENTOUTPUT
Definition: text.h:59
#define STATEMENTHELP
Definition: text.h:58
#define STATEMENTEXIT
Definition: text.h:68
#define STATEMENTLOAD
Definition: text.h:62
#define STATEMENTFOOTER
Definition: text.h:69
#define STATEMENTLIST
Definition: text.h:60
#define STATEMENTEXECUTE
Definition: text.h:55
#define APPENDHELP(x)
Definition: help.cpp:82
CharBuffer * output
Definition: nodes.h:85
#define STATEMENTCLEAR
Definition: text.h:50
#define STATEMENTEVAL
Definition: text.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ argument

Symbol HelpStatement::argument
private

Definition at line 51 of file help.h.

Referenced by Execute(), and HelpStatement().

◆ ident

char* HelpStatement::ident
private

Definition at line 52 of file help.h.

Referenced by Execute(), HelpStatement(), and ~HelpStatement().


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