CardGame
Rogue-like card videogame
Loading...
Searching...
No Matches
iotext.h
Go to the documentation of this file.
1#ifndef IOTEXT_H
2#define IOTEXT_H
3
4#include <iostream>
5#include <string>
6#include <string_view>
7#include <vector>
8
9class RenderedHand;
10
19class IOText
20{
21
22 public:
29 IOText(std::ostream& out, std::istream& in) : m_out{out}, m_in{in} {}
30
32 void println(std::string_view msg);
34 void print(std::string_view msg) const;
35
37 void getln(std::string& line);
38
39 int promptInt(std::string_view prompt, int validLimit);
40
47 void promptln(std::string& line, std::string_view prompt);
48
54 void printCards(const std::vector<std::string>& cardToPrintGrid);
55
63 void printHand(const RenderedHand& handToPrint);
64
65 private:
66 std::ostream& m_out;
67 std::istream& m_in;
68};
69
70#endif // IOTEXT_H
Text-based input/output interface for terminal interaction.
Definition: iotext.h:20
void getln(std::string &line)
Reads a line of input into the given string.
Definition: iotext.cpp:8
void promptln(std::string &line, std::string_view prompt)
Prints a prompt and reads a line of input.
Definition: iotext.cpp:10
void printCards(const std::vector< std::string > &cardToPrintGrid)
Prints a rendered card grid to the output.
Definition: iotext.cpp:50
void println(std::string_view msg)
Prints a line followed by a newline.
Definition: iotext.cpp:4
void print(std::string_view msg) const
Prints a line (with newline).
Definition: iotext.cpp:6
int promptInt(std::string_view prompt, int validLimit)
Definition: iotext.cpp:16
IOText(std::ostream &out, std::istream &in)
Constructs an IOText interface using the given streams.
Definition: iotext.h:29
void printHand(const RenderedHand &handToPrint)
Prints a rendered hand to the output.
Definition: iotext.cpp:58
Rendered representation of a hand for terminal output.
Definition: handRenderer.h:18