#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2021 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_STORAGE_WRITER_H #define NUCLEX_STORAGE_WRITER_H #include "Config.h" #include // for std::uintX_t and std::intX_t types #include // for std::string namespace Nuclex { namespace Storage { // ------------------------------------------------------------------------------------------- // /// Writes data into a stream or other destination class Writer { /// Destroys a binary data writer public: NUCLEX_STORAGE_API virtual ~Writer() {} /// Writes a boolean into the stream /// Boolean that will be written public: virtual void Write(bool value) = 0; /// Writes an unsigned 8 bit integer into the stream /// 8 bit integer that will be written public: virtual void Write(std::uint8_t value) = 0; /// Writes a signed 8 bit integer into the stream /// 8 bit integer that will be written public: virtual void Write(std::int8_t value) = 0; /// Writes an unsigned 16 bit integer into the stream /// 16 bit integer that will be written public: virtual void Write(std::uint16_t value) = 0; /// Writes a signed 16 bit integer into the stream /// 16 bit integer that will be written public: virtual void Write(std::int16_t value) = 0; /// Writes an unsigned 32 bit integer into the stream /// 32 bit integer that will be written public: virtual void Write(std::uint32_t value) = 0; /// Writes a signed 32 bit integer into the stream /// 32 bit integer that will be written public: virtual void Write(std::int32_t value) = 0; /// Writes an unsigned 64 bit integer into the stream /// 64 bit integer that will be written public: virtual void Write(std::uint64_t value) = 0; /// Writes a signed 64 bit integer into the stream /// 64 bit integer that will be written public: virtual void Write(std::int64_t value) = 0; /// Writes a floating point value into the stream /// Floating point value that will be written public: virtual void Write(float value) = 0; /// Writes a double precision floating point value into the stream /// Double precision floating point value that will be written public: virtual void Write(double value) = 0; /// Writes a string into the stream /// String that will be written /// /// If possible, use UTF-8 for any strings. /// public: virtual void Write(const std::string &value) = 0; /// Writes C style zero-terminated string /// C style string that will be written /// /// This overload is only provided because otherwise, passing a string constant /// to the write method would cause the overload to be called. /// public: NUCLEX_STORAGE_API void Write(const char *value) { Write(std::string(value)); } /// Writes a wide string into the stream /// Wide string that will be written /// /// Avoid using this. Wide characters are 16 bit on Windows, 32 bit on Linux and /// you'll be stuck with an unportable mess of halved UTF-32 characters or /// UTF-16 characters stuck in a UTF-32 wide character string. Only use UTF-8 /// in your public APIs. /// public: virtual void Write(const std::wstring &value) = 0; /// Writes C style zero-terminated string /// C style string that will be written /// /// /// Avoid using this. Wide characters are 16 bit on Windows, 32 bit on Linux and /// you'll be stuck with an unportable mess of halved UTF-32 characters or /// UTF-16 characters stuck in a UTF-32 wide character string. Only use UTF-8 /// in your public APIs. /// /// /// This overload is only provided because otherwise, passing a string constant /// to the write method would cause the overload to be called. /// /// public: NUCLEX_STORAGE_API void Write(const wchar_t *value) { Write(std::wstring(value)); } /// Writes a chunk of bytes into the stream /// Buffer the bytes that will be written /// Number of bytes to write public: virtual void Write(const void *buffer, std::size_t byteCount) = 0; }; // ------------------------------------------------------------------------------------------- // }} // namespace Nuclex::Storage #endif // NUCLEX_STORAGE_WRITER_H