-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.hpp
More file actions
53 lines (42 loc) · 1.2 KB
/
main.hpp
File metadata and controls
53 lines (42 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <cstdint>
#include <string>
#include <uuid/uuid.h>
#include <cstring>
#include <algorithm>
#include <fstream>
#include <map>
#include "object.hpp"
#include "gift.hpp"
#include "prayer.hpp"
#include "link.hpp"
static constexpr auto kDbName = "./database/";
static constexpr auto kMenu = "1. Make gift\n2. View gift\n3. Make prayer\n4. Call Perune\n5. Exit";
static constexpr size_t kMaxCacheSize = 0x100;
static constexpr size_t kMaxPasswordSize = 0x100;
static constexpr auto kMaxPrayerTextSize = kMaxPasswordSize;
std::unordered_map<std::string, Object*> gCache;
// menu handlers
size_t MakeGift(void);
size_t ViewGift(void);
size_t MakePrayer(void);
size_t CallPerune(void);
// json utils
json GetJsonFromFile(std::string);
json GetObjectJson(std::string);
bool CheckJson(json);
void CreateObjects(json, json, json);
// cache utils
template <typename T>
T* GetObjectFromCache(std::string& ObjectId);
template <typename T>
void DeleteFromCache(T* pObj);
void AddObjectToCache(Object* pObj);
void FlushCacheToDb();
// db utils
template <typename T>
T* GetObjectFromDb(std::string ObjectId);
void AddObjectToDb(Object* pObj);
// other utils
Gift* GetGift(void);
void trim(std::string& buf);