mFrame
載入中...
搜尋中...
無符合項目
Pointers.h
1
7#ifndef MFRAME_27CD9666_FD9F_478C_983C_06FC70DDE127
8#define MFRAME_27CD9666_FD9F_478C_983C_06FC70DDE127
9
10/* ***************************************************************************************
11 * Include
12 */
13
14//----------------------------------------------------------------------------------------
15#include "./../lang/NonInstantiable.h"
16
17//----------------------------------------------------------------------------------------
18
19/* ***************************************************************************************
20 * Namespace
21 */
22namespace ufm::lang {
23 class Pointers;
24} // namespace ufm::lang
25
26/* ***************************************************************************************
27 * Class/Interface/Struct/Enum
28 */
29
37 /* *************************************************************************************
38 * Variable
39 */
40
41 /* *************************************************************************************
42 * Abstract Method
43 */
44
45 /* *************************************************************************************
46 * Construct Method
47 */
48 protected:
53 virtual ~Pointers(void) override = default;
54
55 /* *************************************************************************************
56 * Operator Method
57 */
58
59 /* *************************************************************************************
60 * Override Method
61 */
62
63 /* *************************************************************************************
64 * Public Method
65 */
66
67 /* *************************************************************************************
68 * Protected Method
69 */
70
71 /* *************************************************************************************
72 * Private Method
73 */
74
75 /* *************************************************************************************
76 * Static Variable
77 */
78 private:
79 static void* const vNullPointer;
80 /* *************************************************************************************
81 * Static Method
82 */
83 public:
90 static void* const& getReferenceNullPointer(void);
91
99 static inline uint32 toUnsignedInt(const void* pointer) {
100 return reinterpret_cast<uint32>(pointer);
101 }
102
109 static inline uint32 toSignedInt(const void* pointer) {
110 return reinterpret_cast<uint32>(pointer);
111 }
112
122 template <class T>
123 static T* shift(T* pointer, int shift) {
124 return reinterpret_cast<T*>(reinterpret_cast<int>(pointer) + shift);
125 }
126
136 template <class T>
137 static T* shift(T* pointer, uint32 shift) {
138 return reinterpret_cast<T*>(reinterpret_cast<uint32>(pointer) + shift);
139 }
140
149 template <class T>
150 static const T* shift(const T* pointer, int shift) {
151 return reinterpret_cast<T*>(reinterpret_cast<int>(pointer) + shift);
152 }
153
162 template <class T>
163 static const T* shift(const T* pointer, uint32 shift) {
164 return reinterpret_cast<T*>(reinterpret_cast<uint32>(pointer) + shift);
165 }
166
175 template <class T>
176 static inline T* cast(void* src) {
177 return static_cast<T*>(src);
178 }
179
188 template <class T>
189 static inline T* cast(uint32 address) {
190 return static_cast<T*>(reinterpret_cast<void*>(address));
191 }
192
202 static void copy(void* destination, const void* source, int length);
203
213 static void move(void* destination, const void* source, int length);
214
225 static int compare(const void* src1, const void* src2, int length);
226
236 static void wipe(void* src, int value, int length);
237
246 static void wipe(void* src, int length);
247
256 static int getStringLength(const char* src);
257};
258
259/* ***************************************************************************************
260 * End of file
261 */
262
263#endif /* MFRAME_27CD9666_FD9F_478C_983C_06FC70DDE127 */
Definition NonInstantiable.h:29
指標操作工具類別
Definition Pointers.h:36
static T * shift(T *pointer, uint32 shift)
指標位址偏移計算(無符號整數)
Definition Pointers.h:137
static const T * shift(const T *pointer, uint32 shift)
常數地址偏移(無符號整數)
Definition Pointers.h:163
static int getStringLength(const char *src)
取得C字串的長度
static uint32 toSignedInt(const void *pointer)
轉換為整數
Definition Pointers.h:109
static const T * shift(const T *pointer, int shift)
常數地址偏移
Definition Pointers.h:150
static uint32 toUnsignedInt(const void *pointer)
將指標轉換為無符號整數
Definition Pointers.h:99
static void move(void *destination, const void *source, int length)
移動記憶體區塊
static void copy(void *destination, const void *source, int length)
複製記憶體區塊
static T * shift(T *pointer, int shift)
指標位址偏移計算
Definition Pointers.h:123
static void *const & getReferenceNullPointer(void)
獲取空指標的常數引用
static void wipe(void *src, int value, int length)
將記憶體區塊設置為指定值
static int compare(const void *src1, const void *src2, int length)
比較兩記憶體區塊的內容
static T * cast(void *src)
型態轉換輔助方法
Definition Pointers.h:176
static T * cast(uint32 address)
型態轉換
Definition Pointers.h:189
virtual ~Pointers(void) override=default
Destroy the Pointers object.
static void wipe(void *src, int length)
將記憶體區塊清零
Definition Appendable.h:23