https://github.com/arapelle/arba-strn
A C++ library providing short trivially comparable string classes whose hash are trivially computable.
https://github.com/arapelle/arba-strn
cmake cpp cpp20 cpp20-library hash library string
Last synced: 5 months ago
JSON representation
A C++ library providing short trivially comparable string classes whose hash are trivially computable.
- Host: GitHub
- URL: https://github.com/arapelle/arba-strn
- Owner: arapelle
- License: mit
- Created: 2019-12-01T16:41:49.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-05-01T10:05:49.000Z (about 1 year ago)
- Last Synced: 2025-05-01T10:30:19.636Z (about 1 year ago)
- Topics: cmake, cpp, cpp20, cpp20-library, hash, library, string
- Language: C++
- Homepage:
- Size: 172 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Concept #
The purpose is to provide short string classes (8 bytes max) whose hashs are trivially computable
(no loop operation), and comparison operations are trivial too (no loop operation again).
# Install #
## Requirements ##
Binaries:
- A C++20 compiler (ex: g++-14)
- CMake 3.26 or later
Testing Libraries (optional):
- [Google Test](https://github.com/google/googletest) 1.14 or later (optional)
## Clone
```
git clone https://github.com/arapelle/arba-strn --recurse-submodules
```
## Use with `conan`
Create the conan package.
```
conan create . --build=missing -c
```
Add a requirement in your conanfile project file.
```python
def requirements(self):
self.requires("arba-strn/0.6.0")
```
## Quick Install ##
There is a cmake script at the root of the project which builds the library in *Release* mode and install it (default options are used).
```
cd /path/to/arba-strn
cmake -P cmake/scripts/quick_install.cmake
```
Use the following to quickly install a different mode.
```
cmake -P cmake/scripts/quick_install.cmake -- TESTS BUILD Debug DIR /tmp/local
```
## Uninstall ##
There is a uninstall cmake script created during installation. You can use it to uninstall properly this library.
```
cd /path/to/installed-arba-strn/
cmake -P uninstall.cmake
```
# How to use
## Example - "Hi world"
```c++
#include
#include
#include
int main()
{
strn::string64 str("Hi world");
std::cout << str << std::endl;
return EXIT_SUCCESS;
}
```
## Example - As a map key
```c++
#include
#include
#include
#include
int main()
{
std::unordered_map dict;
dict["id1"] = "A long string";
dict["id2"] = "Another long string";
dict["12345678"] = "'12345678' length is string64 max length.";
// dict["123456789"] = "It cannot compile as only 8-length or shorter C-string are accepted.";
std::cout << dict["id1"] << std::endl << std::endl;
for (const auto& entry : dict)
std::cout << entry.first << ": " << entry.second << std::endl;
return EXIT_SUCCESS;
}
# License
[MIT License](./LICENSE.md) © arba-strn