How-To Guides

This library has two purposes: to provide some cross-platform abstractions, and to provide often used utility functionality for other interpeer projects.

For this reason, it seems prudent to cut to the chase, and provide guides for how to accomplish certain tasks with this library. These are sorted by related concerns, which are also reflected in the include directories and namespaces of the library.

Support with C++ Types

How-To make C++ types comparable

Making complex C++ types comparable, e.g. for use in sorted containers such as std::map.

How-To make C++ types hashable

Create hashes from C++ types, and make them usable in e.g. unsorted containers such as std::unordered_map.

Special C++ Types

How-To work with binary data

Using bytes – and avoiding both char * and void * in the process.

How-To use variable sized integers

Use a special integer type to signal that you might want to serialize it in variable length encoding.

How-To use extended type traits

Using extended type traits.

Serialization

How-To (de-)serialize integers

Serialize and deserialize integer types.

How-To (de-)serialize integers in variable length

Variable sized integer serialization and deserialization.

Filesystem Utilities

How-To convert filesystem paths between WIN32 and POSIX

Convert between POSIX-style and WIN32-style paths.

How-To generate temporary file names

Generate names for temporary files in appropriate scratch directories.

Socket and Network Utilities

How-To use socket addresses in a portable way

Use different types of socket address and interface with system APIs for this.

How-To parse CIDR addresses into socket_address

Create socket addresses from CIDR-style strings.

How-To determine a socket address scope

Work with network masks and similar scope issues.

How-To create a network

Create a network, and determine some special addresses in it.

How-To manage a network

Manage address assignments in a network.

How-To work with URLs

Parse and manipulate Uniform Resource Locators (URLs).

How-To parse IP headers

Parse addresses from IPv4 and IPv6 packet headers.

String Utilities

How-To work with UTF8 encoding

Convert to- and from UTF-8 strings on Windows.

How-To perform common string manipulations

Perform some common string manipulations, such as upper- and lowercasing strings, finding parts, or splitting them.

How-To work with URL encoding

Use URL encoding for strings.

How-To work with hex encoding

Hex encode or decode strings, and also use hex dumps for debugging.

System Utiliities

How-To deal with system errors

Deal with system error codes in a platform independent way.

How-To write cross-platform plugins

Write memory in a platform independent way.

How-To deal with process identifiers

Access process IDs in a platform independent way.

sys-plugin

Write cross-platform plugins.

Concurrency

How-To use tasklets

Using tasklets to simplify thread management.

How-To share data with a concurrent queue

Using a concurrent queue for sharing data between threads.

How-To dispatch commands to threads (CQRS)

Dispatch commands to worker threads and fetch results.

How-To use lock policies

Use lock policies to write code that may use locks, but can also be used lock free.

Miscellaneous

How-To use CRC32 checksums

Calculate and verify CRC32 checksums.

How-To create random numbers

Generate random bits in a cryptographically unsafe way.

How-To create exponential backoff timeouts

Generate exponential backoff series for timeouts.

How-To create log output

Use logging at various log levels in your code and choose your preferred logging backend.