Base module
base module contains reusable cross platform tools and utilities.base
The base module contains reusable cross platform tools and utilities.
Namespaces
| Name | Description |
|---|---|
hex | Hexadecimal encoding and decoding helpers. |
ipc | Classes for inter-process communication. |
test | Modern unit testing framework. |
time | Classes and functions for handling time. |
base64 | Base64 encoding and decoding helpers. |
deleter | Deleter helpers for objects managed through custom destruction routines. |
numeric | Integer parsing and formatting helpers. |
basic | Interface classes. |
fs | Cross-platform filesystem path and file helpers. |
util | Miscellaneous string, parsing, and version utilities. |
Classes
| Name | Description |
|---|---|
Pipe | Named pipe / stdio stream built on uv_pipe_t. |
Idler | Asynchronous type that triggers callbacks when the event loop is idle. |
Queue | Thread-safe queue container. |
RunnableQueue | Queue of runnable tasks for sequential execution. |
SyncQueue | SyncQueue extends Synchronizer to implement a synchronized FIFO queue which receives T objects from any thread and synchronizes them for safe consumption by the associated event loop. |
AsyncQueue | AsyncQueue is a thread-based queue which receives packets from any thread source and dispatches them asynchronously. |
Timer | Asynchronous event based timer. |
MutableBuffer | The MutableBuffer class provides a safe representation of a buffer that can be modified. It does not own the underlying data, and so is cheap to copy or assign. |
ConstBuffer | The ConstBuffer class provides a safe representation of a buffer that cannot be modified. It does not own the underlying data, and so is cheap to copy or assign. |
BitReader | Class for reading binary streams. |
BitWriter | Class for reading/writing binary streams. |
DynamicBitWriter | Class for reading/writing dynamically resizable binary streams. |
LogWriter | Log output stream writer. |
AsyncLogWriter | Thread based log output stream writer. |
Logger | Logger class. |
LogChannel | Named log output channel with configurable severity level and formatting. |
ConsoleChannel | Log channel that writes formatted messages to standard output. |
FileChannel | Log channel that writes formatted messages to a file. |
RotatingFileChannel | Log channel that writes to time-rotated log files. |
RefCounted | Base class for intrusive reference counting. |
IntrusivePtr | Intrusive smart pointer for RefCounted objects. |
Random | Random implements a pseudo random number generator (PRNG) using the Mersenne Twister algorithm (std::mt19937). |
Runner | Runner is a virtual interface for implementing asynchronous objects such as threads and futures. |
Signal< RT(Args...), MutexT > | Thread-safe signal and slot implementation for callback-based event dispatch. |
Stream | Basic stream type for sockets and pipes. |
Thread | Platform-independent wrapper around an operating system thread. |
Process | Spawns and manages a child process with stdin/stdout/stderr pipes. |
Timeout | Timeout counter which expires after a given delay. Delay is specified in milliseconds. |
TimedToken | Token that expires after the specified duration. |
Timestamp | A Timestamp stores a monotonic* time value with (theoretical) microseconds resolution. Timestamps can be compared with each other and simple arithmetics are supported. |
Timespan | A class that represents time spans up to microsecond resolution. |
DateTime | This class represents an instant in time, expressed in years, months, days, hours, minutes, seconds and milliseconds based on the Gregorian calendar. The class is mainly useful for conversions between UTC, Julian day and Gregorian calendar dates. |
Timezone | This class provides information about the current timezone. |
LocalDateTime | This class represents an instant in local time (as opposed to UTC), expressed in years, months, days, hours, minutes, seconds and milliseconds based on the Gregorian calendar. |
DateTimeFormat | Definition of date/time formats and various constants used by DateTimeFormatter and DateTimeParser. |
DateTimeFormatter | This class converts dates and times into strings, supporting a variety of standard and custom formats. |
DateTimeParser | This class provides a method for parsing dates and times from strings. All parsing methods do their best to parse a meaningful result, even from malformed input strings. |
Stopwatch | A simple facility to measure time intervals with microsecond resolution. |
ThreadedStreamReader | Threaded stream reader class. |
StreamWriter | Packet stream writer class. |
State | State class for state machines. |
Stateful | State machine implementation. |
IRegistry | Abstract interface for object registries. |
Singleton | Helper template class for managing singleton objects allocated on the heap. |
KeyedStore | A keyed store of unique_ptr values with optional lifecycle hooks. Not thread-safe; designed for single-threaded event loop contexts. |
KVCollection | A keyed value store (values stored by copy, not pointer). |
NVCollection | A storage container for a name value collections. This collection can store multiple entries for each name, and it's getters are case-insensitive. |
Application | Main icey application class. |
SyncPacketQueue | Synchronized packet queue for event loop integration. |
AsyncPacketQueue | Thread-based asynchronous packet dispatch queue. |
RateLimiter | Token bucket rate limiter for throttling message send frequency. |
PacketStreamAdapter | This class is a wrapper for integrating external classes with the a PacketStream's data flow and state machine. |
PacketProcessor | This class is a virtual interface for creating PacketStreamAdapters which process that and emit the IPacket type. |
PacketStream | Processes and broadcasts IPackets through a configurable adapter graph. |
Synchronizer | Synchronizer enables any thread to communicate with the associated event loop via synchronized callbacks. |
TimedManager | Timed pointer manager |
IPacketCreationStrategy | Abstract strategy for creating typed packets from raw buffer data. |
PacketFactory | Priority-ordered factory that creates typed packets from raw buffers using registered strategies. |
StreamManager | Manages a named collection of PacketStream instances with lifecycle callbacks. |
IDiagnostic | Abstract interface for diagnostic information providers. |
AsyncDiagnostic | Asynchronous diagnostic information collector. |
DiagnosticManager | Registry and manager for diagnostic providers. |
PacketTransaction | Request/response transaction with timeout and retry logic. |
Base64PacketEncoder | Packet processor that Base64-encodes packet data. |
Task | Abstract base class for implementing asynchronous tasks. |
TaskRunner | Runner for tasks that inherit the [Task](icy-Task.html#task) interface. |
IPacket | The basic packet type which is passed around the icey system. IPacket can be extended for each protocol to enable polymorphic processing and callbacks using PacketStream and friends. |
FlagPacket | Packet for sending bitwise flags along the packet stream. |
RawPacket | RawPacket is the default data packet type which consists of an optionally managed char pointer and a size value. |
Configuration | Configuration is an abstract base class for managing different kinds of configuration storage back ends such as JSON, XML, or database. |
ScopedConfiguration | ScopedConfiguration provides multiple levels of configuration for a module. Multiple levels means that there is a module level scope, and a default scope. When a property is accessed, the module scope value will be used if available, otherwise the default scope value will be used. |
Error | Basic error type. |
LogStream | No-op log record used when logging is compiled out. |
NullSharedMutex | No-op mutex for single-threaded signal usage. When all signal operations occur on a single libuv event loop thread, the shared_mutex is unnecessary overhead. |
Bitwise | Container for smart management of bitwise integer flags. |
AbstractDelegate | Abstract delegate interface. |
FunctionDelegate | The [FunctionDelegate](icy-FunctionDelegate.html#functiondelegate) contains a std::function. |
ClassDelegate | The [ClassDelegate](icy-ClassDelegate.html#classdelegate) contains a pointer to a class member. |
ConstClassDelegate | The [ConstClassDelegate](icy-ConstClassDelegate.html#constclassdelegate) contains a pointer to a const class member. |
PolymorphicDelegate | Polymorphic function delegate. |
OptionParser | Command-line option parser. |
ShutdownCmd | Shutdown command packet for signalling process termination. |
PacketAdapterReference | Provides a reference to a PacketStreamAdapter with optional ownership. |
PacketStreamState | State machine states for PacketStream. |
PacketCreationStrategy | This template class implements an adapter that sits between an SignalBase and an object receiving notifications from it. |
SharedLibrary | Loads a shared library at runtime and resolves exported symbols. |
DiagnosticState | State definitions for diagnostic providers. |
TransactionState | State machine states for PacketTransaction. |
IPacketInfo | An abstract interface for packet sources to provide extra information about packets. |
Enumerations
| Name | Description |
|---|---|
Level | Logging severity levels used by Logger and LogChannel. |
ByteOrder | Byte-order policy used when reading or writing multi-byte integers. |
PacketRetention | Describes how an adapter treats incoming packet lifetime beyond the current synchronous call chain. |
PacketFlags | Flags which determine how the packet is handled by the PacketStream. |
Level
enum LevelLogging severity levels used by Logger and LogChannel.
| Value | Description |
|---|---|
Trace | Most verbose diagnostic output. |
Debug | Debug-only diagnostic output. |
Info | Normal informational output. |
Warn | Warning output for recoverable problems. |
Error | Error output for failed operations. |
Fatal | Fatal output immediately before termination. |
ByteOrder
enum ByteOrderByte-order policy used when reading or writing multi-byte integers.
| Value | Description |
|---|---|
Network | Default, use network byte order (big endian). |
Host | Use the native order of the host. |
PacketRetention
enum PacketRetentionDescribes how an adapter treats incoming packet lifetime beyond the current synchronous call chain.
Borrowed adapters must finish using the packet before emit()/process() returns. Cloned and Retained adapters are explicit ownership boundaries: callers may mutate or free borrowed input only after such a boundary, or after the whole synchronous write/emit call has returned.
| Value | Description |
|---|---|
Borrowed | Packet is only used synchronously during the current emit/process call. |
Cloned | Adapter makes its own copy before deferred or asynchronous use. |
Retained | Adapter retains the original packet object beyond the current call chain. |
PacketFlags
enum PacketFlagsFlags which determine how the packet is handled by the PacketStream.
| Value | Description |
|---|---|
NoModify | The packet should not be modified by processors. |
Final | The final packet in the stream. |
Typedefs
| Return | Name | Description |
|---|---|---|
std::vector< char > | Buffer | Core buffer type. |
LogChannel | NullChannel | Null log channel. |
Signal< void()> | NullSignal | Zero-argument signal alias used for simple local event notifications. |
Signal< RT, std::shared_mutex > | ThreadSignal | Cross-thread signal variant. |
Signal< RT, NullSharedMutex > | LocalSignal | Compatibility alias for the single-threaded fast path. |
uv_process_options_t | ProcessOptions | Raw libuv process spawn options passed through to uv_spawn. |
std::map< std::string, std::string > | StringMap | Generic string-to-string map used for headers, options, and environment-style metadata. |
std::vector< std::string > | StringVec | Generic string vector used for argument lists and ordered string collections. |
std::map< std::string, std::string > | OptionMap | Command Line Option Parser. |
Signal< void(IPacket &)> | PacketSignal | Signal that broadcasts [IPacket](icy-IPacket.html#ipacket) types. |
PacketStreamAdapter | PacketSource | For 0.8.x compatibility. |
PacketProcessor | IPacketizer | Compatibility alias for a packet processor that packetizes stream output. |
PacketProcessor | IDepacketizer | For 0.8.x compatibility. |
std::vector< PacketAdapterReference::Ptr > | PacketAdapterVec | Ordered list of packet adapter references used for sources and processors. |
std::vector< PacketStream * > | PacketStreamVec | Non-owning list of packet stream pointers used for graph traversal helpers. |
std::vector< PacketStream::Ptr > | PacketStreamPtrVec | Owning list of packet stream handles retained across stream graphs. |
std::unique_ptr< IPacketCreationStrategy > | PacketCreationStrategyPtr | Owning handle for one packet creation strategy. |
std::vector< PacketCreationStrategyPtr > | PacketCreationStrategyList | Ordered list of packet creation strategies consulted by a packet factory. |
Buffer
std::vector< char > Buffer()Core buffer type.
NullChannel
LogChannel NullChannel()Null log channel.
Redifine the base [LogChannel](icy-LogChannel.html#logchannel) as NullChannel so it can be logically used as a disabled log channel.
NullSignal
Signal< void()> NullSignal()Zero-argument signal alias used for simple local event notifications.
ThreadSignal
template<typename RT> Signal< RT, std::shared_mutex > ThreadSignal()Cross-thread signal variant.
LocalSignal
template<typename RT> Signal< RT, NullSharedMutex > LocalSignal()Compatibility alias for the single-threaded fast path.
ProcessOptions
uv_process_options_t ProcessOptions()Raw libuv process spawn options passed through to uv_spawn.
StringMap
std::map< std::string, std::string > StringMap()Generic string-to-string map used for headers, options, and environment-style metadata.
StringVec
std::vector< std::string > StringVec()Generic string vector used for argument lists and ordered string collections.
OptionMap
std::map< std::string, std::string > OptionMap()Command Line Option Parser.
PacketSignal
Signal< void(IPacket &)> PacketSignal()Signal that broadcasts [IPacket](icy-IPacket.html#ipacket) types.
PacketSource
PacketStreamAdapter PacketSource()For 0.8.x compatibility.
IPacketizer
PacketProcessor IPacketizer()Compatibility alias for a packet processor that packetizes stream output.
IDepacketizer
PacketProcessor IDepacketizer()For 0.8.x compatibility.
PacketAdapterVec
std::vector< PacketAdapterReference::Ptr > PacketAdapterVec()Ordered list of packet adapter references used for sources and processors.
PacketStreamVec
std::vector< PacketStream * > PacketStreamVec()Non-owning list of packet stream pointers used for graph traversal helpers.
PacketStreamPtrVec
std::vector< PacketStream::Ptr > PacketStreamPtrVec()Owning list of packet stream handles retained across stream graphs.
PacketCreationStrategyPtr
std::unique_ptr< IPacketCreationStrategy > PacketCreationStrategyPtr()Owning handle for one packet creation strategy.
PacketCreationStrategyList
std::vector< PacketCreationStrategyPtr > PacketCreationStrategyList()Ordered list of packet creation strategies consulted by a packet factory.
Functions
| Return | Name | Description |
|---|---|---|
void | runOnce | Schedules func to run once at the beginning of the next event loop iteration. Uses a uv_prepare_t handle that self-destructs after the first invocation. |
std::string | formatError inline | Formats a human-readable error string from a message and a libuv error code. If err is not UV_UNKNOWN, the libuv error description is appended after a colon. |
void | throwError inline | Throws a std::runtime_error with a formatted error message. |
MutableBuffer | mutableBuffer inline | Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from an arbitrary pointer and size. |
MutableBuffer | mutableBuffer inline | Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a std::string. |
MutableBuffer | mutableBuffer inline | Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a const std::string. Casts away constness; use with care. |
MutableBuffer | mutableBuffer inline | Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a const std::vector. Casts away constness; use with care. |
MutableBuffer | mutableBuffer inline | Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a Buffer. |
MutableBuffer | mutableBuffer inline | Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a const Buffer. Casts away constness; use with care. |
ConstBuffer | constBuffer inline | Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from an arbitrary pointer and size. |
ConstBuffer | constBuffer inline | Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a std::string. |
ConstBuffer | constBuffer inline | Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a std::vector. |
constexpr ConstBuffer | constBuffer inline | Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6). |
ConstBuffer | constBuffer inline | Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a Buffer. |
ConstBuffer | constBuffer inline | Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a const Buffer. Casts away constness internally; use with care. |
constexpr PointerToPodType | bufferCast inline | Casts a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) to a specified pointer-to-POD type. |
constexpr PointerToPodType | bufferCast inline | Casts a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) to a specified pointer-to-POD type. |
Level | getLevelFromString inline | Converts a log level string to its corresponding Level enum value. Unrecognized strings default to Level::Trace. |
const char * | getStringFromLevel inline | Converts a Level enum value to its lowercase string representation. |
void | logArgs | Write a single logging argument into the destination stream. |
void | logArgs | Write multiple logging arguments into the destination stream in order. |
constexpr const char * | str_end | Return a pointer to the null terminator of a C string. |
constexpr bool | str_slant | Return true if the C string contains a forward or back slash. |
constexpr const char * | r_slant | Walk backward to the character after the last path separator. |
constexpr const char * | _fileName | Return the filename portion of a compile-time path string. |
std::string | _methodName inline | Extract the class-qualified method name from a compiler pretty-function string. |
void | deleteLater inline | Schedules deferred deletion of ptr on the next event loop iteration. This is essential for deleting objects that may still be referenced by pending libuv callbacks (e.g. socket adapters with in-flight I/O). Uses a self-cleaning uv_idle_t handle that fires once and then closes itself. |
IntrusivePtr< T > | makeIntrusive | Creates an IntrusivePtr managing a newly heap-allocated T. Equivalent to std::make_shared. |
std::shared_ptr< internal::Slot< RT, Args... > > | slot | Creates a slot that binds a non-const class member function to an instance. |
std::shared_ptr< internal::Slot< RT, Args... > > | slot | Creates a slot that wraps a free (static) function pointer. |
void | swap inline | Exchange two DateTime values. |
void | swap inline | Exchange two LocalDateTime values. |
void | swap inline | Exchange two Timestamp values. |
void | swap inline | Exchange two Timespan values. |
std::string | getExePath | Cross-platform utilities. |
std::string | getCwd | Return the current working directory. |
uint64_t | getFreeMemory | Returns the current amount of free memory. |
uint64_t | getTotalMemory | Returns the current amount of used memory. |
int | numCpuCores | Returns the number of CPU cores. |
void | sleep | Pause the current thread for the given ms duration. |
void | pause | Pause the current thread until enter is pressed. |
std::string | getHostname | Return the system hostname. |
std::string | getEnv | Return an environment variable or the default value. |
bool | getEnvBool | Return an environment variable boolean or the default value. The variable must be 1 or true for this function to return true. |
void | set8 inline | Writes a single byte at the given offset in memory. |
uint8_t | get8 inline | Reads a single byte at the given offset from memory. |
void | setBE16 inline | Writes a 16-bit value to memory in big-endian byte order. |
void | setBE32 inline | Writes a 32-bit value to memory in big-endian byte order. |
void | setBE64 inline | Writes a 64-bit value to memory in big-endian byte order. |
uint16_t | getBE16 inline | Reads a 16-bit big-endian value from memory. |
uint32_t | getBE32 inline | Reads a 32-bit big-endian value from memory. |
uint64_t | getBE64 inline | Reads a 64-bit big-endian value from memory. |
void | setLE16 inline | Writes a 16-bit value to memory in little-endian byte order. |
void | setLE32 inline | Writes a 32-bit value to memory in little-endian byte order. |
void | setLE64 inline | Writes a 64-bit value to memory in little-endian byte order. |
uint16_t | getLE16 inline | Reads a 16-bit little-endian value from memory. |
uint32_t | getLE32 inline | Reads a 32-bit little-endian value from memory. |
uint64_t | getLE64 inline | Reads a 64-bit little-endian value from memory. |
bool | isBigEndian inline | Returns true if the host CPU is big-endian. |
uint16_t | hostToNetwork16 inline | Converts a 16-bit value from host byte order to network (big-endian) byte order. |
uint32_t | hostToNetwork32 inline | Converts a 32-bit value from host byte order to network (big-endian) byte order. |
uint64_t | hostToNetwork64 inline | Converts a 64-bit value from host byte order to network (big-endian) byte order. |
uint16_t | networkToHost16 inline | Converts a 16-bit value from network (big-endian) byte order to host byte order. |
uint32_t | networkToHost32 inline | Converts a 32-bit value from network (big-endian) byte order to host byte order. |
uint64_t | networkToHost64 inline | Converts a 64-bit value from network (big-endian) byte order to host byte order. |
void | onShutdownSignal inline | Installs a SIGINT handler on the given event loop. When the signal fires, callback is invoked with opaque and the signal handle is closed. |
void | waitForShutdown inline | Installs a SIGINT handler and runs the event loop until shutdown. Equivalent to calling onShutdownSignal() then uv_run(). |
std::shared_ptr< internal::Slot< RT, IT & > > | packetSlot | Creates a signal slot that filters by packet subtype PT before invoking method. |
constexpr unsigned | [`operator | `](#operator) |
RawPacket | rawPacket inline | Constructs a non-owning RawPacket from a mutable buffer (borrowed pointer). |
RawPacket | rawPacket inline | Constructs an owning RawPacket from a const buffer (data is copied). |
RawPacket | rawPacket inline | Constructs a non-owning RawPacket from a raw mutable pointer (borrowed). |
RawPacket | rawPacket inline | Constructs an owning RawPacket from a const char pointer (data is copied). |
runOnce
template<typename Function, typename... Args> void runOnce(uv::Loop * loop, Function && func, Args &&... args)Schedules func to run once at the beginning of the next event loop iteration. Uses a uv_prepare_t handle that self-destructs after the first invocation.
Parameters
loopEvent loop on which to schedule the callback.funcCallable to invoke on the next loop tick.argsArguments forwarded to func.
formatError
inline
inline std::string formatError(std::string_view message, int err)Formats a human-readable error string from a message and a libuv error code. If err is not UV_UNKNOWN, the libuv error description is appended after a colon.
Parameters
messageDescriptive context for the error.errlibuv error code (e.g. from a faileduv_*call). Defaults toUV_UNKNOWN.
Returns
Formatted error string.
throwError
inline
inline void throwError(std::string_view message, int err)Throws a std::runtime_error with a formatted error message.
Parameters
messageDescriptive context for the error.errlibuv error code to append. Defaults toUV_UNKNOWN.
mutableBuffer
inline
template<typename T> inline MutableBuffer mutableBuffer(T data, size_t size)Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from an arbitrary pointer and size.
Parameters
TPointer type; must be implicitly castable tovoid*.
Parameters
dataPointer to the start of the memory region.sizeNumber of bytes in the region.
Returns
[MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) referencing the given memory.
mutableBuffer
inline
inline MutableBuffer mutableBuffer(std::string & str)Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a std::string.
Parameters
strSource string. Must remain valid while the buffer is in use.
Returns
[MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) wrapping the string's internal storage.
mutableBuffer
inline
inline MutableBuffer mutableBuffer(const std::string & str)Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a const std::string. Casts away constness; use with care.
Parameters
strSource string. Must remain valid while the buffer is in use.
Returns
[MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) wrapping the string's internal storage.
mutableBuffer
inline
template<typename T> inline MutableBuffer mutableBuffer(const std::vector< T > & vec)Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a const std::vector. Casts away constness; use with care.
Parameters
TElement type of the vector.
Parameters
vecSource vector. Must remain valid while the buffer is in use.
Returns
[MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) wrapping the vector's internal storage.
mutableBuffer
inline
inline MutableBuffer mutableBuffer(Buffer & buf)Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a Buffer.
Parameters
bufSource buffer. Must remain valid while the buffer is in use.
Returns
[MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) wrapping the buffer's data.
mutableBuffer
inline
inline MutableBuffer mutableBuffer(const Buffer & buf)Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a const Buffer. Casts away constness; use with care.
Parameters
bufSource buffer. Must remain valid while the buffer is in use.
Returns
[MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) wrapping the buffer's data.
constBuffer
inline
template<typename T> inline ConstBuffer constBuffer(T data, size_t size)Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from an arbitrary pointer and size.
Parameters
TPointer type; must be implicitly castable toconst void*.
Parameters
dataPointer to the start of the memory region.sizeNumber of bytes in the region.
Returns
[ConstBuffer](icy-ConstBuffer.html#constbuffer-6) referencing the given memory.
constBuffer
inline
inline ConstBuffer constBuffer(const std::string & str)Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a std::string.
Parameters
strSource string. Must remain valid while the buffer is in use.
Returns
[ConstBuffer](icy-ConstBuffer.html#constbuffer-6) wrapping the string's internal storage.
constBuffer
inline
template<typename T> inline ConstBuffer constBuffer(const std::vector< T > & vec)Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a std::vector.
Parameters
TElement type of the vector.
Parameters
vecSource vector. Must remain valid while the buffer is in use.
Returns
[ConstBuffer](icy-ConstBuffer.html#constbuffer-6) wrapping the vector's internal storage.
constBuffer
inline
inline constexpr ConstBuffer constBuffer(const MutableBuffer & buf)Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6).
Parameters
bufSource mutable buffer.
Returns
[ConstBuffer](icy-ConstBuffer.html#constbuffer-6) referencing the same memory region.
constBuffer
inline
template<typename T> inline ConstBuffer constBuffer(Buffer & buf)Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a Buffer.
Parameters
TUnused; kept for overload symmetry.
Parameters
bufSource buffer. Must remain valid while the buffer is in use.
Returns
[ConstBuffer](icy-ConstBuffer.html#constbuffer-6) wrapping the buffer's data.
constBuffer
inline
template<typename T> inline ConstBuffer constBuffer(const Buffer & buf)Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a const Buffer. Casts away constness internally; use with care.
Parameters
TUnused; kept for overload symmetry.
Parameters
bufSource buffer. Must remain valid while the buffer is in use.
Returns
[ConstBuffer](icy-ConstBuffer.html#constbuffer-6) wrapping the buffer's data.
bufferCast
inline
template<typename PointerToPodType> inline constexpr PointerToPodType bufferCast(const MutableBuffer & b)Casts a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) to a specified pointer-to-POD type.
Parameters
PointerToPodTypeTarget pointer type (e.g.char*,uint8_t*).
Parameters
bSource mutable buffer.
Returns
Pointer to the buffer's data, cast to PointerToPodType.
bufferCast
inline
template<typename PointerToPodType> inline constexpr PointerToPodType bufferCast(const ConstBuffer & b)Casts a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) to a specified pointer-to-POD type.
Parameters
PointerToPodTypeTarget pointer type (e.g.const char*,const uint8_t*).
Parameters
bSource const buffer.
Returns
Pointer to the buffer's data, cast to PointerToPodType.
getLevelFromString
inline
inline Level getLevelFromString(const char * level)Converts a log level string to its corresponding Level enum value. Unrecognized strings default to Level::Trace.
Parameters
levelLowercase level string: "trace", "debug", "info", "warn", "error", or "fatal".
Returns
The matching Level enum value.
getStringFromLevel
inline
inline const char * getStringFromLevel(Level level)Converts a Level enum value to its lowercase string representation.
Parameters
levelThe log level to convert.
Returns
Lowercase C string: "trace", "debug", "info", "warn", "error", or "fatal".
logArgs
template<typename T> void logArgs(std::ostream & o, T && t)Write a single logging argument into the destination stream.
Parameters
oDestination stream.tArgument to append with operator<<.
logArgs
template<typename T, typename... Args> void logArgs(std::ostream & o, T && t, Args &&... args)Write multiple logging arguments into the destination stream in order.
Parameters
oDestination stream.tFirst argument to append.argsRemaining arguments to append recursively.
str_end
constexpr const char * str_end(const char * str)Return a pointer to the null terminator of a C string.
str_slant
constexpr bool str_slant(const char * str)Return true if the C string contains a forward or back slash.
r_slant
constexpr const char * r_slant(const char * str)Walk backward to the character after the last path separator.
_fileName
constexpr const char * _fileName(const char * str)Return the filename portion of a compile-time path string.
_methodName
inline
inline std::string _methodName(std::string_view fsig)Extract the class-qualified method name from a compiler pretty-function string.
deleteLater
inline
template<typename T> inline void deleteLater(T * ptr, uv::Loop * loop)Schedules deferred deletion of ptr on the next event loop iteration. This is essential for deleting objects that may still be referenced by pending libuv callbacks (e.g. socket adapters with in-flight I/O). Uses a self-cleaning uv_idle_t handle that fires once and then closes itself.
Parameters
TType of the object to delete.
Parameters
ptrObject to delete. Does nothing if nullptr.loopEvent loop on which to schedule the deletion.
makeIntrusive
template<typename T, typename... Args> IntrusivePtr< T > makeIntrusive(Args &&... args)Creates an IntrusivePtr managing a newly heap-allocated T. Equivalent to std::make_shared.
Parameters
TType to construct; must inherit from RefCounted.
Parameters
argsArguments forwarded to T's constructor.
Returns
IntrusivePtr
slot
template<class Class, class RT, typename... Args> std::shared_ptr< internal::Slot< RT, Args... > > slot(Class * instance, RT(Class::*)(Args...) method, int id, int priority)Creates a slot that binds a non-const class member function to an instance.
The returned SlotPtr can be passed to Signal::attach() or operator+=, and to Signal::detach() or operator-= to disconnect it later.
Parameters
ClassThe class that owns the member function.RTReturn type of the member function.ArgsParameter types of the member function.
Parameters
instancePointer to the object on whichmethodwill be called.methodPointer to the non-const member function to bind.idExplicit slot ID to assign; pass-1to auto-assign.priorityHigher values are called first; pass-1for default ordering.
Returns
A SlotPtr ready to attach to a compatible [Signal](icy-Signal.html#signal).
Creates a slot that binds a const class member function to an instance. Uses the same slot ID and priority rules as the non-const overload above.
slot
template<class RT, typename... Args> std::shared_ptr< internal::Slot< RT, Args... > > slot(RT(*)(Args...) method, int id, int priority)Creates a slot that wraps a free (static) function pointer.
Parameters
RTReturn type of the function.ArgsParameter types of the function.
Parameters
methodPointer to the free function to bind.idExplicit slot ID to assign; pass-1to auto-assign.priorityHigher values are called first; pass-1for default ordering.
Returns
A SlotPtr ready to attach to a compatible [Signal](icy-Signal.html#signal).
swap
inline
inline void swap(DateTime & d1, DateTime & d2)Exchange two DateTime values.
swap
inline
inline void swap(LocalDateTime & d1, LocalDateTime & d2)Exchange two LocalDateTime values.
swap
inline
inline void swap(Timestamp & s1, Timestamp & s2)Exchange two Timestamp values.
swap
inline
inline void swap(Timespan & s1, Timespan & s2)Exchange two Timespan values.
getExePath
std::string getExePath()Cross-platform utilities.
Returns the current executable path.
getCwd
std::string getCwd()Return the current working directory.
getFreeMemory
uint64_t getFreeMemory()Returns the current amount of free memory.
getTotalMemory
uint64_t getTotalMemory()Returns the current amount of used memory.
numCpuCores
int numCpuCores()Returns the number of CPU cores.
sleep
void sleep(int ms)Pause the current thread for the given ms duration.
pause
void pause()Pause the current thread until enter is pressed.
getHostname
std::string getHostname()Return the system hostname.
getEnv
std::string getEnv(std::string_view name, std::string_view defaultValue)Return an environment variable or the default value.
getEnvBool
bool getEnvBool(std::string_view name)Return an environment variable boolean or the default value. The variable must be 1 or true for this function to return true.
set8
inline
inline void set8(void * memory, size_t offset, uint8_t v)Writes a single byte at the given offset in memory.
Parameters
memoryPointer to the destination buffer.offsetByte offset within the buffer.vValue to write.
get8
inline
inline uint8_t get8(const void * memory, size_t offset)Reads a single byte at the given offset from memory.
Parameters
memoryPointer to the source buffer.offsetByte offset within the buffer.
Returns
The byte value at the specified offset.
setBE16
inline
inline void setBE16(void * memory, uint16_t v)Writes a 16-bit value to memory in big-endian byte order.
Parameters
memoryPointer to the destination buffer (must be at least 2 bytes).vValue to write.
setBE32
inline
inline void setBE32(void * memory, uint32_t v)Writes a 32-bit value to memory in big-endian byte order.
Parameters
memoryPointer to the destination buffer (must be at least 4 bytes).vValue to write.
setBE64
inline
inline void setBE64(void * memory, uint64_t v)Writes a 64-bit value to memory in big-endian byte order.
Parameters
memoryPointer to the destination buffer (must be at least 8 bytes).vValue to write.
getBE16
inline
inline uint16_t getBE16(const void * memory)Reads a 16-bit big-endian value from memory.
Parameters
memoryPointer to the source buffer (must be at least 2 bytes).
Returns
The 16-bit value in host byte order.
getBE32
inline
inline uint32_t getBE32(const void * memory)Reads a 32-bit big-endian value from memory.
Parameters
memoryPointer to the source buffer (must be at least 4 bytes).
Returns
The 32-bit value in host byte order.
getBE64
inline
inline uint64_t getBE64(const void * memory)Reads a 64-bit big-endian value from memory.
Parameters
memoryPointer to the source buffer (must be at least 8 bytes).
Returns
The 64-bit value in host byte order.
setLE16
inline
inline void setLE16(void * memory, uint16_t v)Writes a 16-bit value to memory in little-endian byte order.
Parameters
memoryPointer to the destination buffer (must be at least 2 bytes).vValue to write.
setLE32
inline
inline void setLE32(void * memory, uint32_t v)Writes a 32-bit value to memory in little-endian byte order.
Parameters
memoryPointer to the destination buffer (must be at least 4 bytes).vValue to write.
setLE64
inline
inline void setLE64(void * memory, uint64_t v)Writes a 64-bit value to memory in little-endian byte order.
Parameters
memoryPointer to the destination buffer (must be at least 8 bytes).vValue to write.
getLE16
inline
inline uint16_t getLE16(const void * memory)Reads a 16-bit little-endian value from memory.
Parameters
memoryPointer to the source buffer (must be at least 2 bytes).
Returns
The 16-bit value in host byte order.
getLE32
inline
inline uint32_t getLE32(const void * memory)Reads a 32-bit little-endian value from memory.
Parameters
memoryPointer to the source buffer (must be at least 4 bytes).
Returns
The 32-bit value in host byte order.
getLE64
inline
inline uint64_t getLE64(const void * memory)Reads a 64-bit little-endian value from memory.
Parameters
memoryPointer to the source buffer (must be at least 8 bytes).
Returns
The 64-bit value in host byte order.
isBigEndian
inline
inline bool isBigEndian()Returns true if the host CPU is big-endian.
Returns
true if the host byte order is big-endian, false if little-endian.
hostToNetwork16
inline
inline uint16_t hostToNetwork16(uint16_t n)Converts a 16-bit value from host byte order to network (big-endian) byte order.
Parameters
nValue in host byte order.
Returns
Value in network byte order.
hostToNetwork32
inline
inline uint32_t hostToNetwork32(uint32_t n)Converts a 32-bit value from host byte order to network (big-endian) byte order.
Parameters
nValue in host byte order.
Returns
Value in network byte order.
hostToNetwork64
inline
inline uint64_t hostToNetwork64(uint64_t n)Converts a 64-bit value from host byte order to network (big-endian) byte order.
Parameters
nValue in host byte order.
Returns
Value in network byte order.
networkToHost16
inline
inline uint16_t networkToHost16(uint16_t n)Converts a 16-bit value from network (big-endian) byte order to host byte order.
Parameters
nValue in network byte order.
Returns
Value in host byte order.
networkToHost32
inline
inline uint32_t networkToHost32(uint32_t n)Converts a 32-bit value from network (big-endian) byte order to host byte order.
Parameters
nValue in network byte order.
Returns
Value in host byte order.
networkToHost64
inline
inline uint64_t networkToHost64(uint64_t n)Converts a 64-bit value from network (big-endian) byte order to host byte order.
Parameters
nValue in network byte order.
Returns
Value in host byte order.
onShutdownSignal
inline
inline void onShutdownSignal(std::function< void(void *)> callback, void * opaque, uv::Loop * loop)Installs a SIGINT handler on the given event loop. When the signal fires, callback is invoked with opaque and the signal handle is closed.
Parameters
callbackOptional function called on SIGINT.opaqueOptional user data pointer passed to the callback.loopEvent loop to attach the signal watcher to.
waitForShutdown
inline
inline void waitForShutdown(std::function< void(void *)> callback, void * opaque, uv::Loop * loop)Installs a SIGINT handler and runs the event loop until shutdown. Equivalent to calling onShutdownSignal() then uv_run().
Parameters
callbackOptional function called on SIGINT before the loop exits.opaqueOptional user data pointer passed to the callback.loopEvent loop to run.
packetSlot
template<class Class, class RT, class PT, class IT> std::shared_ptr< internal::Slot< RT, IT & > > packetSlot(Class * instance, RT(Class::*)(PT &) method, int id, int priority)Creates a signal slot that filters by packet subtype PT before invoking method.
The returned slot is connected to a PacketSignal (which broadcasts [IPacket](icy-IPacket.html#ipacket)&). The slot performs a dynamic_cast on each received packet; if the cast succeeds, the listener method is called with the derived type PT. Non-matching packets are silently ignored.
Parameters
ClassListener class type.RTReturn type of the listener method.PTDerived packet type the listener expects (must derive fromIT).ITBase packet interface type; defaults to[IPacket](icy-IPacket.html#ipacket).
Parameters
instancePointer to the listener object.methodMember function pointer onClassaccepting aPT&.idOptional slot identifier; -1 for automatic assignment.priorityOptional slot priority; higher values run first.
Returns
A shared slot suitable for connecting to a PacketSignal.
operator|
constexpr unsigned operator|(PacketFlags lhs, PacketFlags rhs)Combine PacketFlags values into a bitmask.
rawPacket
inline
inline RawPacket rawPacket(const MutableBuffer & buf, unsigned flags, std::unique_ptr< IPacketInfo > info)Constructs a non-owning RawPacket from a mutable buffer (borrowed pointer).
rawPacket
inline
inline RawPacket rawPacket(const ConstBuffer & buf, unsigned flags, std::unique_ptr< IPacketInfo > info)Constructs an owning RawPacket from a const buffer (data is copied).
rawPacket
inline
inline RawPacket rawPacket(char * data, size_t size, unsigned flags, std::unique_ptr< IPacketInfo > info)Constructs a non-owning RawPacket from a raw mutable pointer (borrowed).
rawPacket
inline
inline RawPacket rawPacket(const char * data, size_t size, unsigned flags, std::unique_ptr< IPacketInfo > info)Constructs an owning RawPacket from a const char pointer (data is copied).
