From bdeaff2b14a01c88e7d001d2739cc000b36f89f1 Mon Sep 17 00:00:00 2001
From: Julien Osman <julien.osman@csgroup.eu>
Date: Tue, 19 May 2020 18:26:23 +0200
Subject: [PATCH] ENH: Add new method MetadataStorageInterface::SetAsVector

---
 .../Metadata/include/otbMetadataStorageInterface.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/Modules/Core/Metadata/include/otbMetadataStorageInterface.h b/Modules/Core/Metadata/include/otbMetadataStorageInterface.h
index 2206a65223..7153a11e6b 100644
--- a/Modules/Core/Metadata/include/otbMetadataStorageInterface.h
+++ b/Modules/Core/Metadata/include/otbMetadataStorageInterface.h
@@ -59,6 +59,20 @@ public:
     {
     SetMetadataValue(path.c_str(), value.c_str(), band);
     }
+
+  /** Parse a std::vector to a metadata value */
+  template < typename T> void SetAsVector(const char *path, std::vector<T> value, const char sep=' ', int band=-1)
+  {
+    std::ostringstream oss;
+    oss << "[";
+    otb::Join(oss, value, std::string(&sep));
+    oss << "]";
+    SetMetadataValue(path, oss.str().c_str(), band);
+  }
+  template < typename T> void SetAsVector(const std::string& path, std::vector<T> value, const char sep=' ', int band=-1)
+  {
+    SetAsVector(path.c_str(), value, sep, band);
+  }
 };
 
 
-- 
GitLab