CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
binary_reader.h
1
2#pragma once
3
4#include "system/array.h"
5#include "system/string.h"
6#include "system/idisposable.h"
7#include "system/decimal.h"
8#include "fwd.h"
9
10namespace System {
11 namespace IO {
12 class Stream;
13 }
14 namespace Text {
15 class Encoding;
16 class Decoder;
17 }
18}
19
20namespace System { namespace IO {
25 class ASPOSECPP_SHARED_CLASS BinaryReader: public IDisposable
26 {
27 RTTI_INFO(System::IO::BinaryReader, ::System::BaseTypesInfo<System::IDisposable>)
28 private:
30 SharedPtr<Stream> m_stream;
32 ArrayPtr<uint8_t> m_buffer;
36 ArrayPtr<char_t> charBuffer;
38 ArrayPtr<uint8_t> charByteBuffer;
39
40 //
41 // 128 chars should cover most strings in one grab.
42 enum {
44 MaxBufferSize = 128
45 };
46
48 bool m_disposed;
51 const bool leave_open;
54 void * m_native_converter;
56 bool m_isMemoryStream;
57
58 public:
62 ASPOSECPP_SHARED_API BinaryReader(const SharedPtr<Stream>& input);
67 ASPOSECPP_SHARED_API BinaryReader(const SharedPtr<Stream>& input, const SharedPtr<Text::Encoding>& encoding);
74 ASPOSECPP_SHARED_API BinaryReader(const SharedPtr<Stream>& input, const SharedPtr<Text::Encoding>& encoding, bool leaveOpen);
75
77 virtual ASPOSECPP_SHARED_API SharedPtr<Stream> get_BaseStream();
78
80 virtual ASPOSECPP_SHARED_API void Close();
81
83 virtual ASPOSECPP_SHARED_API ~BinaryReader();
84
88 virtual ASPOSECPP_SHARED_API int PeekChar();
89
93 virtual ASPOSECPP_SHARED_API int Read();
94
100 virtual ASPOSECPP_SHARED_API int Read(ArrayPtr<uint8_t> buffer, int index, int count);
101
108 virtual ASPOSECPP_SHARED_API int Read(ArrayPtr<char_t> buffer, int index, int count);
109
110 private:
113 void Dispose(bool disposing);
116 void FillBuffer(int numBytes);
124 ASPOSECPP_SHARED_API int ReadCharBytes(const ArrayPtr<char_t>& buffer, int index, int count, int &bytes_read);
125
126 protected:
129 ASPOSECPP_SHARED_API int Read7BitEncodedInt();
130
131 public:
134 virtual ASPOSECPP_SHARED_API bool ReadBoolean();
135
138 virtual ASPOSECPP_SHARED_API uint8_t ReadByte();
139
143 virtual ASPOSECPP_SHARED_API ArrayPtr<uint8_t> ReadBytes(int count);
144
148 virtual ASPOSECPP_SHARED_API char_t ReadChar();
149
153 virtual ASPOSECPP_SHARED_API ArrayPtr<char_t> ReadChars(int count);
154
155 //virtual decimal ReadDecimal();
158 virtual ASPOSECPP_SHARED_API double ReadDouble();
159
162 virtual ASPOSECPP_SHARED_API int16_t ReadInt16();
163
166 virtual ASPOSECPP_SHARED_API int ReadInt32();
167
170 virtual ASPOSECPP_SHARED_API int64_t ReadInt64();
171
172 //C# TO C++ CONVERTER NOTE: The following .NET attribute has no direct equivalent in native C++:
173 //ORIGINAL LINE: [CLSCompliant(false)] public virtual sbyte ReadSByte()
176 virtual ASPOSECPP_SHARED_API int8_t ReadSByte();
179 virtual ASPOSECPP_SHARED_API String ReadString();
182 virtual ASPOSECPP_SHARED_API float ReadSingle();
185 virtual ASPOSECPP_SHARED_API uint16_t ReadUInt16();
188 virtual ASPOSECPP_SHARED_API uint32_t ReadUInt32();
191 virtual ASPOSECPP_SHARED_API uint64_t ReadUInt64();
194 virtual ASPOSECPP_SHARED_API Decimal ReadDecimal();
196 virtual ASPOSECPP_SHARED_API void Dispose() override;
197
198 private:
200 void InitializeInstanceFields();
201 };
202
203}}
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 reader that reads primitive data types as binary data in particular encoding....
Definition: binary_reader.h:26
virtual float ReadSingle()
Reads 4 bytes from the input stream and returns them as a single-precision floating point value.
virtual char_t ReadChar()
Reads a single character from the input stream.
virtual void Dispose() override
Releases all resources used by the current object and closes the undelying stream.
virtual String ReadString()
Reads a string from the current stream. The string is prefixed with the length, encoded as an integer...
virtual void Close()
Closes the current BinaryReader object and the underlying input stream.
virtual uint32_t ReadUInt32()
Reads 4 bytes from the input stream and returns them as an unsigned 32-bit integer value.
virtual uint64_t ReadUInt64()
Reads 8 bytes from the input stream and returns them as an unsigned 64-bit integer value.
BinaryReader(const SharedPtr< Stream > &input, const SharedPtr< Text::Encoding > &encoding)
Constructs an instance of BinaryReader class that reads data from the specified stream using the spec...
virtual Decimal ReadDecimal()
NOT IMPLEMENTED.
virtual uint16_t ReadUInt16()
Reads 2 bytes from the input stream and returns them as an unsigned 16-bit integer value.
virtual int PeekChar()
Reads a single character from the input stream without changing the stream's read cursor.
virtual int16_t ReadInt16()
Reads 2 bytes from the input stream and returns them as a 16-bit integer value.
virtual SharedPtr< Stream > get_BaseStream()
Returns the input stream.
virtual int64_t ReadInt64()
Reads 8 bytes from the input stream and returns them as a 64-bit integer value.
virtual ~BinaryReader()
Destructor.
virtual int Read(ArrayPtr< char_t > buffer, int index, int count)
Reads the specified number of characters from the input stream, converts them to UTF-16 encoding and ...
virtual int ReadInt32()
Reads 4 bytes from the input stream and returns them as a 32-bit integer value.
int Read7BitEncodedInt()
Reads integer value encoded in 7-bit (8th bit used as overflow park).
virtual bool ReadBoolean()
Reads a single byte from the input stream and returns its boolean representation.
virtual uint8_t ReadByte()
Reads a single byte from the input stream.
BinaryReader(const SharedPtr< Stream > &input)
Constructs an instance of BinaryReader class that reads data from the specified stream using UTF-8 en...
virtual int Read(ArrayPtr< uint8_t > buffer, int index, int count)
Reads the specified number of bytes from the input stream and writes them to the specified byte array...
virtual double ReadDouble()
Reads 8 bytes from the input stream and returns them as a double-precision floating point value.
virtual ArrayPtr< uint8_t > ReadBytes(int count)
Reads the specified number of bytes from the input stream.
virtual int Read()
Reads a single character from the input stream.
virtual int8_t ReadSByte()
Reads a single byte from the input stream and returns it as a signed 8-bit integer value.
virtual ArrayPtr< char_t > ReadChars(int count)
Reads the specified number of characters from the input stream and returns them in UTF-16 ecoding.
BinaryReader(const SharedPtr< Stream > &input, const SharedPtr< Text::Encoding > &encoding, bool leaveOpen)
Constructs an instance of BinaryReader class that reads data from the specified stream using the spec...
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
@ Text
Defines color adjustment information for text.
@ Stream
The type that supports reliable, two-way, connection-based byte streams without duplication of data a...
Definition: db_command.h:9