mFrame
載入中...
搜尋中...
無符合項目
Memory.h
1
8#ifndef MFRAME_D6A75B59_D8E5_4FB2_BAB8_41477CE17D21
9#define MFRAME_D6A75B59_D8E5_4FB2_BAB8_41477CE17D21
10
11/* ***************************************************************************************
12 * Include
13 */
14
15//----------------------------------------------------------------------------------------
16#include "./../lang/Data.h"
17#include "./../lang/NonCopyable.h"
18
19/* ***************************************************************************************
20 * Namespace
21 */
22namespace ufm::lang {
23 class Memory;
24 class String;
25} // namespace ufm::lang
26
27/* ***************************************************************************************
28 * Class/struct/Struct
29 */
30
39 /* *************************************************************************************
40 * Variable
41 */
42 private:
43 Memory* vNext;
44
45 /* *************************************************************************************
46 * Abstract Method
47 */
48
49 /* *************************************************************************************
50 * Construct Method
51 */
52 public:
57 explicit Memory(const Data& data);
58
64 inline Memory(const void* pointer, int length) : Memory(Data(pointer, length)) {
65 return;
66 }
67
73 inline Memory(void* pointer, int length) : Memory(Data(pointer, length)) {
74 return;
75 }
76
82 template <typename T, size_t N>
83 inline Memory(T (&array)[N]) : Memory(array, static_cast<int>(N * sizeof(T))) {
84 return;
85 }
86
92 template <typename T, size_t N>
93 inline Memory(const T (&array)[N]) : Memory(Data(array)) {
94 return;
95 }
96
102 inline Memory(void* pointer, uint32 length)
103 : Memory(Data(pointer, static_cast<int>(length))) {
104 return;
105 }
106
112
117 Memory(Memory& other) noexcept;
118
123 Memory(Memory&& other) noexcept;
124
128 virtual ~Memory(void) override;
129
130 /* *************************************************************************************
131 * Operator Method
132 */
133
134 /* *************************************************************************************
135 * Public Method
136 */
137 public:
143 inline bool isHeapMemory(void) const {
144 return (this->vNext != nullptr);
145 }
146
153 bool resize(int size);
154
155 /* *************************************************************************************
156 * Protected Method
157 */
158
159 /* *************************************************************************************
160 * Private Method
161 */
162
163 /* *************************************************************************************
164 * Static Variable
165 */
166
167 /* *************************************************************************************
168 * Static Method
169 */
170 public:
175 static inline ufm::lang::Memory nullMemory(void) {
176 return Memory(static_cast<const void*>(nullptr), 0);
177 }
178};
179
180/* ***************************************************************************************
181 * End of file
182 */
183
184#endif /* MFRAME_D6A75B59_D8E5_4FB2_BAB8_41477CE17D21 */
資料封裝與操作類別
Definition Data.h:37
int length(void) const
取得資料長度
Definition Data.h:153
動態記憶體管理類別
Definition Memory.h:38
Memory(void *pointer, int length)
以指標與長度初始化 Memory
Definition Memory.h:73
virtual ~Memory(void) override
解構子,釋放記憶體資源
Memory(Memory &other) noexcept
移動建構子(淺層複製)
Memory(void *pointer, uint32 length)
以指標與無符號長度初始化 Memory
Definition Memory.h:102
bool isHeapMemory(void) const
判斷是否為堆積記憶體
Definition Memory.h:143
Memory(int length)
以指定長度分配記憶體
Memory(const T(&array)[N])
以常數陣列初始化 Memory
Definition Memory.h:93
Memory(const Data &data)
以 Data 物件初始化 Memory
static ufm::lang::Memory nullMemory(void)
取得空 Memory 物件
Definition Memory.h:175
Memory(Memory &&other) noexcept
移動建構子
bool resize(int size)
調整記憶體大小
Memory(const void *pointer, int length)
以常數指標與長度初始化 Memory
Definition Memory.h:64
Memory(T(&array)[N])
以陣列初始化 Memory
Definition Memory.h:83
E * pointer(void) const
模板方法,取得內部指標並轉換為指定型態(不指定偏移)
Definition Pointer.h:398
Definition Appendable.h:23
禁止複製的結構
Definition NonCopyable.h:38