Add flag to aos_dump and log_cat to print integers in hex format.

Define new --use_hex flag on aos_dump and log_cat applications that
controls how integers are formatted in the output.
Add use_hex field to JsonOptions struct used by FlatbufferToJson.
Update internal helpers used by FlatbufferToJson to act on new tag.

Change-Id: I26dea2cc37de3af4a1e10852e0df8ff93a696802
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/fast_string_builder.h b/aos/fast_string_builder.h
index 9e111ff..aa6b619 100644
--- a/aos/fast_string_builder.h
+++ b/aos/fast_string_builder.h
@@ -37,7 +37,7 @@
 
   // Append integer to result, converted to string representation.
   template <typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
-  void AppendInt(T val);
+  void AppendInt(T val, bool use_hex = false);
 
   void Append(std::string_view);
 
@@ -70,11 +70,18 @@
 };
 
 template <typename T, typename>
-void FastStringBuilder::AppendInt(T val) {
-  std::size_t index = str_.size();
-  Resize(absl::numbers_internal::kFastToBufferSize);
-  char *end = absl::numbers_internal::FastIntToBuffer(val, str_.data() + index);
-  str_.resize(end - str_.data());
+void FastStringBuilder::AppendInt(T val, bool use_hex) {
+  if (use_hex) {
+    // This is not fast like the decimal path, but hex should be used in limited cases.
+    std::stringstream ss;
+    ss << std::hex << val;
+    str_ += ss.str();
+  } else {
+    std::size_t index = str_.size();
+    Resize(absl::numbers_internal::kFastToBufferSize);
+    char *end = absl::numbers_internal::FastIntToBuffer(val, str_.data() + index);
+    str_.resize(end - str_.data());
+  }
 }
 
 }  // namespace aos