DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
BinaryReader.h
Go to the documentation of this file.
1#pragma once
2#include "Common.h"
3#include "System/Object.h"
5#include "System/IO/Stream.h"
6#include "System/Array.h"
7#include "System/String.h"
9
10namespace DotNetDupe {
11 namespace System {
12 namespace IO {
13
20 class BinaryReader : public Object, public IDisposable {
21 public:
27 DOTNETDUPE_API explicit BinaryReader(Stream* pStream, bool bLeaveOpen = false, bool bIsLittleEndian = true);
28
34 DOTNETDUPE_API explicit BinaryReader(SmartPointer<Stream> spStream, bool bLeaveOpen = false, bool bIsLittleEndian = true);
35
38
40 DOTNETDUPE_API virtual void Close();
41
43 DOTNETDUPE_API void Dispose() override;
44
48
51 DOTNETDUPE_API bool IsLittleEndian() const;
52
55 DOTNETDUPE_API void SetLittleEndian(bool bIsLittleEndian);
56
59 DOTNETDUPE_API virtual bool ReadBoolean();
60
63 DOTNETDUPE_API virtual byte ReadByte();
64
67 DOTNETDUPE_API virtual signed char ReadSByte();
68
71 DOTNETDUPE_API virtual char ReadChar();
72
76 DOTNETDUPE_API virtual Array<byte> ReadBytes(int iCount);
77
83 DOTNETDUPE_API virtual int Read(Array<byte>& arrBuffer, int iIndex, int iCount);
84
87 DOTNETDUPE_API virtual short ReadInt16();
88
91 DOTNETDUPE_API virtual unsigned short ReadUInt16();
92
95 DOTNETDUPE_API virtual int ReadInt32();
96
99 DOTNETDUPE_API virtual unsigned int ReadUInt32();
100
103 DOTNETDUPE_API virtual long long ReadInt64();
104
107 DOTNETDUPE_API virtual unsigned long long ReadUInt64();
108
111 DOTNETDUPE_API virtual float ReadSingle();
112
115 DOTNETDUPE_API virtual double ReadDouble();
116
120 DOTNETDUPE_API virtual String ReadString(int iLength);
121
122 private:
123 Stream* m_pStream;
124 SmartPointer<Stream> m_spOwnedStream;
125 bool m_bLeaveOpen;
126 bool m_bIsLittleEndian;
127 bool m_bDisposed;
128
129 void EnsureNotDisposed() const;
130 void FillBuffer(char* pBuffer, int iCount);
131 };
132
134
135 }
136 }
137}
Provides methods for creating, manipulating, searching, and sorting arrays.
Defines common cross-platform macros, export decorators, and fundamental types.
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition Common.h:20
Base object class for DotNetDupe mirroring .NET System.Object.
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
High-performance UTF-8 / UTF-16 string manipulation class mirroring .NET System.String.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition Array.h:29
virtual String ReadString(int iLength)
Reads a string of specified byte length from the current stream.
bool IsLittleEndian() const
Gets whether values are decoded in little-endian order.
virtual int Read(Array< byte > &arrBuffer, int iIndex, int iCount)
Reads the specified number of bytes from the stream into an array starting at a specific index.
virtual short ReadInt16()
Reads a 2-byte signed integer from the current stream.
virtual bool ReadBoolean()
Reads a Boolean value from the current stream and advances the current position by one byte.
virtual int ReadInt32()
Reads a 4-byte signed integer from the current stream.
virtual double ReadDouble()
Reads an 8-byte floating point value from the current stream.
virtual signed char ReadSByte()
Reads a signed byte from this stream and advances the current position by one byte.
virtual float ReadSingle()
Reads a 4-byte floating point value from the current stream.
virtual unsigned long long ReadUInt64()
Reads an 8-byte unsigned integer from the current stream.
virtual void Close()
Closes the current reader and the underlying stream if configured.
virtual long long ReadInt64()
Reads an 8-byte signed integer from the current stream.
virtual Array< byte > ReadBytes(int iCount)
Reads the specified number of bytes from the current stream into a byte array.
virtual unsigned short ReadUInt16()
Reads a 2-byte unsigned integer from the current stream.
void Dispose() override
Releases all unmanaged resources used by the BinaryReader.
virtual byte ReadByte()
Reads the next byte from the current stream and advances the current position by one byte.
virtual unsigned int ReadUInt32()
Reads a 4-byte unsigned integer from the current stream.
BinaryReader(Stream *pStream, bool bLeaveOpen=false, bool bIsLittleEndian=true)
Initializes a new instance of the BinaryReader class based on the specified stream and endianness.
Stream * GetBaseStream() const
Exposes access to the underlying stream.
void SetLittleEndian(bool bIsLittleEndian)
Sets the endianness for binary decoding.
virtual char ReadChar()
Reads the next character from the current stream.
Provides a mechanism for releasing unmanaged resources.
Definition IDisposable.h:13
Provides a generic view of a sequence of bytes.
Definition Stream.h:16
Supports all classes in the DotNetDupe class hierarchy.
Definition Object.h:18
A unified smart pointer that supports both unique and shared ownership semantics.
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition String.h:74
SmartPointer< BinaryReader > BinaryReaderPtr