Base module

Base module

The base module contains reusable cross platform tools and utilities.

base

The base module contains reusable cross platform tools and utilities.

Namespaces

NameDescription
hexHexadecimal encoding and decoding helpers.
ipcClasses for inter-process communication.
testModern unit testing framework.
timeClasses and functions for handling time.
base64Base64 encoding and decoding helpers.
deleterDeleter helpers for objects managed through custom destruction routines.
numericInteger parsing and formatting helpers.
basicInterface classes.
fsCross-platform filesystem path and file helpers.
utilMiscellaneous string, parsing, and version utilities.

Classes

NameDescription
PipeNamed pipe / stdio stream built on uv_pipe_t.
IdlerAsynchronous type that triggers callbacks when the event loop is idle.
QueueThread-safe queue container.
RunnableQueueQueue of runnable tasks for sequential execution.
SyncQueueSyncQueue 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.
AsyncQueueAsyncQueue is a thread-based queue which receives packets from any thread source and dispatches them asynchronously.
TimerAsynchronous event based timer.
MutableBufferThe 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.
ConstBufferThe 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.
BitReaderClass for reading binary streams.
BitWriterClass for reading/writing binary streams.
DynamicBitWriterClass for reading/writing dynamically resizable binary streams.
LogWriterLog output stream writer.
AsyncLogWriterThread based log output stream writer.
LoggerLogger class.
LogChannelNamed log output channel with configurable severity level and formatting.
ConsoleChannelLog channel that writes formatted messages to standard output.
FileChannelLog channel that writes formatted messages to a file.
RotatingFileChannelLog channel that writes to time-rotated log files.
RefCountedBase class for intrusive reference counting.
IntrusivePtrIntrusive smart pointer for RefCounted objects.
RandomRandom implements a pseudo random number generator (PRNG) using the Mersenne Twister algorithm (std::mt19937).
RunnerRunner 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.
StreamBasic stream type for sockets and pipes.
ThreadPlatform-independent wrapper around an operating system thread.
ProcessSpawns and manages a child process with stdin/stdout/stderr pipes.
TimeoutTimeout counter which expires after a given delay. Delay is specified in milliseconds.
TimedTokenToken that expires after the specified duration.
TimestampA Timestamp stores a monotonic* time value with (theoretical) microseconds resolution. Timestamps can be compared with each other and simple arithmetics are supported.
TimespanA class that represents time spans up to microsecond resolution.
DateTimeThis 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.
TimezoneThis class provides information about the current timezone.
LocalDateTimeThis 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.
DateTimeFormatDefinition of date/time formats and various constants used by DateTimeFormatter and DateTimeParser.
DateTimeFormatterThis class converts dates and times into strings, supporting a variety of standard and custom formats.
DateTimeParserThis 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.
StopwatchA simple facility to measure time intervals with microsecond resolution.
ThreadedStreamReaderThreaded stream reader class.
StreamWriterPacket stream writer class.
StateState class for state machines.
StatefulState machine implementation.
IRegistryAbstract interface for object registries.
SingletonHelper template class for managing singleton objects allocated on the heap.
KeyedStoreA keyed store of unique_ptr values with optional lifecycle hooks. Not thread-safe; designed for single-threaded event loop contexts.
KVCollectionA keyed value store (values stored by copy, not pointer).
NVCollectionA storage container for a name value collections. This collection can store multiple entries for each name, and it's getters are case-insensitive.
ApplicationMain icey application class.
SyncPacketQueueSynchronized packet queue for event loop integration.
AsyncPacketQueueThread-based asynchronous packet dispatch queue.
RateLimiterToken bucket rate limiter for throttling message send frequency.
PacketStreamAdapterThis class is a wrapper for integrating external classes with the a PacketStream's data flow and state machine.
PacketProcessorThis class is a virtual interface for creating PacketStreamAdapters which process that and emit the IPacket type.
PacketStreamProcesses and broadcasts IPackets through a configurable adapter graph.
SynchronizerSynchronizer enables any thread to communicate with the associated event loop via synchronized callbacks.
TimedManagerTimed pointer manager
IPacketCreationStrategyAbstract strategy for creating typed packets from raw buffer data.
PacketFactoryPriority-ordered factory that creates typed packets from raw buffers using registered strategies.
StreamManagerManages a named collection of PacketStream instances with lifecycle callbacks.
IDiagnosticAbstract interface for diagnostic information providers.
AsyncDiagnosticAsynchronous diagnostic information collector.
DiagnosticManagerRegistry and manager for diagnostic providers.
PacketTransactionRequest/response transaction with timeout and retry logic.
Base64PacketEncoderPacket processor that Base64-encodes packet data.
TaskAbstract base class for implementing asynchronous tasks.
TaskRunnerRunner for tasks that inherit the [Task](icy-Task.html#task) interface.
IPacketThe 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.
FlagPacketPacket for sending bitwise flags along the packet stream.
RawPacketRawPacket is the default data packet type which consists of an optionally managed char pointer and a size value.
ConfigurationConfiguration is an abstract base class for managing different kinds of configuration storage back ends such as JSON, XML, or database.
ScopedConfigurationScopedConfiguration 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.
ErrorBasic error type.
LogStreamNo-op log record used when logging is compiled out.
NullSharedMutexNo-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.
BitwiseContainer for smart management of bitwise integer flags.
AbstractDelegateAbstract delegate interface.
FunctionDelegateThe [FunctionDelegate](icy-FunctionDelegate.html#functiondelegate) contains a std::function.
ClassDelegateThe [ClassDelegate](icy-ClassDelegate.html#classdelegate) contains a pointer to a class member.
ConstClassDelegateThe [ConstClassDelegate](icy-ConstClassDelegate.html#constclassdelegate) contains a pointer to a const class member.
PolymorphicDelegatePolymorphic function delegate.
OptionParserCommand-line option parser.
ShutdownCmdShutdown command packet for signalling process termination.
PacketAdapterReferenceProvides a reference to a PacketStreamAdapter with optional ownership.
PacketStreamStateState machine states for PacketStream.
PacketCreationStrategyThis template class implements an adapter that sits between an SignalBase and an object receiving notifications from it.
SharedLibraryLoads a shared library at runtime and resolves exported symbols.
DiagnosticStateState definitions for diagnostic providers.
TransactionStateState machine states for PacketTransaction.
IPacketInfoAn abstract interface for packet sources to provide extra information about packets.

Enumerations

NameDescription
LevelLogging severity levels used by Logger and LogChannel.
ByteOrderByte-order policy used when reading or writing multi-byte integers.
PacketRetentionDescribes how an adapter treats incoming packet lifetime beyond the current synchronous call chain.
PacketFlagsFlags which determine how the packet is handled by the PacketStream.

Level

enum Level

Logging severity levels used by Logger and LogChannel.

ValueDescription
TraceMost verbose diagnostic output.
DebugDebug-only diagnostic output.
InfoNormal informational output.
WarnWarning output for recoverable problems.
ErrorError output for failed operations.
FatalFatal output immediately before termination.

ByteOrder

enum ByteOrder

Byte-order policy used when reading or writing multi-byte integers.

ValueDescription
NetworkDefault, use network byte order (big endian).
HostUse the native order of the host.

PacketRetention

enum PacketRetention

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.

ValueDescription
BorrowedPacket is only used synchronously during the current emit/process call.
ClonedAdapter makes its own copy before deferred or asynchronous use.
RetainedAdapter retains the original packet object beyond the current call chain.

PacketFlags

enum PacketFlags

Flags which determine how the packet is handled by the PacketStream.

ValueDescription
NoModifyThe packet should not be modified by processors.
FinalThe final packet in the stream.

Typedefs

ReturnNameDescription
std::vector< char >BufferCore buffer type.
LogChannelNullChannelNull log channel.
Signal< void()>NullSignalZero-argument signal alias used for simple local event notifications.
Signal< RT, std::shared_mutex >ThreadSignalCross-thread signal variant.
Signal< RT, NullSharedMutex >LocalSignalCompatibility alias for the single-threaded fast path.
uv_process_options_tProcessOptionsRaw libuv process spawn options passed through to uv_spawn.
std::map< std::string, std::string >StringMapGeneric string-to-string map used for headers, options, and environment-style metadata.
std::vector< std::string >StringVecGeneric string vector used for argument lists and ordered string collections.
std::map< std::string, std::string >OptionMapCommand Line Option Parser.
Signal< void(IPacket &)>PacketSignalSignal that broadcasts [IPacket](icy-IPacket.html#ipacket) types.
PacketStreamAdapterPacketSourceFor 0.8.x compatibility.
PacketProcessorIPacketizerCompatibility alias for a packet processor that packetizes stream output.
PacketProcessorIDepacketizerFor 0.8.x compatibility.
std::vector< PacketAdapterReference::Ptr >PacketAdapterVecOrdered list of packet adapter references used for sources and processors.
std::vector< PacketStream * >PacketStreamVecNon-owning list of packet stream pointers used for graph traversal helpers.
std::vector< PacketStream::Ptr >PacketStreamPtrVecOwning list of packet stream handles retained across stream graphs.
std::unique_ptr< IPacketCreationStrategy >PacketCreationStrategyPtrOwning handle for one packet creation strategy.
std::vector< PacketCreationStrategyPtr >PacketCreationStrategyListOrdered 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

ReturnNameDescription
voidrunOnceSchedules 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::stringformatError inlineFormats 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.
voidthrowError inlineThrows a std::runtime_error with a formatted error message.
MutableBuffermutableBuffer inlineCreates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from an arbitrary pointer and size.
MutableBuffermutableBuffer inlineCreates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a std::string.
MutableBuffermutableBuffer inlineCreates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a const std::string. Casts away constness; use with care.
MutableBuffermutableBuffer inlineCreates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a const std::vector. Casts away constness; use with care.
MutableBuffermutableBuffer inlineCreates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a Buffer.
MutableBuffermutableBuffer inlineCreates a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) from a const Buffer. Casts away constness; use with care.
ConstBufferconstBuffer inlineCreates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from an arbitrary pointer and size.
ConstBufferconstBuffer inlineCreates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a std::string.
ConstBufferconstBuffer inlineCreates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a std::vector.
constexpr ConstBufferconstBuffer inlineCreates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6).
ConstBufferconstBuffer inlineCreates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a Buffer.
ConstBufferconstBuffer inlineCreates a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) from a const Buffer. Casts away constness internally; use with care.
constexpr PointerToPodTypebufferCast inlineCasts a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) to a specified pointer-to-POD type.
constexpr PointerToPodTypebufferCast inlineCasts a [ConstBuffer](icy-ConstBuffer.html#constbuffer-6) to a specified pointer-to-POD type.
LevelgetLevelFromString inlineConverts a log level string to its corresponding Level enum value. Unrecognized strings default to [Level::Trace](api_icy.md#namespaceicy_1aad3e81b3cd2daab89338dae9b5323f6badd4ec0ac4e58f7c32a01244ae91150b1).
const char *getStringFromLevel inlineConverts a Level enum value to its lowercase string representation.
voidlogArgsWrite a single logging argument into the destination stream.
voidlogArgsWrite multiple logging arguments into the destination stream in order.
constexpr const char *str_endReturn a pointer to the null terminator of a C string.
constexpr boolstr_slantReturn true if the C string contains a forward or back slash.
constexpr const char *r_slantWalk backward to the character after the last path separator.
constexpr const char *_fileNameReturn the filename portion of a compile-time path string.
std::string_methodName inlineExtract the class-qualified method name from a compiler pretty-function string.
voiddeleteLater inlineSchedules 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 >makeIntrusiveCreates an IntrusivePtr managing a newly heap-allocated T. Equivalent to std::make_shared.
std::shared_ptr< internal::Slot< RT, Args... > >slotCreates a slot that binds a non-const class member function to an instance.
std::shared_ptr< internal::Slot< RT, Args... > >slotCreates a slot that wraps a free (static) function pointer.
voidswap inlineExchange two DateTime values.
voidswap inlineExchange two LocalDateTime values.
voidswap inlineExchange two Timestamp values.
voidswap inlineExchange two Timespan values.
std::stringgetExePathCross-platform utilities.
std::stringgetCwdReturn the current working directory.
uint64_tgetFreeMemoryReturns the current amount of free memory.
uint64_tgetTotalMemoryReturns the current amount of used memory.
intnumCpuCoresReturns the number of CPU cores.
voidsleepPause the current thread for the given ms duration.
voidpausePause the current thread until enter is pressed.
std::stringgetHostnameReturn the system hostname.
std::stringgetEnvReturn an environment variable or the default value.
boolgetEnvBoolReturn an environment variable boolean or the default value. The variable must be 1 or true for this function to return true.
voidset8 inlineWrites a single byte at the given offset in memory.
uint8_tget8 inlineReads a single byte at the given offset from memory.
voidsetBE16 inlineWrites a 16-bit value to memory in big-endian byte order.
voidsetBE32 inlineWrites a 32-bit value to memory in big-endian byte order.
voidsetBE64 inlineWrites a 64-bit value to memory in big-endian byte order.
uint16_tgetBE16 inlineReads a 16-bit big-endian value from memory.
uint32_tgetBE32 inlineReads a 32-bit big-endian value from memory.
uint64_tgetBE64 inlineReads a 64-bit big-endian value from memory.
voidsetLE16 inlineWrites a 16-bit value to memory in little-endian byte order.
voidsetLE32 inlineWrites a 32-bit value to memory in little-endian byte order.
voidsetLE64 inlineWrites a 64-bit value to memory in little-endian byte order.
uint16_tgetLE16 inlineReads a 16-bit little-endian value from memory.
uint32_tgetLE32 inlineReads a 32-bit little-endian value from memory.
uint64_tgetLE64 inlineReads a 64-bit little-endian value from memory.
boolisBigEndian inlineReturns true if the host CPU is big-endian.
uint16_thostToNetwork16 inlineConverts a 16-bit value from host byte order to network (big-endian) byte order.
uint32_thostToNetwork32 inlineConverts a 32-bit value from host byte order to network (big-endian) byte order.
uint64_thostToNetwork64 inlineConverts a 64-bit value from host byte order to network (big-endian) byte order.
uint16_tnetworkToHost16 inlineConverts a 16-bit value from network (big-endian) byte order to host byte order.
uint32_tnetworkToHost32 inlineConverts a 32-bit value from network (big-endian) byte order to host byte order.
uint64_tnetworkToHost64 inlineConverts a 64-bit value from network (big-endian) byte order to host byte order.
voidonShutdownSignal inlineInstalls a SIGINT handler on the given event loop. When the signal fires, callback is invoked with opaque and the signal handle is closed.
voidwaitForShutdown inlineInstalls 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 & > >packetSlotCreates a signal slot that filters by packet subtype PT before invoking method.
constexpr unsigned[`operator`](#operator)
RawPacketrawPacket inlineConstructs a non-owning RawPacket from a mutable buffer (borrowed pointer).
RawPacketrawPacket inlineConstructs an owning RawPacket from a const buffer (data is copied).
RawPacketrawPacket inlineConstructs a non-owning RawPacket from a raw mutable pointer (borrowed).
RawPacketrawPacket inlineConstructs 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

  • loop Event loop on which to schedule the callback.

  • func Callable to invoke on the next loop tick.

  • args Arguments 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

  • message Descriptive context for the error.

  • err libuv error code (e.g. from a failed uv_* call). Defaults to UV_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

  • message Descriptive context for the error.

  • err libuv error code to append. Defaults to UV_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

  • T Pointer type; must be implicitly castable to void*.

Parameters

  • data Pointer to the start of the memory region.

  • size Number 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

  • str Source 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

  • str Source 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

  • T Element type of the vector.

Parameters

  • vec Source 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

  • buf Source 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

  • buf Source 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

  • T Pointer type; must be implicitly castable to const void*.

Parameters

  • data Pointer to the start of the memory region.

  • size Number 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

  • str Source 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

  • T Element type of the vector.

Parameters

  • vec Source 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

  • buf Source 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

  • T Unused; kept for overload symmetry.

Parameters

  • buf Source 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

  • T Unused; kept for overload symmetry.

Parameters

  • buf Source 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

  • PointerToPodType Target pointer type (e.g. char*, uint8_t*).

Parameters

  • b Source 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

  • PointerToPodType Target pointer type (e.g. const char*, const uint8_t*).

Parameters

  • b Source 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](api_icy.md#namespaceicy_1aad3e81b3cd2daab89338dae9b5323f6badd4ec0ac4e58f7c32a01244ae91150b1).

Parameters

  • level Lowercase 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

  • level The 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

  • o Destination stream.

  • t Argument 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

  • o Destination stream.

  • t First argument to append.

  • args Remaining 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

  • T Type of the object to delete.

Parameters

  • ptr Object to delete. Does nothing if nullptr.

  • loop Event 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

  • T Type to construct; must inherit from RefCounted.

Parameters

  • args Arguments forwarded to T's constructor.

Returns

IntrusivePtr owning the new object.


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

  • Class The class that owns the member function.

  • RT Return type of the member function.

  • Args Parameter types of the member function.

Parameters

  • 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.

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

  • RT Return type of the function.

  • Args Parameter types of the function.

Parameters

  • 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.

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

  • memory Pointer to the destination buffer.

  • offset Byte offset within the buffer.

  • v Value 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

  • memory Pointer to the source buffer.

  • offset Byte 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

  • memory Pointer to the destination buffer (must be at least 2 bytes).

  • v Value 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

  • memory Pointer to the destination buffer (must be at least 4 bytes).

  • v Value 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

  • memory Pointer to the destination buffer (must be at least 8 bytes).

  • v Value to write.


getBE16

inline

inline uint16_t getBE16(const void * memory)

Reads a 16-bit big-endian value from memory.

Parameters

  • memory Pointer 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

  • memory Pointer 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

  • memory Pointer 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

  • memory Pointer to the destination buffer (must be at least 2 bytes).

  • v Value 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

  • memory Pointer to the destination buffer (must be at least 4 bytes).

  • v Value 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

  • memory Pointer to the destination buffer (must be at least 8 bytes).

  • v Value to write.


getLE16

inline

inline uint16_t getLE16(const void * memory)

Reads a 16-bit little-endian value from memory.

Parameters

  • memory Pointer 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

  • memory Pointer 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

  • memory Pointer 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

  • n Value 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

  • n Value 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

  • n Value 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

  • n Value 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

  • n Value 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

  • n Value 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

  • callback Optional function called on SIGINT.

  • opaque Optional user data pointer passed to the callback.

  • loop Event 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()](api_icy.md#onshutdownsignal) then uv_run().

Parameters

  • callback Optional function called on SIGINT before the loop exits.

  • opaque Optional user data pointer passed to the callback.

  • loop Event 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

  • 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).

Parameters

  • 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.

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).