mFrame
載入中...
搜尋中...
無符合項目
ufm::lang::Memory 類別 參考文件

動態記憶體管理類別 更多...

#include <Memory.h>

類別ufm::lang::Memory的繼承圖:
ufm::lang::Data ufm::lang::NonCopyable ufm::lang::Pointer ufm::lang::Object ufm::lang::Interface ufm::lang::Strings ufm::util::PArray

公開方法(Public Methods)

 Memory (const Data &data)
 Data 物件初始化 Memory
 
 Memory (const void *pointer, int length)
 以常數指標與長度初始化 Memory
 
 Memory (void *pointer, int length)
 以指標與長度初始化 Memory
 
template<typename T , size_t N>
 Memory (T(&array)[N])
 以陣列初始化 Memory
 
template<typename T , size_t N>
 Memory (const T(&array)[N])
 以常數陣列初始化 Memory
 
 Memory (void *pointer, uint32 length)
 以指標與無符號長度初始化 Memory
 
 Memory (int length)
 以指定長度分配記憶體
 
 Memory (Memory &other) noexcept
 移動建構子(淺層複製)
 
 Memory (Memory &&other) noexcept
 移動建構子
 
virtual ~Memory (void) override
 解構子,釋放記憶體資源
 
bool isHeapMemory (void) const
 判斷是否為堆積記憶體
 
bool resize (int size)
 調整記憶體大小
 
- 公開方法(Public Methods) 繼承自 ufm::lang::Data
 Data (void)
 預設建構子,初始化空資料物件
 
 Data (const char *pointer)
 以字元指標初始化資料物件
 
template<typename T , size_t N>
 Data (T(&array)[N])
 以字元陣列初始化資料物件
 
template<typename T , size_t N>
 Data (const T(&array)[N])
 以常數字元陣列初始化資料物件
 
 Data (const void *pointer, int length)
 以常數指標與長度初始化資料物件
 
 Data (void *pointer, int length)
 以可修改指標與長度初始化資料物件
 
 Data (const Data &other)
 複製建構子
 
Dataoperator= (const Data &other)=default
 賦值運算子
 
virtual int copy (const void *source, int shift, int start, int length) override
 複製來源資料至本物件
 
bool isReadOnly (void) const
 判斷資料是否唯讀
 
int length (void) const
 取得資料長度
 
uint32 lengthUnsigned (void) const
 取得資料長度 (無符號)
 
int wipe (void)
 擦除所有資料 (預設值 0x00)
 
int wipe (uint8 value)
 擦除所有資料 (指定值)
 
int wipe (uint8 value, int length)
 擦除資料 (指定值與長度)
 
int popArray (int start, int length)
 取出資料 (不儲存)
 
int popArray (void *source, int start, int length)
 取出資料並儲存至指定指標
 
int insertArray (const void *source, int start, int length)
 插入資料至本物件
 
bool inRange (void *address) const
 判斷指定位址是否在資料範圍內
 
int wipe (uint8 value, int start, int length)
 擦除資料 (指定值、起始位置與長度)
 
ufm::lang::Data subData (int beginIndex, int length) const
 取得子資料區段
 
int insertArray (const void *source, int shift, int start, int length)
 插入資料 (含來源位移)
 
int popArray (void *source, int shift, int start, int length)
 取出資料 (含來源位移)
 
virtual int hashdata (void) const
 計算資料雜湊值
 
int copy (const void *source, int length)
 繼承 Pointer 類別的 copy 方法 使 Data 可直接呼叫 Pointer 的 copy 實作
 
int copy (const void *source, int offset, int length)
 繼承 Pointer 類別的 copy 方法 使 Data 可直接呼叫 Pointer 的 copy 實作
 
- 公開方法(Public Methods) 繼承自 ufm::lang::Pointer
 Pointer (void)
 儲存指標的內部成員變數
 
 Pointer (const void *pointer)
 建立一個 Pointer 物件,並以 const void* 初始化內部指標
 
 Pointer (void *pointer)
 建立一個 Pointer 物件,並以 void* 初始化內部指標
 
 Pointer (uint32 pointer)
 建立一個 Pointer 物件,並以 32 位元整數表示的位址初始化
 
 Pointer (const Pointer &other)
 複製建構子,從另一個 Pointer 物件複製內部位址
 
 operator void * (void)
 隱式轉換為 void*,可直接取得內部指標
 
 operator const char * (void)
 隱式轉換為 const char*,適用於字串存取
 
bool operator== (const void *pointer)
 比較內部指標與外部指標是否相同
 
bool operator== (const Pointer &pointer)
 比較兩個 Pointer 物件的內部指標是否相同
 
template<typename E >
 operator E* (void)
 模板運算子,將內部指標轉換為指定型態的指標(非 const 版本)
 
template<typename E >
 operator E* (void) const
 模板運算子,將內部指標轉換為指定型態的指標(const 版本)
 
Pointeroperator= (const Pointer &other)=default
 賦值運算子,將另一個 Pointer 物件的內部指標複製到當前物件
 
int copyTo (void *destination, int length) const
 複製內部資料至目標記憶體區塊
 
int copyTo (void *destination, int start, int length) const
 複製內部資料至目標記憶體區塊,可指定來源起始位置
 
bool compairStrings (const char *str) const
 比較內部資料與傳入字串是否相同(從起始位置開始比較)
 
bool compairStrings (const char *str, int start) const
 比較內部資料與傳入字串是否相同,可指定來源資料起始位置
 
bool compair (const void *source, int length) const
 比較內部資料與來源資料是否相等(從起始位置開始比較)
 
bool compair (const void *source, int start, int length) const
 比較內部資料與來源資料是否相等,可指定來源資料的起始偏移
 
int indexOf (char ch, int start, int limit) const
 在內部資料中查找指定字元 ch,回傳該字元的偏移位置
 
int indexOfStrings (const char *str, int limit) const
 在內部資料中查找指定字串,回傳該字串的偏移位置(使用預設起始位置)
 
int indexOfStrings (const char *str, int start, int limit) const
 在內部資料中查找指定字串,回傳該字串的偏移位置
 
int copy (const void *source, int length)
 複製來源資料至內部資料區塊,使用預設偏移參數
 
int copy (const void *source, int offset, int length)
 複製來源資料至內部資料區塊,可指定目標位址偏移
 
char getByte (int shift) const
 取得指定偏移處的 byte 值
 
int getInteger (int shift) const
 取得指定偏移處的整數值
 
short getShort (int shift) const
 取得指定偏移處的 short 值
 
Pointer getPointer (int offset) const
 以指定偏移建立新的 Pointer 物件
 
uint32 getAddress (void) const
 取得內部記憶體位址的整數表示
 
bool isAlignment32Bit (void)
 檢查內部位址是否 32 位元對齊
 
bool isAlignment64Bit (void)
 檢查內部位址是否 64 位元對齊
 
bool isNull (void) const
 檢查內部指標是否為空
 
template<typename E = void*>
E * pointer (void) const
 模板方法,取得內部指標並轉換為指定型態(不指定偏移)
 
template<typename E = void*>
E * pointer (int offset) const
 模板方法,取得內部指標並轉換為指定型態(指定偏移)
 
template<typename E = void*>
E * pointer (uint32 offset) const
 模板方法,取得內部指標並轉換為指定型態(指定偏移,使用 uint32 參數)
 
virtual int copyTo (void *destination, int offset, int destinationOffset, int length) const
 將內部資料複製到目標記憶體區塊,可指定來源與目標的起始偏移
 
virtual bool compair (const void *source, int offset, int sourceOffset, int length) const
 比較內部資料與來源資料是否相等,可指定各自的起始偏移與比較長度
 
virtual int indexOfData (const void *destination, int destinationLen, int start=0, int limit=0) const
 尋找指定 pattern 是否存在於內部資料中,並返回第一個符合條件的偏移量
 
virtual void move (int head, int offset, int length)
 將來源位置的資料以中間緩衝區方式移動至新的位置
 
- 公開方法(Public Methods) 繼承自 ufm::lang::Object
void * operator new (size_t n)
 使用運算子 new 分配記憶體
 
void * operator new (size_t n, void *p)
 在指定記憶體上調用運算子 new
 
virtual ufm::lang::ObjectgetObject (void) override
 取得對應的 Object 物件
 
void delay (int milliseconds) const
 延遲指定的毫秒數進行執行緒等待
 
bool equals (Object *object) const
 判斷與另一物件是否為相同參照(指標型態比較)
 
bool equals (Object &object) const
 判斷與另一物件是否為相同參照(參照型態比較)
 
void wait (void) const
 使當前線程等待直到被通知
 
bool wait (int timeout) const
 等待通知或超時
 
bool yield (void) const
 讓執行緒讓渡控制權給同優先權的下一個執行緒
 
int lock (void) const
 核心鎖定,鎖定期間禁止線程切換
 
int unlock (void) const
 核心解鎖
 
ufm::sys::ThreadcurrentThread (void) const
 取得當前執行緒指標
 
virtual int hashcode (void) const
 返回對象的哈希碼值。支持這種方法是為了散列表,如HashMap提供的那樣。
 
- 公開方法(Public Methods) 繼承自 ufm::lang::Interface
virtual ~Interface (void)=default
 虛擬析構函式
 
- 公開方法(Public Methods) 繼承自 ufm::lang::NonCopyable
 NonCopyable (void)=default
 建構一個新的 NonCopyable 物件
 
 NonCopyable (const NonCopyable &other)=delete
 禁止複製建構子
 
NonCopyableoperator= (const NonCopyable &other)=delete
 禁止複製賦值運算子
 

靜態公開方法(Static Public Methods)

static ufm::lang::Memory nullMemory (void)
 取得空 Memory 物件
 

詳細描述

動態記憶體管理類別

提供動態記憶體分配、大小調整、移動語意(淺層複製),禁止複製(繼承 NonCopyable),適用於需動態管理記憶體的場景。

1.0.0

建構子與解構子說明文件

◆ Memory() [1/9]

ufm::lang::Memory::Memory ( const Data & data)
explicit

Data 物件初始化 Memory

參數
data資料來源物件

◆ Memory() [2/9]

ufm::lang::Memory::Memory ( const void * pointer,
int length )
inline

以常數指標與長度初始化 Memory

參數
pointer資料來源指標
length資料長度

◆ Memory() [3/9]

ufm::lang::Memory::Memory ( void * pointer,
int length )
inline

以指標與長度初始化 Memory

參數
pointer資料來源指標
length資料長度

◆ Memory() [4/9]

template<typename T , size_t N>
ufm::lang::Memory::Memory ( T(&) array[N])
inline

以陣列初始化 Memory

樣版參數
T資料型態
N陣列長度

◆ Memory() [5/9]

template<typename T , size_t N>
ufm::lang::Memory::Memory ( const T(&) array[N])
inline

以常數陣列初始化 Memory

樣版參數
T資料型態
N陣列長度

◆ Memory() [6/9]

ufm::lang::Memory::Memory ( void * pointer,
uint32 length )
inline

以指標與無符號長度初始化 Memory

參數
pointer資料來源指標
length資料長度 (uint32)

◆ Memory() [7/9]

ufm::lang::Memory::Memory ( int length)

以指定長度分配記憶體

參數
length記憶體長度

◆ Memory() [8/9]

ufm::lang::Memory::Memory ( Memory & other)
noexcept

移動建構子(淺層複製)

參數
other來源 Memory 物件

◆ Memory() [9/9]

ufm::lang::Memory::Memory ( Memory && other)
noexcept

移動建構子

參數
other來源 Memory 物件

函式成員說明文件

◆ isHeapMemory()

bool ufm::lang::Memory::isHeapMemory ( void ) const
inline

判斷是否為堆積記憶體

傳回值
true 屬於堆積記憶體
false 非堆積記憶體

◆ nullMemory()

static ufm::lang::Memory ufm::lang::Memory::nullMemory ( void )
inlinestatic

取得空 Memory 物件

傳回值
Memory 物件

◆ resize()

bool ufm::lang::Memory::resize ( int size)

調整記憶體大小

參數
size新記憶體大小
傳回值
true 成功
false 失敗

此類別(class) 文件是由下列檔案中產生: