Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Hall.cpp
diff options
context:
space:
mode:
1 files changed, 26 insertions, 0 deletions
-rw-r--r--src/Models/Hall.cpp26
diff --git a/src/Models/Hall.cpp b/src/Models/Hall.cpp
index d1c25f7..feacdac 100644
--- a/src/Models/Hall.cpp
+++ b/src/Models/Hall.cpp
@@ -21,22 +21,43 @@ unsigned Hall::get_seatsPerRow() const {
return seatsPerRow;
}
+/*! \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 Hall::read(std::istream& istr) {
istr.read((char*)&number, sizeof(number));
istr.read((char*)&rows, sizeof(rows));
istr.read((char*)&seatsPerRow, sizeof(seatsPerRow));
}
+/*! \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 Hall::write(std::ostream& ostr) const {
ostr.write((char*)&number, sizeof(number));
ostr.write((char*)&rows, sizeof(rows));
ostr.write((char*)&seatsPerRow, sizeof(seatsPerRow));
}
+/*! \return -1 if number < other.number, 1 if number > other.number, 0 if number == other.number
+ */
int Hall::compare(const Hall& other) const {
return (number > other.get_number()) - (number < other.get_number());
}
+/*!
+ * Uses the stream's >> operator to read and parse all internal values.
+ *
+ * \note Best used with std::cin or text std::ifstream
+ */
std::istream& operator>>(std::istream& istr, Hall& hall) {
int number;
unsigned rows, seatsPerRow;
@@ -45,6 +66,11 @@ std::istream& operator>>(std::istream& istr, Hall& hall) {
return istr;
}
+/*!
+ * Uses the stream's << operator to write all internal data.
+ *
+ * \note Best used with std::cout or text std::ofstream
+ */
std::ostream& operator<<(std::ostream& ostr, const Hall& hall) {
return ostr << hall.get_number() << " " << hall.get_rows() << " "<< hall.get_seatsPerRow();
}