creating json for new user
This commit is contained in:
parent
ddb1c277a3
commit
99e34a1faa
18
user.cpp
18
user.cpp
@ -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
7
user.h
@ -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();
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "user.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user