From 58ca52080970236afb8e525a519d7f2ad9f1d2e5 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Mon, 9 Jul 2018 13:01:25 +0200 Subject: [PATCH 1/5] .clang-format added --- .clang-format | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..3fa41ba --- /dev/null +++ b/.clang-format @@ -0,0 +1,115 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: true + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Linux +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 100 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: false +IndentPPDirectives: None +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +RawStringFormats: + - Delimiter: pb + Language: TextProto + BasedOnStyle: google +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 8 +UseTab: Never +... + From 0b0e754b4908ec8ed124158d541cb83c85c1036a Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Mon, 9 Jul 2018 13:02:00 +0200 Subject: [PATCH 2/5] launch.json added --- .vscode/launch.json | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..17dfcc6 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,27 @@ +{ + // Verwendet IntelliSense zum Ermitteln möglicher Attribute. + // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen. + // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "(gdb) Launch", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/bin/kima2", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": true, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file From 7a6c664014d044b85e3501fc508e2c59c680c270 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Mon, 9 Jul 2018 13:03:03 +0200 Subject: [PATCH 3/5] Code beautifying --- src/core/database.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/core/database.cpp b/src/core/database.cpp index b017565..1ad5f43 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -5,20 +5,17 @@ Database::Database(const std::string& dbname) : db(nullptr) { const int errCode = sqlite3_open(dbname.c_str(), &db); - if(errCode) { + if (errCode) { throw std::runtime_error("Could not open database file."); } } -Database::~Database() -{ - sqlite3_close(db); -} +Database::~Database() { sqlite3_close(db); } void Database::exec(const std::string& sql) { const int errCode = sqlite3_exec(db, sql.c_str(), nullptr, nullptr, nullptr); - if(errCode) { + if (errCode) { throw std::runtime_error("Error in SQL execution."); } } \ No newline at end of file From 74b7f5f57f0ed2f572c779d92f1ebd9b143f0428 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Mon, 9 Jul 2018 13:03:25 +0200 Subject: [PATCH 4/5] uuid handling improved --- src/core/entity.cpp | 17 +++++++++++++++-- src/core/entity.h | 15 +++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/core/entity.cpp b/src/core/entity.cpp index 4c9ece5..ac48025 100644 --- a/src/core/entity.cpp +++ b/src/core/entity.cpp @@ -1,7 +1,20 @@ #include "entity.h" -#include +#include -Entity::Entity() : uuid(boost::uuids::random_generator()()) +#include +#include + +Entity::Entity() {} + +void Entity::createUuid() { + static boost::uuids::random_generator generator{}; + uuid = generator(); +} + +void Entity::createUuidFromString(const std::string& uuid_string) +{ + boost::uuids::string_generator generator{}; + uuid = generator(uuid_string); } \ No newline at end of file diff --git a/src/core/entity.h b/src/core/entity.h index e7afcbe..b36d9a3 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -7,12 +7,15 @@ class Entity { -public: + public: Entity(); - ~Entity(); - const boost::uuids::uuid& getUuid() {return uuid;}; -private: - boost::uuids::uuid uuid; + virtual ~Entity() = 0; + const boost::uuids::uuid& getUuid() { return uuid; }; + void createUuid(); + void createUuidFromString(const std::string& uuid_string); + + private: + boost::uuids::uuid uuid{}; }; -#endif //ENTITY_H \ No newline at end of file +#endif // ENTITY_H \ No newline at end of file From c1fa3cb404874582f86fe7562e975cbabacc5094 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Mon, 9 Jul 2018 13:03:43 +0200 Subject: [PATCH 5/5] ... --- src/gui/kima2.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kima2.cpp b/src/gui/kima2.cpp index bc69ee4..78ae9c1 100644 --- a/src/gui/kima2.cpp +++ b/src/gui/kima2.cpp @@ -1,7 +1,10 @@ +#include "../core/entity.h" +#include +#include int main() { - /* code */ + return 0; }