Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Reservation.cpp
diff options
context:
space:
mode:
Commitbf7689ba06764b72a6212549a5c8a39e294cceee (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-08 20:40:30 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-08 20:40:30 +0300
Filesa9ff9780c4f502de58b9d075290acbacf4769d44 /src/Models/Reservation.cpp
FMI-OOP-P1_TicketSystem-bf7689ba06764b72a6212549a5c8a39e294cceee.tar
FMI-OOP-P1_TicketSystem-bf7689ba06764b72a6212549a5c8a39e294cceee.tar.gz
FMI-OOP-P1_TicketSystem-bf7689ba06764b72a6212549a5c8a39e294cceee.zip
Parenta8388cfdc47386dcb61f1b5bb9190ce382bf3f1d (diff)
Fully documented all Models
1 files changed, 29 insertions, 0 deletions
-rw-r--r--src/Models/Reservation.cpp29
diff --git a/src/Models/Reservation.cpp b/src/Models/Reservation.cpp
index 159b996..002ba29 100644
--- a/src/Models/Reservation.cpp
+++ b/src/Models/Reservation.cpp
@@ -23,28 +23,57 @@ const char* Reservation::get_note() const {
return note;
}
+/*! \param istr An input stream
+ *
+ * Directly reads bytes from stream (calls read() function).
+ * Uses ticket's read() function.
+ *
+ * \remark Doesn't alter the stream in any other way.
+ * \note Best used with binary ifstream
+ */
void Reservation::read(std::istream& istr) {
ticket.read(istr);
istr.read(password, sizeof(password));
istr.read(note, sizeof(note));
}
+/*! \param ostr An output stream
+ *
+ * Directly writes bytes to stream (calls write() function).
+ * Uses ticket's write() function.
+ *
+ * \remark Doesn't alter the stream in any other way.
+ * \note Best used with binary ofstream
+ */
void Reservation::write(std::ostream& ostr) const {
ticket.write(ostr);
ostr.write(password, sizeof(password));
ostr.write(note, sizeof(note));
}
+/*! \return Compares tickets
+ */
int Reservation::compare(const Reservation& other) const {
return ticket.compare(other.ticket);
}
+/*!
+ * Uses the stream's >> operator to read and parse the ticket.
+ * Password and note are left blank.
+ *
+ * \note Best used with std::cin or text std::ifstream
+ */
std::istream& operator>>(std::istream& istr, Reservation& reservation) {
strncpy(reservation.password, "", PASSWORD_LEN);
strncpy(reservation.note, "", NOTE_LEN);
return istr >> reservation.ticket;
}
+/*!
+ * Uses the stream's << operator to write the ticket only.
+ *
+ * \note Best used with std::cout or text std::ofstream
+ */
std::ostream& operator<<(std::ostream& ostr, const Reservation& reservation) {
return ostr << reservation.ticket;
}