SPSL is a header-only library for "special" string implementations. It contains the following string class templates:
ArrayString
/ArrayStringW
: Purely stack based string, similar to "plain" C arrays.PasswordString
/PasswordStringW
: String variant for sensitive data. All memory used by this string implementation is locked in RAM (i.e. it may not be swapped to disk) and is wiped before it's returned to the OS.
If you're interested in the motivation behind these templates, check out the Motivation document. If you're interested in the nitty gritty details of how this library works, head over to Implementation.
SPSL is a header-only library, so you don't need to compile anything. Just download it, include it in your project and you're good to go:
#include <spsl.hpp>
spsl::ArrayString<64> a1("I'm a stack-based string and can store 64 characters + NUL");
spsl::ArrayStringW<32> a2(L"Wide characters are ok, too.");
spsl::PasswordString pw1("I'm a secret!");
spsl::PasswordStringW pw2(L"Dream on...");
However, there are a lot of unit tests in this library. If you want to run them (to check compatibility with your platform or if you played with some library code), the next sections are for you.
The SPSL itself only relies on the STL and has no dependencies. To compile the tests, you'll need:
- CMake 3.2 or higher
- GSL-Lite (as git submodule):
Used to test compatibility with
gsl::byte
.
(A copy of the Catch2 test framework is contained.)
Supported compilers (we'll, the ones I've tested) include GCC 4.9+ and clang 4+ on Linux and Microsoft Visual Studio 2015+.
Make sure to clone this repository with:
git clone --recurse-submodules https://github.com/dermojo/spsl.git
SPSL comes with a lot of unit tests. They are compiled into the testlib
executable, which can
be run standalone or from cmake/ctest.
To build and run all tests, run the usual CMake commands:
mkdir build
cd build
cmake ..
cmake --build .
ctest -VV
This project is licensed under the MIT License - see the LICENSE file for details.
tl;dr: Feel free to use and modify the code or to include it in your commercial application.
This library uses the MurmurHash3 hash functions, copied thankfully from https://github.com/aappleby/smhasher. Thanks a lot!