Base module
base module contains reusable cross platform tools and utilities.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. |
Task | Abstract base class for implementing asynchronous tasks. |
TaskRunner | Runner for tasks that inherit the 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. |
LogVoidify | Adapts a LogStream expression to void so the streaming log macros can short-circuit on the level filter inside a ternary (glog-style): the message arguments are never evaluated for filtered-out levels. |
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 contains a std::function. |
ClassDelegate | The ClassDelegate contains a pointer to a class member. |
ConstClassDelegate | The 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. |
Macros
| Name | Description |
|---|---|
expect | |
__CLASS_FUNCTION__ | |
ICY_LOG_STREAM | |
STrace | |
SDebug | |
SInfo | |
SWarn | |
SError | |
ICY_LOG_WRITE | |
LTrace | |
LDebug | |
LInfo | |
LWarn | |
LError |
expect
#define expect(x) icy::test::expectImpl(x, #x, __FILE__, __LINE__)Defined in src/base/include/icy/test.h:67
CLASS_FUNCTION
#define __CLASS_FUNCTION__ _methodName(__PRETTY_FUNCTION__)Defined in src/base/include/icy/logger.h:624
ICY_LOG_STREAM
#define ICY_LOG_STREAM(lvl) !icy::Logger::levelEnabled(lvl) \
? (void)0 \
: icy::LogVoidify() & \
icy::LogStream(lvl, icy::_fileName(__FILE__), __LINE__)Defined in src/base/include/icy/logger.h:634
STrace
#define STrace ICY_LOG_STREAM(icy::Level::Trace)Defined in src/base/include/icy/logger.h:640
SDebug
#define SDebug ICY_LOG_STREAM(icy::Level::Debug)Defined in src/base/include/icy/logger.h:641
SInfo
#define SInfo ICY_LOG_STREAM(icy::Level::Info)Defined in src/base/include/icy/logger.h:642
SWarn
#define SWarn ICY_LOG_STREAM(icy::Level::Warn)Defined in src/base/include/icy/logger.h:643
SError
#define SError ICY_LOG_STREAM(icy::Level::Error)Defined in src/base/include/icy/logger.h:644
ICY_LOG_WRITE
#define ICY_LOG_WRITE(lvl, ...) do { \
if (icy::Logger::levelEnabled(lvl)) \
icy::LogStream(lvl, icy::_fileName(__FILE__), __LINE__) \
.write(__VA_ARGS__); \
} while (0)Defined in src/base/include/icy/logger.h:646
LTrace
#define LTrace(...) ICY_LOG_WRITE(icy::Level::Trace, __VA_ARGS__)Defined in src/base/include/icy/logger.h:653
LDebug
#define LDebug(...) ICY_LOG_WRITE(icy::Level::Debug, __VA_ARGS__)Defined in src/base/include/icy/logger.h:654
LInfo
#define LInfo(...) ICY_LOG_WRITE(icy::Level::Info, __VA_ARGS__)Defined in src/base/include/icy/logger.h:655
LWarn
#define LWarn(...) ICY_LOG_WRITE(icy::Level::Warn, __VA_ARGS__)Defined in src/base/include/icy/logger.h:656
LError
#define LError(...) ICY_LOG_WRITE(icy::Level::Error, __VA_ARGS__)Defined in src/base/include/icy/logger.h:657
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 LevelDefined in src/base/include/icy/logger.h:38
Logging 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 ByteOrderDefined in src/base/include/icy/byteorder.h:31
Byte-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 PacketRetentionDefined in src/base/include/icy/packetstream.h:202
Describes 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 PacketFlagsDefined in src/base/include/icy/packetstream.h:211
Flags 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 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
using Buffer = std::vector< char >Defined in src/base/include/icy/buffer.h:29
Core buffer type.
NullChannel
using NullChannel = LogChannelType: LogChannel
Defined in src/base/include/icy/logger.h:447
Null log channel.
Redifine the base LogChannel as NullChannel so it can be logically used as a disabled log channel.
NullSignal
using NullSignal = Signal< void()>Type: Signal< void()>
Defined in src/base/include/icy/signal.h:636
Zero-argument signal alias used for simple local event notifications.
ThreadSignal
using ThreadSignal = Signal< RT, std::shared_mutex >Type: Signal< RT, std::shared_mutex >
Defined in src/base/include/icy/signal.h:640
Cross-thread signal variant.
LocalSignal
using LocalSignal = Signal< RT, NullSharedMutex >Type: Signal< RT, NullSharedMutex >
Defined in src/base/include/icy/signal.h:644
Compatibility alias for the single-threaded fast path.
ProcessOptions
using ProcessOptions = uv_process_options_tDefined in src/base/include/icy/process.h:28
Raw libuv process spawn options passed through to uv_spawn.
StringMap
using StringMap = std::map< std::string, std::string >Defined in src/base/include/icy/collection.h:275
Generic string-to-string map used for headers, options, and environment-style metadata.
StringVec
using StringVec = std::vector< std::string >Defined in src/base/include/icy/collection.h:278
Generic string vector used for argument lists and ordered string collections.
OptionMap
using OptionMap = std::map< std::string, std::string >Defined in src/base/include/icy/application.h:100
Command Line Option Parser.
PacketSignal
using PacketSignal = Signal< void(IPacket &)>Type: Signal< void(IPacket &)>
Defined in src/base/include/icy/packetsignal.h:24
Signal that broadcasts IPacket types.
PacketSource
using PacketSource = PacketStreamAdapterType: PacketStreamAdapter
Defined in src/base/include/icy/packetstream.h:106
For 0.8.x compatibility.
IPacketizer
using IPacketizer = PacketProcessorType: PacketProcessor
Defined in src/base/include/icy/packetstream.h:141
Compatibility alias for a packet processor that packetizes stream output.
IDepacketizer
using IDepacketizer = PacketProcessorType: PacketProcessor
Defined in src/base/include/icy/packetstream.h:142
For 0.8.x compatibility.
PacketAdapterVec
using PacketAdapterVec = std::vector< PacketAdapterReference::Ptr >Type: std::vector< PacketAdapterReference::Ptr >
Defined in src/base/include/icy/packetstream.h:192
Ordered list of packet adapter references used for sources and processors.
PacketStreamVec
using PacketStreamVec = std::vector< PacketStream * >Type: std::vector< PacketStream * >
Defined in src/base/include/icy/packetstream.h:653
Non-owning list of packet stream pointers used for graph traversal helpers.
PacketStreamPtrVec
using PacketStreamPtrVec = std::vector< PacketStream::Ptr >Type: std::vector< PacketStream::Ptr >
Defined in src/base/include/icy/packetstream.h:656
Owning list of packet stream handles retained across stream graphs.
PacketCreationStrategyPtr
using PacketCreationStrategyPtr = std::unique_ptr< IPacketCreationStrategy >Type: std::unique_ptr< IPacketCreationStrategy >
Defined in src/base/include/icy/packetfactory.h:46
Owning handle for one packet creation strategy.
PacketCreationStrategyList
using PacketCreationStrategyList = std::vector< PacketCreationStrategyPtr >Type: std::vector< PacketCreationStrategyPtr >
Defined in src/base/include/icy/packetfactory.h:49
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 from an arbitrary pointer and size. |
MutableBuffer | mutableBuffer inline | Creates a MutableBuffer from a std::string. |
MutableBuffer | mutableBuffer inline | Creates a MutableBuffer from a const std::string. Casts away constness; use with care. |
MutableBuffer | mutableBuffer inline | Creates a MutableBuffer from a const std::vector. Casts away constness; use with care. |
MutableBuffer | mutableBuffer inline | Creates a MutableBuffer from a Buffer. |
MutableBuffer | mutableBuffer inline | Creates a MutableBuffer from a const Buffer. Casts away constness; use with care. |
ConstBuffer | constBuffer inline | Creates a ConstBuffer from an arbitrary pointer and size. |
ConstBuffer | constBuffer inline | Creates a ConstBuffer from a std::string. |
ConstBuffer | constBuffer inline | Creates a ConstBuffer from a std::vector. |
constexpr ConstBuffer | constBuffer inline constexpr | Creates a ConstBuffer from a MutableBuffer. |
ConstBuffer | constBuffer inline | Creates a ConstBuffer from a Buffer. |
ConstBuffer | constBuffer inline | Creates a ConstBuffer from a const Buffer. Casts away constness internally; use with care. |
constexpr PointerToPodType | bufferCast inline constexpr | Casts a MutableBuffer to a specified pointer-to-POD type. |
constexpr PointerToPodType | bufferCast inline constexpr | Casts a ConstBuffer 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 constexpr | Return a pointer to the null terminator of a C string. |
constexpr bool | str_slant constexpr | Return true if the C string contains a forward or back slash. |
constexpr const char * | r_slant constexpr | Walk backward to the character after the last path separator. |
constexpr const char * | _fileName constexpr | 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) constexpr` |
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)Defined in src/base/include/icy/once.h:29
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
| Parameter | Type | Description |
|---|---|---|
loop | uv::Loop * | Event loop on which to schedule the callback. |
func | Function && | Callable to invoke on the next loop tick. |
args | Args &&... | Arguments forwarded to func. |
formatError
inline
inline std::string formatError(std::string_view message, int err = UV_UNKNOWN)Defined in src/base/include/icy/error.h:101
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.
Returns
Formatted error string.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | std::string_view | Descriptive context for the error. |
err | int | libuv error code (e.g. from a failed uv_* call). Defaults to UV_UNKNOWN. |
throwError
inline
inline void throwError(std::string_view message, int err = UV_UNKNOWN)Defined in src/base/include/icy/error.h:116
Throws a std::runtime_error with a formatted error message.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | std::string_view | Descriptive context for the error. |
err | int | libuv error code to append. Defaults to UV_UNKNOWN. |
mutableBuffer
inline
template<typename T> inline MutableBuffer mutableBuffer(T data, size_t size)Defined in src/base/include/icy/buffer.h:82
Creates a MutableBuffer from an arbitrary pointer and size.
Returns
MutableBuffer referencing the given memory.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | T | Pointer to the start of the memory region. |
size | size_t | Number of bytes in the region. |
mutableBuffer
inline
inline MutableBuffer mutableBuffer(std::string & str)Defined in src/base/include/icy/buffer.h:90
Creates a MutableBuffer from a std::string.
Returns
MutableBuffer wrapping the string's internal storage.
Parameters
| Parameter | Type | Description |
|---|---|---|
str | std::string & | Source string. Must remain valid while the buffer is in use. |
mutableBuffer
inline
inline MutableBuffer mutableBuffer(const std::string & str)Defined in src/base/include/icy/buffer.h:100
Creates a MutableBuffer from a const std::string. Casts away constness; use with care.
Returns
MutableBuffer wrapping the string's internal storage.
Parameters
| Parameter | Type | Description |
|---|---|---|
str | const std::string & | Source string. Must remain valid while the buffer is in use. |
mutableBuffer
inline
template<typename T> inline MutableBuffer mutableBuffer(const std::vector< T > & vec)Defined in src/base/include/icy/buffer.h:111
Creates a MutableBuffer from a const std::vector. Casts away constness; use with care.
Returns
MutableBuffer wrapping the vector's internal storage.
Parameters
| Parameter | Type | Description |
|---|---|---|
vec | const std::vector< T > & | Source vector. Must remain valid while the buffer is in use. |
mutableBuffer
inline
inline MutableBuffer mutableBuffer(Buffer & buf)Defined in src/base/include/icy/buffer.h:119
Creates a MutableBuffer from a Buffer.
Returns
MutableBuffer wrapping the buffer's data.
Parameters
| Parameter | Type | Description |
|---|---|---|
buf | Buffer & | Source buffer. Must remain valid while the buffer is in use. |
mutableBuffer
inline
inline MutableBuffer mutableBuffer(const Buffer & buf)Defined in src/base/include/icy/buffer.h:128
Creates a MutableBuffer from a const Buffer. Casts away constness; use with care.
Returns
MutableBuffer wrapping the buffer's data.
Parameters
| Parameter | Type | Description |
|---|---|---|
buf | const Buffer & | Source buffer. Must remain valid while the buffer is in use. |
constBuffer
inline
template<typename T> inline ConstBuffer constBuffer(T data, size_t size)Defined in src/base/include/icy/buffer.h:187
Creates a ConstBuffer from an arbitrary pointer and size.
Returns
ConstBuffer referencing the given memory.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | T | Pointer to the start of the memory region. |
size | size_t | Number of bytes in the region. |
constBuffer
inline
inline ConstBuffer constBuffer(const std::string & str)Defined in src/base/include/icy/buffer.h:195
Creates a ConstBuffer from a std::string.
Returns
ConstBuffer wrapping the string's internal storage.
Parameters
| Parameter | Type | Description |
|---|---|---|
str | const std::string & | Source string. Must remain valid while the buffer is in use. |
constBuffer
inline
template<typename T> inline ConstBuffer constBuffer(const std::vector< T > & vec)Defined in src/base/include/icy/buffer.h:205
Creates a ConstBuffer from a std::vector.
Returns
ConstBuffer wrapping the vector's internal storage.
Parameters
| Parameter | Type | Description |
|---|---|---|
vec | const std::vector< T > & | Source vector. Must remain valid while the buffer is in use. |
constBuffer
inline constexpr
constexpr inline constexpr ConstBuffer constBuffer(const MutableBuffer & buf)Defined in src/base/include/icy/buffer.h:213
Creates a ConstBuffer from a MutableBuffer.
Returns
ConstBuffer referencing the same memory region.
Parameters
| Parameter | Type | Description |
|---|---|---|
buf | const MutableBuffer & | Source mutable buffer. |
constBuffer
inline
template<typename T> inline ConstBuffer constBuffer(Buffer & buf)Defined in src/base/include/icy/buffer.h:223
Creates a ConstBuffer from a Buffer.
Returns
ConstBuffer wrapping the buffer's data.
Parameters
| Parameter | Type | Description |
|---|---|---|
buf | Buffer & | Source buffer. Must remain valid while the buffer is in use. |
constBuffer
inline
template<typename T> inline ConstBuffer constBuffer(const Buffer & buf)Defined in src/base/include/icy/buffer.h:234
Creates a ConstBuffer from a const Buffer. Casts away constness internally; use with care.
Returns
ConstBuffer wrapping the buffer's data.
Parameters
| Parameter | Type | Description |
|---|---|---|
buf | const Buffer & | Source buffer. Must remain valid while the buffer is in use. |
bufferCast
inline constexpr
template<typename PointerToPodType> constexpr inline constexpr PointerToPodType bufferCast(const MutableBuffer & b)Defined in src/base/include/icy/buffer.h:250
Casts a MutableBuffer to a specified pointer-to-POD type.
Returns
Pointer to the buffer's data, cast to PointerToPodType.
Parameters
| Parameter | Type | Description |
|---|---|---|
b | const MutableBuffer & | Source mutable buffer. |
bufferCast
inline constexpr
template<typename PointerToPodType> constexpr inline constexpr PointerToPodType bufferCast(const ConstBuffer & b)Defined in src/base/include/icy/buffer.h:261
Casts a ConstBuffer to a specified pointer-to-POD type.
Returns
Pointer to the buffer's data, cast to PointerToPodType.
Parameters
| Parameter | Type | Description |
|---|---|---|
b | const ConstBuffer & | Source const buffer. |
getLevelFromString
inline
inline Level getLevelFromString(const char * level)Defined in src/base/include/icy/logger.h:53
Converts a log level string to its corresponding Level enum value. Unrecognized strings default to Level::Trace.
Returns
The matching Level enum value.
Parameters
| Parameter | Type | Description |
|---|---|---|
level | const char * | Lowercase level string: "trace", "debug", "info", "warn", "error", or "fatal". |
getStringFromLevel
inline
inline const char * getStringFromLevel(Level level)Defined in src/base/include/icy/logger.h:74
Converts a Level enum value to its lowercase string representation.
Returns
Lowercase C string: "trace", "debug", "info", "warn", "error", or "fatal".
Parameters
| Parameter | Type | Description |
|---|---|---|
level | Level | The log level to convert. |
logArgs
template<typename T> void logArgs(std::ostream & o, T && t)Defined in src/base/include/icy/logger.h:255
Write a single logging argument into the destination stream.
Parameters
| Parameter | Type | Description |
|---|---|---|
o | std::ostream & | Destination stream. |
t | T && | Argument to append with operator<<. |
logArgs
template<typename T, typename... Args> void logArgs(std::ostream & o, T && t, Args &&... args)Defined in src/base/include/icy/logger.h:265
Write multiple logging arguments into the destination stream in order.
Parameters
| Parameter | Type | Description |
|---|---|---|
o | std::ostream & | Destination stream. |
t | T && | First argument to append. |
args | Args &&... | Remaining arguments to append recursively. |
str_end
constexpr
constexpr constexpr const char * str_end(const char * str)Defined in src/base/include/icy/logger.h:582
Return a pointer to the null terminator of a C string.
str_slant
constexpr
constexpr constexpr bool str_slant(const char * str)Defined in src/base/include/icy/logger.h:588
Return true if the C string contains a forward or back slash.
r_slant
constexpr
constexpr constexpr const char * r_slant(const char * str)Defined in src/base/include/icy/logger.h:594
Walk backward to the character after the last path separator.
_fileName
constexpr
constexpr constexpr const char * _fileName(const char * str)Defined in src/base/include/icy/logger.h:600
Return the filename portion of a compile-time path string.
_methodName
inline
inline std::string _methodName(std::string_view fsig)Defined in src/base/include/icy/logger.h:617
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)Defined in src/base/include/icy/memory.h:32
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
| Parameter | Type | Description |
|---|---|---|
ptr | T * | Object to delete. Does nothing if nullptr. |
loop | uv::Loop * | Event loop on which to schedule the deletion. |
makeIntrusive
template<typename T, typename... Args> IntrusivePtr< T > makeIntrusive(Args &&... args)Defined in src/base/include/icy/memory.h:206
Creates an IntrusivePtr managing a newly heap-allocated T. Equivalent to std::make_shared.
Returns
IntrusivePtr owning the new object.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | Args &&... | Arguments forwarded to T's constructor. |
slot
template<class Class, class RT, typename... Args> std::shared_ptr< internal::Slot< RT, Args... > > slot(Class * instance, RT(Class::*)(Args...) method, int id = -1, int priority = -1)Defined in src/base/include/icy/signal.h:667
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.
Returns
A SlotPtr ready to attach to a compatible 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.
Parameters
| Parameter | Type | Description |
|---|---|---|
instance | Class * | Pointer to the object on which method will be called. |
method | RT(Class::*)(Args...) | Pointer to the non-const member function to bind. |
id | int | Explicit slot ID to assign; pass -1 to auto-assign. |
priority | int | Higher values are called first; pass -1 for default ordering. |
slot
template<class RT, typename... Args> std::shared_ptr< internal::Slot< RT, Args... > > slot(RT(*)(Args...) method, int id = -1, int priority = -1)Defined in src/base/include/icy/signal.h:693
Creates a slot that wraps a free (static) function pointer.
Returns
A SlotPtr ready to attach to a compatible Signal.
Parameters
| Parameter | Type | Description |
|---|---|---|
method | RT(*)(Args...) | Pointer to the free function to bind. |
id | int | Explicit slot ID to assign; pass -1 to auto-assign. |
priority | int | Higher values are called first; pass -1 for default ordering. |
swap
inline
inline void swap(DateTime & d1, DateTime & d2)Defined in src/base/include/icy/datetime.h:631
Exchange two DateTime values.
swap
inline
inline void swap(LocalDateTime & d1, LocalDateTime & d2)Defined in src/base/include/icy/datetime.h:1044
Exchange two LocalDateTime values.
swap
inline
inline void swap(Timestamp & s1, Timestamp & s2)Defined in src/base/include/icy/datetime.h:1491
Exchange two Timestamp values.
swap
inline
inline void swap(Timespan & s1, Timespan & s2)Defined in src/base/include/icy/datetime.h:1647
Exchange two Timespan values.
getExePath
std::string getExePath()Defined in src/base/include/icy/platform.h:30
Cross-platform utilities.
Returns the current executable path.
getCwd
std::string getCwd()Defined in src/base/include/icy/platform.h:33
Return the current working directory.
getFreeMemory
uint64_t getFreeMemory()Defined in src/base/include/icy/platform.h:36
Returns the current amount of free memory.
getTotalMemory
uint64_t getTotalMemory()Defined in src/base/include/icy/platform.h:39
Returns the current amount of used memory.
numCpuCores
int numCpuCores()Defined in src/base/include/icy/platform.h:42
Returns the number of CPU cores.
sleep
void sleep(int ms)Defined in src/base/include/icy/platform.h:45
Pause the current thread for the given ms duration.
pause
void pause()Defined in src/base/include/icy/platform.h:48
Pause the current thread until enter is pressed.
getHostname
std::string getHostname()Defined in src/base/include/icy/platform.h:51
Return the system hostname.
getEnv
std::string getEnv(std::string_view name, std::string_view defaultValue = "")Defined in src/base/include/icy/platform.h:54
Return an environment variable or the default value.
getEnvBool
bool getEnvBool(std::string_view name)Defined in src/base/include/icy/platform.h:58
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)Defined in src/base/include/icy/byteorder.h:42
Writes a single byte at the given offset in memory.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | void * | Pointer to the destination buffer. |
offset | size_t | Byte offset within the buffer. |
v | uint8_t | Value to write. |
get8
inline
inline uint8_t get8(const void * memory, size_t offset)Defined in src/base/include/icy/byteorder.h:51
Reads a single byte at the given offset from memory.
Returns
The byte value at the specified offset.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | const void * | Pointer to the source buffer. |
offset | size_t | Byte offset within the buffer. |
setBE16
inline
inline void setBE16(void * memory, uint16_t v)Defined in src/base/include/icy/byteorder.h:59
Writes a 16-bit value to memory in big-endian byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | void * | Pointer to the destination buffer (must be at least 2 bytes). |
v | uint16_t | Value to write. |
setBE32
inline
inline void setBE32(void * memory, uint32_t v)Defined in src/base/include/icy/byteorder.h:68
Writes a 32-bit value to memory in big-endian byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | void * | Pointer to the destination buffer (must be at least 4 bytes). |
v | uint32_t | Value to write. |
setBE64
inline
inline void setBE64(void * memory, uint64_t v)Defined in src/base/include/icy/byteorder.h:79
Writes a 64-bit value to memory in big-endian byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | void * | Pointer to the destination buffer (must be at least 8 bytes). |
v | uint64_t | Value to write. |
getBE16
inline
inline uint16_t getBE16(const void * memory)Defined in src/base/include/icy/byteorder.h:94
Reads a 16-bit big-endian value from memory.
Returns
The 16-bit value in host byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | const void * | Pointer to the source buffer (must be at least 2 bytes). |
getBE32
inline
inline uint32_t getBE32(const void * memory)Defined in src/base/include/icy/byteorder.h:103
Reads a 32-bit big-endian value from memory.
Returns
The 32-bit value in host byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | const void * | Pointer to the source buffer (must be at least 4 bytes). |
getBE64
inline
inline uint64_t getBE64(const void * memory)Defined in src/base/include/icy/byteorder.h:114
Reads a 64-bit big-endian value from memory.
Returns
The 64-bit value in host byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | const void * | Pointer to the source buffer (must be at least 8 bytes). |
setLE16
inline
inline void setLE16(void * memory, uint16_t v)Defined in src/base/include/icy/byteorder.h:129
Writes a 16-bit value to memory in little-endian byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | void * | Pointer to the destination buffer (must be at least 2 bytes). |
v | uint16_t | Value to write. |
setLE32
inline
inline void setLE32(void * memory, uint32_t v)Defined in src/base/include/icy/byteorder.h:138
Writes a 32-bit value to memory in little-endian byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | void * | Pointer to the destination buffer (must be at least 4 bytes). |
v | uint32_t | Value to write. |
setLE64
inline
inline void setLE64(void * memory, uint64_t v)Defined in src/base/include/icy/byteorder.h:149
Writes a 64-bit value to memory in little-endian byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | void * | Pointer to the destination buffer (must be at least 8 bytes). |
v | uint64_t | Value to write. |
getLE16
inline
inline uint16_t getLE16(const void * memory)Defined in src/base/include/icy/byteorder.h:164
Reads a 16-bit little-endian value from memory.
Returns
The 16-bit value in host byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | const void * | Pointer to the source buffer (must be at least 2 bytes). |
getLE32
inline
inline uint32_t getLE32(const void * memory)Defined in src/base/include/icy/byteorder.h:173
Reads a 32-bit little-endian value from memory.
Returns
The 32-bit value in host byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | const void * | Pointer to the source buffer (must be at least 4 bytes). |
getLE64
inline
inline uint64_t getLE64(const void * memory)Defined in src/base/include/icy/byteorder.h:184
Reads a 64-bit little-endian value from memory.
Returns
The 64-bit value in host byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
memory | const void * | Pointer to the source buffer (must be at least 8 bytes). |
isBigEndian
inline
inline bool isBigEndian()Defined in src/base/include/icy/byteorder.h:198
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)Defined in src/base/include/icy/byteorder.h:207
Converts a 16-bit value from host byte order to network (big-endian) byte order.
Returns
Value in network byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
n | uint16_t | Value in host byte order. |
hostToNetwork32
inline
inline uint32_t hostToNetwork32(uint32_t n)Defined in src/base/include/icy/byteorder.h:217
Converts a 32-bit value from host byte order to network (big-endian) byte order.
Returns
Value in network byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
n | uint32_t | Value in host byte order. |
hostToNetwork64
inline
inline uint64_t hostToNetwork64(uint64_t n)Defined in src/base/include/icy/byteorder.h:227
Converts a 64-bit value from host byte order to network (big-endian) byte order.
Returns
Value in network byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
n | uint64_t | Value in host byte order. |
networkToHost16
inline
inline uint16_t networkToHost16(uint16_t n)Defined in src/base/include/icy/byteorder.h:237
Converts a 16-bit value from network (big-endian) byte order to host byte order.
Returns
Value in host byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
n | uint16_t | Value in network byte order. |
networkToHost32
inline
inline uint32_t networkToHost32(uint32_t n)Defined in src/base/include/icy/byteorder.h:245
Converts a 32-bit value from network (big-endian) byte order to host byte order.
Returns
Value in host byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
n | uint32_t | Value in network byte order. |
networkToHost64
inline
inline uint64_t networkToHost64(uint64_t n)Defined in src/base/include/icy/byteorder.h:253
Converts a 64-bit value from network (big-endian) byte order to host byte order.
Returns
Value in host byte order.
Parameters
| Parameter | Type | Description |
|---|---|---|
n | uint64_t | Value in network byte order. |
onShutdownSignal
inline
inline void onShutdownSignal(std::function< void(void *)> callback = nullptr, void * opaque = nullptr, uv::Loop * loop = uv::defaultLoop())Defined in src/base/include/icy/application.h:163
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
| Parameter | Type | Description |
|---|---|---|
callback | std::function< void(void *)> | Optional function called on SIGINT. |
opaque | void * | Optional user data pointer passed to the callback. |
loop | uv::Loop * | Event loop to attach the signal watcher to. |
waitForShutdown
inline
inline void waitForShutdown(std::function< void(void *)> callback = nullptr, void * opaque = nullptr, uv::Loop * loop = uv::defaultLoop())Defined in src/base/include/icy/application.h:187
Installs a SIGINT handler and runs the event loop until shutdown. Equivalent to calling onShutdownSignal() then uv_run().
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | std::function< void(void *)> | Optional function called on SIGINT before the loop exits. |
opaque | void * | Optional user data pointer passed to the callback. |
loop | uv::Loop * | Event loop to run. |
packetSlot
template<class Class, class RT, class PT, class IT = IPacket> std::shared_ptr< internal::Slot< RT, IT & > > packetSlot(Class * instance, RT(Class::*)(PT &) method, int id = -1, int priority = -1)Defined in src/base/include/icy/packetsignal.h:45
Creates a signal slot that filters by packet subtype PT before invoking method.
The returned slot is connected to a PacketSignal (which broadcasts 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.
Returns
A shared slot suitable for connecting to a PacketSignal.
Parameters
| Parameter | Type | Description |
|---|---|---|
instance | Class * | Pointer to the listener object. |
method | RT(Class::*)(PT &) | Member function pointer on Class accepting a PT&. |
id | int | Optional slot identifier; -1 for automatic assignment. |
priority | int | Optional slot priority; higher values run first. |
operator|
constexpr
constexpr constexpr unsigned operator|(PacketFlags lhs, PacketFlags rhs)Defined in src/base/include/icy/packetstream.h:218
Combine PacketFlags values into a bitmask.
rawPacket
inline
inline RawPacket rawPacket(const MutableBuffer & buf, unsigned flags = 0, std::unique_ptr< IPacketInfo > info = nullptr)Defined in src/base/include/icy/packet.h:269
Constructs a non-owning RawPacket from a mutable buffer (borrowed pointer).
rawPacket
inline
inline RawPacket rawPacket(const ConstBuffer & buf, unsigned flags = 0, std::unique_ptr< IPacketInfo > info = nullptr)Defined in src/base/include/icy/packet.h:276
Constructs an owning RawPacket from a const buffer (data is copied).
rawPacket
inline
inline RawPacket rawPacket(char * data = nullptr, size_t size = 0, unsigned flags = 0, std::unique_ptr< IPacketInfo > info = nullptr)Defined in src/base/include/icy/packet.h:283
Constructs a non-owning RawPacket from a raw mutable pointer (borrowed).
rawPacket
inline
inline RawPacket rawPacket(const char * data = nullptr, size_t size = 0, unsigned flags = 0, std::unique_ptr< IPacketInfo > info = nullptr)Defined in src/base/include/icy/packet.h:291
Constructs an owning RawPacket from a const char pointer (data is copied).
