Compare commits

...

5 commits

Author SHA1 Message Date
c1fa3cb404 ... 2018-07-09 13:03:43 +02:00
74b7f5f57f uuid handling improved 2018-07-09 13:03:25 +02:00
7a6c664014 Code beautifying 2018-07-09 13:03:03 +02:00
0b0e754b49 launch.json added 2018-07-09 13:02:00 +02:00
58ca520809 .clang-format added 2018-07-09 13:01:25 +02:00
6 changed files with 173 additions and 15 deletions

115
.clang-format Normal file
View file

@ -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
...

27
.vscode/launch.json vendored Normal file
View file

@ -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
}
]
}
]
}

View file

@ -5,20 +5,17 @@
Database::Database(const std::string& dbname) : db(nullptr) Database::Database(const std::string& dbname) : db(nullptr)
{ {
const int errCode = sqlite3_open(dbname.c_str(), &db); const int errCode = sqlite3_open(dbname.c_str(), &db);
if(errCode) { if (errCode) {
throw std::runtime_error("Could not open database file."); throw std::runtime_error("Could not open database file.");
} }
} }
Database::~Database() Database::~Database() { sqlite3_close(db); }
{
sqlite3_close(db);
}
void Database::exec(const std::string& sql) void Database::exec(const std::string& sql)
{ {
const int errCode = sqlite3_exec(db, sql.c_str(), nullptr, nullptr, nullptr); const int errCode = sqlite3_exec(db, sql.c_str(), nullptr, nullptr, nullptr);
if(errCode) { if (errCode) {
throw std::runtime_error("Error in SQL execution."); throw std::runtime_error("Error in SQL execution.");
} }
} }

View file

@ -1,7 +1,20 @@
#include "entity.h" #include "entity.h"
#include <boost/uuid/uuid_generators.hpp> #include <iostream>
Entity::Entity() : uuid(boost::uuids::random_generator()()) #include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
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);
} }

View file

@ -7,12 +7,15 @@
class Entity class Entity
{ {
public: public:
Entity(); Entity();
~Entity(); virtual ~Entity() = 0;
const boost::uuids::uuid& getUuid() {return uuid;}; const boost::uuids::uuid& getUuid() { return uuid; };
private: void createUuid();
boost::uuids::uuid uuid; void createUuidFromString(const std::string& uuid_string);
private:
boost::uuids::uuid uuid{};
}; };
#endif //ENTITY_H #endif // ENTITY_H

View file

@ -1,7 +1,10 @@
#include "../core/entity.h"
#include <iostream>
#include <boost/uuid/uuid_io.hpp>
int main() int main()
{ {
/* code */
return 0; return 0;
} }