DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
BinaryWriter.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 BinaryWriter : public Object, public IDisposable {
21 public:
27 DOTNETDUPE_API explicit BinaryWriter(Stream* pStream, bool bLeaveOpen = false, bool bIsLittleEndian = true);
28
34 DOTNETDUPE_API explicit BinaryWriter(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
46 DOTNETDUPE_API virtual void Flush();
47
51
54 DOTNETDUPE_API bool IsLittleEndian() const;
55
58 DOTNETDUPE_API void SetLittleEndian(bool bIsLittleEndian);
59
64 DOTNETDUPE_API virtual long Seek(long lOffset, int iOrigin);
65
68 DOTNETDUPE_API virtual void Write(bool bValue);
69
72 DOTNETDUPE_API virtual void Write(byte bValue);
73
76 DOTNETDUPE_API virtual void Write(char chValue);
77
80 DOTNETDUPE_API virtual void Write(signed char chValue);
81
84 DOTNETDUPE_API virtual void Write(const Array<byte>& arrBuffer);
85
90 DOTNETDUPE_API virtual void Write(const Array<byte>& arrBuffer, int iIndex, int iCount);
91
94 DOTNETDUPE_API virtual void Write(short iValue);
95
98 DOTNETDUPE_API virtual void Write(unsigned short uValue);
99
102 DOTNETDUPE_API virtual void Write(int iValue);
103
106 DOTNETDUPE_API virtual void Write(unsigned int uValue);
107
110 DOTNETDUPE_API virtual void Write(long long llValue);
111
114 DOTNETDUPE_API virtual void Write(unsigned long long ullValue);
115
118 DOTNETDUPE_API virtual void Write(float fValue);
119
122 DOTNETDUPE_API virtual void Write(double dValue);
123
126 DOTNETDUPE_API virtual void Write(const String& sValue);
127
128 private:
129 Stream* m_pStream;
130 SmartPointer<Stream> m_spOwnedStream;
131 bool m_bLeaveOpen;
132 bool m_bIsLittleEndian;
133 bool m_bDisposed;
134
135 void EnsureNotDisposed() const;
136 void WriteInternal(const char* pBuffer, int iCount);
137 };
138
140
141 }
142 }
143}
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
bool IsLittleEndian() const
Gets whether values are encoded in little-endian order.
virtual void Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
void Dispose() override
Releases all unmanaged resources used by the BinaryWriter.
Stream * GetBaseStream() const
Exposes access to the underlying stream.
virtual void Close()
Closes the current BinaryWriter and the underlying stream if configured.
virtual long Seek(long lOffset, int iOrigin)
Sets the position within the current stream.
virtual void Write(bool bValue)
Writes a one-byte Boolean value to the current stream, with 0 representing false and 1 representing t...
void SetLittleEndian(bool bIsLittleEndian)
Sets the endianness for binary encoding.
BinaryWriter(Stream *pStream, bool bLeaveOpen=false, bool bIsLittleEndian=true)
Initializes a new instance of the BinaryWriter class based on the specified stream and endianness.
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< BinaryWriter > BinaryWriterPtr