basic classes

This commit is contained in:
Benedikt Galbavy 2023-10-12 18:57:06 +02:00
parent bc37b40f09
commit bc539bd093
5 changed files with 58 additions and 2 deletions

View File

@ -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

21
mail.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include <chrono>
#include <string>
#include <vector>
struct mail {
std::string filename;
/* metadata */
int64_t timestamp;
std::string sender;
std::vector<std::string> receipient;
std::string subject;
const bool operator<(const mail& left) {
return this->timestamp < left.timestamp;
}
void remove();
};

View File

@ -1,3 +1,5 @@
#include "user.h"
int main (int argc, char* argv[])
{
//

3
user.cpp Normal file
View File

@ -0,0 +1,3 @@
#include "user.h"
user::~user() {}

30
user.h Normal file
View File

@ -0,0 +1,30 @@
#pragma once
#include "mail.h"
#include <string>
#include <set>
template <typename T>
static const bool ptr_cmp = [](T* left, T* right) { return *left < *right; };
typedef std::set<mail*, decltype(ptr_cmp<int>)> maillist;
class user {
public:
user(std::string name, maillist mails)
: name(name), mails(mails)
{};
~user();
void addMail(mail mail);
std::set<mail*> getMails();
private:
const std::string name;
maillist mails;
};