Update .clang-format style.

- Add IndentWidth to 4
- Apply new .clang-format style
This commit is contained in:
realaltffour 2020-04-11 14:13:24 +03:00
parent c87e54c568
commit 13b59e6bef
No known key found for this signature in database
GPG Key ID: 7115CD2AC9A76A56
9 changed files with 17320 additions and 16938 deletions

View File

@ -33,6 +33,7 @@ SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false' SpacesInSquareBrackets: 'false'
Standard: Auto Standard: Auto
TabWidth: '4' TabWidth: '4'
IndentWidth: '4'
UseTab: Always UseTab: Always
... ...

View File

@ -3,6 +3,6 @@
mkdir build mkdir build
cd build cd build
conan install .. --build missing conan install .. --build missing
cmake -DCMAKE_BUILD_TYPE=Debug .. cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_BUILD_TYPE=Debug ..
make -j9 make -j9
cd .. cd ..

View File

@ -3,6 +3,6 @@
mkdir build mkdir build
cd build cd build
conan install .. --build missing conan install .. --build missing
cmake -DCMAKE_BUILD_TYPE=Release .. cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_BUILD_TYPE=Release ..
make -j9 make -j9
cd .. cd ..

View File

@ -1,72 +1,72 @@
#include "data.h" #include "data.h"
void to_json(json& j, const Date& date) { 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) { void from_json(const json& j, Date& date) {
j.at("day").get_to(date.day); j.at("day").get_to(date.day);
j.at("month").get_to(date.month); j.at("month").get_to(date.month);
j.at("year").get_to(date.year); j.at("year").get_to(date.year);
} }
void to_json(json& j, const Project& proj) { void to_json(json& j, const Project& proj) {
j = json{{"name", proj.name}, j = json{{"name", proj.name},
{"desc", proj.desc}, {"desc", proj.desc},
{"uuid", proj.uuid}, {"uuid", proj.uuid},
{"pri", proj.pri}, {"pri", proj.pri},
{"creationDate", proj.creationDate}, {"creationDate", proj.creationDate},
{"doneDate", proj.doneDate}, {"doneDate", proj.doneDate},
{"isDone", proj.isDone}}; {"isDone", proj.isDone}};
} }
void from_json(const json& j, Project& proj) { void from_json(const json& j, Project& proj) {
j.at("name").get_to(proj.name); j.at("name").get_to(proj.name);
j.at("desc").get_to(proj.desc); j.at("desc").get_to(proj.desc);
j.at("uuid").get_to(proj.uuid); j.at("uuid").get_to(proj.uuid);
j.at("pri").get_to(proj.pri); j.at("pri").get_to(proj.pri);
j.at("creationDate").get_to(proj.creationDate); j.at("creationDate").get_to(proj.creationDate);
j.at("doneDate").get_to(proj.doneDate); j.at("doneDate").get_to(proj.doneDate);
j.at("isDone").get_to(proj.isDone); j.at("isDone").get_to(proj.isDone);
} }
void to_json(json& j, const Skid& skid) { void to_json(json& j, const Skid& skid) {
j = json{ j = json{
{"projects", *skid.projects}, {"projects", *skid.projects},
{"creationDate", skid.creationDate}, {"creationDate", skid.creationDate},
}; };
} }
void from_json(const json& j, Skid& skid) { void from_json(const json& j, Skid& skid) {
j.at("projects").get_to(*skid.projects); j.at("projects").get_to(*skid.projects);
j.at("creationDate").get_to(skid.creationDate); j.at("creationDate").get_to(skid.creationDate);
} }
void to_json(json& j, const DB& db) { void to_json(json& j, const DB& db) {
j = json{{"projects", *db.projects}, j = json{{"projects", *db.projects},
{"creationDate", db.creationDate}, {"creationDate", db.creationDate},
{"lastAccessTime", db.lastAccessTime}}; {"lastAccessTime", db.lastAccessTime}};
} }
void from_json(const json& j, DB& db) { void from_json(const json& j, DB& db) {
j.at("projects").get_to(*db.projects); j.at("projects").get_to(*db.projects);
j.at("creationDate").get_to(db.creationDate); j.at("creationDate").get_to(db.creationDate);
j.at("lastAccessTime").get_to(db.lastAccessTime); j.at("lastAccessTime").get_to(db.lastAccessTime);
} }
void writeDB(DB db, const std::string& dest) { void writeDB(DB db, const std::string& dest) {
try { try {
std::ofstream f(dest); std::ofstream f(dest);
json j = db; json j = db;
std::cout << "hello" << std::endl; std::cout << "hello" << std::endl;
f << j; f << j;
} catch(std::exception& ex) { } catch(std::exception& ex) {
std::cout << "Failed writing database to: " << dest << std::endl; std::cout << "Failed writing database to: " << dest << std::endl;
std::cout << "Error: " << ex.what() << std::endl; std::cout << "Error: " << ex.what() << std::endl;
} }
} }
void loadDB(DB& db, const std::string& src) { void loadDB(DB& db, const std::string& src) {
try { try {
std::ifstream f(src); std::ifstream f(src);
json j; json j;
f >> j; f >> j;
db = j; db = j;
} catch(const std::exception& ex) { } catch(const std::exception& ex) {
std::cout << "Failed loading database from: " << src << std::endl; std::cout << "Failed loading database from: " << src << std::endl;
std::cout << "Error: " << ex.what() << std::endl; std::cout << "Error: " << ex.what() << std::endl;
} }
} }

View File

@ -17,24 +17,24 @@ using nlohmann::json;
/////////////// DATA CONTAINING STRUCTURES /////////////////// /////////////// DATA CONTAINING STRUCTURES ///////////////////
struct Date { struct Date {
int day = 0; int day = 0;
int month = 0; // 0-11 int month = 0; // 0-11
int year = 0; // + 1900 for currentyear int year = 0; // + 1900 for currentyear
}; };
struct Project { struct Project {
std::string name = ""; std::string name = "";
std::string desc = ""; std::string desc = "";
std::string uuid; std::string uuid;
int pri = 0; int pri = 0;
Date creationDate; Date creationDate;
Date doneDate; Date doneDate;
bool isDone = false; bool isDone = false;
}; };
struct Skid { struct Skid {
std::vector<Project>* projects = {}; std::vector<Project>* projects = {};
Date creationDate; Date creationDate;
}; };
/////////////// END OF DATA CONTAINING STRUCTURES //////////// /////////////// END OF DATA CONTAINING STRUCTURES ////////////
@ -44,26 +44,26 @@ struct Skid {
enum EventType { Access = 0, Creation = 1, Modification = 2, None = -1 }; enum EventType { Access = 0, Creation = 1, Modification = 2, None = -1 };
struct Event { struct Event {
int id = -1; int id = -1;
EventType type = EventType::None; EventType type = EventType::None;
std::string mesg = ""; std::string mesg = "";
}; };
struct EventLog { struct EventLog {
std::vector<Event>* events; std::vector<Event>* events;
std::string sha512 = ""; std::string sha512 = "";
}; };
/////////////// EVENT END OF HISTORY SYSTEM STRUCTURES ///////////// /////////////// EVENT END OF HISTORY SYSTEM STRUCTURES /////////////
// Main Database that represents the skidjular directory. // Main Database that represents the skidjular directory.
struct DB { struct DB {
std::map<std::string, Project>* projects; std::map<std::string, Project>* projects;
std::vector<Skid> skids; std::vector<Skid> skids;
EventLog log; EventLog log;
Date creationDate; Date creationDate;
Date lastAccessTime; Date lastAccessTime;
}; };
////////////// Utilities for the Database structure //////////////// ////////////// Utilities for the Database structure ////////////////

View File

@ -8,62 +8,63 @@
#include "modules/init.h" #include "modules/init.h"
Module* get_Mod(std::string name) { Module* get_Mod(std::string name) {
return nullptr; if(true) {}
return nullptr;
}; };
void dispatch_Mod(Module* mod, std::string args){}; void dispatch_Mod(Module* mod, std::string args){};
int main(int argc, const char* argv[]) { int main(int argc, const char* argv[]) {
using namespace boost::program_options; using namespace boost::program_options;
using namespace std; using namespace std;
try { try {
options_description general("General Options"); options_description general("General Options");
general.add_options()("help", "Help Message")( general.add_options()("help", "Help Message")(
"help-module", value<string>(), "Module for help message")( "help-module", value<string>(), "Module for help message")(
"module", value<string>(), "Module to execute")( "module", value<string>(), "Module to execute")(
"module-args", value<string>(), "Arguments to use"); "module-args", value<string>(), "Arguments to use");
positional_options_description general_positional; positional_options_description general_positional;
general_positional.add("module", 1); general_positional.add("module", 1);
general_positional.add("module-args", 10); general_positional.add("module-args", 10);
variables_map vm; variables_map vm;
store(command_line_parser(argc, argv) store(command_line_parser(argc, argv)
.options(general) .options(general)
.allow_unregistered() .allow_unregistered()
.positional(general_positional) .positional(general_positional)
.run(), .run(),
vm); vm);
notify(vm); notify(vm);
if(vm.count("help")) { if(vm.count("help")) {
std::cout << general << "\n"; std::cout << general << "\n";
exit(0); exit(0);
} else if(vm.count("help-module")) { } else if(vm.count("help-module")) {
auto name = vm["help-module"].as<string>(); auto name = vm["help-module"].as<string>();
auto module = get_Mod(name); auto module = get_Mod(name);
if(!module) { if(!module) {
std::cout << "Module not found.\n"; std::cout << "Module not found.\n";
exit(1); exit(1);
} }
std::cout << module->desc << "\n"; std::cout << module->desc << "\n";
} else if(vm.count("module")) { } else if(vm.count("module")) {
auto name = vm["module"].as<string>(); auto name = vm["module"].as<string>();
auto module = get_Mod(name); auto module = get_Mod(name);
if(!module) { if(!module) {
std::cout << "Module not found.\n"; std::cout << "Module not found.\n";
exit(1); exit(1);
} }
if(vm.count("module-args")) { if(vm.count("module-args")) {
auto args = vm["module-args"].as<string>(); auto args = vm["module-args"].as<string>();
dispatch_Mod(module, args); dispatch_Mod(module, args);
} else } else
dispatch_Mod(module, ""); dispatch_Mod(module, "");
} else { } else {
std::cout << general << "\n"; std::cout << general << "\n";
exit(0); exit(0);
} }
} catch(const error& ex) { cerr << ex.what() << '\n'; } } catch(const error& ex) { cerr << ex.what() << '\n'; }
return 0; return 0;
} }

View File

@ -9,9 +9,9 @@ using ModuleFn = std::function<void(std::string arguments)>;
using ModuleFnDispatcher = std::function<void(std::string arguments)>; using ModuleFnDispatcher = std::function<void(std::string arguments)>;
struct Module { struct Module {
std::string name; std::string name;
std::string desc; std::string desc;
std::map<std::string, ModuleFn> funcs; std::map<std::string, ModuleFn> funcs;
}; };
#endif #endif

View File

@ -3,35 +3,35 @@
#include "../data.h" #include "../data.h"
void init_create(init_args arg) { void init_create(init_args arg) {
std::cout << "Creating database in current directory." << std::endl; std::cout << "Creating database in current directory." << std::endl;
DB db; DB db;
time_t t = time(0); time_t t = time(0);
struct tm* currentTime = localtime(&t); struct tm* currentTime = localtime(&t);
db.creationDate.day = currentTime->tm_mday; db.creationDate.day = currentTime->tm_mday;
db.creationDate.month = currentTime->tm_mon; db.creationDate.month = currentTime->tm_mon;
db.creationDate.year = currentTime->tm_year; db.creationDate.year = currentTime->tm_year;
db.lastAccessTime.day = currentTime->tm_mday; db.lastAccessTime.day = currentTime->tm_mday;
db.lastAccessTime.month = currentTime->tm_mon; db.lastAccessTime.month = currentTime->tm_mon;
db.lastAccessTime.year = currentTime->tm_year; db.lastAccessTime.year = currentTime->tm_year;
// Mandatory stuff to stop segmantion fault due to // Mandatory stuff to stop segmantion fault due to
// pointers unintialized. // pointers unintialized.
db.projects = new std::map<std::string, Project>(); db.projects = new std::map<std::string, Project>();
db.log.events = new std::vector<Event>(); db.log.events = new std::vector<Event>();
// TODO: Add event logging // TODO: Add event logging
writeDB(db, ".db"); writeDB(db, ".db");
} }
void init_dispatch() { void init_dispatch() {
init_args arg; init_args arg;
init_create(arg); init_create(arg);
} }
init_mod init_new() { init_mod init_new() {
init_mod mod; init_mod mod;
mod.name = "Init"; mod.name = "Init";
mod.desc = "Creates skidjular directory in $(pwd)"; mod.desc = "Creates skidjular directory in $(pwd)";
return mod; return mod;
} }

33964
vendor/json.hpp vendored

File diff suppressed because it is too large Load Diff