CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
binary_writer.h
1
2#ifndef __binary_writer_h__
3#define __binary_writer_h__
4
5#include "system/idisposable.h"
6#include "system/text/encoding.h"
7#include "system/io/seekorigin.h"
8#include "system/io/stream.h"
9#include "system/array.h"
10#include "system/decimal.h"
11#include "fwd.h"
12
13namespace System { namespace IO {
18 class ASPOSECPP_SHARED_CLASS BinaryWriter: public IDisposable
19 {
20 RTTI_INFO(System::IO::BinaryWriter, ::System::BaseTypesInfo<System::IDisposable>)
21
22 public:
29 ASPOSECPP_SHARED_API BinaryWriter(const StreamPtr& stream, const EncodingPtr& encoding = System::Text::Encoding::get_UTF8Unmarked(), bool leaveopen = false);
31 ASPOSECPP_SHARED_API ~BinaryWriter();
32
34 ASPOSECPP_SHARED_API StreamPtr get_BaseStream();
36 ASPOSECPP_SHARED_API void Flush();
38 ASPOSECPP_SHARED_API void Close();
40 ASPOSECPP_SHARED_API void Dispose() override;
45 ASPOSECPP_SHARED_API int64_t Seek(int offset, System::IO::SeekOrigin origin = System::IO::SeekOrigin::Begin);
48 virtual ASPOSECPP_SHARED_API void Write(uint8_t value);
53 virtual ASPOSECPP_SHARED_API void Write(const ArrayPtr<uint8_t>& buffer, int index = 0, int count = -1);
58 virtual ASPOSECPP_SHARED_API void Write(const ArrayPtr<char_t>& buffer, int index = 0, int count = -1);
62 virtual ASPOSECPP_SHARED_API void Write(bool value);
65 virtual ASPOSECPP_SHARED_API void Write(char16_t value);
68 virtual ASPOSECPP_SHARED_API void Write(int16_t value);
71 virtual ASPOSECPP_SHARED_API void Write(int value);
74 virtual ASPOSECPP_SHARED_API void Write(int64_t value);
77 virtual ASPOSECPP_SHARED_API void Write(uint16_t value);
80 virtual ASPOSECPP_SHARED_API void Write(uint32_t value);
83 virtual ASPOSECPP_SHARED_API void Write(uint64_t value);
86 virtual ASPOSECPP_SHARED_API void Write(float value);
89 virtual ASPOSECPP_SHARED_API void Write(double value);
92 virtual ASPOSECPP_SHARED_API void Write(const Decimal& value);
95 virtual ASPOSECPP_SHARED_API void Write(const String& value);
98 virtual ASPOSECPP_SHARED_API void Write(const char_t* value);
99
100 protected:
103 ASPOSECPP_SHARED_API void Dispose(bool disposing);
104
107 ASPOSECPP_SHARED_API void Write7BitEncodedInt(int value);
108
109 private:
111 StreamPtr m_stream;
113 EncodingPtr m_encoding;
115 ArrayPtr<uint8_t> m_buffer;
118 bool m_leaveopen;
119
120 };
121
124
125}}
126
127#endif
Represents a decimal number. This type should be allocated on stack and passed to functions by value ...
Definition: decimal.h:107
Defines method that releases resources owned by the current object. Objects of this class should only...
Definition: idisposable.h:30
Represents a writer that writes values of primitive types to a byte stream. Objects of this class sho...
Definition: binary_writer.h:19
virtual void Write(uint64_t value)
Writes the specified unsigned 64-bit integer value to the output stream.
virtual void Write(char16_t value)
Writes the specified 16-bit wide character value to the output stream.
virtual void Write(uint8_t value)
Writes the specified unsigned 8-bit integer value to the output stream.
virtual void Write(double value)
Writes the specified double-precision floating point value to the output stream.
void Close()
Closes the current BinaryWriter object and the underlying output stream.
virtual void Write(const ArrayPtr< uint8_t > &buffer, int index=0, int count=-1)
Writes the specified subrange of bytes from the specified byte array to the output stream.
virtual void Write(uint32_t value)
Writes the specified unsigned 32-bit integer value to the output stream.
void Dispose() override
Releases all resources used by the current object and closes the undelying stream.
~BinaryWriter()
Destructor.
virtual void Write(int value)
Writes the specified 32-bit integer value to the output stream.
virtual void Write(uint16_t value)
Writes the specified unsigned 16-bit integer value to the output stream.
int64_t Seek(int offset, System::IO::SeekOrigin origin=System::IO::SeekOrigin::Begin)
Sets the position of the stream represented by the current object.
virtual void Write(const char_t *value)
Writes a length-prefixed string in the current encoding to the output stream.
void Write7BitEncodedInt(int value)
Writes int value byte by byte.
virtual void Write(float value)
Writes the specified single-precision floating point value to the output stream.
virtual void Write(bool value)
Writes single byte with a value of 0 if value is 'true' and 1 if value is 'false' to the output strea...
virtual void Write(const String &value)
Writes a length-prefixed string in the current encoding to the output stream.
virtual void Write(int16_t value)
Writes the specified 16-bit integer value to the output stream.
void Dispose(bool disposing)
Releases all resources used by the current object and closes the undelying stream.
virtual void Write(const ArrayPtr< char_t > &buffer, int index=0, int count=-1)
Writes the specified subrange of UTF-16 characters from the specified character array to the output s...
BinaryWriter(const StreamPtr &stream, const EncodingPtr &encoding=System::Text::Encoding::get_UTF8Unmarked(), bool leaveopen=false)
Constructs an instance of BinaryWriter class that writes data to the specified stream using the speci...
void Flush()
Flushes the output stream.
virtual void Write(int64_t value)
Writes the specified 64-bit integer value to the output stream.
StreamPtr get_BaseStream()
Returns the output stream.
virtual void Write(const Decimal &value)
Writes the byte representation of the specified Decimal value to the output stream.
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
static EncodingPtr get_UTF8Unmarked()
Only internal, to be used by the class libraries: Unmarked and non-input-validating.
SharedPtr< BinaryWriter > BinaryWriterPtr
An alias for a shared pointer to this class.
Definition: binary_writer.h:123
SeekOrigin
Specifies the reference position in the stream relative to which the position to seek to is specified...
Definition: seekorigin.h:11
@ Begin
Beginning of the stream.
Definition: db_command.h:9