9.0 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
Inter-process text transport and typed named-channel communication for applications that need client/server messaging, local server-side channel participants, batched package delivery, and optional Windows-only NamedPipe or HTTP transports.
- Use
INetworkProtocolServer,INetworkProtocolClient,INetworkProtocolConnectionandINetworkProtocolCallbackfor raw asynchronous text-message transport. - 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>for the default channel implementation over anINetworkProtocol*transport. - Use
vl::inter_process::named_pipe::NamedPipeServer/vl::inter_process::named_pipe::NamedPipeClientandvl::inter_process::windows_http::HttpServer/vl::inter_process::windows_http::HttpClientonly when targeting Windows, because the current built-in NamedPipe and HTTP implementations are Windows-only. - Use
vl::inter_process::windows_http::HttpClientApiandvl::inter_process::windows_http::HttpServerApiwhen implementing or maintaining the Windows HTTP transport layer directly.
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