From bc539bd093a13790f03e0af97c3dd82805e37e98 Mon Sep 17 00:00:00 2001 From: Benedikt Galbavy Date: Thu, 12 Oct 2023 18:57:06 +0200 Subject: [PATCH] basic classes --- Makefile | 4 ++-- mail.h | 21 +++++++++++++++++++++ server.cpp | 2 ++ user.cpp | 3 +++ user.h | 30 ++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 mail.h create mode 100644 user.cpp create mode 100644 user.h diff --git a/Makefile b/Makefile index 1a0223d..5c7171a 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ all: client server client: client.cpp - g++ -std=c++17 -Wall -Werror -fsanitize=address -o twmailer-client client.cpp + g++ -std=c++20 -Wall -Werror -fsanitize=address -o twmailer-client client.cpp server: server.cpp - g++ -std=c++17 -Wall -Werror -fsanitize=address -o twmailer-server server.cpp + g++ -std=c++20 -Wall -Werror -fsanitize=address -o twmailer-server server.cpp clean: rm -f twmailer-client twmailer-server \ No newline at end of file diff --git a/mail.h b/mail.h new file mode 100644 index 0000000..5a57f2c --- /dev/null +++ b/mail.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include +#include + +struct mail { + std::string filename; + + /* metadata */ + int64_t timestamp; + std::string sender; + std::vector receipient; + std::string subject; + + const bool operator<(const mail& left) { + return this->timestamp < left.timestamp; + } + + void remove(); +}; \ No newline at end of file diff --git a/server.cpp b/server.cpp index 87c1b0e..832e101 100644 --- a/server.cpp +++ b/server.cpp @@ -1,3 +1,5 @@ +#include "user.h" + int main (int argc, char* argv[]) { // diff --git a/user.cpp b/user.cpp new file mode 100644 index 0000000..fdd3f17 --- /dev/null +++ b/user.cpp @@ -0,0 +1,3 @@ +#include "user.h" + +user::~user() {} \ No newline at end of file diff --git a/user.h b/user.h new file mode 100644 index 0000000..f43d3a3 --- /dev/null +++ b/user.h @@ -0,0 +1,30 @@ +#pragma once + +#include "mail.h" + +#include +#include + + +template +static const bool ptr_cmp = [](T* left, T* right) { return *left < *right; }; + +typedef std::set)> maillist; + +class user { +public: + + user(std::string name, maillist mails) + : name(name), mails(mails) + {}; + ~user(); + + void addMail(mail mail); + std::set getMails(); + +private: + + const std::string name; + maillist mails; + +}; \ No newline at end of file