CardGame
Rogue-like card videogame
Loading...
Searching...
No Matches
IOText Class Reference

Text-based input/output interface for terminal interaction. More...

#include <iotext.h>

Collaboration diagram for IOText:

Public Member Functions

 IOText (std::ostream &out, std::istream &in)
 Constructs an IOText interface using the given streams.
 
void println (std::string_view msg)
 Prints a line followed by a newline.
 
void print (std::string_view msg) const
 Prints a line (with newline).
 
void getln (std::string &line)
 Reads a line of input into the given string.
 
int promptInt (std::string_view prompt, int validLimit)
 
void promptln (std::string &line, std::string_view prompt)
 Prints a prompt and reads a line of input.
 
void printCards (const std::vector< std::string > &cardToPrintGrid)
 Prints a rendered card grid to the output.
 
void printHand (const RenderedHand &handToPrint)
 Prints a rendered hand to the output.
 

Detailed Description

Text-based input/output interface for terminal interaction.

IOText provides an abstraction over input and output streams used by the terminal UI. It is responsible only for printing text and rendered grids, and for reading user input.

IOText does not implement any game logic or rendering logic;

Constructor & Destructor Documentation

◆ IOText()

IOText::IOText ( std::ostream &  out,
std::istream &  in 
)
inline

Constructs an IOText interface using the given streams.

Parameters
outOutput stream used for printing.
inInput stream used for reading user input.

Member Function Documentation

◆ getln()

void IOText::getln ( std::string &  line)

Reads a line of input into the given string.

◆ print()

void IOText::print ( std::string_view  msg) const

Prints a line (with newline).

◆ printCards()

void IOText::printCards ( const std::vector< std::string > &  cardToPrintGrid)

Prints a rendered card grid to the output.

Parameters
cardToPrintGridASCII grid representing a single card or row of cards.

◆ printHand()

void IOText::printHand ( const RenderedHand handToPrint)

Prints a rendered hand to the output.

One or two rows are printed depending on the contents of RenderedHand.

Parameters
handToPrintRendered hand structure to print.

◆ println()

void IOText::println ( std::string_view  msg)

Prints a line followed by a newline.

◆ promptInt()

int IOText::promptInt ( std::string_view  prompt,
int  validLimit 
)

◆ promptln()

void IOText::promptln ( std::string &  line,
std::string_view  prompt 
)

Prints a prompt and reads a line of input.

Parameters
lineOutput string receiving the input.
promptPrompt text printed before reading input.

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