trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [trafficserver] branch master updated: BufferWriter: Add data() method for access to the internal buffer for API consistency with std:string and ts::string_view.
Date Fri, 29 Sep 2017 13:37:54 GMT
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 879fe70  BufferWriter: Add data() method for access to the internal buffer for API
consistency with std:string and ts::string_view.
879fe70 is described below

commit 879fe70da0665a30e212cb8d66002a5881b2adb9
Author: Alan M. Carroll <amc@apache.org>
AuthorDate: Thu Sep 28 17:02:10 2017 -0500

    BufferWriter: Add data() method for access to the internal buffer for API consistency
with std:string and ts::string_view.
---
 lib/ts/BufferWriter.h                  | 10 ++++++++++
 lib/ts/unit-tests/test_BufferWriter.cc |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/lib/ts/BufferWriter.h b/lib/ts/BufferWriter.h
index d3e41c9..43872e6 100644
--- a/lib/ts/BufferWriter.h
+++ b/lib/ts/BufferWriter.h
@@ -60,6 +60,9 @@ public:
     return write(sV.data(), sV.size());
   }
 
+  /// Return the written buffer.
+  virtual const char *data() const = 0;
+
   // Returns true if the instance is in an error state.
   //
   virtual bool error() const = 0;
@@ -170,6 +173,13 @@ public:
   //
   using BufferWriter::write;
 
+  /// Return the written buffer.
+  const char *
+  data() const override
+  {
+    return _buf;
+  }
+
   bool
   error() const override
   {
diff --git a/lib/ts/unit-tests/test_BufferWriter.cc b/lib/ts/unit-tests/test_BufferWriter.cc
index 419907e..3bbd3cb 100644
--- a/lib/ts/unit-tests/test_BufferWriter.cc
+++ b/lib/ts/unit-tests/test_BufferWriter.cc
@@ -69,6 +69,11 @@ TEST_CASE("BufferWriter::write(StringView)", "[BWWSV]")
     }
 
     // Dummies.
+    const char *
+    data() const override
+    {
+      return nullptr;
+    }
     size_t
     capacity() const override
     {

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Mime
View raw message