amath  1.8.5
Simple command line calculator
MemoryStatement Class Reference

Show memory usage. More...

#include <memory.h>

Inheritance diagram for MemoryStatement:
Collaboration diagram for MemoryStatement:

Public Member Functions

 MemoryStatement ()
 
 ~MemoryStatement ()
 
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 ()
 

Additional Inherited Members

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

Detailed Description

Show memory usage.

Definition at line 39 of file memory.h.

Constructor & Destructor Documentation

◆ MemoryStatement()

MemoryStatement::MemoryStatement ( )

Definition at line 37 of file memory.cpp.

References StatementNode::StatementNode().

Referenced by Parser::ParseStatement().

38  : StatementNode()
39 {
40 }
StatementNode()
Definition: node.cpp:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~MemoryStatement()

MemoryStatement::~MemoryStatement ( )

Definition at line 42 of file memory.cpp.

43 {
44 }

Member Function Documentation

◆ Execute()

char * MemoryStatement::Execute ( )
virtual

Implements StatementNode.

Definition at line 46 of file memory.cpp.

References CharBuffer::Append(), DecimalSystem::DecimalSystem(), CharBuffer::Empty(), CharBuffer::EnsureSize(), CharBuffer::GetString(), NumeralSystem::GetText(), MemUsage(), SyntaxNode::output, RealNumber::RealNumber(), and StrLen().

47 {
48  long blocks, size, peak;
49  MemUsage(&blocks, &size, &peak);
50  Number* a = new RealNumber(static_cast<int>(blocks));
51  Number* b = new RealNumber(static_cast<int>(size));
52  Number* c = new RealNumber(static_cast<int>(peak));
53 
54  NumeralSystem* ns = new DecimalSystem(8);
55  output->Empty();
57  StrLen(TXTMEMBLOCKS) + 8 +
58  StrLen(TXTMEMSIZE) + 12 +
59  StrLen(TXTMEMMAXSIZE) + 12);
61  output->Append(ns->GetText(a));
64  output->Append(ns->GetText(b));
67  output->Append(ns->GetText(c));
69 
70  delete a;
71  delete b;
72  delete c;
73  delete ns;
74  return output->GetString();
75 }
#define NEWLINE
Definition: amath.h:222
void Empty()
Definition: charbuf.cpp:218
char * GetString() const
Definition: charbuf.cpp:306
#define TXTMEMSIZE
Definition: text.h:75
void Append(const char *source)
Definition: charbuf.cpp:262
Definition: numb.h:66
virtual const char * GetText(Number *number)=0
Represent a real number with 15 significant digits.
Definition: real.h:45
#define TXTMEMBLOCKS
Definition: text.h:74
#define TXTMEMMAXSIZE
Definition: text.h:76
void MemUsage(long *, long *, long *)
Get memory usage in the global memory list.
Definition: mem.c:242
int StrLen(const char *string)
Get the length of a null terminated string.
Definition: strlen.c:34
Base class for all numeral systems.
Definition: ntext.h:49
CharBuffer * output
Definition: nodes.h:85
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:

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