Use linked list with push front for logs
This commit is contained in:
parent
3a0d35da65
commit
aa4d661f66
|
@ -2,6 +2,7 @@
|
|||
#define DATA_H
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -50,7 +51,7 @@ struct Entry {
|
|||
};
|
||||
|
||||
struct Log {
|
||||
std::vector<Entry>* entries = nullptr;
|
||||
std::list<Entry>* entries = nullptr;
|
||||
};
|
||||
|
||||
/////////////// EVENT END OF HISTORY SYSTEM STRUCTURES /////////////
|
||||
|
|
|
@ -26,8 +26,8 @@ void logEntry(const std::string& msg, EntryType type) {
|
|||
ev.creationDate.year = currentTime->tm_year + 1900;
|
||||
|
||||
if (!s_log.entries)
|
||||
s_log.entries = new std::vector<Entry>();
|
||||
s_log.entries->push_back(ev);
|
||||
s_log.entries = new std::list<Entry>();
|
||||
s_log.entries->push_front(ev);
|
||||
}
|
||||
|
||||
void writeLog(const std::string& loc, bool append) {
|
||||
|
|
|
@ -18,7 +18,7 @@ void init_create(init_args arg) {
|
|||
// Mandatory stuff to stop segmantion fault due to
|
||||
// pointers unintialized.
|
||||
db.projects = new std::map<std::string, Project>();
|
||||
db.log.entries = new std::vector<Entry>();
|
||||
db.log.entries = new std::list<Entry>();
|
||||
|
||||
logEntry("Creating database.", EntryType::Creation);
|
||||
writeDB(db, ".db");
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <time.h>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include "../data.h"
|
||||
|
|
Loading…
Reference in New Issue