1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements.  See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership.  The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License.  You may obtain a copy of the License at
8 //
9 //   http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied.  See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17 
18 #pragma once
19 
20 #include <cstdint>
21 
22 #include "arrow/io/interfaces.h"
23 #include "arrow/util/visibility.h"
24 
25 namespace arrow {
26 namespace io {
27 
28 // Output stream that just writes to stdout.
29 class ARROW_EXPORT StdoutStream : public OutputStream {
30  public:
31   StdoutStream();
~StdoutStream()32   ~StdoutStream() override {}
33 
34   Status Close() override;
35   bool closed() const override;
36 
37   Result<int64_t> Tell() const override;
38 
39   Status Write(const void* data, int64_t nbytes) override;
40 
41  private:
42   int64_t pos_;
43 };
44 
45 // Output stream that just writes to stderr.
46 class ARROW_EXPORT StderrStream : public OutputStream {
47  public:
48   StderrStream();
~StderrStream()49   ~StderrStream() override {}
50 
51   Status Close() override;
52   bool closed() const override;
53 
54   Result<int64_t> Tell() const override;
55 
56   Status Write(const void* data, int64_t nbytes) override;
57 
58  private:
59   int64_t pos_;
60 };
61 
62 // Input stream that just reads from stdin.
63 class ARROW_EXPORT StdinStream : public InputStream {
64  public:
65   StdinStream();
~StdinStream()66   ~StdinStream() override {}
67 
68   Status Close() override;
69   bool closed() const override;
70 
71   Result<int64_t> Tell() const override;
72 
73   Result<int64_t> Read(int64_t nbytes, void* out) override;
74 
75   Result<std::shared_ptr<Buffer>> Read(int64_t nbytes) override;
76 
77  private:
78   int64_t pos_;
79 };
80 
81 }  // namespace io
82 }  // namespace arrow
83