basic classes
This commit is contained in:
parent
bc37b40f09
commit
bc539bd093
4
Makefile
4
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
|
||||
21
mail.h
Normal file
21
mail.h
Normal 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();
|
||||
};
|
||||
@ -1,3 +1,5 @@
|
||||
#include "user.h"
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
//
|
||||
|
||||
30
user.h
Normal file
30
user.h
Normal 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;
|
||||
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user