diff options
Diffstat (limited to 'src/google/protobuf/io/zero_copy_stream_impl.h')
-rw-r--r-- | src/google/protobuf/io/zero_copy_stream_impl.h | 96 |
1 files changed, 51 insertions, 45 deletions
diff --git a/src/google/protobuf/io/zero_copy_stream_impl.h b/src/google/protobuf/io/zero_copy_stream_impl.h index ea978bfb..46062a85 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl.h +++ b/src/google/protobuf/io/zero_copy_stream_impl.h @@ -47,6 +47,8 @@ #include <google/protobuf/stubs/common.h> +#include <google/protobuf/port_def.inc> + namespace google { namespace protobuf { namespace io { @@ -60,7 +62,7 @@ namespace io { // The latter will introduce an extra layer of buffering, harming performance. // Also, it's conceivable that FileInputStream could someday be enhanced // to use zero-copy file descriptors on OSs which support them. -class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream { +class PROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream { public: // Creates a stream that reads from the given Unix file descriptor. // If a block_size is given, it specifies the number of bytes that @@ -87,24 +89,24 @@ class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream { int GetErrno() { return copying_input_.GetErrno(); } // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size); - void BackUp(int count); - bool Skip(int count); - int64 ByteCount() const; + bool Next(const void** data, int* size) override; + void BackUp(int count) override; + bool Skip(int count) override; + int64 ByteCount() const override; private: - class LIBPROTOBUF_EXPORT CopyingFileInputStream : public CopyingInputStream { + class PROTOBUF_EXPORT CopyingFileInputStream : public CopyingInputStream { public: CopyingFileInputStream(int file_descriptor); - ~CopyingFileInputStream(); + ~CopyingFileInputStream() override; bool Close(); void SetCloseOnDelete(bool value) { close_on_delete_ = value; } int GetErrno() { return errno_; } // implements CopyingInputStream --------------------------------- - int Read(void* buffer, int size); - int Skip(int count); + int Read(void* buffer, int size) override; + int Skip(int count) override; private: // The file descriptor. @@ -137,14 +139,14 @@ class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream { // harming performance. Also, it's conceivable that FileOutputStream could // someday be enhanced to use zero-copy file descriptors on OSs which // support them. -class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream { +class PROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream { public: // Creates a stream that writes to the given Unix file descriptor. // If a block_size is given, it specifies the size of the buffers // that should be returned by Next(). Otherwise, a reasonable default // is used. explicit FileOutputStream(int file_descriptor, int block_size = -1); - ~FileOutputStream(); + ~FileOutputStream() override; // Flushes any buffers and closes the underlying file. Returns false if // an error occurs during the process; use GetErrno() to examine the error. @@ -170,22 +172,22 @@ class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream { int GetErrno() { return copying_output_.GetErrno(); } // implements ZeroCopyOutputStream --------------------------------- - bool Next(void** data, int* size); - void BackUp(int count); - int64 ByteCount() const; + bool Next(void** data, int* size) override; + void BackUp(int count) override; + int64 ByteCount() const override; private: - class LIBPROTOBUF_EXPORT CopyingFileOutputStream : public CopyingOutputStream { + class PROTOBUF_EXPORT CopyingFileOutputStream : public CopyingOutputStream { public: CopyingFileOutputStream(int file_descriptor); - ~CopyingFileOutputStream(); + ~CopyingFileOutputStream() override; bool Close(); void SetCloseOnDelete(bool value) { close_on_delete_ = value; } int GetErrno() { return errno_; } // implements CopyingOutputStream -------------------------------- - bool Write(const void* buffer, int size); + bool Write(const void* buffer, int size) override; private: // The file descriptor. @@ -211,7 +213,7 @@ class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream { // // Note that for reading files (or anything represented by a file descriptor), // FileInputStream is more efficient. -class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { +class PROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { public: // Creates a stream that reads from the given C++ istream. // If a block_size is given, it specifies the number of bytes that @@ -220,19 +222,19 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { explicit IstreamInputStream(std::istream* stream, int block_size = -1); // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size); - void BackUp(int count); - bool Skip(int count); - int64 ByteCount() const; + bool Next(const void** data, int* size) override; + void BackUp(int count) override; + bool Skip(int count) override; + int64 ByteCount() const override; private: - class LIBPROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream { + class PROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream { public: CopyingIstreamInputStream(std::istream* input); - ~CopyingIstreamInputStream(); + ~CopyingIstreamInputStream() override; // implements CopyingInputStream --------------------------------- - int Read(void* buffer, int size); + int Read(void* buffer, int size) override; // (We use the default implementation of Skip().) private: @@ -254,28 +256,29 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { // // Note that for writing files (or anything represented by a file descriptor), // FileOutputStream is more efficient. -class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { +class PROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { public: // Creates a stream that writes to the given C++ ostream. // If a block_size is given, it specifies the size of the buffers // that should be returned by Next(). Otherwise, a reasonable default // is used. explicit OstreamOutputStream(std::ostream* stream, int block_size = -1); - ~OstreamOutputStream(); + ~OstreamOutputStream() override; // implements ZeroCopyOutputStream --------------------------------- - bool Next(void** data, int* size); - void BackUp(int count); - int64 ByteCount() const; + bool Next(void** data, int* size) override; + void BackUp(int count) override; + int64 ByteCount() const override; private: - class LIBPROTOBUF_EXPORT CopyingOstreamOutputStream : public CopyingOutputStream { + class PROTOBUF_EXPORT CopyingOstreamOutputStream + : public CopyingOutputStream { public: CopyingOstreamOutputStream(std::ostream* output); - ~CopyingOstreamOutputStream(); + ~CopyingOstreamOutputStream() override; // implements CopyingOutputStream -------------------------------- - bool Write(const void* buffer, int size); + bool Write(const void* buffer, int size) override; private: // The stream. @@ -299,17 +302,18 @@ class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { // ConcatenatingInputStream may do odd things. It is suggested that you do // not use ConcatenatingInputStream on streams that might produce read errors // other than end-of-stream. -class LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream { +class PROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream { public: // All streams passed in as well as the array itself must remain valid // until the ConcatenatingInputStream is destroyed. ConcatenatingInputStream(ZeroCopyInputStream* const streams[], int count); + ~ConcatenatingInputStream() override = default; // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size); - void BackUp(int count); - bool Skip(int count); - int64 ByteCount() const; + bool Next(const void** data, int* size) override; + void BackUp(int count) override; + bool Skip(int count) override; + int64 ByteCount() const override; private: @@ -326,16 +330,16 @@ class LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream { // A ZeroCopyInputStream which wraps some other stream and limits it to // a particular byte count. -class LIBPROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream { +class PROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream { public: LimitingInputStream(ZeroCopyInputStream* input, int64 limit); - ~LimitingInputStream(); + ~LimitingInputStream() override; // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size); - void BackUp(int count); - bool Skip(int count); - int64 ByteCount() const; + bool Next(const void** data, int* size) override; + void BackUp(int count) override; + bool Skip(int count) override; + int64 ByteCount() const override; private: @@ -350,6 +354,8 @@ class LIBPROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream { } // namespace io } // namespace protobuf - } // namespace google + +#include <google/protobuf/port_undef.inc> + #endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__ |