Switch to hex string for post code representation in handler config

As title, using list of integers only make parsing the JSON easier
but would be really hard for developers to interpret or confirm
if the correct post code is being used (Especially since most CPU
vendors tend to document post codes as HEX strings).

This also adds a name and description field to each handler
configuration to allow for ease of documentation.

Change-Id: I0215e98483aa6c5c3bae4f20d918118fdda9fa90
Signed-off-by: Amithash Prasad <amithash@meta.com>
diff --git a/inc/post_code.hpp b/inc/post_code.hpp
index 262a773..5a3895e 100644
--- a/inc/post_code.hpp
+++ b/inc/post_code.hpp
@@ -71,6 +71,8 @@
 
 struct PostCodeHandler
 {
+    std::string name;
+    std::string description;
     primarycode_t primary;
     std::optional<secondarycode_t> secondary;
     std::vector<std::string> targets;
diff --git a/src/post_code.cpp b/src/post_code.cpp
index edad39d..23f0a4f 100644
--- a/src/post_code.cpp
+++ b/src/post_code.cpp
@@ -65,14 +65,36 @@
     }
 }
 
+std::vector<uint8_t> decodeHexString(const std::string& hex)
+{
+    std::vector<uint8_t> out;
+    // The post-code is at least 1 byte. So, we need at
+    // least a 4 char string.
+    if (hex.size() < 4 || hex.size() % 2 != 0 || hex.substr(0, 2) != "0x")
+    {
+        throw std::runtime_error("Bad Hex String: " + hex);
+    }
+    for (size_t i = 2; i < hex.size(); i += 2)
+    {
+        std::string byteString = hex.substr(i, 2);
+        uint8_t byte = (uint8_t)std::strtol(byteString.c_str(), NULL, 16);
+        out.push_back(byte);
+    }
+    return out;
+}
+
 void from_json(const json& j, PostCodeHandler& handler)
 {
-    j.at("primary").get_to(handler.primary);
+    std::string primary;
+    j.at("name").get_to(handler.name);
+    j.at("description").get_to(handler.description);
+    j.at("primary").get_to(primary);
+    handler.primary = decodeHexString(primary);
     if (j.contains("secondary"))
     {
-        secondarycode_t secondary;
+        std::string secondary;
         j.at("secondary").get_to(secondary);
-        handler.secondary = secondary;
+        handler.secondary = decodeHexString(secondary);
     }
     if (j.contains("targets"))
     {