This library is header only so the most basic way to use it is to
- Download the sources
- Set your include path to
lib/inc
Note that you need to have your compiler to use at least C++20 mode in order for build to succeed.
With modern CMake the easiest way to use this library is
include(FetchContent)
FetchContent_Declare(sys_string
GIT_REPOSITORY git@github.com:gershnik/sys_string.git
GIT_TAG <desired tag like v3.2>
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(sys_string)
...
target_link_libraries(mytarget
PRIVATE
sys_string::sys_string
)Alternatively, you can clone this repository somewhere and do this:
add_subdirectory(<dowload_path>/lib, sys_string)
...
target_link_libraries(mytarget
PRIVATE
sys_string::sys_string
)Note that you need to have your compiler to default to at least C++17 or set CMAKE_CXX_STANDARD to at least 17 in order for build to succeed.
You can also build and install this library on your system using CMake.
- Download or clone this repository into SOME_PATH
- On command line:
cd SOME_PATH
cmake -S . -B build
cmake --build build
#Optional
#cmake --build build --target run-test
#install to /usr/local
sudo cmake --install build
#or for a different prefix
#cmake --install build --prefix /usrOnce the library has been installed it can be used in the following ways:
Set the include directory to <prefix>/include where <prefix> is the install prefix from above.
find_package(sys_string)
target_link_libraries(mytarget
PRIVATE
sys_string::sys_string
)Add the output of pkg-config --cflags sys_string to your compiler flags.
Note that the default installation prefix /usr/local might not be in the list of places your
pkg-config looks into. If so you might need to do:
export PKG_CONFIG_PATH=/usr/local/share/pkgconfigbefore running pkg-config
Whichever method you use you can set the following macros (either on command line or before including any library headers) to control the library behavior:
SYS_STRING_NO_S_MACRO- set it to 1 to disable shortS()macro. See Usage for detailsSYS_STRING_USE_GENERIC- set it to 1 to useconst char *as defaultsys_stringstorage regardless of platform.SYS_STRING_USE_ICU- set it to 1 to use ICU instead of internal code for case conversion, normalization and grapheme iteration. ICU headers must present on include path and available via#include <unicode/...>. You will also need to link with ICU libraries.SYS_STRING_WIN_BSTR- set it to 1 to useBSTRas defaultsys_stringstorage on Windows. It has no effect on other platforms.SYS_STRING_WIN_HSTRING- set it to 1 to useHSTRINGas defaultsys_stringstorage on Windows. It has no effect on other platforms.SYS_STRING_ENABLE_PYTHON- set it to 1 to enable Python support. This requires header<Python.h>to be available on the include path. If enabled thesys_string_pystrand related classes become available. This doesn't change the defaultsys_string.SYS_STRING_USE_PYTHON- set it to 1 to make Python strings the defaultsys_stringstorage. This automatically enablesSYS_STRING_ENABLE_PYTHONand has the same requirements.