diff options
Fully documented all Models
1 files changed, 27 insertions, 1 deletions
| -rw-r--r-- | src/Models/Ticket.cpp | 28 |
diff --git a/src/Models/Ticket.cpp b/src/Models/Ticket.cpp index 196f5f5..bc8ef84 100644 --- a/src/Models/Ticket.cpp +++ b/src/Models/Ticket.cpp @@ -15,24 +15,45 @@ unsigned Ticket::get_seat() const { return seat; } +/*! \param istr An input stream + * + * Directly reads bytes from stream (calls read() function). + * + * \remark Doesn't alter the stream in any other way. + * \note Best used with binary ifstream + */ void Ticket::read(std::istream& istr) { istr.read((char*)&row, sizeof(row)); istr.read((char*)&seat, sizeof(seat)); } +/*! \param ostr An output stream + * + * Directly writes bytes to stream (calls write() function). + * + * \remark Doesn't alter the stream in any other way. + * \note Best used with binary ofstream + */ void Ticket::write(std::ostream& ostr) const { ostr.write((const char*)&row, sizeof(row)); ostr.write((const char*)&seat, sizeof(seat)); } +/*! \return If rows are equal, -1 if seat < other.seat, 1 if seat > other.seat, 0 if seat == other.seat, else the same, but for rows + */ int Ticket::compare(const Ticket& other) const { if (row == other.row) return (seat > other.seat) - (seat < other.seat); return (row > other.row) - (row < other.row); } -/* General */ +/* Outside of class */ +/*! + * Uses the stream's >> operator to read and parse row and seat. + * + * \note Best used with std::cin or text std::ifstream + */ std::istream& operator>>(std::istream& istr, Ticket& ticket) { unsigned row, seat; istr >> row >> seat; @@ -40,6 +61,11 @@ std::istream& operator>>(std::istream& istr, Ticket& ticket) { return istr; } +/*! + * Uses the stream's << operator to write row and seat, separated by a space. + * + * \note Best used with std::cout or text std::ofstream + */ std::ostream& operator<<(std::ostream& ostr, const Ticket& ticket) { return ostr << ticket.get_row() << " " << ticket.get_seat(); } |
