From 5fd845eeb304b8f408772e6db17e40ace84c7b40 Mon Sep 17 00:00:00 2001 From: teskann Date: Mon, 30 May 2022 12:04:28 +0200 Subject: [PATCH] Get rid of submodule and download blns.txt from master directly --- .gitignore | 6 +++++- .gitmodules | 3 --- CMakeLists.txt | 3 ++- README.md | 34 ++++++++++++++++++++-------------- big-list-of-naughty-strings | 1 - examples/example.cpp | 2 +- src/blns/blns.cpp | 5 +++-- 7 files changed, 31 insertions(+), 23 deletions(-) delete mode 100644 .gitmodules delete mode 160000 big-list-of-naughty-strings diff --git a/.gitignore b/.gitignore index 271938e..d95b334 100644 --- a/.gitignore +++ b/.gitignore @@ -88,4 +88,8 @@ Makefile #CLion .idea -cmake-* \ No newline at end of file +cmake-* +build + +# Blns.txt downloaded file +blns.txt \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c3382cb..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "big-list-of-naughty-strings"] - path = big-list-of-naughty-strings - url = https://github.com/minimaxir/big-list-of-naughty-strings.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 02c77cc..0fb6c7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.5) project(blnscpp VERSION 1.0) - +file(DOWNLOAD https://raw.githubusercontent.com/minimaxir/big-list-of-naughty-strings/master/blns.txt + ${CMAKE_CURRENT_LIST_DIR}/blns.txt) include(cmake/build_example.cmake) diff --git a/README.md b/README.md index 4f4fb5f..1764cb4 100644 --- a/README.md +++ b/README.md @@ -16,21 +16,13 @@ Powerلُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ冗 Œ„´‰ˇÁ¨ˆØ∏” ``` -# Example Usage -```c++ -#include "blns.h" -#include - -auto blns = blns::Blns{}; -for (auto const &ns : blns.getStrings()) { - std::cout << ns << "\n"; -} -``` - # CMake Integration You can setup your CMake project to use BLNS using [CPM](https://github.com/cpm-cmake/CPM.cmake) -(no need to download / clone this repo manually): +(no need to download / clone this repo manually). + +Consider you want to add blns to a project called `myapp`. Here is what +your CMakeLists.txt file looks like: ```cmake project("myapp") @@ -49,9 +41,23 @@ With this setup, you can use blns like so in `myapp.cpp`: #include int main() { - auto blns = blns::Blns{}; + auto blns = blns::Blns(); for (auto const &ns : blns.getStrings()) { - std::cout << ns << "\n"; + std::cout << ns << std::endl; } } +``` + +# Local Build + +```bash +mkdir build && cd build +cmake .. +cmake --build . +``` + +Run example : + +```bash +./blns_example ``` \ No newline at end of file diff --git a/big-list-of-naughty-strings b/big-list-of-naughty-strings deleted file mode 160000 index 894882e..0000000 --- a/big-list-of-naughty-strings +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 894882e7d1f3f2383aa472fdce4a80b8cd256df4 diff --git a/examples/example.cpp b/examples/example.cpp index 3872cdd..294d951 100644 --- a/examples/example.cpp +++ b/examples/example.cpp @@ -5,6 +5,6 @@ int main() { auto blns = blns::Blns{}; for (auto const &ns : blns.getStrings()) { - std::cout << ns << "\n"; + std::cout << ns << std::endl; } } \ No newline at end of file diff --git a/src/blns/blns.cpp b/src/blns/blns.cpp index 7d664e0..77148f2 100644 --- a/src/blns/blns.cpp +++ b/src/blns/blns.cpp @@ -5,9 +5,10 @@ blns::Blns::Blns() { std::ifstream blnsFile = std::filesystem::path(__FILE__).parent_path() - / ".." / ".." / "big-list-of-naughty-strings" / "blns.txt"; + / ".." / ".." / "blns.txt"; - // If this assertion fails, ensure that you have correctly initialized and updated the submodules for this repo + // If this assertion fails, ensure that you have correctly + // downloaded blns.txt at the root of the project during cmake build assert(blnsFile.is_open()); std::string line;