From 6cc2945c1d1e6ca7bad0542c79de423df5e2db8b Mon Sep 17 00:00:00 2001
From: Ferenc Szontágh <szf@fsociety.hu>
Date: Fri, 18 Apr 2025 18:13:29 +0000
Subject: [PATCH] implements object type

---
 src/Symbols/Value.hpp |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/Symbols/Value.hpp b/src/Symbols/Value.hpp
index f7040c0..4985d5b 100644
--- a/src/Symbols/Value.hpp
+++ b/src/Symbols/Value.hpp
@@ -4,6 +4,7 @@
 #include <algorithm>
 #include <stdexcept>
 #include <string>
+#include <map>
 #include <variant>
 
 #include "VariableTypes.hpp"
@@ -12,7 +13,8 @@
 
 class Value {
   public:
-    using Variant = std::variant<int, double, float, std::string, bool>;
+    using ObjectMap = std::map<std::string, Value>;
+    using Variant = std::variant<int, double, float, std::string, bool, ObjectMap>;
 
     Value() = default;
 
@@ -27,6 +29,10 @@
     Value(const char * v) : value_(std::string(v)) { type_ = Symbols::Variables::Type::STRING; }
 
     Value(bool v) : value_(v) { type_ = Symbols::Variables::Type::BOOLEAN; }
+    /**
+     * @brief Construct an object value from a map of member names to Values.
+     */
+    Value(const ObjectMap & v) : value_(v) { type_ = Symbols::Variables::Type::OBJECT; }
 
     Value(const std::string & str, bool autoDetectType) { *this = fromString(str, autoDetectType); }
 
@@ -70,6 +76,8 @@
                     return val ? "true" : "false";
                 } else if constexpr (std::is_same_v<T, std::string>) {
                     return val;
+                } else if constexpr (std::is_same_v<T, ObjectMap>) {
+                    return "[object]";
                 } else {
                     return std::to_string(val);
                 }

--
Gitblit v1.9.3