-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMemBuffer.h
More file actions
92 lines (76 loc) · 3.52 KB
/
Copy pathMemBuffer.h
File metadata and controls
92 lines (76 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
NS_BEGIN
// Forward declarations
class CMemStream;
//#################################################################################################
class CMemBuffer final
{
public:
CMemBuffer(void) = default;
CMemBuffer(const CMemBuffer &src);
CMemBuffer(CMemBuffer &&src) noexcept;
explicit CMemBuffer(const CMemStream &buf);
explicit CMemBuffer(CMemStream &&buf) noexcept;
explicit CMemBuffer(const size_t nBufSize);
CMemBuffer(PCBYTE pBuf, const size_t nDataSize);
CMemBuffer(PCBYTE pBuf, const size_t nDataSize, const size_t nBufSize);
explicit CMemBuffer(PCSTR sz, const bool bIncludeNullTerm = true);
explicit CMemBuffer(PCWSTR sz, const bool bIncludeNullTerm = true);
explicit CMemBuffer(const CStr8 &str, const bool bIncludeNullTerm = true);
explicit CMemBuffer(const CStrW &str, const bool bIncludeNullTerm = true);
explicit CMemBuffer(const CStr16 &str, const bool bIncludeNullTerm = true);
~CMemBuffer(void);
CMemBuffer &Attach(PBYTE pBuf, const size_t nDataSize, const size_t nBufSize = 0);
PBYTE Detach(void) noexcept;
void SecureErase(void);
CMemBuffer &operator=(const CMemBuffer &src);
CMemBuffer &operator=(CMemBuffer &&src) noexcept;
CMemBuffer &operator=(const CMemStream &buf);
CMemBuffer &operator=(CMemStream &&buf) noexcept;
bool Assign(const CMemBuffer &buf);
bool Assign(PCBYTE pBuf, const size_t nDataSize);
bool Assign(PCSTR sz, const bool bIncludeNullTerm = true);
bool Assign(PCWSTR sz, const bool bIncludeNullTerm = true);
bool Assign(const CStr8 &str, const bool bIncludeNullTerm = true);
bool Assign(const CStrW &str, const bool bIncludeNullTerm = true);
bool Assign(const CStr16 &str, const bool bIncludeNullTerm = true);
CMemBuffer &operator+=(const CMemBuffer &src);
bool Append(const CMemBuffer &buf);
bool Append(PCBYTE pBuf, const size_t nDataSize);
bool Append(PCSTR sz, const bool bIncludeNullTerm = true);
bool Append(PCWSTR sz, const bool bIncludeNullTerm = true);
bool Append(const CStr8 &str, const bool bIncludeNullTerm = true);
bool Append(const CStrW &str, const bool bIncludeNullTerm = true);
bool Append(const CStr16 &str, const bool bIncludeNullTerm = true);
bool Prepend(const CMemBuffer &buf);
bool Prepend(PCBYTE pBuf, const size_t nDataSize);
bool Prepend(PCSTR sz, const bool bIncludeNullTerm = true);
bool Prepend(PCWSTR sz, const bool bIncludeNullTerm = true);
bool Prepend(const CStr8 &str, const bool bIncludeNullTerm = true);
bool Prepend(const CStrW &str, const bool bIncludeNullTerm = true);
bool Prepend(const CStr16 &str, const bool bIncludeNullTerm = true);
bool operator==(const CMemBuffer &buf) const noexcept;
bool operator!=(const CMemBuffer &buf) const noexcept;
bool Compare(const CMemBuffer &buf) const noexcept;
bool Compare(PCBYTE pBuf, const size_t nDataSize) const noexcept;
operator PBYTE(void) noexcept;
operator PCBYTE(void) const noexcept;
BYTE GetAt(const size_t nIndex) const noexcept;
void SetAt(const size_t nIndex, const BYTE n) noexcept;
BYTE& operator[](const size_t nIndex);
BYTE operator[](const size_t nIndex) const;
void Reverse(void);
bool IsEmpty(void) const noexcept;
void Empty(void);
PBYTE GetBuffer(void) noexcept;
PCBYTE GetBuffer(void) const noexcept;
size_t GetDataSize(void) const noexcept;
void SetDataSize(const size_t nDataSize) noexcept;
size_t GetBufferSize(void) const noexcept;
bool SetBufferSize(const size_t nBufSize);
private:
PBYTE m_pBuf = nullptr;
size_t m_nDataSize = 0;
size_t m_nBufSize = 0;
};
NS_END