amath
1.8.5
Simple command line calculator
|
Encapsulate an character array which can be used as a string. More...
#include <charbuf.h>
Public Member Functions | |
CharBuffer () | |
Initialize without allocating memory. More... | |
CharBuffer (unsigned int size) | |
Initialize while allocating specified amount of memory. More... | |
~CharBuffer () | |
void | ClearBuffer () |
Release memory in buffer. More... | |
void | ClearAndCopy (const char *source) |
Release memory, allocate and copy source. More... | |
void | ClearAndAlloc (unsigned int size) |
Release memory and allocate new size. More... | |
void | EnsureSize (unsigned int size) |
Ensure a memory block of specified size is allocated. More... | |
void | EnsureSize (unsigned int blocksize, unsigned int blocks) |
void | EnsureMinimumSize () |
void | EnsureGrowth (unsigned int size) |
void | Empty () |
bool | IsEmpty () const |
bool | Is (const char *string) const |
Compare content of CharBuffer with string) More... | |
bool | Contains (const char c) const |
void | Copy (CharBuffer *buf) |
void | Append (const char *source) |
void | Append (const char c) |
void | Append (const char c, unsigned int count) |
void | DeleteLastChar () |
bool | RemoveTrailing (const char c) |
bool | RemoveTrailing (const char *string) |
char * | GetString () const |
Private Attributes | |
char * | buf |
char * | ptr |
unsigned int | cursize |
Static Private Attributes | |
static const unsigned int | minimumSize = 64 |
Friends | |
class | AnsiConoleEngine |
Encapsulate an character array which can be used as a string.
The CharBuffer class eases the task of allocating a releasing memory.
CharBuffer::CharBuffer | ( | ) |
Initialize without allocating memory.
Definition at line 38 of file charbuf.cpp.
References buf, cursize, and ptr.
Referenced by AnsiConoleEngine::AnsiConoleEngine(), ErrorNode::ErrorNode(), Evaluator::Evaluator(), PromptStatement::Execute(), FunctionList::FunctionList(), StandardProgram::Initialize(), StandardFilesystem::ListDirectory(), StandardFilesystem::LoadTextFile(), NumeralSystem::NumeralSystem(), PreferencesBase::PreferencesBase(), SyntaxNode::SyntaxNode(), UserFunction::UserFunction(), and VariableList::VariableList().
|
explicit |
Initialize while allocating specified amount of memory.
Definition at line 49 of file charbuf.cpp.
References buf, cursize, minimumSize, and ptr.
Referenced by SaveStatement::Execute(), and PositionalNumeralSystem::GetText().
CharBuffer::~CharBuffer | ( | ) |
Definition at line 56 of file charbuf.cpp.
References ClearBuffer().
void CharBuffer::Append | ( | const char * | source | ) |
Definition at line 262 of file charbuf.cpp.
References ptr.
Referenced by ErrorNode::ErrorNode(), SaveStatement::Execute(), PlotStatement::Execute(), MemoryStatement::Execute(), EvalStatement::Execute(), InputStatement::Execute(), DigitsStatement::Execute(), OutputStatement::Execute(), DeleteStatement::Execute(), ErrorNode::Execute(), StatementBlockNode::Execute(), PreferencesBase::GetDescription(), PositionalNumeralSystem::GetName(), PositionalNumeralSystem::GetSpecialCase(), DecimalSystem::GetText(), UnaryNode::GetText(), PositionalNumeralSystem::GetText(), FunctionNode::GetText(), AbsoluteNode::GetText(), FactorialNode::GetText(), NumericOperator::GetText(), StandardProgram::Initialize(), UserFunction::InitializeTexts(), FunctionList::ListContent(), VariableList::ListContent(), StandardFilesystem::ListDirectory(), AnsiConoleEngine::ProcessChar(), AnsiConoleEngine::ShowLast(), and AnsiConoleEngine::ShowNext().
void CharBuffer::Append | ( | const char | c | ) |
Definition at line 245 of file charbuf.cpp.
References ptr.
Referenced by PlotStatement::Execute(), PromptStatement::Execute(), ErrorNode::Execute(), PreferencesBase::GetDescription(), DecimalSystem::GetText(), PositionalNumeralSystem::GetText(), StandardProgram::Initialize(), UserFunction::InitializeTexts(), PositionalNumeralSystem::IntegerToBuffer(), FunctionList::ListContent(), VariableList::ListContent(), StandardFilesystem::LoadTextFile(), and AnsiConoleEngine::ProcessChar().
void CharBuffer::Append | ( | const char | c, |
unsigned int | count | ||
) |
Definition at line 250 of file charbuf.cpp.
References ptr.
Referenced by ErrorNode::Execute(), and StandardFilesystem::ListDirectory().
void CharBuffer::ClearAndAlloc | ( | unsigned int | size | ) |
Release memory and allocate new size.
Definition at line 92 of file charbuf.cpp.
References buf, ClearBuffer(), cursize, minimumSize, and ptr.
Referenced by ErrorNode::Execute(), and AnsiConoleEngine::StartInput().
void CharBuffer::ClearAndCopy | ( | const char * | source | ) |
Release memory, allocate and copy source.
Definition at line 81 of file charbuf.cpp.
References AllocAndCopy(), buf, ClearBuffer(), cursize, and ptr.
Referenced by Evaluator::Evaluate(), ExecuteStatement::Execute(), PromptStatement::Execute(), HelpStatement::Execute(), and NumericValueNode::GetNodeText().
void CharBuffer::ClearBuffer | ( | ) |
Release memory in buffer.
Definition at line 65 of file charbuf.cpp.
References buf, cursize, and ptr.
Referenced by FunctionList::Clear(), VariableList::Clear(), ClearAndAlloc(), ClearAndCopy(), Evaluator::Evaluate(), StatementBlockNode::Execute(), HelpStatement::StatementHelp(), and ~CharBuffer().
bool CharBuffer::Contains | ( | const char | c | ) | const |
Definition at line 199 of file charbuf.cpp.
Referenced by DecimalSystem::GetText().
void CharBuffer::Copy | ( | CharBuffer * | buf | ) |
Definition at line 233 of file charbuf.cpp.
References buf, cursize, EnsureSize(), GetString(), and ptr.
Referenced by PositionalNumeralSystem::GetText().
void CharBuffer::DeleteLastChar | ( | ) |
Definition at line 228 of file charbuf.cpp.
References ptr.
Referenced by StandardProgram::Initialize().
void CharBuffer::Empty | ( | ) |
Definition at line 218 of file charbuf.cpp.
References buf, EnsureMinimumSize(), and ptr.
Referenced by SaveStatement::Execute(), PlotStatement::Execute(), MemoryStatement::Execute(), DigitsStatement::Execute(), EvalStatement::Execute(), InputStatement::Execute(), OutputStatement::Execute(), DeleteStatement::Execute(), ErrorNode::Execute(), StatementBlockNode::Execute(), FunctionDefinitionNode::FunctionDefinitionNode(), PreferencesBase::GetDescription(), PositionalNumeralSystem::GetName(), PositionalNumeralSystem::GetSpecialCase(), DecimalSystem::GetText(), UnaryNode::GetText(), PositionalNumeralSystem::GetText(), FunctionNode::GetText(), AbsoluteNode::GetText(), FactorialNode::GetText(), NumericOperator::GetText(), StandardProgram::Initialize(), UserFunction::InitializeTexts(), FunctionList::ListContent(), VariableList::ListContent(), StandardFilesystem::ListDirectory(), StandardFilesystem::LoadTextFile(), NumeralSystem::NumeralSystem(), AnsiConoleEngine::ProcessChar(), AnsiConoleEngine::ShowLast(), and AnsiConoleEngine::ShowNext().
void CharBuffer::EnsureGrowth | ( | unsigned int | size | ) |
Definition at line 169 of file charbuf.cpp.
References buf, EnsureSize(), and ptr.
Referenced by PlotStatement::Execute(), StatementBlockNode::Execute(), DecimalSystem::GetText(), StandardFilesystem::ListDirectory(), AnsiConoleEngine::ProcessChar(), and AnsiConoleEngine::ShowNext().
void CharBuffer::EnsureMinimumSize | ( | ) |
Definition at line 100 of file charbuf.cpp.
References buf, minimumSize, and ptr.
Referenced by Empty(), and FunctionDefinitionNode::FunctionDefinitionNode().
void CharBuffer::EnsureSize | ( | unsigned int | size | ) |
Ensure a memory block of specified size is allocated.
Definition at line 114 of file charbuf.cpp.
References buf, cursize, MemCopy(), minimumSize, and ptr.
Referenced by Copy(), EnsureGrowth(), ErrorNode::ErrorNode(), MemoryStatement::Execute(), InputStatement::Execute(), OutputStatement::Execute(), DigitsStatement::Execute(), EvalStatement::Execute(), DeleteStatement::Execute(), PreferencesBase::GetDescription(), PositionalNumeralSystem::GetName(), UnaryNode::GetText(), FunctionNode::GetText(), AbsoluteNode::GetText(), FactorialNode::GetText(), NumericOperator::GetText(), StandardProgram::Initialize(), FunctionList::ListContent(), VariableList::ListContent(), StandardFilesystem::ListDirectory(), AnsiConoleEngine::ShowLast(), and AnsiConoleEngine::ShowNext().
void CharBuffer::EnsureSize | ( | unsigned int | blocksize, |
unsigned int | blocks | ||
) |
Definition at line 146 of file charbuf.cpp.
References buf, cursize, MemCopy(), and ptr.
Referenced by StandardFilesystem::LoadTextFile().
char * CharBuffer::GetString | ( | ) | const |
Definition at line 306 of file charbuf.cpp.
Referenced by Copy(), AnsiConoleEngine::CopyLine(), ErrorNode::ErrorNode(), LoadStatement::Execute(), SaveStatement::Execute(), ShowStatement::Execute(), ExecuteStatement::Execute(), PlotStatement::Execute(), ListStatement::Execute(), MemoryStatement::Execute(), FunctionDefinitionNode::Execute(), DigitsStatement::Execute(), OutputStatement::Execute(), PromptStatement::Execute(), EvalStatement::Execute(), InputStatement::Execute(), DeleteStatement::Execute(), HelpStatement::Execute(), ErrorNode::Execute(), StatementBlockNode::Execute(), UserFunction::GetDefinitionName(), UserFunction::GetDefinitionText(), PreferencesBase::GetDescription(), AnsiConoleEngine::GetLine(), PositionalNumeralSystem::GetName(), NumericValueNode::GetNodeText(), Evaluator::GetResult(), PositionalNumeralSystem::GetSpecialCase(), DecimalSystem::GetText(), FunctionDefinitionNode::GetText(), UnaryNode::GetText(), PositionalNumeralSystem::GetText(), FunctionNode::GetText(), AbsoluteNode::GetText(), FactorialNode::GetText(), NumericOperator::GetText(), UserFunction::InitializeTexts(), Is(), FunctionList::ListContent(), VariableList::ListContent(), StandardFilesystem::ListDirectory(), StandardLanguage::LoadCatalog(), AnsiConoleEngine::ProcessChar(), AnsiConoleEngine::ShowLast(), AnsiConoleEngine::ShowNext(), StandardProgram::Start(), and HelpStatement::StatementHelp().
bool CharBuffer::Is | ( | const char * | string | ) | const |
Compare content of CharBuffer with string)
Definition at line 194 of file charbuf.cpp.
References GetString(), and StrIsEqual().
Referenced by PositionalNumeralSystem::GetText().
bool CharBuffer::IsEmpty | ( | ) | const |
Definition at line 174 of file charbuf.cpp.
Referenced by StandardProgram::Start().
bool CharBuffer::RemoveTrailing | ( | const char | c | ) |
Definition at line 270 of file charbuf.cpp.
Referenced by PromptStatement::Execute(), DecimalSystem::GetText(), and PositionalNumeralSystem::GetText().
bool CharBuffer::RemoveTrailing | ( | const char * | string | ) |
Definition at line 286 of file charbuf.cpp.
References buf, ptr, StrIsEqual(), and StrLen().
|
friend |
|
private |
Definition at line 81 of file charbuf.h.
Referenced by CharBuffer(), ClearAndAlloc(), ClearAndCopy(), ClearBuffer(), Contains(), Copy(), Empty(), EnsureGrowth(), EnsureMinimumSize(), EnsureSize(), GetString(), IsEmpty(), AnsiConoleEngine::ProcessChar(), RemoveTrailing(), AnsiConoleEngine::ShowLast(), AnsiConoleEngine::ShowNext(), and AnsiConoleEngine::StartInput().
|
private |
Definition at line 83 of file charbuf.h.
Referenced by CharBuffer(), ClearAndAlloc(), ClearAndCopy(), ClearBuffer(), Copy(), and EnsureSize().
|
staticprivate |
Definition at line 84 of file charbuf.h.
Referenced by CharBuffer(), ClearAndAlloc(), EnsureMinimumSize(), and EnsureSize().
|
private |
Definition at line 82 of file charbuf.h.
Referenced by Append(), CharBuffer(), ClearAndAlloc(), ClearAndCopy(), ClearBuffer(), Contains(), Copy(), DeleteLastChar(), Empty(), EnsureGrowth(), EnsureMinimumSize(), EnsureSize(), GetString(), IsEmpty(), AnsiConoleEngine::ProcessChar(), and RemoveTrailing().