This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new a5c5ad2  ARROW-2203: [C++] StderrStream class
a5c5ad2 is described below

commit a5c5ad211216434f1753606b8f90573566deb00f
Author: rvernica <[email protected]>
AuthorDate: Tue Feb 27 10:39:08 2018 +0100

    ARROW-2203: [C++] StderrStream class
    
    Output stream that just writes to stderr. Adapted from StdoutStream, but 
use `cerr` instead of `cout`.
    
    Author: rvernica <[email protected]>
    
    Closes #1657 from rvernica/patch-1 and squashes the following commits:
    
    535dd25 <rvernica> Fix lint issue - trim whitespace
    4aa45b0 <rvernica> ARROW-2203:  StderrStream class
---
 cpp/src/arrow/util/io-util.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/cpp/src/arrow/util/io-util.h b/cpp/src/arrow/util/io-util.h
index 864e1bd..2a01be1 100644
--- a/cpp/src/arrow/util/io-util.h
+++ b/cpp/src/arrow/util/io-util.h
@@ -51,6 +51,29 @@ class StdoutStream : public OutputStream {
   int64_t pos_;
 };
 
+// Output stream that just writes to stderr.
+class StderrStream : public OutputStream {
+ public:
+  StderrStream() : pos_(0) { set_mode(FileMode::WRITE); }
+  ~StderrStream() override {}
+
+  Status Close() override { return Status::OK(); }
+
+  Status Tell(int64_t* position) const override {
+    *position = pos_;
+    return Status::OK();
+  }
+
+  Status Write(const void* data, int64_t nbytes) override {
+    pos_ += nbytes;
+    std::cerr.write(reinterpret_cast<const char*>(data), nbytes);
+    return Status::OK();
+  }
+
+ private:
+  int64_t pos_;
+};
+
 // Input stream that just reads from stdin.
 class StdinStream : public InputStream {
  public:

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to