base module contains reusable cross platform tools and utilities.The base module contains reusable cross platform tools and utilities.
| 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. |
| 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. |
| 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. |
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. |
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. |
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. |
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. |
| 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. |
std::vector< char > Buffer()Core buffer type.
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.
Signal< void()> NullSignal()Zero-argument signal alias used for simple local event notifications.
template<typename RT> Signal< RT, std::shared_mutex > ThreadSignal()Cross-thread signal variant.
template<typename RT> 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.
| 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](api_icy.md#namespaceicy_1aad3e81b3cd2daab89338dae9b5323f6badd4ec0ac4e58f7c32a01244ae91150b1). |
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()](api_icy.md#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). |
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.
loop Event loop on which to schedule the callback.
func Callable to invoke on the next loop tick.
args Arguments forwarded to func.
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.
message Descriptive context for the error.
err libuv error code (e.g. from a failed uv_* call). Defaults to UV_UNKNOWN.
Formatted error string.
inline
inline void throwError(std::string_view message, int err)Throws a std::runtime_error with a formatted error message.
message Descriptive context for the error.
err libuv error code to append. Defaults to UV_UNKNOWN.
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.
T Pointer type; must be implicitly castable to void*.data Pointer to the start of the memory region.
size Number of bytes in the region.
[MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) referencing the given memory.
inline
inline MutableBuffer mutableBuffer(std::string & str)Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a std::string.
str Source string. Must remain valid while the buffer is in use.[MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) wrapping the string's internal storage.
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.
str Source string. Must remain valid while the buffer is in use.[MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) wrapping the string's internal storage.
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.
T Element type of the vector.vec Source vector. Must remain valid while the buffer is in use.[MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) wrapping the vector's internal storage.
inline
inline MutableBuffer mutableBuffer(Buffer & buf)Creates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a Buffer.
buf Source buffer. Must remain valid while the buffer is in use.[MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) wrapping the buffer's data.
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.
buf Source buffer. Must remain valid while the buffer is in use.[MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) wrapping the buffer's data.
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.
T Pointer type; must be implicitly castable to const void*.data Pointer to the start of the memory region.
size Number of bytes in the region.
[ConstBuffer](icy-ConstBuffer.html#constbuffer-6) referencing the given memory.
inline
inline ConstBuffer constBuffer(const std::string & str)Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a std::string.
str Source string. Must remain valid while the buffer is in use.[ConstBuffer](icy-ConstBuffer.html#constbuffer-6) wrapping the string's internal storage.
inline
template<typename T> inline ConstBuffer constBuffer(const std::vector< T > & vec)Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a std::vector.
T Element type of the vector.vec Source vector. Must remain valid while the buffer is in use.[ConstBuffer](icy-ConstBuffer.html#constbuffer-6) wrapping the vector's internal storage.
inline
inline constexpr ConstBuffer constBuffer(const MutableBuffer & buf)Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6).
buf Source mutable buffer.[ConstBuffer](icy-ConstBuffer.html#constbuffer-6) referencing the same memory region.
inline
template<typename T> inline ConstBuffer constBuffer(Buffer & buf)Creates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a Buffer.
T Unused; kept for overload symmetry.buf Source buffer. Must remain valid while the buffer is in use.[ConstBuffer](icy-ConstBuffer.html#constbuffer-6) wrapping the buffer's data.
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.
T Unused; kept for overload symmetry.buf Source buffer. Must remain valid while the buffer is in use.[ConstBuffer](icy-ConstBuffer.html#constbuffer-6) wrapping the buffer's data.
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.
PointerToPodType Target pointer type (e.g. char*, uint8_t*).b Source mutable buffer.Pointer to the buffer's data, cast to PointerToPodType.
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.
PointerToPodType Target pointer type (e.g. const char*, const uint8_t*).b Source const buffer.Pointer to the buffer's data, cast to PointerToPodType.
inline
inline Level getLevelFromString(const char * level)Converts a log level string to its corresponding Level enum value. Unrecognized strings default to [Level::Trace](api_icy.md#namespaceicy_1aad3e81b3cd2daab89338dae9b5323f6badd4ec0ac4e58f7c32a01244ae91150b1).
level Lowercase level string: "trace", "debug", "info", "warn", "error", or "fatal".The matching Level enum value.
inline
inline const char * getStringFromLevel(Level level)Converts a Level enum value to its lowercase string representation.
level The log level to convert.Lowercase C string: "trace", "debug", "info", "warn", "error", or "fatal".
template<typename T> void logArgs(std::ostream & o, T && t)Write a single logging argument into the destination stream.
o Destination stream.
t Argument to append with operator<<.
template<typename T, typename... Args> void logArgs(std::ostream & o, T && t, Args &&... args)Write multiple logging arguments into the destination stream in order.
o Destination stream.
t First argument to append.
args Remaining arguments to append recursively.
constexpr const char * str_end(const char * str)Return a pointer to the null terminator of a C string.
constexpr bool str_slant(const char * str)Return true if the C string contains a forward or back slash.
constexpr const char * r_slant(const char * str)Walk backward to the character after the last path separator.
constexpr const char * _fileName(const char * str)Return the filename portion of a compile-time path string.
inline
inline std::string _methodName(std::string_view fsig)Extract the class-qualified method name from a compiler pretty-function string.
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.
T Type of the object to delete.ptr Object to delete. Does nothing if nullptr.
loop Event loop on which to schedule the deletion.
template<typename T, typename... Args> IntrusivePtr< T > makeIntrusive(Args &&... args)Creates an IntrusivePtr managing a newly heap-allocated T. Equivalent to std::make_shared.
T Type to construct; must inherit from RefCountedargs Arguments forwarded to T's constructor.IntrusivePtr
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.
Class The class that owns the member function.
RT Return type of the member function.
Args Parameter types of the member function.
instance Pointer to the object on which method will be called.
method Pointer to the non-const member function to bind.
id Explicit slot ID to assign; pass -1 to auto-assign.
priority Higher values are called first; pass -1 for default ordering.
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.
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.
RT Return type of the function.
Args Parameter types of the function.
method Pointer to the free function to bind.
id Explicit slot ID to assign; pass -1 to auto-assign.
priority Higher values are called first; pass -1 for default ordering.
A SlotPtr ready to attach to a compatible [Signal](icy-Signal.html#signal).
inline
inline void swap(DateTime & d1, DateTime & d2)Exchange two DateTime values.
inline
inline void swap(LocalDateTime & d1, LocalDateTime & d2)Exchange two LocalDateTime values.
inline
inline void swap(Timestamp & s1, Timestamp & s2)Exchange two Timestamp values.
inline
inline void swap(Timespan & s1, Timespan & s2)Exchange two Timespan values.
std::string getExePath()Cross-platform utilities.
Returns the current executable path.
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(int ms)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(std::string_view name, std::string_view defaultValue)Return an environment variable or the default value.
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.
inline
inline void set8(void * memory, size_t offset, uint8_t v)Writes a single byte at the given offset in memory.
memory Pointer to the destination buffer.
offset Byte offset within the buffer.
v Value to write.
inline
inline uint8_t get8(const void * memory, size_t offset)Reads a single byte at the given offset from memory.
memory Pointer to the source buffer.
offset Byte offset within the buffer.
The byte value at the specified offset.
inline
inline void setBE16(void * memory, uint16_t v)Writes a 16-bit value to memory in big-endian byte order.
memory Pointer to the destination buffer (must be at least 2 bytes).
v Value to write.
inline
inline void setBE32(void * memory, uint32_t v)Writes a 32-bit value to memory in big-endian byte order.
memory Pointer to the destination buffer (must be at least 4 bytes).
v Value to write.
inline
inline void setBE64(void * memory, uint64_t v)Writes a 64-bit value to memory in big-endian byte order.
memory Pointer to the destination buffer (must be at least 8 bytes).
v Value to write.
inline
inline uint16_t getBE16(const void * memory)Reads a 16-bit big-endian value from memory.
memory Pointer to the source buffer (must be at least 2 bytes).The 16-bit value in host byte order.
inline
inline uint32_t getBE32(const void * memory)Reads a 32-bit big-endian value from memory.
memory Pointer to the source buffer (must be at least 4 bytes).The 32-bit value in host byte order.
inline
inline uint64_t getBE64(const void * memory)Reads a 64-bit big-endian value from memory.
memory Pointer to the source buffer (must be at least 8 bytes).The 64-bit value in host byte order.
inline
inline void setLE16(void * memory, uint16_t v)Writes a 16-bit value to memory in little-endian byte order.
memory Pointer to the destination buffer (must be at least 2 bytes).
v Value to write.
inline
inline void setLE32(void * memory, uint32_t v)Writes a 32-bit value to memory in little-endian byte order.
memory Pointer to the destination buffer (must be at least 4 bytes).
v Value to write.
inline
inline void setLE64(void * memory, uint64_t v)Writes a 64-bit value to memory in little-endian byte order.
memory Pointer to the destination buffer (must be at least 8 bytes).
v Value to write.
inline
inline uint16_t getLE16(const void * memory)Reads a 16-bit little-endian value from memory.
memory Pointer to the source buffer (must be at least 2 bytes).The 16-bit value in host byte order.
inline
inline uint32_t getLE32(const void * memory)Reads a 32-bit little-endian value from memory.
memory Pointer to the source buffer (must be at least 4 bytes).The 32-bit value in host byte order.
inline
inline uint64_t getLE64(const void * memory)Reads a 64-bit little-endian value from memory.
memory Pointer to the source buffer (must be at least 8 bytes).The 64-bit value in host byte order.
inline
inline bool isBigEndian()Returns true if the host CPU is big-endian.
true if the host byte order is big-endian, false if little-endian.
inline
inline uint16_t hostToNetwork16(uint16_t n)Converts a 16-bit value from host byte order to network (big-endian) byte order.
n Value in host byte order.Value in network byte order.
inline
inline uint32_t hostToNetwork32(uint32_t n)Converts a 32-bit value from host byte order to network (big-endian) byte order.
n Value in host byte order.Value in network byte order.
inline
inline uint64_t hostToNetwork64(uint64_t n)Converts a 64-bit value from host byte order to network (big-endian) byte order.
n Value in host byte order.Value in network byte order.
inline
inline uint16_t networkToHost16(uint16_t n)Converts a 16-bit value from network (big-endian) byte order to host byte order.
n Value in network byte order.Value in host byte order.
inline
inline uint32_t networkToHost32(uint32_t n)Converts a 32-bit value from network (big-endian) byte order to host byte order.
n Value in network byte order.Value in host byte order.
inline
inline uint64_t networkToHost64(uint64_t n)Converts a 64-bit value from network (big-endian) byte order to host byte order.
n Value in network byte order.Value in host byte order.
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.
callback Optional function called on SIGINT.
opaque Optional user data pointer passed to the callback.
loop Event loop to attach the signal watcher to.
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()](api_icy.md#onshutdownsignal) then uv_run().
callback Optional function called on SIGINT before the loop exits.
opaque Optional user data pointer passed to the callback.
loop Event loop to run.
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.
Class Listener class type.
RT Return type of the listener method.
PT Derived packet type the listener expects (must derive from IT).
IT Base packet interface type; defaults to [IPacket](icy-IPacket.html#ipacket).
instance Pointer to the listener object.
method Member function pointer on Class accepting a PT&.
id Optional slot identifier; -1 for automatic assignment.
priority Optional slot priority; higher values run first.
A shared slot suitable for connecting to a PacketSignal.
constexpr unsigned operator|(PacketFlags lhs, PacketFlags rhs)Combine PacketFlags values into a bitmask.
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).
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).
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).
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).