Skip to content

Commit

Permalink
Get rid of submodule and download blns.txt from master directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Teskann committed May 30, 2022
1 parent 29efbe2 commit 5fd845e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 23 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ Makefile

#CLion
.idea
cmake-*
cmake-*
build

# Blns.txt downloaded file
blns.txt
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

34 changes: 20 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,13 @@ Powerلُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ冗
Œ„´‰ˇÁ¨ˆØ∏”
```

# Example Usage
```c++
#include "blns.h"
#include <iostream>

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")
Expand All @@ -49,9 +41,23 @@ With this setup, you can use blns like so in `myapp.cpp`:
#include <iostream>

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
```
1 change: 0 additions & 1 deletion big-list-of-naughty-strings
Submodule big-list-of-naughty-strings deleted from 894882
2 changes: 1 addition & 1 deletion examples/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
5 changes: 3 additions & 2 deletions src/blns/blns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5fd845e

Please sign in to comment.