diff options
Autocommit at 07.05.2022 @ 16:53
5 files changed, 20 insertions, 6 deletions
| -rw-r--r-- | src/Generic/String/String.cpp | 18 | ||||
| -rw-r--r-- | src/Generic/String/String.h | 2 | ||||
| -rw-r--r-- | src/Models/Event.cpp | 2 | ||||
| -rw-r--r-- | src/Models/Hall.cpp | 2 | ||||
| -rw-r--r-- | src/Models/Hall.h | 2 |
diff --git a/src/Generic/String/String.cpp b/src/Generic/String/String.cpp index 0b3bf1f..6b50c64 100644 --- a/src/Generic/String/String.cpp +++ b/src/Generic/String/String.cpp @@ -68,6 +68,16 @@ String& String::operator=(String&& other) { return *this; } +void String::read(std::istream& istr) { + istr.read((char*)&length, sizeof(length)); + istr.read(str, sizeof(char) * length); +} + +void String::write(std::ostream& ostr) const { + ostr.write((char*)&length, sizeof(length)); + ostr.write(str, sizeof(char) * length); +} + int String::compare(const String& other) const { return strcmp(str, other.str); } @@ -77,8 +87,12 @@ char& String::operator[](unsigned index) { } std::istream& operator>>(std::istream& istr, String& event) { - istr >> event.str; + istr.getline(event.str, 1024); + event.length = strlen(event.str); return istr; } -friend std::ostream& operator<<(std::ostream& ostr, const String& event); + +std::ostream& operator<<(std::ostream& ostr, const String& event) { + return ostr << event.str; +} diff --git a/src/Generic/String/String.h b/src/Generic/String/String.h index 5f1dbfa..88deed9 100644 --- a/src/Generic/String/String.h +++ b/src/Generic/String/String.h @@ -26,7 +26,7 @@ public: String& operator=(String&& other); void read(std::istream& istr); - void write(std::ostream& ostr); + void write(std::ostream& ostr) const; int compare(const String& other) const; char& operator[](unsigned index); diff --git a/src/Models/Event.cpp b/src/Models/Event.cpp index 71bf63a..18d0f91 100644 --- a/src/Models/Event.cpp +++ b/src/Models/Event.cpp @@ -30,7 +30,7 @@ const Date& Event::get_date() const { } void Event::read(std::istream& istr) { - hall.read(istr); + istr.read(istr.hall, sizeof(hall)); name.read(istr); date.read(istr); tickets.read(istr); diff --git a/src/Models/Hall.cpp b/src/Models/Hall.cpp index b1c7ed3..41644df 100644 --- a/src/Models/Hall.cpp +++ b/src/Models/Hall.cpp @@ -27,7 +27,7 @@ void Hall::read(std::istream& istr) { istr.read((char*)&seatsPerRow, sizeof(seatsPerRow)); } -void Hall::write(std::ostream& ostr) { +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)); diff --git a/src/Models/Hall.h b/src/Models/Hall.h index 3cdcac4..af7acb1 100644 --- a/src/Models/Hall.h +++ b/src/Models/Hall.h @@ -19,7 +19,7 @@ public: unsigned get_seatsPerRow() const; void read(std::istream& istr); - void write(std::ostream& ostr); + void write(std::ostream& ostr) const; int compare(const Hall& other) const; friend std::istream& operator>>(std::istream& istr, Hall& hall); |
