diff OrthancFramework/UnitTestsSources/FileStorageTests.cpp @ 4484:64f06e7d5fc7

new abstraction IMemoryBuffer to avoid unnecessary copies of std::string buffers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 28 Jan 2021 19:03:19 +0100
parents d9473bd5ed43
children cff7fdfc83a4
line wrap: on
line diff
--- a/OrthancFramework/UnitTestsSources/FileStorageTests.cpp	Thu Jan 28 16:59:40 2021 +0100
+++ b/OrthancFramework/UnitTestsSources/FileStorageTests.cpp	Thu Jan 28 19:03:19 2021 +0100
@@ -58,7 +58,10 @@
   std::string uid = Toolbox::GenerateUuid();
   s.Create(uid.c_str(), &data[0], data.size(), FileContentType_Unknown);
   std::string d;
-  s.Read(d, uid, FileContentType_Unknown);
+  {
+    std::unique_ptr<IMemoryBuffer> buffer(s.Read(uid, FileContentType_Unknown));
+    buffer->MoveToString(d);    
+  }
   ASSERT_EQ(d.size(), data.size());
   ASSERT_FALSE(memcmp(&d[0], &data[0], data.size()));
   ASSERT_EQ(s.GetSize(uid), data.size());
@@ -73,7 +76,10 @@
   std::string uid = Toolbox::GenerateUuid();
   s.Create(uid.c_str(), &data[0], data.size(), FileContentType_Unknown);
   std::string d;
-  s.Read(d, uid, FileContentType_Unknown);
+  {
+    std::unique_ptr<IMemoryBuffer> buffer(s.Read(uid, FileContentType_Unknown));
+    buffer->MoveToString(d);    
+  }
   ASSERT_EQ(d.size(), data.size());
   ASSERT_FALSE(memcmp(&d[0], &data[0], data.size()));
   ASSERT_EQ(s.GetSize(uid), data.size());