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

指標操作工具類別 更多...

#include <Pointers.h>

類別ufm::lang::Pointers的繼承圖:
ufm::lang::NonInstantiable ufm::lang::Object ufm::lang::Interface

靜態公開方法(Static Public Methods)

static void *const & getReferenceNullPointer (void)
 獲取空指標的常數引用
 
static uint32 toUnsignedInt (const void *pointer)
 將指標轉換為無符號整數
 
static uint32 toSignedInt (const void *pointer)
 轉換為整數
 
template<class T >
static T * shift (T *pointer, int shift)
 指標位址偏移計算
 
template<class T >
static T * shift (T *pointer, uint32 shift)
 指標位址偏移計算(無符號整數)
 
template<class T >
static const T * shift (const T *pointer, int shift)
 常數地址偏移
 
template<class T >
static const T * shift (const T *pointer, uint32 shift)
 常數地址偏移(無符號整數)
 
template<class T >
static T * cast (void *src)
 型態轉換輔助方法
 
template<class T >
static T * cast (uint32 address)
 型態轉換
 
static void copy (void *destination, const void *source, int length)
 複製記憶體區塊
 
static void move (void *destination, const void *source, int length)
 移動記憶體區塊
 
static int compare (const void *src1, const void *src2, int length)
 比較兩記憶體區塊的內容
 
static void wipe (void *src, int value, int length)
 將記憶體區塊設置為指定值
 
static void wipe (void *src, int length)
 將記憶體區塊清零
 
static int getStringLength (const char *src)
 取得C字串的長度
 

保護方法(Protected Methods)

virtual ~Pointers (void) override=default
 Destroy the Pointers object.
 
- 保護方法(Protected Methods) 繼承自 ufm::lang::NonInstantiable
 NonInstantiable (void)=delete
 禁止實例化 NonInstantiable 類別
 
 NonInstantiable (const NonInstantiable &)=delete
 禁止複製建構函式
 
virtual ~NonInstantiable (void) override=default
 Destroy the Non Instantiable object.
 
NonInstantiableoperator= (const NonInstantiable &)=delete
 
NonInstantiableoperator= (NonInstantiable &&)=delete
 

額外的繼承成員

- 公開方法(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
 虛擬析構函式
 

詳細描述

指標操作工具類別

本類別提供針對指標的位元組轉換、偏移、拷貝、移動與比較等各項操作, 並以靜態方法提供便利的功能實作。

函式成員說明文件

◆ cast() [1/2]

template<class T >
static T * ufm::lang::Pointers::cast ( uint32 address)
inlinestatic

型態轉換

樣版參數
T原始型態
參數
address來源地址
t轉換型態
傳回值
T* 轉換後的型態

◆ cast() [2/2]

template<class T >
static T * ufm::lang::Pointers::cast ( void * src)
inlinestatic

型態轉換輔助方法

樣版參數
T目標型態
參數
src來源指標
傳回值
T* 轉換後的型態指標
提供安全的型態轉換機制,建議優先使用此方法而非直接轉型

◆ compare()

static int ufm::lang::Pointers::compare ( const void * src1,
const void * src2,
int length )
static

比較兩記憶體區塊的內容

按位元組比較兩個記憶體區塊。

參數
src1區塊1指標
src2區塊2指標
length比較的位元組數
傳回值
int 若相等返回0;若不相等返回差值

◆ copy()

static void ufm::lang::Pointers::copy ( void * destination,
const void * source,
int length )
static

複製記憶體區塊

將來源記憶體區塊的內容複製到目標區塊(逐位元組複製)。

參數
destination目標記憶體區塊指標
source來源記憶體區塊指標
length要複製的位元組數

◆ getReferenceNullPointer()

static void *const & ufm::lang::Pointers::getReferenceNullPointer ( void )
static

獲取空指標的常數引用

傳回值
void* const& 返回一個指向空指標的常數引用
這個方法用於需要空指標引用的場合,比直接使用 nullptr 更安全

◆ getStringLength()

static int ufm::lang::Pointers::getStringLength ( const char * src)
static

取得C字串的長度

計算以 '\0' 結尾的字串長度,不包含終止符。

參數
src原始字串指標
傳回值
int 字串長度

◆ move()

static void ufm::lang::Pointers::move ( void * destination,
const void * source,
int length )
static

移動記憶體區塊

將來源記憶體區塊移動到目標區塊,用於來源與目標可能重疊的情況。

參數
destination目標記憶體區塊指標
source來源記憶體區塊指標
length要移動的位元組數

◆ shift() [1/4]

template<class T >
static const T * ufm::lang::Pointers::shift ( const T * pointer,
int shift )
inlinestatic

常數地址偏移

樣版參數
T類別
參數
pointer常數地址來源
shift偏移
傳回值
const T* 常數地址

◆ shift() [2/4]

template<class T >
static const T * ufm::lang::Pointers::shift ( const T * pointer,
uint32 shift )
inlinestatic

常數地址偏移(無符號整數)

樣版參數
T類別
參數
pointer常數地址來源
shift偏移
傳回值
const T* 常數地址

◆ shift() [3/4]

template<class T >
static T * ufm::lang::Pointers::shift ( T * pointer,
int shift )
inlinestatic

指標位址偏移計算

樣版參數
T指標類型
參數
pointer原始指標
shift偏移量(可為正或負)
傳回值
T* 偏移後的新指標
用於記憶體位址的精確偏移,需注意不要超出有效範圍

◆ shift() [4/4]

template<class T >
static T * ufm::lang::Pointers::shift ( T * pointer,
uint32 shift )
inlinestatic

指標位址偏移計算(無符號整數)

樣版參數
T指標類型
參數
pointer原始指標
shift偏移量(無符號整數)
傳回值
T* 偏移後的新指標
用於記憶體位址的精確偏移,需注意不要超出有效範圍

◆ toSignedInt()

static uint32 ufm::lang::Pointers::toSignedInt ( const void * pointer)
inlinestatic

轉換為整數

參數
pointer地址
傳回值
uint32 整數

◆ toUnsignedInt()

static uint32 ufm::lang::Pointers::toUnsignedInt ( const void * pointer)
inlinestatic

將指標轉換為無符號整數

參數
pointer要轉換的指標
傳回值
uint32 轉換後的無符號整數值
常用於需要將指標值用於計算或比較的場合

◆ wipe() [1/2]

static void ufm::lang::Pointers::wipe ( void * src,
int length )
static

將記憶體區塊清零

將 src 開始的記憶體區塊填充為0。

參數
src目標記憶體區塊指標
length填充的位元組數

◆ wipe() [2/2]

static void ufm::lang::Pointers::wipe ( void * src,
int value,
int length )
static

將記憶體區塊設置為指定值

將 src 開始的記憶體區塊填充為指定的整數值。

參數
src目標記憶體區塊指標
value填充值
length填充的位元組數

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