]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
include/buffer: add helpers for uint8_t vectors
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 22 Aug 2024 16:58:12 +0000 (12:58 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 5 Sep 2024 13:39:33 +0000 (09:39 -0400)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit 814245ce789836a4e6224f2f9fb2b3c54241030d)

src/include/buffer.h

index 16ee0055ad21aefaf00d376bd75350d731cfac65..2b82e683da2e2f45f50c2343047ec91602bfb890 100644 (file)
@@ -700,6 +700,12 @@ struct error_code;
       void copy_shallow(unsigned len, ptr &dest);
       void copy(unsigned len, list &dest);
       void copy(unsigned len, std::string &dest);
+      template<typename A>
+      void copy(unsigned len, std::vector<uint8_t,A>& u8v) {
+        u8v.resize(len);
+        copy(len, (char*)u8v.data());
+      }
+
       void copy_all(list &dest);
 
       // get a pointer to the currenet iterator position, return the
@@ -1140,6 +1146,10 @@ struct error_code;
     void append(std::string_view s) {
       append(s.data(), s.length());
     }
+    template<typename A>
+    void append(const std::vector<uint8_t,A>& u8v) {
+      append((const char *)u8v.data(), u8v.size());
+    }
 #endif // __cplusplus >= 201703L
     void append(const ptr& bp);
     void append(ptr&& bp);