Add init module.

- Update .clang-format's IndentWidth
- Apply new .clang-format.
- Add init module.
This commit is contained in:
realaltffour 2020-04-11 16:02:29 +03:00
parent 13b59e6bef
commit b1008403bb
No known key found for this signature in database
GPG Key ID: 7115CD2AC9A76A56
6 changed files with 883 additions and 873 deletions

View File

@ -22,7 +22,7 @@ ColumnLimit: '80'
CompactNamespaces: 'true'
IncludeBlocks: Preserve
IndentWidth: '2'
SpaceBeforeParens: Never
SpaceBeforeParens: 'ControlStatements'
SpaceBeforeRangeBasedForLoopColon: 'false'
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: '1'

View File

@ -51,7 +51,6 @@ 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;

View File

@ -8,10 +8,16 @@
#include "modules/init.h"
Module* get_Mod(std::string name) {
if(true) {}
if (name == "init") {
return init_new();
}
return nullptr;
};
void dispatch_Mod(Module* mod, std::string args){};
void dispatch_Mod(std::string mod, std::string args) {
if (mod == "init") {
init_dispatch(args);
}
};
int main(int argc, const char* argv[]) {
using namespace boost::program_options;
@ -49,16 +55,15 @@ int main(int argc, const char* argv[]) {
std::cout << module->desc << "\n";
} else if (vm.count("module")) {
auto name = vm["module"].as<string>();
auto module = get_Mod(name);
if(!module) {
if (!get_Mod(name)) {
std::cout << "Module not found.\n";
exit(1);
}
if (vm.count("module-args")) {
auto args = vm["module-args"].as<string>();
dispatch_Mod(module, args);
dispatch_Mod(name, args);
} else
dispatch_Mod(module, "");
dispatch_Mod(name, "");
} else {
std::cout << general << "\n";
exit(0);

View File

@ -24,14 +24,14 @@ void init_create(init_args arg) {
writeDB(db, ".db");
}
void init_dispatch() {
void init_dispatch(std::string arguments) {
init_args arg;
init_create(arg);
}
init_mod init_new() {
init_mod mod;
mod.name = "Init";
mod.desc = "Creates skidjular directory in $(pwd)";
init_mod* init_new() {
init_mod* mod = new init_mod{};
mod->name = "Init";
mod->desc = "Creates skidjular directory in $(pwd)";
return mod;
}

View File

@ -11,7 +11,7 @@
struct init_args {};
struct init_mod : init_args, Module {};
init_mod init_new();
init_mod* init_new();
void init_create(init_args arg);
void init_dispatch(std::string arguments);

30
vendor/json.hpp vendored
View File

@ -5438,7 +5438,8 @@ class binary_reader {
get();
}
if(JSON_HEDLEY_UNLIKELY(current != std::char_traits<char>::eof())) {
if (JSON_HEDLEY_UNLIKELY(current !=
std::char_traits<char>::eof())) {
return sax->parse_error(
chars_read, get_token_string(),
parse_error::create(
@ -7616,7 +7617,8 @@ class lexer {
get() == 'u')) {
const int codepoint2 = get_codepoint();
if(JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) {
if (JSON_HEDLEY_UNLIKELY(codepoint2 ==
-1)) {
error_message = "invalid string: '\\u' "
"must be followed by "
"4 hex digits";
@ -7660,7 +7662,8 @@ class lexer {
return token_type::parse_error;
}
} else {
if(JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and
if (JSON_HEDLEY_UNLIKELY(
0xDC00 <= codepoint1 and
codepoint1 <= 0xDFFF)) {
error_message =
"invalid string: surrogate "
@ -8103,8 +8106,8 @@ class lexer {
// U+0800..U+0FFF: bytes E0 A0..BF 80..BF
case 0xE0: {
if(JSON_HEDLEY_UNLIKELY(
not(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) {
if (JSON_HEDLEY_UNLIKELY(not(
next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) {
return token_type::parse_error;
}
break;
@ -8126,8 +8129,8 @@ class lexer {
case 0xEC:
case 0xEE:
case 0xEF: {
if(JSON_HEDLEY_UNLIKELY(
not(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) {
if (JSON_HEDLEY_UNLIKELY(not(
next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) {
return token_type::parse_error;
}
break;
@ -8135,8 +8138,8 @@ class lexer {
// U+D000..U+D7FF: bytes ED 80..9F 80..BF
case 0xED: {
if(JSON_HEDLEY_UNLIKELY(
not(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) {
if (JSON_HEDLEY_UNLIKELY(not(
next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) {
return token_type::parse_error;
}
break;
@ -11565,7 +11568,8 @@ class binary_writer {
write_number(
static_cast<std::int8_t>(j.m_value.number_integer));
} else if (j.m_value.number_integer >=
(std::numeric_limits<std::int16_t>::min)() and
(std::numeric_limits<
std::int16_t>::min)() and
j.m_value.number_integer <=
(std::numeric_limits<std::int16_t>::max)()) {
// int 16
@ -11573,7 +11577,8 @@ class binary_writer {
write_number(static_cast<std::int16_t>(
j.m_value.number_integer));
} else if (j.m_value.number_integer >=
(std::numeric_limits<std::int32_t>::min)() and
(std::numeric_limits<
std::int32_t>::min)() and
j.m_value.number_integer <=
(std::numeric_limits<std::int32_t>::max)()) {
// int 32
@ -11581,7 +11586,8 @@ class binary_writer {
write_number(static_cast<std::int32_t>(
j.m_value.number_integer));
} else if (j.m_value.number_integer >=
(std::numeric_limits<std::int64_t>::min)() and
(std::numeric_limits<
std::int64_t>::min)() and
j.m_value.number_integer <=
(std::numeric_limits<std::int64_t>::max)()) {
// int 64