Update .clang-format style.
- Add IndentWidth to 4 - Apply new .clang-format style
This commit is contained in:
parent
c87e54c568
commit
13b59e6bef
|
@ -33,6 +33,7 @@ SpacesInParentheses: 'false'
|
|||
SpacesInSquareBrackets: 'false'
|
||||
Standard: Auto
|
||||
TabWidth: '4'
|
||||
IndentWidth: '4'
|
||||
UseTab: Always
|
||||
|
||||
...
|
||||
|
|
2
build.sh
2
build.sh
|
@ -3,6 +3,6 @@
|
|||
mkdir build
|
||||
cd build
|
||||
conan install .. --build missing
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_BUILD_TYPE=Debug ..
|
||||
make -j9
|
||||
cd ..
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
mkdir build
|
||||
cd build
|
||||
conan install .. --build missing
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_BUILD_TYPE=Release ..
|
||||
make -j9
|
||||
cd ..
|
||||
|
|
96
src/data.cpp
96
src/data.cpp
|
@ -1,72 +1,72 @@
|
|||
#include "data.h"
|
||||
|
||||
void to_json(json& j, const Date& date) {
|
||||
j = json{{"day", date.day}, {"month", date.day}, {"year", date.year}};
|
||||
j = json{{"day", date.day}, {"month", date.day}, {"year", date.year}};
|
||||
}
|
||||
void from_json(const json& j, Date& date) {
|
||||
j.at("day").get_to(date.day);
|
||||
j.at("month").get_to(date.month);
|
||||
j.at("year").get_to(date.year);
|
||||
j.at("day").get_to(date.day);
|
||||
j.at("month").get_to(date.month);
|
||||
j.at("year").get_to(date.year);
|
||||
}
|
||||
void to_json(json& j, const Project& proj) {
|
||||
j = json{{"name", proj.name},
|
||||
{"desc", proj.desc},
|
||||
{"uuid", proj.uuid},
|
||||
{"pri", proj.pri},
|
||||
{"creationDate", proj.creationDate},
|
||||
{"doneDate", proj.doneDate},
|
||||
{"isDone", proj.isDone}};
|
||||
j = json{{"name", proj.name},
|
||||
{"desc", proj.desc},
|
||||
{"uuid", proj.uuid},
|
||||
{"pri", proj.pri},
|
||||
{"creationDate", proj.creationDate},
|
||||
{"doneDate", proj.doneDate},
|
||||
{"isDone", proj.isDone}};
|
||||
}
|
||||
void from_json(const json& j, Project& proj) {
|
||||
j.at("name").get_to(proj.name);
|
||||
j.at("desc").get_to(proj.desc);
|
||||
j.at("uuid").get_to(proj.uuid);
|
||||
j.at("pri").get_to(proj.pri);
|
||||
j.at("creationDate").get_to(proj.creationDate);
|
||||
j.at("doneDate").get_to(proj.doneDate);
|
||||
j.at("isDone").get_to(proj.isDone);
|
||||
j.at("name").get_to(proj.name);
|
||||
j.at("desc").get_to(proj.desc);
|
||||
j.at("uuid").get_to(proj.uuid);
|
||||
j.at("pri").get_to(proj.pri);
|
||||
j.at("creationDate").get_to(proj.creationDate);
|
||||
j.at("doneDate").get_to(proj.doneDate);
|
||||
j.at("isDone").get_to(proj.isDone);
|
||||
}
|
||||
void to_json(json& j, const Skid& skid) {
|
||||
j = json{
|
||||
{"projects", *skid.projects},
|
||||
{"creationDate", skid.creationDate},
|
||||
};
|
||||
j = json{
|
||||
{"projects", *skid.projects},
|
||||
{"creationDate", skid.creationDate},
|
||||
};
|
||||
}
|
||||
void from_json(const json& j, Skid& skid) {
|
||||
j.at("projects").get_to(*skid.projects);
|
||||
j.at("creationDate").get_to(skid.creationDate);
|
||||
j.at("projects").get_to(*skid.projects);
|
||||
j.at("creationDate").get_to(skid.creationDate);
|
||||
}
|
||||
void to_json(json& j, const DB& db) {
|
||||
j = json{{"projects", *db.projects},
|
||||
{"creationDate", db.creationDate},
|
||||
{"lastAccessTime", db.lastAccessTime}};
|
||||
j = json{{"projects", *db.projects},
|
||||
{"creationDate", db.creationDate},
|
||||
{"lastAccessTime", db.lastAccessTime}};
|
||||
}
|
||||
void from_json(const json& j, DB& db) {
|
||||
j.at("projects").get_to(*db.projects);
|
||||
j.at("creationDate").get_to(db.creationDate);
|
||||
j.at("lastAccessTime").get_to(db.lastAccessTime);
|
||||
j.at("projects").get_to(*db.projects);
|
||||
j.at("creationDate").get_to(db.creationDate);
|
||||
j.at("lastAccessTime").get_to(db.lastAccessTime);
|
||||
}
|
||||
|
||||
void writeDB(DB db, const std::string& dest) {
|
||||
try {
|
||||
std::ofstream f(dest);
|
||||
json j = db;
|
||||
std::cout << "hello" << std::endl;
|
||||
f << j;
|
||||
} catch(std::exception& ex) {
|
||||
std::cout << "Failed writing database to: " << dest << std::endl;
|
||||
std::cout << "Error: " << ex.what() << std::endl;
|
||||
}
|
||||
try {
|
||||
std::ofstream f(dest);
|
||||
json j = db;
|
||||
std::cout << "hello" << std::endl;
|
||||
f << j;
|
||||
} catch(std::exception& ex) {
|
||||
std::cout << "Failed writing database to: " << dest << std::endl;
|
||||
std::cout << "Error: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void loadDB(DB& db, const std::string& src) {
|
||||
try {
|
||||
std::ifstream f(src);
|
||||
json j;
|
||||
f >> j;
|
||||
db = j;
|
||||
} catch(const std::exception& ex) {
|
||||
std::cout << "Failed loading database from: " << src << std::endl;
|
||||
std::cout << "Error: " << ex.what() << std::endl;
|
||||
}
|
||||
try {
|
||||
std::ifstream f(src);
|
||||
json j;
|
||||
f >> j;
|
||||
db = j;
|
||||
} catch(const std::exception& ex) {
|
||||
std::cout << "Failed loading database from: " << src << std::endl;
|
||||
std::cout << "Error: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
44
src/data.h
44
src/data.h
|
@ -17,24 +17,24 @@ using nlohmann::json;
|
|||
/////////////// DATA CONTAINING STRUCTURES ///////////////////
|
||||
|
||||
struct Date {
|
||||
int day = 0;
|
||||
int month = 0; // 0-11
|
||||
int year = 0; // + 1900 for currentyear
|
||||
int day = 0;
|
||||
int month = 0; // 0-11
|
||||
int year = 0; // + 1900 for currentyear
|
||||
};
|
||||
|
||||
struct Project {
|
||||
std::string name = "";
|
||||
std::string desc = "";
|
||||
std::string uuid;
|
||||
int pri = 0;
|
||||
Date creationDate;
|
||||
Date doneDate;
|
||||
bool isDone = false;
|
||||
std::string name = "";
|
||||
std::string desc = "";
|
||||
std::string uuid;
|
||||
int pri = 0;
|
||||
Date creationDate;
|
||||
Date doneDate;
|
||||
bool isDone = false;
|
||||
};
|
||||
|
||||
struct Skid {
|
||||
std::vector<Project>* projects = {};
|
||||
Date creationDate;
|
||||
std::vector<Project>* projects = {};
|
||||
Date creationDate;
|
||||
};
|
||||
|
||||
/////////////// END OF DATA CONTAINING STRUCTURES ////////////
|
||||
|
@ -44,26 +44,26 @@ struct Skid {
|
|||
enum EventType { Access = 0, Creation = 1, Modification = 2, None = -1 };
|
||||
|
||||
struct Event {
|
||||
int id = -1;
|
||||
EventType type = EventType::None;
|
||||
std::string mesg = "";
|
||||
int id = -1;
|
||||
EventType type = EventType::None;
|
||||
std::string mesg = "";
|
||||
};
|
||||
|
||||
struct EventLog {
|
||||
std::vector<Event>* events;
|
||||
std::string sha512 = "";
|
||||
std::vector<Event>* events;
|
||||
std::string sha512 = "";
|
||||
};
|
||||
|
||||
/////////////// EVENT END OF HISTORY SYSTEM STRUCTURES /////////////
|
||||
|
||||
// Main Database that represents the skidjular directory.
|
||||
struct DB {
|
||||
std::map<std::string, Project>* projects;
|
||||
std::vector<Skid> skids;
|
||||
EventLog log;
|
||||
std::map<std::string, Project>* projects;
|
||||
std::vector<Skid> skids;
|
||||
EventLog log;
|
||||
|
||||
Date creationDate;
|
||||
Date lastAccessTime;
|
||||
Date creationDate;
|
||||
Date lastAccessTime;
|
||||
};
|
||||
|
||||
////////////// Utilities for the Database structure ////////////////
|
||||
|
|
99
src/main.cpp
99
src/main.cpp
|
@ -8,62 +8,63 @@
|
|||
#include "modules/init.h"
|
||||
|
||||
Module* get_Mod(std::string name) {
|
||||
return nullptr;
|
||||
if(true) {}
|
||||
return nullptr;
|
||||
};
|
||||
void dispatch_Mod(Module* mod, std::string args){};
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
using namespace boost::program_options;
|
||||
using namespace std;
|
||||
using namespace boost::program_options;
|
||||
using namespace std;
|
||||
|
||||
try {
|
||||
options_description general("General Options");
|
||||
general.add_options()("help", "Help Message")(
|
||||
"help-module", value<string>(), "Module for help message")(
|
||||
"module", value<string>(), "Module to execute")(
|
||||
"module-args", value<string>(), "Arguments to use");
|
||||
positional_options_description general_positional;
|
||||
general_positional.add("module", 1);
|
||||
general_positional.add("module-args", 10);
|
||||
try {
|
||||
options_description general("General Options");
|
||||
general.add_options()("help", "Help Message")(
|
||||
"help-module", value<string>(), "Module for help message")(
|
||||
"module", value<string>(), "Module to execute")(
|
||||
"module-args", value<string>(), "Arguments to use");
|
||||
positional_options_description general_positional;
|
||||
general_positional.add("module", 1);
|
||||
general_positional.add("module-args", 10);
|
||||
|
||||
variables_map vm;
|
||||
store(command_line_parser(argc, argv)
|
||||
.options(general)
|
||||
.allow_unregistered()
|
||||
.positional(general_positional)
|
||||
.run(),
|
||||
vm);
|
||||
notify(vm);
|
||||
variables_map vm;
|
||||
store(command_line_parser(argc, argv)
|
||||
.options(general)
|
||||
.allow_unregistered()
|
||||
.positional(general_positional)
|
||||
.run(),
|
||||
vm);
|
||||
notify(vm);
|
||||
|
||||
if(vm.count("help")) {
|
||||
std::cout << general << "\n";
|
||||
exit(0);
|
||||
} else if(vm.count("help-module")) {
|
||||
auto name = vm["help-module"].as<string>();
|
||||
auto module = get_Mod(name);
|
||||
if(!module) {
|
||||
std::cout << "Module not found.\n";
|
||||
exit(1);
|
||||
}
|
||||
std::cout << module->desc << "\n";
|
||||
} else if(vm.count("module")) {
|
||||
auto name = vm["module"].as<string>();
|
||||
auto module = get_Mod(name);
|
||||
if(!module) {
|
||||
std::cout << "Module not found.\n";
|
||||
exit(1);
|
||||
}
|
||||
if(vm.count("module-args")) {
|
||||
auto args = vm["module-args"].as<string>();
|
||||
dispatch_Mod(module, args);
|
||||
} else
|
||||
dispatch_Mod(module, "");
|
||||
} else {
|
||||
std::cout << general << "\n";
|
||||
exit(0);
|
||||
}
|
||||
if(vm.count("help")) {
|
||||
std::cout << general << "\n";
|
||||
exit(0);
|
||||
} else if(vm.count("help-module")) {
|
||||
auto name = vm["help-module"].as<string>();
|
||||
auto module = get_Mod(name);
|
||||
if(!module) {
|
||||
std::cout << "Module not found.\n";
|
||||
exit(1);
|
||||
}
|
||||
std::cout << module->desc << "\n";
|
||||
} else if(vm.count("module")) {
|
||||
auto name = vm["module"].as<string>();
|
||||
auto module = get_Mod(name);
|
||||
if(!module) {
|
||||
std::cout << "Module not found.\n";
|
||||
exit(1);
|
||||
}
|
||||
if(vm.count("module-args")) {
|
||||
auto args = vm["module-args"].as<string>();
|
||||
dispatch_Mod(module, args);
|
||||
} else
|
||||
dispatch_Mod(module, "");
|
||||
} else {
|
||||
std::cout << general << "\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
} catch(const error& ex) { cerr << ex.what() << '\n'; }
|
||||
} catch(const error& ex) { cerr << ex.what() << '\n'; }
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ using ModuleFn = std::function<void(std::string arguments)>;
|
|||
using ModuleFnDispatcher = std::function<void(std::string arguments)>;
|
||||
|
||||
struct Module {
|
||||
std::string name;
|
||||
std::string desc;
|
||||
std::map<std::string, ModuleFn> funcs;
|
||||
std::string name;
|
||||
std::string desc;
|
||||
std::map<std::string, ModuleFn> funcs;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,35 +3,35 @@
|
|||
#include "../data.h"
|
||||
|
||||
void init_create(init_args arg) {
|
||||
std::cout << "Creating database in current directory." << std::endl;
|
||||
DB db;
|
||||
time_t t = time(0);
|
||||
struct tm* currentTime = localtime(&t);
|
||||
std::cout << "Creating database in current directory." << std::endl;
|
||||
DB db;
|
||||
time_t t = time(0);
|
||||
struct tm* currentTime = localtime(&t);
|
||||
|
||||
db.creationDate.day = currentTime->tm_mday;
|
||||
db.creationDate.month = currentTime->tm_mon;
|
||||
db.creationDate.year = currentTime->tm_year;
|
||||
db.lastAccessTime.day = currentTime->tm_mday;
|
||||
db.lastAccessTime.month = currentTime->tm_mon;
|
||||
db.lastAccessTime.year = currentTime->tm_year;
|
||||
db.creationDate.day = currentTime->tm_mday;
|
||||
db.creationDate.month = currentTime->tm_mon;
|
||||
db.creationDate.year = currentTime->tm_year;
|
||||
db.lastAccessTime.day = currentTime->tm_mday;
|
||||
db.lastAccessTime.month = currentTime->tm_mon;
|
||||
db.lastAccessTime.year = currentTime->tm_year;
|
||||
|
||||
// Mandatory stuff to stop segmantion fault due to
|
||||
// pointers unintialized.
|
||||
db.projects = new std::map<std::string, Project>();
|
||||
db.log.events = new std::vector<Event>();
|
||||
// Mandatory stuff to stop segmantion fault due to
|
||||
// pointers unintialized.
|
||||
db.projects = new std::map<std::string, Project>();
|
||||
db.log.events = new std::vector<Event>();
|
||||
|
||||
// TODO: Add event logging
|
||||
writeDB(db, ".db");
|
||||
// TODO: Add event logging
|
||||
writeDB(db, ".db");
|
||||
}
|
||||
|
||||
void init_dispatch() {
|
||||
init_args arg;
|
||||
init_create(arg);
|
||||
init_args arg;
|
||||
init_create(arg);
|
||||
}
|
||||
|
||||
init_mod init_new() {
|
||||
init_mod mod;
|
||||
mod.name = "Init";
|
||||
mod.desc = "Creates skidjular directory in $(pwd)";
|
||||
return mod;
|
||||
init_mod mod;
|
||||
mod.name = "Init";
|
||||
mod.desc = "Creates skidjular directory in $(pwd)";
|
||||
return mod;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue