libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
Core Utilities

General-purpose utilities, error handling, and diagnostics. More...

Files

file  namespace.h
 
file  platform.h
 
file  util.h
 

Classes

struct  BuildInfo
 Holds compile-time build information for the library. More...
 
class  CmdLineParser
 Command-line argument parser with callback-driven option handling. More...
 
class  Color
 General-purpose RGBA color. More...
 
class  Env
 Provides access to process environment variables. More...
 
class  Error
 Lightweight error code wrapper for the promeki library. More...
 
class  FourCC
 A four-character code (FourCC) identifier. More...
 
class  JsonObject
 JSON object container wrapping nlohmann::json. More...
 
class  KeyEvent
 Event delivered when a key is pressed or released. More...
 
class  Logger
 Asynchronous thread-safe logging facility. More...
 
class  MemPool
 Thread-safe memory pool allocator with external metadata. More...
 
class  MemSpace
 Abstraction for memory allocation in different address spaces. More...
 
class  Metadata
 Key-value metadata container using typed Variant values. More...
 
class  MouseEvent
 Event delivered for mouse input. More...
 
class  NumName
 Deconstructs a numbered name into its prefix, number, and suffix components. More...
 
class  NumNameSeq
 Describes a NumName sequence with a head and tail range. More...
 
class  ObfuscatedString< N, Seed >
 Compile-time string obfuscation. More...
 
class  Pair< A, B >
 Typed pair container wrapping std::pair. More...
 
class  Random
 Pseudo-random number generator wrapping std::mt19937_64. More...
 
class  StructDatabase< KeyType, StructType >
 A database that maps keys to struct entries, initialized from an initializer list. More...
 
class  System
 Provides system-level utility functions. More...
 
class  Terminal
 Low-level terminal I/O abstraction. More...
 
class  UUID
 Universally Unique Identifier (UUID). More...
 

Macros

#define PROMEKI_SHARED(BASE)
 Macro to simplify making a base object into a native shared object.
 
#define PROMEKI_VARIANT_TYPES
 X-macro that defines all supported Variant types.
 

Typedefs

template<typename T >
using Result = Pair< T, Error >
 Convenience alias for fallible return types.
 

Functions

template<typename Container >
PROMEKI_NAMESPACE_BEGIN Container sorted (Container c)
 Returns a sorted copy of the container.
 
PROMEKI_NAMESPACE_BEGIN constexpr uint64_t fnv1a (const char *s, uint64_t seed=0xcbf29ce484222325ULL)
 Computes the FNV-1a hash of a null-terminated string at compile time.
 
PROMEKI_NAMESPACE_BEGIN void secureZero (void *ptr, size_t size)
 Securely zeros a memory region, guaranteed not to be optimized away.
 

Detailed Description

General-purpose utilities, error handling, and diagnostics.

Variant type, Error reporting, UUID generation, FourCC codes, Metadata key-value store, environment access, command-line parsing, logging, memory pools, platform detection, terminal I/O, and more.

Macro Definition Documentation

◆ PROMEKI_SHARED

#define PROMEKI_SHARED (   BASE)
Value:
public: \
RefCount _promeki_refct; \
virtual BASE *_promeki_clone() const { return new BASE(*this); }
Dynamic array container wrapping std::vector.
Definition list.h:40
An atomic reference count object.
Definition sharedptr.h:101

Macro to simplify making a base object into a native shared object.

You may use this in your class definition to quickly implement the functionality required to make an object into a native shared object. Note, this macro assumes you'll be using polymorphism and so will create a virtual _promeki_clone() function. You'll need to ensure you make your destructor virtual.

Example:

class MyBaseClass {
public:
virtual ~MyBaseClass();
// The rest of your class definition
}
List()=default
Default constructor. Creates an empty list.
#define PROMEKI_SHARED(BASE)
Macro to simplify making a base object into a native shared object.
Definition sharedptr.h:44

It does the following:

  • Adds a public member "RefCount _promeki_refct" for the reference counting.
  • Adds a "virtual BASE *_promeki_clone() const" function that returns a new copy of the object (using the object's copy constructor).

◆ PROMEKI_VARIANT_TYPES

#define PROMEKI_VARIANT_TYPES
Value:
X(TypeInvalid, std::monostate) \
X(TypeBool, bool) \
X(TypeU8, uint8_t) \
X(TypeS8, int8_t) \
X(TypeU16, uint16_t) \
X(TypeS16, int16_t) \
X(TypeU32, uint32_t) \
X(TypeS32, int32_t) \
X(TypeU64, uint64_t) \
X(TypeS64, int64_t) \
X(TypeFloat, float) \
X(TypeDouble, double) \
X(TypeString, String) \
X(TypeDateTime, DateTime) \
X(TypeTimeStamp, TimeStamp) \
X(TypeSize2D, Size2Du32) \
X(TypeUUID, UUID) \
X(TypeTimecode, Timecode) \
X(TypeRational, Rational<int>)
Wall-clock date and time based on std::chrono::system_clock.
Definition datetime.h:39
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
A monotonic timestamp based on std::chrono::steady_clock.
Definition timestamp.h:32
Class for holding and manipulating timecode.
Definition timecode.h:45
Universally Unique Identifier (UUID).
Definition uuid.h:34

X-macro that defines all supported Variant types.

Each entry has the form X(EnumName, CppType). The macro is expanded in several contexts inside VariantImpl:

  • To generate the Type enum (TypeInvalid, TypeBool, ..., TypeRational).
  • To generate the typeName() lookup table.
  • To instantiate the std::variant template parameter list.

The order of entries determines the numeric value of each Type enumerator and must match the order of template arguments passed to std::variant.

Enumerator C++ type
TypeInvalid std::monostate
TypeBool bool
TypeU8 uint8_t
TypeS8 int8_t
TypeU16 uint16_t
TypeS16 int16_t
TypeU32 uint32_t
TypeS32 int32_t
TypeU64 uint64_t
TypeS64 int64_t
TypeFloat float
TypeDouble double
TypeString String
TypeDateTime DateTime
TypeTimeStamp TimeStamp
TypeSize2D Size2Du32
TypeUUID UUID
TypeTimecode Timecode
TypeRational Rational<int>

Typedef Documentation

◆ Result

template<typename T >
using Result = Pair<T, Error>

Convenience alias for fallible return types.

Wraps a value and an Error in a Pair. Structured bindings work naturally: auto [val, err] = someFactory();

Template Parameters
TThe value type.

Function Documentation

◆ fnv1a()

PROMEKI_NAMESPACE_BEGIN constexpr uint64_t fnv1a ( const char s,
uint64_t  seed = 0xcbf29ce484222325ULL 
)
constexpr

Computes the FNV-1a hash of a null-terminated string at compile time.

Uses the 64-bit FNV-1a algorithm to produce a hash from a C string. The function is constexpr, so it can be evaluated at compile time when given a constant expression argument.

Parameters
sPointer to the null-terminated input string.
seedInitial hash value (defaults to the FNV offset basis).
Returns
The 64-bit FNV-1a hash.

◆ secureZero()

PROMEKI_NAMESPACE_BEGIN void secureZero ( void ptr,
size_t  size 
)
inline

Securely zeros a memory region, guaranteed not to be optimized away.

Uses platform-specific secure zeroing primitives when available:

  • Windows: SecureZeroMemory
  • glibc 2.25+/BSD: explicit_bzero
  • Fallback: volatile pointer write loop

This function cannot fail. If ptr is nullptr or size is 0, it is a no-op.

Parameters
ptrPointer to the memory region to zero.
sizeNumber of bytes to zero.

◆ sorted()

Returns a sorted copy of the container.

Template Parameters
ContainerA container with begin()/end() and a copy constructor.
Parameters
cThe source container.
Returns
A sorted copy.