|
FlatImage
A configurable Linux containerization system
|
Understanding these conventions will help you read the code more effectively:
ns_ prefixns_log, ns_parser, ns_filesystems::ns_controllerns_db::ns_portal::ns_daemonThe primary error handling mechanism is Value<T>, an enhanced wrapper around std::expected<T, std::string>:
Pop(expr) - Unwrap a Value<T> or return errorint result = Pop(some_operation());Try(expr, ...) - Convert C++ exceptions to Value<T>auto result = Try(std::stoi("123"), "I::Conversion failed");Catch(expr) - Similar to Try(), but yields the Value object.auto opt = Catch(risky_function());Error(fmt, ...) - Create an error value with automatic loggingreturn Error("E::Invalid configuration: {}", reason);Always use the logger() macro with level prefix:
D:: - Debug (debug information, requires FIM_DEBUG=1)I:: - Info (informational messages)W:: - Warning (non-fatal issues)E:: - Error (normal failures)C:: - Critical (Aborting failures)The project provides simplified macros for common control flow patterns with optional logging:
Conditionally return from a function:
Conditionally break from a loop:
Conditionally continue to next iteration:
The ENUM macro generates enumerations with automatic string conversion:
This is particularly useful for configuration values that need serialization/deserialization.
For memory size calculations, use binary unit literal operators:
Available operators:
_kib - Kibibyte (1024 bytes)_mib - Mebibyte (1024 * 1024 bytes)_gib - Gibibyte (1024 * 1024 * 1024 bytes)```