C++ Utilities  4.9.1
Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities
README.md
Go to the documentation of this file.
1 # C++ utilities
2 Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities.
3 
4 ## Features
5 The library utilizes:
6 
7 * parsing command-line arguments and providing Bash completion
8 * dealing with dates and times
9 * conversion of primitive data types to byte-buffers and vice versa (litte-endian and big-endian)
10 * common string conversions/operations, eg.
11  - character set conversion via iconv
12  - split, join, find and replace
13  - conversion from number to string and vice verca
14  - encoding/decoding base-64
15  - building string without multiple heap allocations (string builder)
16 * IO
17  - reading/writing primitive data types of various sizes (little-endian and big-endian)
18  - reading/writing terminated strings and size-prefixed strings
19  - reading/writing INI files
20  - reading bitwise
21 * building with CMake by providing some modules and templates
22 
23 ## Build instructions
24 ### Requirements
25 #### Build-only dependencies
26 * C++ compiler supporting C++14, tested with
27  - Clang
28  - regular GNU g++
29  - mingw-w64 g++
30  - Cygwin g++
31 * CMake (at least 3.3.0)
32 * cppunit for unit tests (optional)
33 * Doxygen for API documentation (optional)
34 * Graphviz for diagrams in the API documentation (optional)
35 * clang-format for tidying (optional)
36 * llvm-profdata, llvm-cov and cppunit for source-based code coverage analysis (optional)
37 
38 #### Runtime dependencies
39 * The c++utilities library itself only needs
40  - C/C++ standard library supporting C++14
41  - libiconv (might be part of glibc or provided as extra library)
42 * For dependencies of my other projects check the README.md of these projects.
43 
44 ### How to build
45 Just run:
46 ```
47 cd "path/to/build/directory"
48 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/final/install/location" "path/to/projectdirectory"
49 make tidy # format source files (optional)
50 make
51 make check # build and run unit tests (optional)
52 make apidoc # build API documentation (optional)
53 make DESTDIR="/temporary/install/location" install
54 ```
55 
56 #### General notes
57 * Building with qmake is not supported anymore.
58 * The make option ```-j``` can be used for concurrent compilation.
59 * ```LIB_SUFFIX```, ```LIB_SUFFIX_32``` and ```LIB_SUFFIX_64``` can be set to
60  specify a suffix for the library directory, eg. lib*64* or lib*32*. The 32/64 variants are only used when building for 32/64-bit architecture.
61 * By default the build system will *build* shared libs. To *build* also static libraries, set `ENABLE_STATIC_LIBS=ON`. To disable building shared libs
62  set `DISABLE_SHARED_LIBS=ON`.
63 * By default the build system will prefer *linking against* shared libraries. To force *linking against* static libraries set `STATIC_LINKAGE=ON`.
64  However, this will only affect applications. To force linking statically when building shared libraries set `STATIC_LIBRARY_LINKAGE=ON`.
65 
66 #### Building for Windows
67 Building for Windows with Mingw-w64 cross compiler can be utilized using a small
68 [cmake wrapper from Fedora](https://aur.archlinux.org/cgit/aur.git/tree/mingw-cmake.sh?h=mingw-w64-cmake):
69 ```
70 ${_arch}-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/final/install/location" "path/to/source/directory"
71 make DESTDIR="/temporary/install/location" install-mingw-w64-strip
72 ```
73 * To create the \*.ico file for the application icon ffmpeg/avconv is required.
74 * The target ```install-mingw-w64-strip``` in the example will only install files
75  suitable for creating a cross-compiler package and additionally strip the binaries.
76 
77 #### Development builds
78 During development I find it useful to build all required projects (for instace c++utilities, qtutilities, tagparser and tageditor) as one big project.
79 
80 This can be easily achieved by using CMake's ```add_subdirectory()``` function. For project files
81 see the repository [subdirs](https://github.com/Martchus/subdirs). For an example, see
82 [build instructions for Syncthing Tray](https://github.com/Martchus/syncthingtray#building-this-straight).
83 
84 For a debug build, just use ```-DCMAKE_BUILD_TYPE=Debug```.
85 
86 #### Arch Linux package
87 The repository [PKGBUILDs](https://github.com/Martchus/PKGBUILDs) contains files
88 for building Arch Linux packages.
89 
90 PKGBUILD files to build for Windows using the Mingw-w64 compiler are also included.
91 
92 #### RPM packages
93 RPM \*.spec files can be found at [openSUSE Build Servide](https://build.opensuse.org/project/show/home:mkittler).
94 Those files have only been tested under Tumbleweed so far.
95 
96 #### Gentoo
97 Packages are provided by perfect7gentleman; checkout his [repository](https://github.com/perfect7gentleman/pg_overlay).
98 
99 #### Cygwin
100 Scripts to build with Cygwin are provided by svnpenn. Checkout his
101 [repository](https://github.com/svnpenn/glade).
102 
103 ### General notes
104 * There is a workaround for [GCC Bug 66145](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66145) provided
105  in io/catchiofailure.h.
106 
107 ## TODO
108 - remove unused features