This library contains useful classes and functions for quick and simple data manipulation. The idea is that this will not only take the grunt work out of C++, but it will help decrease development time of other projects.
In particular, the idea behind rolling a custom string class was to have better built-in support for string manipulation, as well as full support for different string formats.
Currently only Linux and Windows builds are supported, as those are the only machines I own. Both 64 and 32-bit builds should be fully supported. This also does compile on the Raspberry Pi and seems stable, however, tests currently do not run on that platform.
Strings are chosen by encoding, not character size. In this way, they're consistent across operating systems. They can be implicitly converted between encoding and are done so on-the-fly when interacting with streams.
Strings also have a full suite of operations that can be done on them, and can be cast to and from many types, including std::complex and floats in scientific notation.
When dealing with data that may have an unknown type at compile-time, a generic datatype may come in handy.
Another powerful feature is the support for various generators, with many useful built-ins and support for easy custom generators. For example, a memory efficient way to read lines in a file is with z::file::lines
:
Map, filter, and reduce are of course supported, which makes building custom generators extremely easy.
There are MANY more features of generators, so be sure and check out the examples for more use cases!
Other features include:
As with the rest of this library, all the platform-specific stuff is abstracted away.
Check out the examples/ directory for a longer list of example programs.
Currently the Makefile supports compiling on Linux and Windows only, as those are the only systems I have. ¯\_(ツ)_/¯
It should compile on any 64 or 32-bit flavor of these systems (including the Raspberry Pi!).
The only requirements are Make and a C++ compiler that supports at least C++11 (C++17 or newer preferred). If g++ --version
is 5 or above, chances are you're good.
This library has optional support for serialization via cereal. The following classes should be able to be saved and loaded with cereal:
If cereal is not installed however, this library should compile just fine. Again, totally optional.
By default, make should pick the best options for your machine. If that's not the case, or you want/need different options for any other reason, here are some example flags you can tweak:
CC=c++
to compile with c++
instead of g++
.LN=gcc
to link with gcc
instead of g++
.BITS=64
to target 64-bit architecture instead of that of the host machine. Available options are 64, 32, or null.STD=c++11
to use the C++11 standard instead of the default C++17. This is the same as the -std=...
flag.OPT=X
to set the optimization level. X should be a non-negative integer, (s
or size
), or (f
or fast
).LIBDIR=/lib/install/dir
to set where the library should install under instead of /usr/lib
.ICLDIR=/include/install/dir
to set where the headers should be copied to instead of /usr/include
.Just run make in the project directory. I do the following:
so that it will compile on as many cores as possible. On Windows you may have to run mingw32-make
instead, or if you are crosspiling for Windows on Linux, use make TARGET=win64 -j$(nproc)
or make TARGET=win32 -j$(nproc)
. (Make sure to run make clean
if you change the value of TARGET
!!)
The above will compile as a dynamic library (.so on Linux, .dll on Windows). To compile to a static library:
You should get no errors or warnings. You can open an issue on GitHub if either of those pop up while compiling.
In Linux, either run make install
as superuser or sudo make install
.
In Windows you can save the DLL into whatever directory you want, just make sure the PATH system variable contains that folder.
Alternatively, you can copy the DLL/SO into the working directory of your project and tell the linker to load it from there.
Suppose you have some simple project called example.cpp
. Let's have this file contain the following:
To compile and link to the installed library:
If the DLL/SO and header files are saved in a specific directory that's not in PATH (for example if compiling for Windows):
If linking to the static library (libzed.a), I'd suggest removing unused code to cut down on resultant binary size. The compile step for this is the same, just alter the linker step:
Note the effectiveness of this depends on the architecture and the specific compiler used.
Afterwards, if binary size is still an issue, stripping out symbols may help a bit. You may also be able to use gzexe
to compress the binary and reduce size even further. Note that these tricks will NOT work with dll/so files, only executables!
Download or fork this repo | Documentation is here | Look here if you want to contribute