From 3ca886675225b15ce263d16671f4fd53711e367d Mon Sep 17 00:00:00 2001 From: MoAlyousef Date: Wed, 9 Sep 2020 02:59:09 +0300 Subject: [PATCH] first commit --- .clang-format | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 3 +- CMakeLists.txt | 4 ++- cmake.toml | 13 ++++++++ src/main.cpp | 27 ++++++++++++++- 5 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 .clang-format create mode 100644 cmake.toml diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..66a8eb5 --- /dev/null +++ b/.clang-format @@ -0,0 +1,91 @@ +--- +Language: Cpp +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + 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: Attach +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +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 +IncludeBlocks: Preserve +IndentCaseLabels: false +IndentPPDirectives: None +IndentWidth: 4 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +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 +... diff --git a/.gitignore b/.gitignore index c5e82d7..2af4ba0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -bin \ No newline at end of file +bin +compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 994b4f0..e2f450b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,12 @@ cmake_minimum_required(VERSION 3.0) project(cmk) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + set(CMK_SRCS src/main.cpp ) add_executable(cmk ${CMK_SRCS}) - +target_compile_features(cmk PRIVATE cxx_std_17) target_include_directories(cmk PRIVATE ${CMAKE_CURRENT_LIST_DIR}/vendor) \ No newline at end of file diff --git a/cmake.toml b/cmake.toml new file mode 100644 index 0000000..f574dd9 --- /dev/null +++ b/cmake.toml @@ -0,0 +1,13 @@ +[cmake] +minimum_required = "3.0" + +[project] +name = "cmk" +version = "0.1.0" +authors = ["MoAlyousef "] + +[[executable]] +name = "cmk" +sources = ["src/main.cpp"] +include_directories = ["vendor"] +compile_features = ["cxx_std_17"] diff --git a/src/main.cpp b/src/main.cpp index c272dab..bcd9a47 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1 +1,26 @@ -int main() {} \ No newline at end of file +#include +#include +#include +#include + +int main(int argc, char **argv) try { + std::vector args; + for (int i = 0; i < argc; ++i) + args.push_back(argv[i]); + const auto data = toml::parse("../cmake.toml"); + const auto &cmake = toml::find(data, "cmake"); + const auto cmake_min = toml::find(cmake, "minimum_required"); + const auto &project = toml::find(data, "project"); + const auto name = toml::find(project, "name"); + const auto version = toml::find(project, "version"); + const auto &bin = toml::find(data, "executable"); + const auto bin1 = toml::find(bin, 0); + const auto bin1_name = toml::find(bin1, "name"); + std::cout << cmake_min << std::endl; + std::cout << name << std::endl; + std::cout << version << std::endl; + std::cout << bin.size() << std::endl; + std::cout << bin1_name << std::endl; +} catch (const std::exception &e) { + std::cerr << e.what() << std::endl; +} \ No newline at end of file