From d5186a043e53375e5e0d83f47f99c8282da5db8f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 7 May 2022 16:48:51 +0300 Subject: Autocommit at 07.05.2022 @ 16:48 --- src/Generic/String/String.cpp | 7 +++++++ src/Generic/String/String.h | 8 ++++++++ 2 files changed, 15 insertions(+) (limited to 'src/Generic/String') 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 +#include + 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 -- cgit v1.3.1-23-gd82d