From 99e34a1faae52567d209ce908915e59217549b3b Mon Sep 17 00:00:00 2001 From: Benedikt Galbavy Date: Mon, 16 Oct 2023 13:16:47 +0200 Subject: [PATCH] creating json for new user --- user.cpp | 18 +++++++++++++++++- user.h | 7 +++---- user_handler.h | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/user.cpp b/user.cpp index 4ae6d1b..73f6657 100644 --- a/user.cpp +++ b/user.cpp @@ -1,8 +1,24 @@ #include "user.h" -user::user(fs::path) +#include +#include + +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() {} \ No newline at end of file diff --git a/user.h b/user.h index c2eb7cf..308f949 100644 --- a/user.h +++ b/user.h @@ -12,14 +12,13 @@ namespace fs = std::filesystem; template static const bool ptr_cmp = [](T* left, T* right) { return *left < *right; }; -typedef std::set)> maillist; +typedef std::set)> 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(); diff --git a/user_handler.h b/user_handler.h index 69df5f6..4624c8f 100644 --- a/user_handler.h +++ b/user_handler.h @@ -1,6 +1,7 @@ #pragma once #include "user.h" + #include #include #include