binarystore: Add std::optional for optional config options
The `maxSizeBytes` was using 0 size by default instead of skipping it.
Letting `config.maxSizeBytes` be std::optional allow us to have more
control to see if the 0 value is expected or nullopt.
Change-Id: I128216825609909c489cbd5471b324d88d3aa25b
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/src/main.cpp b/src/main.cpp
index 5cf6c10..bb45f55 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -61,11 +61,13 @@
return nullptr;
}
- log<level::INFO>("Loading from config with",
- entry("BASE_ID=%s", config.blobBaseId.c_str()),
- entry("FILE=%s", config.sysFilePath.c_str()),
- entry("MAX_SIZE=%llx", static_cast<unsigned long long>(
- config.maxSizeBytes)));
+ log<level::INFO>(
+ "Loading from config with",
+ entry("BASE_ID=%s", config.blobBaseId.c_str()),
+ entry("FILE=%s", config.sysFilePath.c_str()),
+ entry("MAX_SIZE=%llx",
+ static_cast<unsigned long long>(
+ config.maxSizeBytes ? *config.maxSizeBytes : 0)));
auto file = std::make_unique<binstore::SysFileImpl>(config.sysFilePath,
config.offsetBytes);