13 KiB
VlppOS Knowledge Base
Project introduction remains in Index.md.
Choosing APIs
Locale Support
Cross-platform localization and globalization with culture-aware string operations and formatting.
- Use
Locale::Invariant()orINVLOCmacro for culture-invariant operations - Use
Locale::SystemDefault()for OS code page interpretation - Use
Locale::UserDefault()for user language and location settings - Use
Locale::Enumerate(locales)to get all supported locales - Use
Get*Formatsmethods for date-time format enumeration - Use
FormatDateandFormatTimefor locale-aware date/time formatting - Use
Get*Namemethods for localized week day and month names - Use
FormatNumberandFormatCurrencyfor locale-aware number formatting - Use
Compare,CompareOrdinal,CompareOrdinalIgnoreCasefor locale-aware string comparison - Use
FindFirst,FindLast,StartsWith,EndsWithfor normalized string searching - Use
InjectLocaleImplto replaceLocaleimplementation for testing and customization - Use
EjectLocaleImplto remove specific injected implementations or reset to default - Use
EnUsLocaleImplclass as platform-independent en-US fallback implementation
File System Operations
Cross-platform file and directory manipulation with path handling and content access.
- Use
FilePathfor path representation and manipulation - Use
GetPathDelimiter,operator/,GetName,GetFolder,GetFullPath,GetRelativePathForfor path operations - Use
IsFile,IsFolder,IsRootto determine path object types - Use
Fileclass for file operations whenFilePath::IsFilereturns true - Use
ReadAllTextWithEncodingTesting,ReadAllTextByBom,ReadAllLinesByBomfor text reading - Use
WriteAllText,WriteAllLinesfor text writing - Use
Exists,Delete,Renamefor file operations - Use
Folderclass for directory operations whenFilePath::IsFolderorFilePath::IsRootreturns true - Use
GetFolders,GetFilesfor directory content enumeration - Use
Create(bool recursively),Delete(bool recursively),Renamefor folder operations - Use
InjectFileSystemImplto replace file system implementation for testing and customization - Use
EjectFileSystemImplto remove specific injected implementations or reset to default
Stream Operations
Unified stream interface for file, memory, and data transformation operations with encoding support.
- Use
IStreaminterface for all stream operations - Use
FileStreamfor file I/O withReadOnly,WriteOnly,ReadWritemodes - Use
MemoryStreamfor in-memory buffer operations - Use
MemoryWrapperStreamfor operating on existing memory buffers - Use
EncoderStreamandDecoderStreamfor data transformation pipelines - Use
IsAvailable,CanRead,CanWrite,CanSeek,CanPeek,IsLimitedfor capability checking - Use
Read,Write,Peek,Seek,SeekFromBegin,SeekFromEnd,Position,Sizefor stream operations - Use
Closefor resource cleanup (automatic on destruction)
Encoding and Decoding
Text encoding conversion between different UTF formats with BOM support and binary data encoding.
- Use
BomEncoderandBomDecoderfor UTF encoding with BOM support - Use
UtfGeneralEncoder<Native, Expect>andUtfGeneralDecoder<Native, Expect>for UTF conversion without BOM - Use
Utf8Encoder,Utf8Decoder,Utf16Encoder,Utf16Decoder,Utf16BEEncoder,Utf16BEDecoder,Utf32Encoder,Utf32Decoderfor specific UTF conversions - Use
MbcsEncoderandMbcsDecoderfor ASCII/MBCS conversion - Use
TestEncodingfor automatic encoding detection - Use
Utf8Base64EncoderandUtf8Base64Decoderfor Base64 encoding in UTF-8 - Use
LzwEncoderandLzwDecoderfor data compression - Use
CopyStream,CompressStream,DecompressStreamhelper functions
Additional Streams
Specialized stream types for caching, recording, and broadcasting data operations.
- Use
CacheStreamfor performance optimization with non-random accessed data, although it supports random accessing if the underlying stream does - Use
RecorderStreamfor copying data from one stream to another during reading - Use
BroadcastStreamfor writing the same data to multiple target streams - Use
Targets()method to manage BroadcastStream destinations
Multi-threading
Cross-platform threading primitives and synchronization mechanisms for concurrent programming.
- Use
ThreadPoolLite::QueueandThreadPoolLite::QueueLambdafor thread pool execution - Use
TaskQueuewhen queued work must run on one blocking task loop instead of the thread pool - Use
Thread::Sleepfor thread pausing - Use
Thread::GetCurrentThreadIdfor thread identification - Use
Thread::CreateAndStartonly when thread pool is insufficient
Synchronization Primitives
Non-waitable synchronization objects for protecting shared resources in multi-threaded environments.
- Use
SpinLockfor protecting very fast code sections - Use
CriticalSectionfor protecting time-consuming code sections - Use
ReaderWriterLockfor multiple reader, single writer scenarios - Use
Enter,TryEnter,Leavefor manual lock management - Use
SPIN_LOCK,CS_LOCK,READER_LOCK,WRITER_LOCKmacros for exception-safe automatic locking - Use
ConditionVariablewithSleepWith,SleepWithForTimefor conditional waiting - Use
WakeOnePending,WakeAllPendingsfor condition variable signaling
Waitable Objects
Cross-process synchronization objects that support waiting operations with timeout capabilities.
- Use
Mutexfor cross-process mutual exclusion - Use
Semaphorefor counting semaphore operations across processes - Use
EventObjectfor event signaling across processes - Use
CreateandOpenmethods for establishing named synchronization objects - Use
Wait,WaitForTimefor blocking operations with optional timeout - Use
WaitAll,WaitAllForTime,WaitAny,WaitAnyForTimefor multiple object synchronization - Use
Signal,Unsignalfor event object state management - Use
Releasefor releasing mutex and semaphore ownership
Inter-Process Network Protocols and Channels
Production-usable asynchronous text-protocol and typed named-channel abstractions. Every concrete network-protocol implementation supplied by this repository, including the async-socket-based Mini HTTP transport, is testing-only; production applications should provide their own INetworkProtocol* implementation.
- Use
INetworkProtocolServer,INetworkProtocolClient,INetworkProtocolConnectionandINetworkProtocolCallbackfor asynchronousWStringmessages. - Use
IChannelServer<TPackage>,IChannelClient<TPackage>,IChannel<TPackage>andIChannelReader<TPackage>for typed named channels with client ids, direct sends, broadcasts and batched writes. - Use
NetworkProtocolChannelServer<TPackage, TSerialization, TServerBase>,NetworkProtocolChannelClient<TPackage, TSerialization>andNetworkProtocolLocalChannelClient<TPackage, TSerialization>to run the channel implementation over a production-ready custom protocol. - Use
vl::inter_process::async_tcp_socket::SocketHttpServerandvl::inter_process::async_tcp_socket::SocketHttpClientonly for testing as the portable Mini HTTP implementation of the raw network-protocol interfaces.
Async-Socket-Based Mini HTTP API
Testing-only layered loopback TCP and HTTP/1.1 APIs for asynchronous binary streams, parsed request/response connections and prefix-dispatched Mini HTTP services. Do not use these APIs in production code.
- Use
vl::inter_process::async_tcp_socket::IAsyncSocketServer,vl::inter_process::async_tcp_socket::IAsyncSocketClient,vl::inter_process::async_tcp_socket::IAsyncSocketConnection,vl::inter_process::async_tcp_socket::IAsyncSocketCallbackandvl::inter_process::async_tcp_socket::AsyncSocketBufferfor asynchronous loopback byte streams. Each server and client exposes its immutable construction port throughGetPort(), and a client creates a fresh transport-preserving lane throughCreateSameEndpointClient(). - Use the platform-neutral
vl::inter_process::async_tcp_socket::CreateDefaultAsyncSocketServerandvl::inter_process::async_tcp_socket::CreateDefaultAsyncSocketClientfactories at the composition boundary. - Use
vl::inter_process::async_tcp_socket::windows_socket::AsyncSocketServer/vl::inter_process::async_tcp_socket::windows_socket::AsyncSocketClient,vl::inter_process::async_tcp_socket::linux_socket::AsyncSocketServer/vl::inter_process::async_tcp_socket::linux_socket::AsyncSocketClient, orvl::inter_process::async_tcp_socket::macos_socket::AsyncSocketServer/vl::inter_process::async_tcp_socket::macos_socket::AsyncSocketClientfor the current platform. - Use
vl::inter_process::async_tcp_socket::HttpRequest,vl::inter_process::async_tcp_socket::HttpResponse,vl::inter_process::async_tcp_socket::HttpRequestServer,vl::inter_process::async_tcp_socket::HttpRequestClient,vl::inter_process::async_tcp_socket::IHttpRequestConnectionandvl::inter_process::async_tcp_socket::IHttpRequestCallbackfor binary-safe sequential HTTP/1.1 exchanges. - Use
vl::inter_process::async_tcp_socket::SocketHttpServerApi,vl::inter_process::async_tcp_socket::SocketHttpRequestContextandvl::inter_process::async_tcp_socket::SocketHttpClientApifor prefix-dispatched Mini HTTP request/response work; inject socket dependencies explicitly, derive the port from the injected socket, reuse the same server pointer when multiple prefixes must share one listener, and treat client-side 404 as a terminalResponseNotFounderror.
Terminal User Interface
Cross-platform owner-thread terminal takeover with input, resize and timer callbacks, a validated cell buffer, Unicode-aware character placement, box-drawing primitives and deterministic backend injection for tests.
- Use
TUI::TryGetConsoleSizeto query the visible terminal before startup. - Use
TUI::InstallListener,TUI::Start,TUI::RunOneCycle,TUI::Stop,TUI::IsInUse,TUI::IsStopRequestedandTUI::UninstallListenerfor lifecycle and owner-thread event processing. - Use
TuiStartOptions,TuiColorModeandTUI::GetColorModeto request and inspect terminal color emission. - Use
ITuiCallbackwithTuiMouseInfo,TuiKeyInfoandTuiCharInfofor startup, shutdown, resize, input and timer callbacks. - Use
TUI::StartTimerandTUI::StopTimerfor deadline-driven callbacks on the TUI owner thread. - Use
TUI::GetBuffer,TUI::GetBufferWidth,TUI::GetBufferHeightandTUI::RenderBufferfor retained cell-buffer rendering. - Use
TuiPixel,TuiPixelGlyph,TuiColorandTUI::MeasureCharto represent and validate terminal cells and scalar widths. - Use
TUI::PrintChar,TUI::DrawLineV,TUI::DrawLineH,TUI::DrawRectandTUI::Clearfor clipped drawing on the active buffer or a caller-owned buffer. - Use
vl::console::unittest::ScopedTuiBackendwithvl::console::unittest::ITuiBackendfor deterministic TUI tests.
Design Explanation
Implementing an Injectable Feature
- Linked-list based dependency injection mechanism enabling runtime replacement and extension of feature implementations while maintaining delegation capabilities
- Three core components:
IFeatureImplbase interface,FeatureImpl<TImpl>template for type-safe delegation, andFeatureInjection<TImpl>manager for chain operations - Standard implementation pattern with interface definition, default implementation, global management functions using static local variables for thread-safe singleton behavior
- Delegation mechanism through
Previous()method allowing partial overrides and full delegation with LIFO injection structure and cascading ejection behavior - Critical lifecycle guarantees where
EndInjectiononly called during explicit operations, and restriction of injection/ejection to application-level code for proper ordering - Real-world implementation demonstrated through DateTime system with platform-specific implementations and testing integration using mock implementations