Fishtank
|
Serializable implementation of Screen using a 2D character buffer. More...
#include <string-screen.h>
Public Member Functions | |
StringScreen (int width, int height) | |
char | charAt (int col, int row) const |
Fetch the character at the given coordinate pair. More... | |
void | charAtPut (int col, int row, char value) |
void | clear () |
std::string | toString () const |
Public Member Functions inherited from Screen | |
Screen (int width, int height) | |
int | width () const |
int | height () const |
Additional Inherited Members | |
Protected Member Functions inherited from Screen | |
void | checkCoordinates (int col, int row) const |
Protected Attributes inherited from Screen | |
int | width_ |
int | height_ |
Serializable implementation of Screen using a 2D character buffer.
This class is designed to assist with unit testing of other classes. Although you should still write tests to make sure this class works as expected, you also shouldn't hesitate to instantiate it as part of unit tests for other classes. (Even though it's a separate unit in many senses.)
Definition at line 13 of file string-screen.h.
|
explicit |
Construct and initialize the buffer. Fill the screen with space (' '
) characters.
width | width in columns |
height | height in rows |
std::out_of_range | if width or height is negative |
Definition at line 3 of file string-screen.cpp.
char StringScreen::charAt | ( | int | col, |
int | row | ||
) | const |
Fetch the character at the given coordinate pair.
col | 0-based column (x) index |
row | 0-based row (y) index |
std::out_of_range | if the row or column is out of bounds (negative or too large) |
Definition at line 7 of file string-screen.cpp.
|
virtual |
Write a character to the internal buffer. Updates the buffer immediately.
col | 0-based column (x) index |
row | 0-based row (y) index |
value | the character to write |
std::out_of_range | if the row or column is out of bounds (negative or too large) |
Implements Screen.
Definition at line 12 of file string-screen.cpp.
|
virtual |
Fill the screen with space (' '
) characters. Updates the buffer immediately.
Implements Screen.
Definition at line 17 of file string-screen.cpp.
std::string StringScreen::toString | ( | ) | const |
Serialize the buffer. Wrap the output in a border:
Definition at line 25 of file string-screen.cpp.