amath  1.8.5
Simple command line calculator
ShowStatement Class Reference

#include <show.h>

Inheritance diagram for ShowStatement:
Collaboration diagram for ShowStatement:

Public Member Functions

 ShowStatement (const char *file)
 
 ~ShowStatement ()
 
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

char * file
 

Additional Inherited Members

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

Detailed Description

Definition at line 35 of file show.h.

Constructor & Destructor Documentation

◆ ShowStatement()

ShowStatement::ShowStatement ( const char *  file)
explicit

Definition at line 35 of file show.cpp.

References AllocAndCopy(), file, and StatementNode::StatementNode().

Referenced by Parser::ParseFileStatement().

36  : StatementNode()
37 {
38  AllocAndCopy(&this->file, file);
39 }
unsigned int AllocAndCopy(char **destination, const char *source)
Allocate memory and copy a string into the array.
Definition: alloccpy.c:40
StatementNode()
Definition: node.cpp:34
char * file
Definition: show.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~ShowStatement()

ShowStatement::~ShowStatement ( )

Definition at line 41 of file show.cpp.

References file.

42 {
43  delete [] file;
44 }
char * file
Definition: show.h:43

Member Function Documentation

◆ Execute()

char * ShowStatement::Execute ( )
virtual

Implements StatementNode.

Definition at line 46 of file show.cpp.

References file, Program::Filesystem, CharBuffer::GetString(), FilesystemBase::LoadTextFile(), and SyntaxNode::output.

47 {
49  if (text == nullptr)
50  {
51  return static_cast<char*>(MSGNOFILE);
52  }
53 
54  delete output;
55  output = text;
56  return text->GetString();
57 }
Master control class.
Definition: program.h:55
char * GetString() const
Definition: charbuf.cpp:306
class FilesystemBase * Filesystem
Definition: program.h:74
virtual CharBuffer * LoadTextFile(const char *name)=0
char * file
Definition: show.h:43
CharBuffer * output
Definition: nodes.h:85
#define MSGNOFILE
Definition: text.h:102
Encapsulate an character array which can be used as a string.
Definition: charbuf.h:44
Here is the call graph for this function:

Member Data Documentation

◆ file

char* ShowStatement::file
private

Definition at line 43 of file show.h.

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


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