creating json for new user

This commit is contained in:
Benedikt Galbavy 2023-10-16 13:16:47 +02:00
parent ddb1c277a3
commit 99e34a1faa
3 changed files with 21 additions and 5 deletions

View File

@ -1,8 +1,24 @@
#include "user.h"
user::user(fs::path)
#include <fstream>
#include <string>
using json = nlohmann::json;
user::user(fs::path user_data)
{
// json stuff go here
}
user::user(std::string name, fs::path user_dir)
: name(name)
{
json user;
user["mails"] = json::array();
user["name"] = name;
std::ofstream ofs(user_dir/(name+".json"));
ofs << user;
}
user::~user() {}

7
user.h
View File

@ -12,14 +12,13 @@ namespace fs = std::filesystem;
template <typename T>
static const bool ptr_cmp = [](T* left, T* right) { return *left < *right; };
typedef std::set<mail*, decltype(ptr_cmp<int>)> maillist;
typedef std::set<mail*, decltype(ptr_cmp<int>)> maillist;
class user {
public:
user(fs::path);
user(std::string name)
: name(name) {};
user(fs::path user_data);
user(std::string name, fs::path user_dir);
~user();

View File

@ -1,6 +1,7 @@
#pragma once
#include "user.h"
#include <filesystem>
#include <map>
#include <string>