diff options
Autocommit at 08.05.2022 @ 09:53
3 files changed, 14 insertions, 0 deletions
| -rw-r--r-- | src/Generic/Date/Date.h | 3 | ||||
| -rw-r--r-- | src/Generic/String/String.cpp | 9 | ||||
| -rw-r--r-- | src/Services/EventService.cpp | 2 |
diff --git a/src/Generic/Date/Date.h b/src/Generic/Date/Date.h index a7c0ecb..a960678 100644 --- a/src/Generic/Date/Date.h +++ b/src/Generic/Date/Date.h @@ -3,6 +3,7 @@ #include <istream> #include <ostream> +#include "../String/String.h" class Date { unsigned short day; @@ -24,6 +25,8 @@ public: unsigned short get_year() const; bool set_year(unsigned short year); + String createCStr(); + void read(std::istream& istr); void write(std::ostream& ostr); int compare(const Date& other) const; diff --git a/src/Generic/String/String.cpp b/src/Generic/String/String.cpp index 4de5a29..bacd72c 100644 --- a/src/Generic/String/String.cpp +++ b/src/Generic/String/String.cpp @@ -36,6 +36,15 @@ unsigned String::get_length() const { } String& String::operator+=(const char* str) { + unsigned strLen = strlen(str); + char* newStr = new char[length + strLen + 1]; + strncpy(newStr, this->str, length + 1); + strncat(newStr, str, strLen + 1); + + delete[] this->str; + this->str = newStr; + length += strLen; + return *this; } diff --git a/src/Services/EventService.cpp b/src/Services/EventService.cpp index 5adbf6b..24ddcaf 100644 --- a/src/Services/EventService.cpp +++ b/src/Services/EventService.cpp @@ -213,6 +213,8 @@ StatusCode EventService::reportReservations(const char* name, const Date& date) result.add(events[i]); } + String outFileName("report.txt-"); + ((outFileName += name) += "-") += date.toCStr(); std::ofstream outFile("report.txt"); // TODO: filename if (!outFile.is_open()) return E_FileCouldNotBeOpened; |
