Parcourir la source

New value type: vector of vector

Eric Ramat il y a 8 mois
Parent
commit
b29c690305
1 fichiers modifiés avec 33 ajouts et 3 suppressions
  1. 33 3
      src/artis-star/common/event/Value.hpp

+ 33 - 3
src/artis-star/common/event/Value.hpp

@@ -101,6 +101,15 @@ class Value {
           for (const auto &e: values) {
             ss << std::boolalpha << e.to_string() << " ";
           }
+        } else if (type() == typeid(std::vector<std::vector<T>>)) {
+          const std::vector<std::vector<T>> &lines = std::any_cast<const std::vector<std::vector<T>> &>(*this);
+
+          for (const auto &values: lines) {
+            for (const auto &e: values) {
+              ss << std::boolalpha << e.to_string() << " ";
+            }
+            ss << "| ";
+          }
         } else {
           ss << std::any_cast<const T &>(*this).to_string();
         }
@@ -119,6 +128,15 @@ class Value {
           for (const auto &e: values) {
             ss << std::boolalpha << e << " ";
           }
+        } else if (type() == typeid(std::vector<std::vector<T>>)) {
+          const std::vector<std::vector<T>> &lines = std::any_cast<const std::vector<std::vector<T>> &>(*this);
+
+          for (const auto &values: lines) {
+            for (const auto &e: values) {
+              ss << std::boolalpha << e << " ";
+            }
+            ss << "| ";
+          }
         } else {
           ss << std::boolalpha << std::any_cast<const T &>(*this);
         }
@@ -147,15 +165,27 @@ public:
 
   Value(const Value &value) : _data(value._data) {}
 
-  template<typename T, std::enable_if_t<not HasToString<T>::Has, bool> = true>
-  Value(const T &value) : _data(new Data<T>(value)) {}
+  template<typename T>
+  Value(const std::vector<std::vector<T>> &value) : _data(new Data<T>(value)) {}
 
   template<typename T>
   Value(const std::vector<T> &value) : _data(new Data<T>(value)) {}
 
-  template<typename T, std::enable_if_t<HasToString<T>::Has, bool> = true>
+  template<typename T>
   Value(const T &value) : _data(new Data<T>(value)) {}
 
+//  template<typename T, std::enable_if_t<not HasToString<T>::Has, bool> = true>
+//  Value(const std::vector<T> &value) : _data(new Data<T>(value)) {}
+//
+//  template<typename T, std::enable_if_t<HasToString<T>::Has, bool> = true>
+//  Value(const std::vector<T> &value) : _data(new Data<T>(value)) {}
+//
+//  template<typename T, std::enable_if_t<not HasToString<T>::Has, bool> = true>
+//  Value(const T &value) : _data(new Data<T>(value)) {}
+//
+//  template<typename T, std::enable_if_t<HasToString<T>::Has, bool> = true>
+//  Value(const T &value) : _data(new Data<T>(value)) {}
+
   template<typename T, size_t size, std::enable_if_t<std::is_same<T, char>::value, bool> = true>
   Value(const T (&value)[size]) : _data(new Data<T>(std::string(value, size))) {}