diff options
Autocommit at 07.05.2022 @ 16:48
2 files changed, 15 insertions, 0 deletions
| -rw-r--r-- | src/Generic/String/String.cpp | 7 | ||||
| -rw-r--r-- | src/Generic/String/String.h | 8 |
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 |
