Calculator
Extensible stack-based calculator primarily in library form
|
Collection of Result information for an operation. More...
#include <Result.h>
Public Types | |
typedef std::string | Message |
typedef std::vector< Message > | Messages |
typedef std::pair< unsigned int, std::string > | PositionMessage |
For convenience, we use a pair for the line and message for a position. More... | |
typedef std::vector< PositionMessage > | PositionMessages |
Public Member Functions | |
Result ()=default | |
Result (std::initializer_list< Message > theMessages) | |
Create with all messages in theMessage. More... | |
Result (std::initializer_list< PositionMessage > thePositionMessages) | |
Create with all the positional messages in thePositionMessages. More... | |
Result (std::initializer_list< Message > theMessages, std::initializer_list< PositionMessage > thePositionMessages) | |
Create with all messages in theMessage and all the positional messages in thePositionMessages. More... | |
const Messages & | getMessages () const |
bool | hasMessage (const std::string &message) const |
Convenience to test with message has been set. More... | |
void | addMessage (const std::string &message) |
Add message. More... | |
const PositionMessages & | getPositionMessages () const |
bool | hasPositionMessage (const unsigned int position, const std::string &message) const |
Convenience to test if the positional message has been set at the position. More... | |
void | addPositionMessage (const unsigned int position, const std::string &message) |
Add the positional message. More... | |
std::string | toString () const |
std::string | toString (const std::string &prefix) const |
Create a string representation of this Result with prefix at the start of each line. More... | |
Collection of Result information for an operation.
Contains non-positional message strings for things like "Ok". May be used by driving code to pass around commands like "quit".
Contains positional messages of stack position (0 is top) and message to indicate what failed, such as Stack Underflow or conversion error on a position in the stack.
typedef std::string Calculator::Result::Message |
typedef std::vector<Message> Calculator::Result::Messages |
typedef std::pair<unsigned int, std::string> Calculator::Result::PositionMessage |
typedef std::vector<PositionMessage> Calculator::Result::PositionMessages |
|
default |
Calculator::Result::Result | ( | std::initializer_list< Message > | theMessages | ) |
Create with all messages in theMessage.
Definition at line 24 of file Result.cpp.
Calculator::Result::Result | ( | std::initializer_list< PositionMessage > | thePositionMessages | ) |
Create with all the positional messages in thePositionMessages.
Definition at line 28 of file Result.cpp.
Calculator::Result::Result | ( | std::initializer_list< Message > | theMessages, |
std::initializer_list< PositionMessage > | thePositionMessages | ||
) |
Create with all messages in theMessage and all the positional messages in thePositionMessages.
Definition at line 32 of file Result.cpp.
void Calculator::Result::addMessage | ( | const std::string & | message | ) |
void Calculator::Result::addPositionMessage | ( | const unsigned int | position, |
const std::string & | message | ||
) |
Add the positional message.
position | the message belongs to |
message | to be added at position |
Definition at line 61 of file Result.cpp.
const Result::Messages & Calculator::Result::getMessages | ( | ) | const |
Definition at line 39 of file Result.cpp.
const Result::PositionMessages & Calculator::Result::getPositionMessages | ( | ) | const |
Definition at line 52 of file Result.cpp.
bool Calculator::Result::hasMessage | ( | const std::string & | message | ) | const |
Convenience to test with message has been set.
message | to test |
Definition at line 43 of file Result.cpp.
bool Calculator::Result::hasPositionMessage | ( | const unsigned int | position, |
const std::string & | message | ||
) | const |
Convenience to test if the positional message has been set at the position.
position | to look for message in |
message | to look for in position |
Definition at line 56 of file Result.cpp.
std::string Calculator::Result::toString | ( | ) | const |
Definition at line 66 of file Result.cpp.
std::string Calculator::Result::toString | ( | const std::string & | prefix | ) | const |
Create a string representation of this Result with prefix at the start of each line.
prefix | to put before each line |
Definition at line 70 of file Result.cpp.