Writes primitive types in binary to a stream and supports writing strings.
Public Constructors | |
| binary_writer (const xtd::string &path) | |
| Initializes a new instance of the binary_writer class for the specified file name.   | |
| binary_writer (std::ostream &stream) | |
| Initializes a new instance of the binary_writer class for the specified stream.   | |
Public Properties | |
| std::optional< std::reference_wrapper< std::ostream > > | base_stream () const | 
| Returns the underlying stream.   | |
Public Methods | |
| virtual void | close () | 
| Closes the xtd::io::binary_writer object and the underlying stream, and releases any system resources associated with the reader.   | |
| virtual void | flush () | 
| Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.   | |
| virtual size_t | seek (size_t offset, std::ios::seekdir origin) | 
| Sets the position within the current stream.   | |
| virtual void | write (bool value) | 
| Writes a one-byte boolean value to the current stream, with 0 representing false and 1 representing true.   | |
| virtual void | write (xtd::byte value) | 
| Writes an unsigned byte to the current stream and advances the stream position by one byte.   | |
| virtual void | write (char value) | 
| Writes a character to the current stream and advances the current position by one byte.   | |
| template<size_t size> | |
| void | write (const std::array< xtd::byte, size > &buffer) | 
| Writes a byte array to the underlying stream.   | |
| template<size_t size> | |
| void | write (const std::array< char, size > &buffer) | 
| Writes a character array to the underlying stream.   | |
| virtual void | write (const std::vector< xtd::byte > &buffer) | 
| Writes a byte array to the underlying stream.   | |
| virtual void | write (const std::vector< xtd::byte > &buffer, size_t index, size_t count) | 
| Writes a region of a byte array to the current stream.   | |
| virtual void | write (const std::vector< char > &buffer) | 
| Writes a character array to the underlying stream.   | |
| virtual void | write (const std::vector< char > &buffer, size_t index, size_t count) | 
| Writes a region of a character array to the current stream.   | |
| virtual void | write (double value) | 
| Writes an eight-byte floating-point value to the current stream and advances the stream position by eight bytes.   | |
| virtual void | write (int16 value) | 
| Writes a two-byte signed integer to the current stream and advances the stream position by two bytes.   | |
| virtual void | write (int32 value) | 
| Writes a four-byte signed integer to the current stream and advances the stream position by four bytes.   | |
| virtual void | write (int64 value) | 
| Writes a eight-byte signed integer to the current stream and advances the stream position by eight bytes.   | |
| virtual void | write (sbyte value) | 
| Writes an signed byte to the current stream and advances the stream position by one byte.   | |
| virtual void | write (float value) | 
| Writes an four-byte floating-point value to the current stream and advances the stream position by four bytes.   | |
| virtual void | write (const string &value) | 
| Writes a length-prefixed string to this stream, and advances the current position of the stream and the specific characters being written to the stream.   | |
| virtual void | write (uint16 value) | 
| Writes a two-byte unsigned integer to the current stream and advances the stream position by two bytes.   | |
| virtual void | write (uint32 value) | 
| Writes a four-byte unsigned integer to the current stream and advances the stream position by four bytes.   | |
| virtual void | write (uint64 value) | 
| Writes a eight-byte unsigned integer to the current stream and advances the stream position by eight bytes.   | |
Additional Inherited Members | |
  Public Member Functions inherited from xtd::object | |
| object ()=default | |
| Create a new instance of the ultimate base class object.   | |
| virtual bool | equals (const object &obj) const noexcept | 
| Determines whether the specified object is equal to the current object.   | |
| virtual size_t | get_hash_code () const noexcept | 
| Serves as a hash function for a particular type.   | |
| virtual type_object | get_type () const noexcept | 
| Gets the type of the current instance.   | |
| template<typename object_t > | |
| xtd::uptr< object_t > | memberwise_clone () const | 
| Creates a shallow copy of the current object.   | |
| virtual xtd::string | to_string () const noexcept | 
| Returns a xtd::string that represents the current object.   | |
  Static Public Member Functions inherited from xtd::object | |
| template<typename object_a_t , typename object_b_t > | |
| static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept | 
| Determines whether the specified object instances are considered equal.   | |
| template<typename object_a_t , typename object_b_t > | |
| static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept | 
| Determines whether the specified object instances are the same instance.   | |
      
  | 
  explicit | 
Initializes a new instance of the binary_writer class for the specified file name.
| path | The complete file path to be read. | 
| xtd::argument_exception | path contains one or more of the invalid characters -or- The system could not retrieve the absolute path.  | 
| xtd::io::io_exception | the handle of the specified file cannot be opened | 
      
  | 
  explicit | 
Initializes a new instance of the binary_writer class for the specified stream.
| stream | The stream to be read. | 
| std::optional< std::reference_wrapper< std::ostream > > xtd::io::binary_writer::base_stream | ( | ) | const | 
Returns the underlying stream.
      
  | 
  virtual | 
Closes the xtd::io::binary_writer object and the underlying stream, and releases any system resources associated with the reader.
      
  | 
  virtual | 
Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.
      
  | 
  virtual | 
Sets the position within the current stream.
| ofsset | A byte offset relative to origin. | 
| origin | A field of std::ios::seekdir indicating the reference point from which the new position is to be obtained. | 
| xtd::io::io_exception | The file pointer was moved to an invalid location. | 
      
  | 
  virtual | 
Writes a one-byte boolean value to the current stream, with 0 representing false and 1 representing true.
| value | The boolean value to write (0 or 1). | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes an unsigned byte to the current stream and advances the stream position by one byte.
| value | The unsigned byte to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes a character to the current stream and advances the current position by one byte.
| value | The character to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  inline | 
Writes a byte array to the underlying stream.
| buffer | A byte array containing the data to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  inline | 
Writes a character array to the underlying stream.
| buffer | A character array containing the data to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes a byte array to the underlying stream.
| buffer | A byte array containing the data to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes a region of a byte array to the current stream.
| buffer | A byte array containing the data to write. | 
| index | The index of the first byte to read from buffer and to write to the stream. | 
| count | The number of bytes to read from buffer and to write to the stream. | 
| xtd::argument_exception | The buffer length minus index is less than count. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes a character array to the underlying stream.
| buffer | A character array containing the data to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes a region of a character array to the current stream.
| buffer | A character array containing the data to write. | 
| index | The index of the first byte to read from buffer and to write to the stream. | 
| count | The number of bytes to read from buffer and to write to the stream. | 
| xtd::argument_exception | The buffer length minus index is less than count. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes an eight-byte floating-point value to the current stream and advances the stream position by eight bytes.
| value | The eight-byte floating-point value to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes a two-byte signed integer to the current stream and advances the stream position by two bytes.
| value | The two-byte signed integer to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes a four-byte signed integer to the current stream and advances the stream position by four bytes.
| value | The four-byte signed integer to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes a eight-byte signed integer to the current stream and advances the stream position by eight bytes.
| value | The eight-byte signed integer to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes an signed byte to the current stream and advances the stream position by one byte.
| value | The signed byte to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes an four-byte floating-point value to the current stream and advances the stream position by four bytes.
| value | The four-byte floating-point value to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes a length-prefixed string to this stream, and advances the current position of the stream and the specific characters being written to the stream.
| value | The value to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes a two-byte unsigned integer to the current stream and advances the stream position by two bytes.
| value | The two-byte unsigned integer to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes a four-byte unsigned integer to the current stream and advances the stream position by four bytes.
| value | The four-byte unsigned integer to write. | 
| xtd::io::io_exception | An I/O error occurs. | 
      
  | 
  virtual | 
Writes a eight-byte unsigned integer to the current stream and advances the stream position by eight bytes.
| value | The eight-byte unsigned integer to write. | 
| xtd::io::io_exception | An I/O error occurs. |