Zth (libzth)

Classes

struct  zth::vector_type< T >
 std::vector type using Config::Allocator::type. More...
 
struct  zth::map_type< Key, T, Compare >
 std::map type using Config::Allocator::type. More...
 
struct  zth::list_type< T >
 std::list type using Config::Allocator::type. More...
 
class  zth::Runnable
 An abstract class, that can be started as a fiber. More...
 
class  zth::UniqueID< T, ThreadSafe >
 Keeps track of a process-wide unique ID within the type T. More...
 
class  zth::Singleton< T >
 Singleton pattern. More...
 
class  zth::ThreadLocalSingleton< T >
 Singleton pattern, but only per-thread. More...
 
class  zth::small_vector< T, Prealloc, Allocator >
 A simple std::vector, which can contain Prealloc without heap allocation. More...
 

Macros

#define ZTH_CLASS_NEW_DELETE(T)
 Define new/delete operators for a class, which are allocator-aware. More...
 
#define zth_dbg(group, fmt, a...)
 Debug printf()-like function. More...
 
#define ZTH_VERSION_MAJOR   1
 Zth major version as int. More...
 
#define ZTH_VERSION_MINOR   1
 Zth minor version as int. More...
 
#define ZTH_VERSION_PATCH   1
 Zth patch version as int. More...
 
#define ZTH_VERSION_SUFFIX   "-alpha"
 Zth version suffix as string literal. More...
 
#define ZTH_VERSION
 Zth version as string literal. More...
 
#define ZTH_VERSION_NUM
 Zth version as number. More...
 

Typedefs

typedef std::basic_string< char, std::char_traits< char >, Config::Allocator< char >::type > zth::string
 std::string type using Config::Allocator::type. More...
 

Functions

void zth::log_color (int color, char const *fmt,...)
 Logs a given printf()-like formatted string using an ANSI color code. More...
 
void zth::logv (char const *fmt, va_list arg)
 Logs a given printf()-like formatted string. More...
 
void zth::log (char const *fmt,...)
 Logs a given printf()-like formatted string. More...
 
constexpr char const * zth::version () noexcept
 Returns the version of Zth. More...
 
char const * zth::banner () noexcept
 Prints a banner line with version and configuration information. More...
 
void zth::abort (char const *fmt,...) noexcept
 Aborts the process after printing the given printf() formatted message. More...
 
void zth::abortv (char const *fmt, va_list args) noexcept
 Aborts the process after printing the given printf() formatted message. More...
 
void zth::log_colorv (int color, char const *fmt, va_list args)
 Logs a given printf()-like formatted string using an ANSI color code. More...
 

Detailed Description

Macro Definition Documentation

◆ ZTH_CLASS_NEW_DELETE

#define ZTH_CLASS_NEW_DELETE (   T)
Value:
public: \
void* operator new(std::size_t UNUSED_PAR(n)) \
{ \
zth_assert(n == sizeof(T)); \
return ::zth::allocate<T>(); \
} \
void operator delete(void* ptr) \
{ \
::zth::deallocate<T>(static_cast<T*>(ptr)); \
} \
\
private:
#define UNUSED_PAR(name)
Definition: macros.h:79

Define new/delete operators for a class, which are allocator-aware.

Put a call to this macro in the private section of your class definition. Additionally, make sure to have a virtual destructor to deallocate subclasses properly.

Parameters
Tthe type of the class for which the operators are to be defined

Definition at line 114 of file allocator.h.

◆ zth_dbg

#define zth_dbg (   group,
  fmt,
  a... 
)

Debug printf()-like function.

Prints the given string for debugging purposes. The string is subject to the EnableDebugPrint configuration, and ANSI coloring.

Parameters
groupone of the zth::Config::Print_x, where only x has to be specified
fmtprintf()-like formatting string
aarguments for fmt

Definition at line 210 of file util.h.

◆ ZTH_VERSION

#define ZTH_VERSION

Zth version as string literal.

Definition at line 47 of file version.h.

◆ ZTH_VERSION_MAJOR

#define ZTH_VERSION_MAJOR   1

Zth major version as int.

◆ ZTH_VERSION_MINOR

#define ZTH_VERSION_MINOR   1

Zth minor version as int.

◆ ZTH_VERSION_NUM

#define ZTH_VERSION_NUM

Zth version as number.

The format is the decimal value MMmmpp, where MM is the major version, mm the minor, and pp the patch version. The suffix is not included.

Definition at line 60 of file version.h.

◆ ZTH_VERSION_PATCH

#define ZTH_VERSION_PATCH   1

Zth patch version as int.

◆ ZTH_VERSION_SUFFIX

#define ZTH_VERSION_SUFFIX   "-alpha"

Zth version suffix as string literal.

Typedef Documentation

◆ string

typedef std::basic_string<char, std::char_traits<char>, Config::Allocator<char>::type> zth::string

std::string type using Config::Allocator::type.

Definition at line 335 of file util.h.

Function Documentation

◆ abort()

void zth::abort ( char const *  fmt,
  ... 
)
noexcept

Aborts the process after printing the given printf() formatted message.

Examples
measure.cpp.

Definition at line 130 of file util.cpp.

◆ abortv()

void zth::abortv ( char const *  fmt,
va_list  args 
)
noexcept

Aborts the process after printing the given printf() formatted message.

Definition at line 142 of file util.cpp.

◆ banner()

char const * zth::banner ( )
noexcept

Prints a banner line with version and configuration information.

Examples
measure.cpp.

Definition at line 34 of file util.cpp.

◆ log()

void zth::log ( char const *  fmt,
  ... 
)
inline

Logs a given printf()-like formatted string.

zth_logv() is used for the actual logging.

See also
zth::log_color()
Examples
5_perf.cpp.

Definition at line 323 of file util.h.

◆ log_color()

void zth::log_color ( int  color,
char const *  fmt,
  ... 
)
inline

Logs a given printf()-like formatted string using an ANSI color code.

zth_logv() is used for the actual logging.

Definition at line 297 of file util.h.

◆ log_colorv()

void zth::log_colorv ( int  color,
char const *  fmt,
va_list  args 
)

Logs a given printf()-like formatted string using an ANSI color code.

zth_logv() is used for the actual logging.

Definition at line 221 of file util.cpp.

◆ logv()

void zth::logv ( char const *  fmt,
va_list  arg 
)
inline

Logs a given printf()-like formatted string.

zth_logv() is used for the actual logging.

See also
zth::log_colorv()

Definition at line 312 of file util.h.

◆ version()

constexpr char const* zth::version ( )
inlineconstexprnoexcept

Returns the version of Zth.

Definition at line 68 of file version.h.