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/include/parse_config.hpp b/include/parse_config.hpp
index b778923..5bef8ad 100644
--- a/include/parse_config.hpp
+++ b/include/parse_config.hpp
@@ -2,6 +2,7 @@
 
 #include <cstdint>
 #include <nlohmann/json.hpp>
+#include <optional>
 #include <string>
 
 using std::uint32_t;
@@ -12,10 +13,10 @@
 
 struct BinaryBlobConfig
 {
-    std::string blobBaseId;  // Required
-    std::string sysFilePath; // Required
-    uint32_t offsetBytes;    // Optional
-    uint32_t maxSizeBytes;   // Optional
+    std::string blobBaseId;               // Required
+    std::string sysFilePath;              // Required
+    std::optional<uint32_t> offsetBytes;  // Optional
+    std::optional<uint32_t> maxSizeBytes; // Optional
 };
 
 /**
@@ -28,8 +29,19 @@
 {
     j.at("blobBaseId").get_to(config.blobBaseId);
     j.at("sysFilePath").get_to(config.sysFilePath);
-    config.offsetBytes = j.value("offsetBytes", 0);
-    config.maxSizeBytes = j.value("maxSizeBytes", 0);
+    if (j.contains("offsetBytes"))
+    {
+        uint32_t val;
+        j.at("offsetBytes").get_to(val);
+        config.offsetBytes = val;
+    }
+
+    if (j.contains("maxSizeBytes"))
+    {
+        uint32_t val;
+        j.at("maxSizeBytes").get_to(val);
+        config.maxSizeBytes = val;
+    }
 }
 
 } // namespace conf