-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaveLoad.cpp
More file actions
94 lines (76 loc) · 2.6 KB
/
saveLoad.cpp
File metadata and controls
94 lines (76 loc) · 2.6 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//Save and Load for Spring 2020 CSCI 221 Deadline Project
//(Serialize and Deserialize)
//Made by Mathew Nitz
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/vector.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
using namespace std;
// map<string, string> myMapPersonal;
// map<string, string> myMapClass;
// map<string, string> myMapPersonalHidden;
// map<string, string> myMapClassHidden;
// template <typename T, typename S>
// ostream& operator<<(ostream& os, const map<T, S>& v)
// {
// for (auto it : v)
// os << it.first << " , "
// << it.second << "\n";
// return os;
// }
void saveDeadlines()
{
//personal
ofstream ofile0((string)getenv("HOME") + "/personal.deadline");
boost::archive::text_oarchive oa0(ofile0);
oa0 << myMapPersonal;
//personal hidden
ofstream ofile1((string)getenv("HOME") + "/personalhidden.deadline");
boost::archive::text_oarchive oa1(ofile1);
oa1 << myMapPersonalHidden;
//class
ofstream ofile2("/var/lib/deadline/class.deadline");
boost::archive::text_oarchive oa2(ofile2);
oa2 << myMapClass;
//class hidden
ofstream ofile3("/var/lib/deadline/classhidden.deadline");
boost::archive::text_oarchive oa3(ofile3);
oa3 << myMapClassHidden;
}
void loadDeadlines()
{
//personal
ifstream file0((string)getenv("HOME") + "/personal.deadline");
boost::archive::text_iarchive ia0(file0);
ia0 >> myMapPersonal;
// cout << "Personal Deadlines:\n" << myMapPersonal << endl;
//personal hidden
ifstream file1((string)getenv("HOME") + "/personalhidden.deadline");
boost::archive::text_iarchive ia1(file1);
ia1 >> myMapPersonalHidden;
// cout << "Personal Hidden Deadlines:\n" << myMapPersonalHidden << endl;
//class
ifstream file2("/var/lib/deadline/class.deadline");
boost::archive::text_iarchive ia2(file2);
ia2 >> myMapClass;
// cout << "Class Deadlines:\n" << myMapClass << endl;
//class hidden
ifstream file3("/var/lib/deadline/classhidden.deadline");
boost::archive::text_iarchive ia3(file3);
ia3 >> myMapClassHidden;
// cout << "Class Hidden Deadlines:\n" << myMapClassHidden << endl;
}
int main()
{
// myMapPersonal.insert(pair<string, string>("Walk the dog", "2020-05-24 16:35"));
// myMapPersonalHidden.insert(pair<string, string>("Hide the dog", "2020-05-24 16:35"));
// myMapClass.insert(pair<string, string>("Class Project", "2020-05-24 16:35"));
// myMapClassHidden.insert(pair<string, string>("Hidden Class Project", "2020-05-24 16:35"));
saveDeadlines();
loadDeadlines();
}