This folder hosts the Core Units of the mORMot Open Source framework, version 2.
With "Core Units", we mean units implementing shared basic functionality of our framework:
- Uncoupled reusable bricks to process files, text, JSON, compression, encryption, network, RTTI, potentially with optimized asm;
- Other higher level features, like ORM, SOA or database access are built on top of those bricks, and are located in the parent folder;
- Cross-Platform and Cross-Compiler: ensure the same code would compile on both FPC and Delphi, on any support platform, regardless the RTL, Operating System, or CPU.
Basic types and reusable stand-alone functions shared by all framework units
- Framework Version and Information
- Common Types Used for Compatibility Between Compilers and CPU
- Numbers (floats and integers) Low-level Definitions
- Integer Arrays Manipulation
ObjArrayPtrArrayInterfaceArrayWrapper Functions- Low-level Types Mapping Binary or Bits Structures
- Buffers (e.g. Hashing and SynLZ compression) Raw Functions
- Efficient
VariantValues Conversion - Sorting/Comparison Functions
- Some Convenient
TStreamdescendants and File access functions - Faster Alternative to RTL Standard Functions
- Raw Shared Types Definitions
Aim of those types and functions is to be cross-platform and cross-compiler, without any dependency but the main FPC/Delphi RTL. It also detects the kind of Intel/AMD it runs on, to adapt to the fastest asm version available. It is the main unit where x86_64 or i386 asm stubs are included.
Cross-platform functions shared by all framework units
- Some Cross-System Type and Constant Definitions
- Gather Operating System Information
- Operating System Specific Types (e.g.
TWinRegistry) - Unicode, Time, File, Console, Library process
- Per Class Properties O(1) Lookup via
vmtAutoTableSlot (e.g. for RTTI cache) TSynLocker/TSynLockedand Low-Level Threading Features- Unix Daemon and Windows Service Support
Aim of this unit is to centralize most used OS-specific API calls, like a SysUtils unit on steroids, to avoid $ifdef/$endif in "uses" clauses.
In practice, no "Windows", nor "Linux/Unix" reference should be needed in regular units, once mormot.core.os is included. :)
See mormot.core.os.mac.pas and mormot.core.os.security.pas units for completion.
MacOS API calls for FPC, as injected to mormot.core.os.pas
- Gather MacOS Specific Operating System Information
This unit uses MacOSAll and link several toolkits, so was not included in mormot.core.os.pas to reduce executable size, but inject this methods at runtime: just include "uses mormot.core.os.mac" in programs needing it.
Cross-Platform Operating System Security Definitions
- Security IDentifier (SID) Definitions
- Security Descriptor Self-Relative Binary Structures
- Access Control List (DACL/SACL) Definitions
- Conditional ACE Expressions SDDL and Binary Support
- Active Directory Definitions
- Security Descriptor Definition Language (SDDL)
TSecurityDescriptorWrapper Object- Kerberos KeyTab File Support
- Basic ASN.1 Support
- Windows API Specific Security Types and Functions
Even if most of those security definitions comes from the Windows/AD world, our framework (re)implemented them in a cross-platform way.
Implementation follows and refers to the official [MS-DTYP] Windows Open Specifications document.
This low-level unit only refers to mormot.core.base.pas and mormot.core.os.pas.
Efficient Unicode Conversion Classes shared by all framework units
- UTF-8 Efficient Encoding / Decoding
- Cross-Platform Charset and CodePage Support
- UTF-8 / UTF-16 / Ansi Conversion Classes
- Text File Loading with BOM/Unicode Support
- Low-Level String Conversion Functions
- Text Case-(in)sensitive Conversion and Comparison
- UTF-8 String Manipulation Functions
TRawUtf8DynArrayProcessing Functions- Operating-System Independent Unicode Process
Text Processing functions shared by all framework units
- CSV-like Iterations over Text Buffers
TTextWriterparent class for Text Generation- Numbers (integers or floats) and Variants to Text Conversion
- Text Formatting functions
- Resource and Time Functions
- HTTP/REST Common Headers Parsing (e.g. cookies)
ESynExceptionclass- Hexadecimal Text And Binary Conversion
Date and Time definitions and process shared by all framework units
- ISO-8601 Compatible Date/Time Text Encoding
TSynDate/TSynDateTime/TSynSystemTimeHigh-Level objectsTUnixTime/TUnixMSTimePOSIX Epoch Compatible 64-bit date/timeTTimeLogefficient 64-bit custom date/time encodingTTextDateWritersupporting date/time ISO-8601 serializationTValuePUtf8Chartext value wrapper record
Cross-Compiler RTTI Definitions shared by all framework units
- Low-Level Cross-Compiler RTTI Definitions
- Enumerations RTTI
- Published
classProperties and Methods RTTI IInvokableInterface RTTI- Efficient Dynamic Arrays and Records Process
- Managed Types Finalization, Random or Copy
- RTTI Value Types used for JSON Parsing
- RTTI-based Registration for Custom JSON Parsing
TRttiMapField Mapping (e.g. DTO/Domain Objects)TObjectWithRttiMethodsTObjectWithIDTClonableClasses- Redirect Most Used FPC RTL Functions to Optimized x86_64 Assembly
Purpose of this unit is to avoid any direct use of TypInfo.pas RTL unit, which is not exactly compatible between compilers, and lacks of direct RTTI access with no memory allocation. We define pointers to RTTI record/object to access TypeInfo() via a set of explicit methods. Here fake record/objects are just wrappers around pointers defined in Delphi/FPC RTL's TypInfo.pas with the magic of inlining. We redefined all RTTI definitions as TRtti* types to avoid confusion with type names as published by the TypInfo unit.
At higher level, the new TRttiCustom class is the main cached entry of our customizable RTTI,accessible from the global Rtti.* methods. It is enhanced as TRttiJson in the mormot.core.json unit to support JSON.
Low-Level Memory Buffers Processing Functions shared by all framework units
- Variable Length Integer Encoding / Decoding
TAlgoCompressCompression/Decompression Classes - withAlgoSynLZAlgoRleLZTFastReader/TBufferWriterBinary Streams- Base64, Base64URI, Base58 and Baudot Encoding / Decoding
- URI-Encoded Text Buffer Process
- Basic MIME Content Types Support
- Text Memory Buffers and Files
TStreamRedirectand other Hash process- Markup (e.g. HTML or Emoji) process
RawByteStringBuffers Aggregation viaTRawByteStringGroup
Low-Level Data Processing Functions shared by all framework units
- RTL
TPersistentor Root Classes with Custom Constructor IAutoFreeandIAutoLockerReference-Counted ProcessTSynListTSynObjectListTSynLockerclassesTObjectStorewith proper Binary Serialization- INI Files and In-memory Access
- Efficient RTTI Values Binary Serialization and Comparison
TDynArrayandTDynArrayHashedWrappersIntegerArrays Extended ProcessRawUtf8String Values Interning andTRawUtf8List- Abstract Radix Tree Classes
JSON functions shared by all framework units
- Low-Level JSON Processing Functions
TTextWriterclass with proper JSON escaping andWriteObject()support- JSON-aware
TSynNameValueTObjectStoreJson - JSON-aware
TSynDictionaryStorage - JSON Unserialization for any kind of Values
- JSON Serialization Wrapper Functions
- Abstract Classes with Auto-Create-Fields
Generics Collections as used by all framework units
- JSON-aware
IList<>List Storage - JSON-aware
IKeyValue<>Dictionary Storage - Collections Factory for
IList<>andIKeyValue<>Instances
In respect to generics.collections from the Delphi or FPC RTL, this unit uses interface as variable holders, and leverage them to reduce the generated code as much as possible, as the Spring4D 2.0 framework does, but for both Delphi and FPC. As a result, compiled units (.dcu/.ppu) and executable are much smaller, and faster to compile.
Those interfaces publish TDynArray and TSynDictionary high-level features like indexing, sorting, JSON/binary serialization or thread safety as Generics strong typing.
Use Collections.NewList<T> and Collections.NewKeyValue<TKey, TValue> factories as main entry points of these efficient data structures.
Variant / TDocVariant feature shared by all framework units
- Low-Level
VariantWrappers - Custom
VariantTypes with JSON support TDocVariantObject/Array Document Holder with JSON supportIDocList/IDocDictadvanced Wrappers ofTDocVariantDocuments- JSON Parsing into
Variant VariantBinary Serialization
Several Indexing and Search Engines, as used by other parts of the framework
- Files Search in Folders
- ScanUtf8, GLOB and SOUNDEX Text Search
- Efficient CSV Parsing using RTTI
- Versatile Expression Search Engine
- Bloom Filter Probabilistic Index
- Binary Buffers Delta Compression
TDynArrayLow-Level Binary SearchTSynFilterandTSynValidateProcessing Classes- Cross-Platform
TSynTimeZoneTime Zones
Logging functions shared by all framework units
- Debug Symbols Processing from Delphi .map or FPC/GDB DWARF
- Logging via
TSynLogFamilyTSynLogISynLog - High-Level Logs and Exception Related Features
- Efficient
.logFile Access viaTSynLogFile - SysLog Messages Support as defined by RFC 5424
Performance Monitoring functions shared by all framework units
- Performance Counters
TSynMonitorProcess Information ClassesTSynMonitorUsageProcess Information Database Storage- Operating System Monitoring
DMI/SMBIOSBinary DecoderTSynFPUExceptionWrapper for FPU Flags Preservation
High-Level Multi-Threading features shared by all framework units
- Thread-Safe
TSynQueueandTPendingTaskList - Thread-Safe
ILockedDocVariantStorage - Background Thread Processing
- Parallel Execution in a Thread Pool
- Server Process Oriented Thread Pool
High-Level Zip/Deflate Compression features shared by all framework units
TSynZipCompressorStream Class- GZ Read/Write Support
.zipArchive File SupportTAlgoDeflateandTAlgoGZHigh-Level Compression Algorithms
Logic-Less {{Mustache}} Templates Rendering
- Mustache Execution Data Context Types
TSynMustacheTemplate Processing
Implements SOLID Process via Interface types
IInvokableInterface Methods and Parameters RTTI ExtractionTInterfaceFactoryGenerating Runtime Implementation ClassTInterfaceResolverTInjectableObjectfor IoC / Dependency InjectionTInterfaceStubfor Dependency Stubbing/MockingTInterfacedObjectFakewith JITted Methods ExecutionTInterfaceMethodExecutefor Method Execution from JSONSetWeakandSetWeakZeroWeak Interface Reference Functions- Code/Documentation Generation Logic Extraction from RTTI
- Documentation Extraction from Source Code Comments
Model-View-Controller (MVC) pattern and Mustache
- Web Views Implementation using Mustache
- ViewModel/Controller Sessions using Cookies
- Web Renderer Returning Mustache Views or Json
- Application ViewModel/Controller using Interfaces
Abstract MVC logic over Mustache, as used by mormot.rest.mvc.pas and mormot.net.mvc.pas.
Testing functions shared by all framework units
- Unit-Testing classes and functions
TInterfaceMockfor Dependency Mocking
An (optional) Multi-thread Friendly Memory Manager for FPC written in x86_64 assembly
- targetting Linux (and Windows) multi-threaded Services
- only for FPC on the x86_64 target - use the RTL MM on Delphi or ARM
- based on FastMM4 proven algorithms by Pierre le Riche
- code has been reduced to the only necessary featureset for production
- deep asm refactoring for cross-platform, compactness and efficiency
- can report detailed statistics (with threads contention and memory leaks)
- mremap() makes large block ReallocMem a breeze on Linux :)
- inlined SSE2 movaps loop is more efficient that subfunction(s)
- lockless round-robin of tiny blocks (<=128/256 bytes) for better scaling
- optional lockless bin list to avoid FreeMem() thread contention
- three app modes: default mono-thread friendly,
FPCMM_SERVERorFPCMM_BOOST