diff options
Autocommit at 07.05.2022 @ 16:48
3 files changed, 18 insertions, 3 deletions
| -rw-r--r-- | src/Generic/String/String.cpp | 7 | ||||
| -rw-r--r-- | src/Generic/String/String.h | 8 | ||||
| -rw-r--r-- | src/Models/Hall.cpp | 6 |
diff --git a/src/Generic/String/String.cpp b/src/Generic/String/String.cpp index 21e6619..0b3bf1f 100644 --- a/src/Generic/String/String.cpp +++ b/src/Generic/String/String.cpp @@ -75,3 +75,10 @@ int String::compare(const String& other) const { char& String::operator[](unsigned index) { return str[index]; } + +std::istream& operator>>(std::istream& istr, String& event) { + istr >> event.str; + + return istr; +} +friend std::ostream& operator<<(std::ostream& ostr, const String& event); diff --git a/src/Generic/String/String.h b/src/Generic/String/String.h index 4465407..5f1dbfa 100644 --- a/src/Generic/String/String.h +++ b/src/Generic/String/String.h @@ -1,6 +1,9 @@ #ifndef HEADER_STRING #define HEADER_STRING +#include <istream> +#include <ostream> + class String { char* str; unsigned length; @@ -22,8 +25,13 @@ public: String(String&& other); String& operator=(String&& other); + void read(std::istream& istr); + void write(std::ostream& ostr); int compare(const String& other) const; char& operator[](unsigned index); + + friend std::istream& operator>>(std::istream& istr, String& event); + friend std::ostream& operator<<(std::ostream& ostr, const String& event); }; #endif diff --git a/src/Models/Hall.cpp b/src/Models/Hall.cpp index 3c45937..b1c7ed3 100644 --- a/src/Models/Hall.cpp +++ b/src/Models/Hall.cpp @@ -28,9 +28,9 @@ void Hall::read(std::istream& istr) { } void Hall::write(std::ostream& ostr) { - istr.write((char*)&number, sizeof(number)); - istr.write((char*)&rows, sizeof(rows)); - istr.write((char*)&seatsPerRow, sizeof(seatsPerRow)); + ostr.write((char*)&number, sizeof(number)); + ostr.write((char*)&rows, sizeof(rows)); + ostr.write((char*)&seatsPerRow, sizeof(seatsPerRow)); } int Hall::compare(const Hall& other) const { |
