diff --git a/.clang-format b/.clang-format index 4fbdb11..cb03ae8 100644 --- a/.clang-format +++ b/.clang-format @@ -1,58 +1,16 @@ --- -Language: Cpp -# BasedOnStyle: Google -AccessModifierOffset: -2 -AlignAfterOpenBracket: true -AlignEscapedNewlinesLeft: true -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AllowShortFunctionsOnASingleLine: Empty -AlwaysBreakAfterDefinitionReturnType: false -AlwaysBreakTemplateDeclarations: true -AlwaysBreakBeforeMultilineStrings: true -BreakBeforeBinaryOperators: None -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BinPackParameters: true -BinPackArguments: true -ColumnLimit: 500 -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -DerivePointerAlignment: false -ExperimentalAutoDetectBinPacking: false -IndentCaseLabels: true -IndentWrappedFunctionNames: false -IndentFunctionDeclarationAfterType: false -MaxEmptyLinesToKeep: 2 -KeepEmptyLinesAtTheStartOfBlocks: false -NamespaceIndentation: None -PenaltyBreakBeforeFirstCallParameter: 1 -PenaltyBreakComment: 300 -PenaltyBreakString: 1000 -PenaltyBreakFirstLessLess: 120 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 200 -PointerAlignment: Left -SpacesBeforeTrailingComments: 1 -Cpp11BracedListStyle: true -Standard: Auto -IndentWidth: 4 -TabWidth: 4 -UseTab: Never -BreakBeforeBraces: Attach -SpacesInParentheses: false -SpacesInSquareBrackets: false -SpacesInAngles: false -SpaceInEmptyParentheses: false -SpacesInCStyleCastParentheses: false -SpaceAfterCStyleCast: true -SpacesInContainerLiterals: true -SpaceBeforeAssignmentOperators: true -ContinuationIndentWidth: 4 -CommentPragmas: '^ IWYU pragma:' -SpaceBeforeParens: ControlStatements \ No newline at end of file + BasedOnStyle: Google + AccessModifierOffset: '-2' + AlignTrailingComments: 'true' + AllowAllParametersOfDeclarationOnNextLine: 'false' + AlwaysBreakTemplateDeclarations: 'No' + BreakBeforeBraces: Attach + ColumnLimit: '100' + ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' + IncludeBlocks: Regroup + IndentPPDirectives: AfterHash + IndentWidth: '2' + NamespaceIndentation: All + BreakBeforeBinaryOperators: All + BreakBeforeTernaryOperators: 'true' +... diff --git a/.cmake-format b/.cmake-format new file mode 100644 index 0000000..8c355cf --- /dev/null +++ b/.cmake-format @@ -0,0 +1,57 @@ +format: + tab_size: 2 + line_width: 100 + dangle_parens: true + +parse: + additional_commands: + cpmaddpackage: + pargs: + nargs: '*' + flags: [] + spelling: CPMAddPackage + kwargs: &cpmaddpackagekwargs + NAME: 1 + FORCE: 1 + VERSION: 1 + GIT_TAG: 1 + DOWNLOAD_ONLY: 1 + GITHUB_REPOSITORY: 1 + GITLAB_REPOSITORY: 1 + GIT_REPOSITORY: 1 + SVN_REPOSITORY: 1 + SVN_REVISION: 1 + SOURCE_DIR: 1 + DOWNLOAD_COMMAND: 1 + FIND_PACKAGE_ARGUMENTS: 1 + NO_CACHE: 1 + GIT_SHALLOW: 1 + URL: 1 + URL_HASH: 1 + URL_MD5: 1 + DOWNLOAD_NAME: 1 + DOWNLOAD_NO_EXTRACT: 1 + HTTP_USERNAME: 1 + HTTP_PASSWORD: 1 + OPTIONS: + + cpmfindpackage: + pargs: + nargs: '*' + flags: [] + spelling: CPMFindPackage + kwargs: *cpmaddpackagekwargs + packageproject: + pargs: + nargs: '*' + flags: [] + spelling: packageProject + kwargs: + NAME: 1 + VERSION: 1 + NAMESPACE: 1 + INCLUDE_DIR: 1 + INCLUDE_DESTINATION: 1 + BINARY_DIR: 1 + COMPATIBILITY: 1 + VERSION_HEADER: 1 + DEPENDENCIES: + diff --git a/CMakeLists.txt b/CMakeLists.txt index 62e34a6..ded31fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,39 +1,66 @@ cmake_minimum_required(VERSION 3.18 FATAL_ERROR) -project(AlgoCpp - LANGUAGES CXX - VERSION 0.0.1 +project( + AlgoCpp + LANGUAGES CXX + VERSION 0.0.1 ) -find_package( OpenCV REQUIRED ) -include(CTest) +# ---- Include guards ---- -SET(ALGOCPP_BUILD_EXAMPLES ON CACHE BOOL "Enables example building" FORCE) -SET(ALGOCPP_BUILD_TESTS ON CACHE BOOL "Enables tests building" FORCE) -SET(ALGOCPP_BUILD_BENCHMARK OFF CACHE BOOL "Enables benchmark building" FORCE) +if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) + message( + FATAL_ERROR + "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there." + ) +endif() -add_library(${PROJECT_NAME} INTERFACE) +# ---- Add dependencies via CPM ---- +# see https://github.com/TheLartians/CPM.cmake for more info -target_include_directories( - ${PROJECT_NAME} - INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR}/include -) +include(cmake/CPM.cmake) -target_compile_features( - ${PROJECT_NAME} - INTERFACE - cxx_std_17 -) +# PackageProject.cmake will be used to make our target installable +CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.8.0") -if (ALGOCPP_BUILD_EXAMPLES) - set(ExamplesDir "${CMAKE_CURRENT_SOURCE_DIR}/examples/") - add_subdirectory(${ExamplesDir}) -endif() +# ---- Add source files ---- -if (ALGOCPP_BUILD_TESTS) - set(TestsDir "${CMAKE_CURRENT_SOURCE_DIR}/tests/") - add_subdirectory(${TestsDir}) -endif() +# Note: globbing sources is considered bad practice as CMake's generators may not detect new files +# automatically. Keep that in mind when changing files, or explicitly mention them here. +file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h") +file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp") + +# ---- Create library ---- + +# Note: for header-only libraries change all PUBLIC flags to INTERFACE and create an interface +# target: add_library(${PROJECT_NAME} INTERFACE) +add_library(${PROJECT_NAME} INTERFACE ${headers} ${sources}) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17) +# being a cross-platform target, we enforce standards conformance on MSVC +target_compile_options(${PROJECT_NAME} INTERFACE "$<$:/permissive->") + +# Link dependencies +target_include_directories( + ${PROJECT_NAME} INTERFACE $ + $ +) + +# ---- Create an installable target ---- +# this allows users to install and find the library via `find_package()`. + +# the location where the project's version header will be placed should match the project's regular +# header paths +string(TOLOWER ${PROJECT_NAME}/version.h VERSION_HEADER_LOCATION) + +packageProject( + NAME ${PROJECT_NAME} + VERSION ${PROJECT_VERSION} + NAMESPACE ${PROJECT_NAME} + BINARY_DIR ${PROJECT_BINARY_DIR} + INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include + INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION} + VERSION_HEADER "${VERSION_HEADER_LOCATION}" + COMPATIBILITY SameMajorVersion +) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c61b663 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/README.md b/README.md index bf57f10..234c6e3 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,34 @@ -# steganography +# AlgoCpp -This is a single header "Least significant bit (LSB)" steganography lib to hide text in an image +This is my repository with self implemented algorithms, written in C++.
Currently available algorithms: + +``` +└── algorithms + ├── search + │ └── linear search + └── sorting + └── bubblesort +``` ## Example ```cpp -#include +// single header include +#include #include int main() { - // hiding secret message - steg::leastSignificantBitEncode("/path_to_input_image/input.png", "/path_to_output_image/output.png", "My secret Message"); - - // decode message from manipulated picture - std::cout << steg::leastSignificantBitDecode("/path_to_manipulated_image/output.png") << std::endl; + std::vector foo{1, 4, 5, 2, 3}; + // check if int is in vector with lenear search + if (algocpp::search::linearSearch(foo, 2)) { + std::cout << "found" << std::endl; + } } ``` +## Requirements + +- C++17 compatible compiler ## Installation via Cmake @@ -28,13 +40,54 @@ project() include(FetchContent) FetchContent_Declare( - CppSteg - GIT_REPOSITORY https://github.com/noctera/CppSteg.git + AlgoCpp + GIT_REPOSITORY https://github.com/noctera/AlgoCpp.git GIT_TAG origin/main ) -FetchContent_MakeAvailable(CppSteg) +FetchContent_MakeAvailable(AlgoCpp) target_link_libraries( - PUBLIC CppSteg + PUBLIC AlgoCpp ) +``` + +## Build the project + +### Build everything at once + +```bash +cmake -S all -B build +cmake --build build + +# docs need to be generated seperately +cmake --build build/docs --target docs +``` + +### Build only the examples + +```bash +cmake -S examples -B build/examples +cmake --build build/examples +``` + +### Build only the tests + +```bash +cmake -S tests -B build/tests +cmake --build build/tests +``` + +### Build only the docs + +```bash +cmake -S docs -B build/docs +cmake --build build/docs --target docs +``` + +### Format the code + +```bash +cmake -S all -B build +cmake --build build --target fix-format +``` diff --git a/all/CMakeLists.txt b/all/CMakeLists.txt new file mode 100644 index 0000000..02c5d82 --- /dev/null +++ b/all/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.18 FATAL_ERROR) + +project(BuildAll LANGUAGES CXX) + +include(../cmake/tools.cmake) + +# needed to generate test target +enable_testing() + +add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../examples ${CMAKE_BINARY_DIR}/examples) +add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../tests ${CMAKE_BINARY_DIR}/tests) +add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../docs ${CMAKE_BINARY_DIR}/docs) diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake new file mode 100644 index 0000000..b5e436a --- /dev/null +++ b/cmake/CPM.cmake @@ -0,0 +1,21 @@ +set(CPM_DOWNLOAD_VERSION 0.32.0) + +if(CPM_SOURCE_CACHE) + # Expand relative path. This is important if the provided path contains a tilde (~) + get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE) + set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +elseif(DEFINED ENV{CPM_SOURCE_CACHE}) + set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +else() + set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +endif() + +if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) + message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") + file(DOWNLOAD + https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} + ) +endif() + +include(${CPM_DOWNLOAD_LOCATION}) diff --git a/cmake/tools.cmake b/cmake/tools.cmake new file mode 100644 index 0000000..2364da9 --- /dev/null +++ b/cmake/tools.cmake @@ -0,0 +1,66 @@ +# this file contains a list of tools that can be activated and downloaded on-demand each tool is +# enabled during configuration by passing an additional `-DUSE_=` argument to CMake + +# only activate tools for top level project +if(NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + return() +endif() + +include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake) + +# enables sanitizers support using the the `USE_SANITIZER` flag available values are: Address, +# Memory, MemoryWithOrigins, Undefined, Thread, Leak, 'Address;Undefined' +if(USE_SANITIZER OR USE_STATIC_ANALYZER) + CPMAddPackage("gh:StableCoder/cmake-scripts#1f822d1fc87c8d7720c074cde8a278b44963c354") + + if(USE_SANITIZER) + include(${cmake-scripts_SOURCE_DIR}/sanitizers.cmake) + endif() + + if(USE_STATIC_ANALYZER) + if("clang-tidy" IN_LIST USE_STATIC_ANALYZER) + set(CLANG_TIDY + ON + CACHE INTERNAL "" + ) + else() + set(CLANG_TIDY + OFF + CACHE INTERNAL "" + ) + endif() + if("iwyu" IN_LIST USE_STATIC_ANALYZER) + set(IWYU + ON + CACHE INTERNAL "" + ) + else() + set(IWYU + OFF + CACHE INTERNAL "" + ) + endif() + if("cppcheck" IN_LIST USE_STATIC_ANALYZER) + set(CPPCHECK + ON + CACHE INTERNAL "" + ) + else() + set(CPPCHECK + OFF + CACHE INTERNAL "" + ) + endif() + + include(${cmake-scripts_SOURCE_DIR}/tools.cmake) + + clang_tidy(${CLANG_TIDY_ARGS}) + include_what_you_use(${IWYU_ARGS}) + cppcheck(${CPPCHECK_ARGS}) + endif() +endif() + +# enables CCACHE support through the USE_CCACHE flag possible values are: YES, NO or equivalent +if(USE_CCACHE) + CPMAddPackage("gh:TheLartians/Ccache.cmake@1.2.3") +endif() diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt new file mode 100644 index 0000000..585abc3 --- /dev/null +++ b/docs/CMakeLists.txt @@ -0,0 +1,76 @@ +cmake_minimum_required(VERSION 3.14 FATAL_ERROR) + +project(AlgoCppDocs) + +# This CMake file will add doc target for convenient documentation generation. +# +# Additional features are supported: * dot = for automatically generated UML diagrams (class, +# include, caller, call, collaboration) * PlantUML = for easy generation of custom diagrams + +# Helper functions +macro(path_linux_to_win MsysPath ResultingPath) + string(REGEX REPLACE "^/([a-zA-Z])/" "\\1:/" ${ResultingPath} "${MsysPath}") +endmacro() +macro(path_win_to_linux MsysPath ResultingPath) + string(REGEX REPLACE "^([a-zA-Z]):/" "/\\1/" ${ResultingPath} "${MsysPath}") +endmacro() + +# enable if doxygen found +find_package(Doxygen 1.8.0) +message(STATUS "Can build doc? ${DOXYGEN_FOUND}") +if(DOXYGEN_FOUND) + # Search for plantUML for creating UML diagrams from doxygen + find_program( + PLANT_UML_PATH plantuml.jar + PATH_SUFFIXES PlantUML plantuml Plantuml + PATHS /usr/bin /usr/share /usr/local/share/ /usr/local/bin c/Program\ Files* + ) + if(NOT PLANT_UML_PATH) + message( + WARNING + "Looking for PlantUML - not found, some UML diagrams will not be generated via doxygen." + ) + else() + message(STATUS " + PlantUML - for custom UML YES ") + endif() + + # Search for DOT for autogenerated UML diagrams from doxygen + find_program(DOT_PATH dot PATH_SUFFIXES graphviz2.38/bin graphviz/bin) + if(NOT DOT_PATH) + message( + WARNING + "Looking for DOT (Graphviz) - not found, some UML diagrams will not be generated via doxygen." + ) + else() + message(STATUS " + Graphviz/Dot - for generated graphs YES ") + endif() + + path_win_to_linux(${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_SOURCE_DIR_LINUX) + path_win_to_linux(${PROJECT_SOURCE_DIR} PROJECT_SOURCE_DIR_LINUX) + path_win_to_linux(${DOT_PATH} DOT_PATH_LINUX) + path_win_to_linux(${PLANT_UML_PATH} PLANT_UML_PATH_LINUX) + path_win_to_linux(${CMAKE_CURRENT_BINARY_DIR} CMAKE_CURRENT_BINARY_DIR_LINUX) + + # configure doxygen configuration file + set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/Doxyfile.in) + set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) + configure_file(${doxyfile_in} ${doxyfile} @ONLY) + + # doc build only target, target is not in default build, so it must be triggered explicitly + add_custom_target( + docs + COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMENT "Generating API documentation with Doxygen" + VERBATIM + ) + + # TODO: Where docs will be installed. Note: if docs shall be not a part of final config, delete + # this install command, docs will be only available in [build_dir]/doc/doc/index.html install( + # DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/ DESTINATION ./share/doc/${PROJECT_NAME} OPTIONAL) +endif() + +# TODO uncomment this if used as a standalone project and you want to use install target set default +# install path if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set (CMAKE_INSTALL_PREFIX +# "${CMAKE_BINARY_DIR}/dist" CACHE PATH "Install path prefix, prepended onto install directories." +# FORCE ) endif() diff --git a/docs/doxygen/Doxyfile.in b/docs/doxygen/Doxyfile.in new file mode 100644 index 0000000..9069fba --- /dev/null +++ b/docs/doxygen/Doxyfile.in @@ -0,0 +1,126 @@ +# Use: `doxygen -g test.txt` to generate all possible settings for this file + +# For modern doxygen style uncomment these three lines: + HTML_EXTRA_STYLESHEET = @CMAKE_CURRENT_SOURCE_DIR@/doxygen/customdoxygen.css + HTML_HEADER = @CMAKE_CURRENT_SOURCE_DIR@/doxygen/header.html + HTML_FOOTER = @CMAKE_CURRENT_SOURCE_DIR@/doxygen/footer.html + +# not interested build output +QUIET = NO + +# Basic settings: +PROJECT_NAME = "@CMAKE_PROJECT_NAME@" +PROJECT_NUMBER = @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@ +STRIP_FROM_PATH = +INPUT = ../include/AlgoCpp \ + ../source \ + ../standalone/source \ + ../README.md +FILE_PATTERNS = *.h \ + *.hpp \ + *.hh \ + *.c \ + *.cc \ + *.cpp.in \ + *.cpp \ + *.md +# EXCLUDE_PATTERNS = json.hpp +RECURSIVE = YES +USE_MDFILE_AS_MAINPAGE = "@CMAKE_CURRENT_SOURCE_DIR_LINUX@/readme.md" +#USE_MDFILE_AS_MAINPAGE = "@PROJECT_SOURCE_DIR_LINUX@/readme.md" +# output location +HTML_OUTPUT = "@CMAKE_CURRENT_BINARY_DIR_LINUX@/doc" + +IMAGE_PATH = "@CMAKE_CURRENT_SOURCE_DIR_LINUX@" + +# We want to create nice UML graphs +PLANTUML_JAR_PATH = "@PLANT_UML_PATH_LINUX@" +DOT_PATH = "@DOT_PATH_LINUX@" + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. +OUTPUT_LANGUAGE = English + +# Color style +HTML_COLORSTYLE_HUE = 220 +HTML_COLORSTYLE_SAT = 40 +HTML_COLORSTYLE_GAMMA = 80 + +# max size 200x55px +PROJECT_LOGO = + + + + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. +REFERENCES_RELATION = YES + +# This is nice to have - callgraphs of functions +HAVE_DOT = YES +CALL_GRAPH = YES +CALLER_GRAPH = YES + +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +GENERATE_LEGEND = YES +INCLUDED_BY_GRAPH = YES +INCLUDE_GRAPH = YES +DOT_IMAGE_FORMAT = png:cairo:cairo + +# More insight to templates, generaly not needed +TEMPLATE_RELATIONS = NO + +# in class diagrams, you will have members and such +# Also they will be bigger +UML_LOOK = YES +UML_LIMIT_NUM_FIELDS = 16 + + + +# should all pictures be collapsed? +HTML_DYNAMIC_SECTIONS = NO + + +# use with: /// @todo Do more stuff. +GENERATE_TODOLIST = YES + +# we want all we can get +EXTRACT_ALL = YES +EXTRACT_STATIC = YES +EXTRACT_PRIVATE = YES + +# We do not need latex output +GENERATE_LATEX = NO +USE_PDFLATEX = NO + +# this makes first sentence from comment block a brief description. +# It is VERY useful +JAVADOC_AUTOBRIEF = YES + +# Why not... +BUILTIN_STL_SUPPORT = YES + +# Do we want source code browser? YES! Do we want strip comments? NO +SOURCE_BROWSER = YES +STRIP_CODE_COMMENTS = NO + +# Side panel +# If you enable this, change .container max-width: 960px; to 1240px +GENERATE_TREEVIEW = NO diff --git a/docs/doxygen/customdoxygen.css b/docs/doxygen/customdoxygen.css new file mode 100644 index 0000000..77abcca --- /dev/null +++ b/docs/doxygen/customdoxygen.css @@ -0,0 +1,1638 @@ +/* The standard CSS for doxygen 1.8.7 */ +/* + Palette + ============= + + see [https://www.google.com/design/spec/style/color.html#color-color-palette] + + Main #5C6BC0 + DarkMain #3F51B5 + + accent #26C6DA + + + + */ + + + +.z-depth-1, .container, .memitem { + box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.13), 0 1px 5px 0 rgba(0, 0, 0, 0.08); +} + +.container { + margin:0 auto; + max-width: 1000px; + background-color: white; +} + +.contents ul { + margin-top: 0.4rem; + margin-bottom: 0.0rem; + padding-left: 1.5rem; +} + +.contents li { + margin-top: 0.4rem; + margin-bottom: 0.0rem; +} + +.contents p{ + margin-top: 0.8rem; + margin-bottom: 0.8rem; +} + + +body, table, div, p, dl { + font: 400 17px Roboto,sans-serif; +} + +/* @group Heading Levels */ + +h1.groupheader { + font-size: 150%; +} + +b { + font-weight: 500; +} + +.title { + font: 400 14px/28px Roboto,sans-serif; + font-size: 150%; + font-weight: 500; + margin: 10px 2px; +} + +h2.groupheader { + border-bottom: 1px solid #879ECB; + color: #354C7B; + font-size: 150%; + font-weight: normal; + margin-top: 1.75em; + padding-top: 8px; + padding-bottom: 4px; + width: 100%; +} + +h3.groupheader { + font-size: 100%; +} + +h1, h2, h3, h4, h5, h6 { + -webkit-transition: text-shadow 0.5s linear; + -moz-transition: text-shadow 0.5s linear; + -ms-transition: text-shadow 0.5s linear; + -o-transition: text-shadow 0.5s linear; + transition: text-shadow 0.5s linear; + margin-right: 15px; +} + +h1{ + margin-top: 2rem; + margin-bottom: 0.2rem; +} +h2{ + margin-top: 1.8rem; + margin-bottom: 0.2rem; +} +h3{ + margin-top: 1.6rem; + margin-bottom: 0.2rem; +} +h4{ + margin-top: 1.4rem; + margin-bottom: 0.2rem; +} +h5{ + margin-top: 1.0rem; + margin-bottom: 0.2rem; +} +h6{ + margin-top: 0.1rem; + margin-bottom: 0rem; +} + + +h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { + text-shadow: 0 0 15px cyan; +} + +dt { + font-weight: bold; +} + +div.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; +} + +p.startli, p.startdd { + margin-top: 2px; +} + +p.starttd { + margin-top: 0px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab{ + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #4665A2; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #9CAFD4; + color: #ffffff; + border: 1px double #869DCA; +} + +.contents a.qindexHL:visited { + color: #ffffff; +} + +a.el { + font-weight: 500; +} + +a.elRef { +} + +a.code, a.code:visited, a.line, a.line:visited { + color: #4665A2; +} + +a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { + color: #4665A2; +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +pre.fragment { + border: none; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 80%; + line-height: 1rem; + font-family: monospace, fixed; + font-size: 105%; +} + +div.fragment { + padding: 0.5rem 0.5rem; + margin: 0.5rem 2px 0.5rem 2px; + background-color: #f0f0f0; + border: none; +} + +div.line { + font-family: monospace, fixed; + font-size: 80%; + min-height: 13px; + line-height: 1rem; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; /* Moz */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + white-space: pre-wrap; /* CSS3 */ + word-wrap: break-word; /* IE 5.5+ */ + text-indent: -53px; + padding-left: 53px; + padding-bottom: 0px; + margin: 0px; + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +div.line.glow { + background-color: cyan; + box-shadow: 0 0 10px cyan; +} + + +span.lineno { + padding-right: 4px; + text-align: right; + border-right: 2px solid #0F0; + background-color: #E8E8E8; + white-space: pre; +} +span.lineno a { + background-color: #D8D8D8; +} + +span.lineno a:hover { + background-color: #C8C8C8; +} + +div.ah { + background-color: black; + font-weight: bold; + color: #ffffff; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + box-shadow: 2px 2px 3px #999; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background-color: #eee; + color: #111; + margin: 0; +} + +div.contents { + margin-top: 2%; + margin-bottom: 2rem; + margin-left: 3%; + margin-right: 3%; + min-height: 640px; +} + +td.indexkey { + background-color: #EBEFF6; + font-weight: bold; + border: 1px solid #C4CFE5; + margin: 2px 0px 2px 0; + padding: 2px 10px; + white-space: nowrap; + vertical-align: top; +} + +td.indexvalue { + background-color: #EBEFF6; + border: 1px solid #C4CFE5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #EEF1F7; +} + +p.formulaDsp { + text-align: center; +} + +div.contents img { + max-width: 100%; + padding-top: 1rem; + padding-bottom 1rem; +} + +img.formulaDsp { + +} + +img.formulaInl { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ + +span.keyword { + color: #008000 +} + +span.keywordtype { + color: #604020 +} + +span.keywordflow { + color: #e08000 +} + +span.comment { + color: #800000 +} + +span.preprocessor { + color: #806020 +} + +span.stringliteral { + color: #002080 +} + +span.charliteral { + color: #008080 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +blockquote { + background-color: #F7F8FB; + border-left: 2px solid #9CAFD4; + margin: 0 24px 0 4px; + padding: 0 12px 0 16px; +} + +/* @end */ + +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #A3B4D7; +} + +th.dirtab { + background: #EBEFF6; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + +} +.memberdecls tr{ + line-height: 1.4rem; +} + +.memberdecls td, .fieldtable tr { + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +.memberdecls td.glow, .fieldtable tr.glow { + background-color: cyan; + box-shadow: 0 0 15px cyan; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #F9FAFC; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memSeparator { + border-bottom: 1px solid #DEE4F0; + line-height: 1px; + margin: 0px; + padding: 0px; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memItemRight { + width: 100%; +} + +.memTemplParams { + color: #4665A2; + white-space: nowrap; + font-size: 80%; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtemplate { + font-size: 80%; + color: #4665A2; + font-weight: normal; + margin-left: 9px; +} + +.memnav { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.mempage { + width: 100%; +} + +.memtitle +{ + display: none; +} + +.memitem { + padding: 0; + margin-bottom: 10px; + margin-top: 30px; + margin-right: 5px; + -webkit-transition: box-shadow 0.5s linear; + -moz-transition: box-shadow 0.5s linear; + -ms-transition: box-shadow 0.5s linear; + -o-transition: box-shadow 0.5s linear; + transition: box-shadow 0.5s linear; + display: table !important; + width: 100%; +} + +.memitem.glow { + box-shadow: 0 0 15px cyan; +} + +.memname { + font-weight: 500; + margin-left: 6px; +} + +.memname td { + vertical-align: bottom; +} + +.memproto, dl.reflist dt { + border-top: 0 solid #A8B8D9; + border-left: 0 solid #A8B8D9; + border-right: 0 solid #A8B8D9; + padding: 6px 0px 6px 0px; + color: #253555; + font-weight: 500; + text-shadow: none; + background-image:none; + background-repeat:no-repeat; + background-color: #E2E8F2; + /* opera specific markup */ + box-shadow: 0px 0 0 0 rgba(0, 0, 0, 0.15); + border-top-right-radius: 0px; + border-top-left-radius: 0px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 0px 0 0 0; + -moz-border-radius-topright: 0px; + -moz-border-radius-topleft: 0px; + /* webkit specific markup */ + -webkit-box-shadow: 0px 0 0 0 rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 0px; + -webkit-border-top-left-radius: 0px; + +} + +.memdoc, dl.reflist dd { + border-bottom: 0 solid #A8B8D9; + border-left: 0 solid #A8B8D9; + border-right: 0 solid #A8B8D9; + padding: 0px 10px 0px 10px; + background-color: #FBFCFD; + border-top-width: 0; + background-image:none; + background-repeat:no-repeat; + background-color: #FFFFFF; + /* opera specific markup */ + border-bottom-left-radius: 0px; + border-bottom-right-radius: 0px; + box-shadow: 0px 0 0 0 rgba(0, 0, 0, 0.15); + /* firefox specific markup */ + -moz-border-radius-bottomleft: 0px; + -moz-border-radius-bottomright: 0px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 0px 0 0 0; + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 0px; + -webkit-border-bottom-right-radius: 0px; + -webkit-box-shadow: 0px 0 0 0 rgba(0, 0, 0, 0.15); +} + +dl.reflist dt { + padding: 5px; +} + +dl.reflist dd { + margin: 0px 0px 10px 0px; + padding: 5px; +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} +.paramname code { + line-height: 16px; +} + +.params, .retval, .exception, .tparams { + margin-left: 0px; + padding-left: 0px; +} + +.params .paramname, .retval .paramname { + font-weight: bold; + vertical-align: top; +} + +.params .paramtype { + font-style: italic; + vertical-align: top; +} + +.params .paramdir { + font-family: "courier new",courier,monospace; + vertical-align: top; +} + +table.mlabels { + border-spacing: 0px; +} + +td.mlabels-left { + width: 100%; + padding: 0px; +} + +td.mlabels-right { + vertical-align: bottom; + padding: 0px; + white-space: nowrap; +} + +span.mlabels { + margin-left: 8px; +} + +span.mlabel { + background-color: #728DC1; + border-top:1px solid #5373B4; + border-left:1px solid #5373B4; + border-right:1px solid #C4CFE5; + border-bottom:1px solid #C4CFE5; + text-shadow: none; + color: white; + margin-right: 4px; + padding: 2px 3px; + border-radius: 3px; + font-size: 7pt; + white-space: nowrap; + vertical-align: middle; +} + + + +/* @end */ + +/* these are for tree view inside a (index) page */ + +div.directory { + margin: 10px 0px; + border-top: 1px solid #9CAFD4; + border-bottom: 1px solid #9CAFD4; + width: 100%; +} + +.directory table { + border-collapse:collapse; +} + +.directory td { + margin: 0px; + padding: 0px; + vertical-align: middle; +} + +.directory td.entry { + white-space: nowrap; + padding-right: 6px; + padding-top: 0.3rem; + padding-bottom: 0.3rem; +} + +.directory td.entry a { + outline:none; +} + +.directory td.entry a img { + border: none; +} + +.directory td.desc { + width: 100%; + padding-left: 6px; + padding-right: 6px; + padding-top: 3px; + padding-bottom: 3px; + border-left: 1px solid rgba(0,0,0,0.05); +} + +.directory tr.even { + padding-left: 6px; + background-color: #F7F8FB; +} + +.directory img { + vertical-align: -30%; +} + +.directory .levels { + white-space: nowrap; + width: 100%; + text-align: right; + font-size: 9pt; +} + +.directory .levels span { + cursor: pointer; + padding-left: 2px; + padding-right: 2px; + color: #3D578C; +} + +.arrow { + color: #9CAFD4; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + cursor: pointer; + font-size: 80%; + display: inline-block; + width: 16px; + height: 16px; +} + +.icon { + font-family: Arial, Helvetica; + font-weight: bold; + font-size: 12px; + height: 14px; + width: 16px; + display: inline-block; + background-color: #728DC1; + color: white; + text-align: center; + border-radius: 4px; + margin-left: 2px; + margin-right: 2px; +} + +.icona { + width: 1rem; + height: 1rem; + padding-right: 0.7rem; + display: inline-block; + vertical-align:middle; + margin-bottom: 4px; + margin-top: 4px; + +} + +.iconfopen { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('ftv2folderopen.png'); + background-position: 0px -1px; + background-repeat: repeat-y; + vertical-align:middle; + display: inline-block; +} + +.iconfclosed { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('ftv2folderclosed.png'); + background-position: 0px -1px; + background-repeat: repeat-y; + vertical-align:middle; + display: inline-block; +} + +.icondoc { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('ftv2doc.png'); + background-position: 0px -1px; + background-repeat: repeat-y; + vertical-align:middle; + display: inline-block; +} + +table.directory { + font: 400 100% Roboto,sans-serif; +} + +/* @end */ + +div.dynheader { + margin-top: 1rem; + font-weight: 500; + + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +address { + font-style: normal; + color: #2A3D61; +} + +table.doxtable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +table.fieldtable { + /*width: 100%;*/ + margin-bottom: 10px; + border: 1px solid #A8B8D9; + border-spacing: 0px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); + box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); +} + +.fieldtable td, .fieldtable th { + padding: 3px 7px 2px; +} + +.fieldtable td.fieldtype, .fieldtable td.fieldname { + white-space: nowrap; + border-right: 1px solid #A8B8D9; + border-bottom: 1px solid #A8B8D9; + vertical-align: top; +} + +.fieldtable td.fieldname { + padding-top: 3px; +} + +.fieldtable td.fielddoc { + border-bottom: 1px solid #A8B8D9; + /*width: 100%;*/ +} + +.fieldtable td.fielddoc p:first-child { + margin-top: 0px; +} + +.fieldtable td.fielddoc p:last-child { + margin-bottom: 2px; +} + +.fieldtable tr:last-child td { + border-bottom: none; +} + +.fieldtable th { + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + font-size: 90%; + color: #253555; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; + -moz-border-radius-topleft: 4px; + -moz-border-radius-topright: 4px; + -webkit-border-top-left-radius: 4px; + -webkit-border-top-right-radius: 4px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-bottom: 1px solid #A8B8D9; +} + + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image:url('tab_b.png'); + background-repeat:repeat-x; + background-position: 0 -5px; + height:30px; + line-height:30px; + color:#8AA0CC; + border:solid 1px #C2CDE4; + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right:15px; + background-image:url('bc_s.png'); + background-repeat:no-repeat; + background-position:right; + color:#364D7C; +} + +.navpath li.navelem a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; + color: #283A5D; + font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + text-decoration: none; +} + +.navpath li.navelem a:hover +{ + color:#6884BD; +} + +.navpath li.footer +{ + list-style-type:none; + float:right; + padding-left:10px; + padding-right:15px; + background-image:none; + background-repeat:no-repeat; + background-position:right; + color:#364D7C; + font-size: 8pt; +} + + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +div.ingroups +{ + font-size: 8pt; + width: 50%; + text-align: left; +} + +div.ingroups a +{ + white-space: nowrap; +} + +div.header +{ + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} + +div.headertitle +{ + padding: 5px 5px 5px 10px; +} + +dl +{ + padding: 0 0 0 10px; +} + +/* dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug */ +dl.section +{ + margin-left: 0px; + padding-left: 0px; +} + +dl.note +{ + margin-left:0px; + padding-left: 3px; + border-left:4px solid; + border-color: #D0C000; +} + +dl.warning, dl.attention +{ + margin-left:0px; + padding-left: 3px; + border-left:4px solid; + border-color: #FF0000; +} + +dl.pre, dl.post, dl.invariant +{ + margin-left:0px; + padding-left: 3px; + border-left:4px solid; + border-color: #00D000; +} + +dl.deprecated +{ + margin-left:0px; + padding-left: 3px; + border-left:4px solid; + border-color: #505050; +} + +dl.todo +{ + margin-left:0px; + padding-left: 3px; + border-left:4px solid; + border-color: #00C0E0; +} + +dl.test +{ + margin-left:0px; + padding-left: 3px; + border-left:4px solid; + border-color: #3030E0; +} + +dl.bug +{ + margin-left:0px; + padding-left: 3px; + border-left:4px solid; + border-color: #C08050; +} + +dl.section dd { + margin-bottom: 6px; +} + + +#projectlogo +{ + text-align: center; + vertical-align: bottom; + border-collapse: separate; +} + +#projectlogo img +{ + border: 0px none; +} + +#projectname +{ + font: 200% Roboto,sans-serif; + margin: 0px; + padding: 2px 0px; +} + +#projectbrief +{ + font: 120% Roboto,sans-serif; + margin: 0px; + padding: 0px; +} + +#projectnumber +{ + font: 50% Roboto,sans-serif; + margin: 0px; + padding: 0px; +} + +#titlearea +{ + padding: 0px; + margin: 0px; + width: 100%; + color: white; + border-bottom: none; + background-color: #3F51B5; +} + +.image +{ + text-align: center; +} + +.dotgraph +{ + text-align: center; +} + +.mscgraph +{ + text-align: center; +} + +.diagraph +{ + text-align: center; +} + +.caption +{ + font-weight: bold; +} + +div.zoom +{ + border: 1px solid #90A5CE; +} + +dl.citelist { + margin-bottom:50px; +} + +dl.citelist dt { + color:#334975; + float:left; + font-weight:bold; + margin-right:10px; + padding:5px; +} + +dl.citelist dd { + margin:2px 0; + padding:5px 0; +} + +div.toc { + padding: 14px 25px; + background-color: #F4F6FA; + border: 1px solid #D8DFEE; + border-radius: 7px 7px 7px 7px; + float: right; + height: auto; + margin: 0 20px 10px 10px; + width: 200px; +} + +div.toc li { + background: url("bdwn.png") no-repeat scroll 0 5px transparent; + font: 10px/1.2 Roboto ,sans-serif; + margin-top: 5px; + padding-left: 10px; + padding-top: 2px; +} + +div.toc h3 { + font: bold 12px/1.2 Roboto ,sans-serif; + color: #4665A2; + border-bottom: 0 none; + margin: 0; +} + +div.toc ul { + list-style: none outside none; + border: medium none; + padding: 0px; +} + +div.toc li.level1 { + margin-left: 0px; +} + +div.toc li.level2 { + margin-left: 15px; +} + +div.toc li.level3 { + margin-left: 30px; +} + +div.toc li.level4 { + margin-left: 45px; +} + +.inherit_header { + font-weight: bold; + color: gray; + cursor: pointer; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.inherit_header td { + padding: 6px 0px 2px 5px; +} + +.inherit { + display: none; +} + +tr.heading h2 { + margin-top: 12px; + margin-bottom: 4px; +} + +/* tooltip related style info */ + +.ttc { + position: absolute; + display: none; +} + +#powerTip { + cursor: default; + white-space: nowrap; + background-color: white; + border: 1px solid gray; + border-radius: 4px 4px 4px 4px; + box-shadow: 1px 1px 7px gray; + display: none; + font-size: smaller; + max-width: 80%; + opacity: 0.9; + padding: 1ex 1em 1em; + position: absolute; + z-index: 2147483647; +} + +#powerTip div.ttdoc { + color: grey; + font-style: italic; +} + +#powerTip div.ttname a { + font-weight: bold; +} + +#powerTip div.ttname { + font-weight: bold; +} + +#powerTip div.ttdeci { + color: #006318; +} + +#powerTip div { + margin: 0px; + padding: 0px; + font: 12px/16px Roboto,sans-serif; +} + +#powerTip:before, #powerTip:after { + content: ""; + position: absolute; + margin: 0px; +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.s:after, #powerTip.s:before, +#powerTip.w:after, #powerTip.w:before, +#powerTip.e:after, #powerTip.e:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.nw:after, #powerTip.nw:before, +#powerTip.sw:after, #powerTip.sw:before { + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; +} + +#powerTip.n:after, #powerTip.s:after, +#powerTip.w:after, #powerTip.e:after, +#powerTip.nw:after, #powerTip.ne:after, +#powerTip.sw:after, #powerTip.se:after { + border-color: rgba(255, 255, 255, 0); +} + +#powerTip.n:before, #powerTip.s:before, +#powerTip.w:before, #powerTip.e:before, +#powerTip.nw:before, #powerTip.ne:before, +#powerTip.sw:before, #powerTip.se:before { + border-color: rgba(128, 128, 128, 0); +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.nw:after, #powerTip.nw:before { + top: 100%; +} + +#powerTip.n:after, #powerTip.ne:after, #powerTip.nw:after { + border-top-color: #ffffff; + border-width: 10px; + margin: 0px -10px; +} +#powerTip.n:before { + border-top-color: #808080; + border-width: 11px; + margin: 0px -11px; +} +#powerTip.n:after, #powerTip.n:before { + left: 50%; +} + +#powerTip.nw:after, #powerTip.nw:before { + right: 14px; +} + +#powerTip.ne:after, #powerTip.ne:before { + left: 14px; +} + +#powerTip.s:after, #powerTip.s:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.sw:after, #powerTip.sw:before { + bottom: 100%; +} + +#powerTip.s:after, #powerTip.se:after, #powerTip.sw:after { + border-bottom-color: #ffffff; + border-width: 10px; + margin: 0px -10px; +} + +#powerTip.s:before, #powerTip.se:before, #powerTip.sw:before { + border-bottom-color: #808080; + border-width: 11px; + margin: 0px -11px; +} + +#powerTip.s:after, #powerTip.s:before { + left: 50%; +} + +#powerTip.sw:after, #powerTip.sw:before { + right: 14px; +} + +#powerTip.se:after, #powerTip.se:before { + left: 14px; +} + +#powerTip.e:after, #powerTip.e:before { + left: 100%; +} +#powerTip.e:after { + border-left-color: #ffffff; + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.e:before { + border-left-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +#powerTip.w:after, #powerTip.w:before { + right: 100%; +} +#powerTip.w:after { + border-right-color: #ffffff; + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.w:before { + border-right-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +@media print +{ + #top { display: none; } + #side-nav { display: none; } + #nav-path { display: none; } + body { overflow:visible; } + h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } + .summary { display: none; } + .memitem { page-break-inside: avoid; } + #doc-content + { + margin-left:0 !important; + height:auto !important; + width:auto !important; + overflow:inherit; + display:inline; + } +} + + +#MSearchBox .right{ + top: 0px; +} +#MSearchBox{ + position: relative; + float: right; +} + +.tablist li { + background-image: none; + line-height: 2rem; +} + +.tablist a { + background-image: none; + text-shadow: none; + color: #E8EAF6; + + border-width: 0 0 2px 0; + border-color: #5C6BC0; + border-style: solid; +} + +.tablist a:hover { + background-image: none; + text-shadow: none; + color: #E8EAF6; + background-color: #3F51B5; + + border-width: 0 0 2px 0; + border-color: #3F51B5; + border-style: solid; +} + + +.tablist li.current a { + background-image: none; + background-color: #3F51B5; + text-shadow: none; + color: #white; + border-width: 0 0 2px 0; + + border-color: #26C6DA; + border-style: solid; + +} + + +.tabs, .tabs2, .tabs3 { + background-image: none; + background-color: #5C6BC0; + width: 100%; + z-index: 101; + font-size: 13px; + font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; +} + + +/* Side Panel */ +#side-nav { + padding: 0 6px 0 0; + margin: 0px; + left: auto; + width: 250px; + +} +#doc-content { + overflow: auto; + padding: 0px; + margin: 0px; + -webkit-overflow-scrolling: touch; +} +.ui-resizable-e { + background: none; + background-color: #5C6BC0; + cursor: e-resize; + height: 100%; + right: 0; + top: 0; + width: 6px; +} + +#nav-tree .selected { + background-image: none; + background-repeat: repeat-x; + color: #fff; + background-color: #3F51B5; + text-shadow: none; +} +#nav-tree .item { + margin: 0px; + padding: 0.3rem 0 0.3rem 0 ; +} +#nav-tree .label { + font-size: 80%; +} diff --git a/docs/doxygen/footer.html b/docs/doxygen/footer.html new file mode 100644 index 0000000..4c5e62a --- /dev/null +++ b/docs/doxygen/footer.html @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/docs/doxygen/header.html b/docs/doxygen/header.html new file mode 100644 index 0000000..80ec8af --- /dev/null +++ b/docs/doxygen/header.html @@ -0,0 +1,59 @@ + + + + + + + +$projectname: $title +$title + + + + + + +$treeview +$search +$mathjax + +$extrastylesheet + + +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
+
$projectname +  $projectnumber +
+
$projectbrief
+
+
$projectbrief
+
$searchbox
+
+ + diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 187f334..33b4512 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,3 +1,29 @@ cmake_minimum_required(VERSION 3.18 FATAL_ERROR) -add_subdirectory(basicExample) \ No newline at end of file +project(AlgoCppExample LANGUAGES CXX) + +# --- Import tools ---- + +include(../cmake/tools.cmake) + +# ---- Dependencies ---- + +include(../cmake/CPM.cmake) + +if(MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +endif() + +CPMAddPackage(NAME AlgoCpp SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..) + +# ---- Create standalone executable ---- + +file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp) + +add_executable(${PROJECT_NAME} ${sources}) + +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 OUTPUT_NAME "AlgoCppExample") + +target_link_libraries(${PROJECT_NAME} AlgoCpp::AlgoCpp) diff --git a/examples/basicExample/CMakeLists.txt b/examples/basicExample/CMakeLists.txt deleted file mode 100644 index e78fcfb..0000000 --- a/examples/basicExample/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -cmake_minimum_required(VERSION 3.18 FATAL_ERROR) - -project(AlgoCpp_basic_usage) - -if(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi") -else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") -endif() - -add_executable( - ${PROJECT_NAME} - main.cpp -) - -target_link_libraries( - ${PROJECT_NAME} - PUBLIC - AlgoCpp -) \ No newline at end of file diff --git a/examples/basicExample/main.cpp b/examples/basicExample/main.cpp deleted file mode 100644 index 1e41319..0000000 --- a/examples/basicExample/main.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include -#include - -int main() {} \ No newline at end of file diff --git a/examples/source/main.cpp b/examples/source/main.cpp new file mode 100644 index 0000000..a75019b --- /dev/null +++ b/examples/source/main.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +int main() { + std::vector foo{1, 4, 5, 2, 3}; + if (algocpp::search::linearSearch(foo, 2)) { + std::cout << "found" << std::endl; + } +} \ No newline at end of file diff --git a/include/AlgoCpp/algorithms.hpp b/include/AlgoCpp/algorithms.hpp index 25bcc9d..d5c4595 100644 --- a/include/AlgoCpp/algorithms.hpp +++ b/include/AlgoCpp/algorithms.hpp @@ -1,5 +1,5 @@ #pragma once +#include +#include #include - -#include "./algorithms/sorting/bubbleSort.hpp" diff --git a/include/AlgoCpp/algorithms/search/linearSearch.hpp b/include/AlgoCpp/algorithms/search/linearSearch.hpp index 9e12c1e..a466cc9 100644 --- a/include/AlgoCpp/algorithms/search/linearSearch.hpp +++ b/include/AlgoCpp/algorithms/search/linearSearch.hpp @@ -1,16 +1,15 @@ #pragma once namespace algocpp { -namespace search { + namespace search { -template -bool linearSearch(T& input, Z item) { - for (auto it = input.begin(); it != input.end(); ++it) { + template bool linearSearch(T& input, Z item) { + for (auto it = input.begin(); it != input.end(); ++it) { if (*it == item) { - return true; + return true; } + } + return false; } - return false; -} -} // namespace search -} // namespace algocpp \ No newline at end of file + } // namespace search +} // namespace algocpp \ No newline at end of file diff --git a/include/AlgoCpp/algorithms/sorting/bubbleSort.hpp b/include/AlgoCpp/algorithms/sorting/bubbleSort.hpp index 84ff99c..72aeb83 100644 --- a/include/AlgoCpp/algorithms/sorting/bubbleSort.hpp +++ b/include/AlgoCpp/algorithms/sorting/bubbleSort.hpp @@ -3,29 +3,28 @@ #include namespace algocpp { -namespace sorting { + namespace sorting { -template -void bubbleSort(T& input) { - // no sorting required - if (input.size() <= 1) { + template void bubbleSort(T& input) { + // no sorting required + if (input.size() <= 1) { return; - } - // count if changes were made in an iteration to indicate if everything is in right order - int changesPerIteration = 0; - while (true) { + } + // count if changes were made in an iteration to indicate if everything is in right order + int changesPerIteration = 0; + while (true) { for (auto it = input.begin(); it != input.end() - 1; ++it) { - if (*it > *std::next(it)) { - std::iter_swap(it, std::next(it)); - ++changesPerIteration; - } + if (*it > *std::next(it)) { + std::iter_swap(it, std::next(it)); + ++changesPerIteration; + } } if (changesPerIteration == 0) { - break; + break; } changesPerIteration = 0; + } } -} -} // namespace sorting -} // namespace algocpp \ No newline at end of file + } // namespace sorting +} // namespace algocpp \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4aedc2d..38d3ad0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,35 +1,36 @@ cmake_minimum_required(VERSION 3.18 FATAL_ERROR) -project(algocpp_tests) +project(AlgoCppTests) -if(ALGOCPP_BUILD_BENCHMARK) - set(BenchmarkFiles "Benchmark.cpp") +# ---- Options ---- +option(TEST_INSTALLED_VERSION "Test the version found by find_package" OFF) +# --- Import tools ---- + +include(../cmake/tools.cmake) + +# ---- Dependencies ---- + +if(ALGOCCP_BUILD_BENCHMARK) + set(BenchmarkFiles "benchmark.cpp") endif() -add_executable( - ${PROJECT_NAME} - "main.cpp" - "sorting/bubbleSort.cpp" - "search/linearSearch.cpp" - ${BenchmarkFiles} - -) +CPMAddPackage("gh:TheLartians/Format.cmake@1.7.0") -include(FetchContent) +CPMAddPackage(GITHUB_REPOSITORY catchorg/Catch2 VERSION 2.13.6) -FetchContent_Declare( - Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v2.13.6 -) +if(TEST_INSTALLED_VERSION) + find_package(AlgoCpp REQUIRED) +else() + CPMAddPackage(NAME AlgoCpp SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..) +endif() -FetchContent_MakeAvailable(Catch2) +# ---- Create binary ---- -target_link_libraries( - ${PROJECT_NAME} - PRIVATE - AlgoCpp - Catch2::Catch2 +file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/search/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sorting/*.cpp ) +add_executable(${PROJECT_NAME} ${sources}) +target_link_libraries(${PROJECT_NAME} AlgoCpp::AlgoCpp Catch2::Catch2) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17) -add_test(AlgoCppLogSuit ${PROJECT_NAME}) \ No newline at end of file +add_test(AlgoCppLogSuit ${PROJECT_NAME}) diff --git a/tests/benchmark.cpp b/tests/benchmark.cpp deleted file mode 100644 index 4317743..0000000 --- a/tests/benchmark.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#define CATCH_CONFIG_ENABLE_BENCHMARKING -#include "AlgoCpp/algorithms/sorting/bubbleSort.hpp" -#include -#include -#include - - -TEST_CASE("Benchmarking", "[bubbleSort]") { - std::vector test1 = {1, 4, 5, 2, 3}; - BENCHMARK("Bubble sort 5") { - return algocpp::sorting::bubbleSort(test1); - }; - - - std::random_device rd; - std::mt19937 mt(rd()); - std::uniform_real_distribution dist(1.0, 1000000.0); - - std::vector test2; - for (int i = 1; i < 50000; ++i) { - test2.push_back(int(dist(mt))); - } - - BENCHMARK("Bubble sort 1000000") { - return algocpp::sorting::bubbleSort(test2); - }; -} diff --git a/tests/main.cpp b/tests/main.cpp index 1741df2..68cd6c0 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -3,6 +3,4 @@ #include -int main(int argc, char** argv) { - return Catch::Session().run(argc, argv); -} \ No newline at end of file +int main(int argc, char** argv) { return Catch::Session().run(argc, argv); } \ No newline at end of file diff --git a/tests/search/linearSearch.cpp b/tests/search/linearSearch.cpp index 599ee94..46b208f 100644 --- a/tests/search/linearSearch.cpp +++ b/tests/search/linearSearch.cpp @@ -1,5 +1,5 @@ #define CATCH_CONFIG_ENABLE_BENCHMARKING -#include "AlgoCpp/algorithms/search/linearSearch.hpp" +#include #include #include #include @@ -8,14 +8,14 @@ using namespace algocpp::search; TEST_CASE("Check if linear search is working", "[linearSearch]") { - std::vector test1 = {1, 4, 5, 2, 3}; - std::vector test2 = {1}; - std::vector test3 = {'c', 'b', 'x', 'm', 'n'}; + std::vector test1 = {1, 4, 5, 2, 3}; + std::vector test2 = {1}; + std::vector test3 = {'c', 'b', 'x', 'm', 'n'}; - REQUIRE(linearSearch(test1, 5) == true); - REQUIRE(linearSearch(test1, 7) == false); - REQUIRE(linearSearch(test2, 1) == true); - REQUIRE(linearSearch(test2, 5) == false); - REQUIRE(linearSearch(test3, 'b') == true); - REQUIRE(linearSearch(test3, 'A') == false); + REQUIRE(linearSearch(test1, 5) == true); + REQUIRE(linearSearch(test1, 7) == false); + REQUIRE(linearSearch(test2, 1) == true); + REQUIRE(linearSearch(test2, 5) == false); + REQUIRE(linearSearch(test3, 'b') == true); + REQUIRE(linearSearch(test3, 'A') == false); } diff --git a/tests/sorting/bubbleSort.cpp b/tests/sorting/bubbleSort.cpp index c2d9cbe..a0f5552 100644 --- a/tests/sorting/bubbleSort.cpp +++ b/tests/sorting/bubbleSort.cpp @@ -1,34 +1,32 @@ #define CATCH_CONFIG_ENABLE_BENCHMARKING -#include "AlgoCpp/algorithms/sorting/bubbleSort.hpp" +#include #include #include #include #include - TEST_CASE("Check if Bubble sort is sorting the right way", "[bubbleSort]") { - std::vector test1 = {1, 4, 5, 2, 3}; - std::vector test2 = {1, 2, 5, 2, 3}; - std::vector test3 = {1, 1, 1, 1, 1}; - std::vector test4 = {1}; - std::array test5 = {5, 3, 1, 4, 2}; - std::vector test6 = {'c', 'b', 'x', 'm', 'n'}; - std::vector test7 = {'c', 'b', 'M', 'x', 'B', 'm', 'n'}; - + std::vector test1 = {1, 4, 5, 2, 3}; + std::vector test2 = {1, 2, 5, 2, 3}; + std::vector test3 = {1, 1, 1, 1, 1}; + std::vector test4 = {1}; + std::array test5 = {5, 3, 1, 4, 2}; + std::vector test6 = {'c', 'b', 'x', 'm', 'n'}; + std::vector test7 = {'c', 'b', 'M', 'x', 'B', 'm', 'n'}; - algocpp::sorting::bubbleSort(test1); - algocpp::sorting::bubbleSort(test2); - algocpp::sorting::bubbleSort(test3); - algocpp::sorting::bubbleSort(test4); - algocpp::sorting::bubbleSort(test5); - algocpp::sorting::bubbleSort(test6); - algocpp::sorting::bubbleSort(test7); + algocpp::sorting::bubbleSort(test1); + algocpp::sorting::bubbleSort(test2); + algocpp::sorting::bubbleSort(test3); + algocpp::sorting::bubbleSort(test4); + algocpp::sorting::bubbleSort(test5); + algocpp::sorting::bubbleSort(test6); + algocpp::sorting::bubbleSort(test7); - REQUIRE(test1 == std::vector{1, 2, 3, 4, 5}); - REQUIRE(test2 == std::vector{1, 2, 2, 3, 5}); - REQUIRE(test3 == std::vector{1, 1, 1, 1, 1}); - REQUIRE(test4 == std::vector{1}); - REQUIRE(test5 == std::array{1, 2, 3, 4, 5}); - REQUIRE(test6 == std::vector{'b', 'c', 'm', 'n', 'x'}); - REQUIRE(test7 == std::vector{'B', 'M', 'b', 'c', 'm', 'n', 'x'}); + REQUIRE(test1 == std::vector{1, 2, 3, 4, 5}); + REQUIRE(test2 == std::vector{1, 2, 2, 3, 5}); + REQUIRE(test3 == std::vector{1, 1, 1, 1, 1}); + REQUIRE(test4 == std::vector{1}); + REQUIRE(test5 == std::array{1, 2, 3, 4, 5}); + REQUIRE(test6 == std::vector{'b', 'c', 'm', 'n', 'x'}); + REQUIRE(test7 == std::vector{'B', 'M', 'b', 'c', 'm', 'n', 'x'}); }