HStringReference 類別

表示從現有字串建立的 HSTRING。

語法

class HStringReference;

備註

新 HSTRING 中備份緩衝區的存留期不會由Windows 執行階段管理。 呼叫端會在堆疊框架上配置來源字串,以避免堆積配置,並消除記憶體流失的風險。 此外,呼叫端必須確保附加 HSTRING 的存留期間,來源字串維持不變。 如需詳細資訊,請參閱 WindowsCreateStringReference 函式

成員

公用建構函式

名稱 描述
HStringReference::HStringReference 初始化 HStringReference 類別的新執行個體。

公用方法

member 描述
HStringReference::CopyTo 將目前的 HStringReference 物件複製到 HSTRING 物件。
HStringReference::Get 擷取基礎 HSTRING 控制碼的值。
HStringReference::GetRawBuffer 擷取基礎字串資料的指標。

公用運算子

名稱 描述
HStringReference::operator= 將另一個 HStringReference 物件的值移至目前的 HStringReference 物件。
HStringReference::operator== 指出兩個參數是否相等。
HStringReference::operator!= 指出兩個參數是否不相等。
HStringReference::operator< 指出第一個參數是否小於第二個參數。

繼承階層架構

HStringReference

需求

標頭: corewrappers.h

命名空間: Microsoft::WRL::Wrappers

HStringReference::CopyTo

將目前的 HStringReference 物件複製到 HSTRING 物件。

HRESULT CopyTo(
   _Out_ HSTRING *str
   ) const throw();

參數

str
接收復本的 HSTRING。

備註

此方法會 呼叫 WindowsDuplicateString 函式。

HStringReference::Get

擷取基礎 HSTRING 控制碼的值。

HSTRING Get() const throw()

傳回值

基礎 HSTRING 控制碼的值。

HStringReference::GetRawBuffer

擷取基礎字串資料的指標。

const wchar_t* GetRawBuffer(unsigned int* length) const;

參數

length 接收資料長度之變數的指標 int

傳回值

const基礎字串資料的指標。

HStringReference::HStringReference

初始化 HStringReference 類別的新執行個體。

template<unsigned int sizeDest>
HStringReference(wchar_t const (&str)[ sizeDest]) throw();

template<unsigned int sizeDest>
HStringReference(wchar_t const (&str)[ sizeDest],
                 unsigned int len) throw();

HStringReference(HStringReference&& other) throw();

參數

sizeDest
指定目的地 HStringReference 緩衝區大小的範本參數。

str
寬字元字串的參考。

len
要在此作業中使用的 str 參數緩衝區長度 上限。 如果未指定 len 參數,則會使用整個 str 參數。 如果 len 大於 sizeDest,len 會設定為 sizeDest-1。

other
另一個 HStringReference 物件。

備註

第一個建構函式會初始化與參數 str 相同的大小的新 HStringReference 物件。

第二個建構函式會初始化參數 len 所指定大小的新 HStringReference 物件。

第三個建構函式會將新的 HStringReference 物件初始化為其他 參數的值 ,然後終結 另一個 參數。

HStringReference::operator=

將另一個 HStringReference 物件的值移至目前的 HStringReference 物件。

HStringReference& operator=(HStringReference&& other) throw()

參數

other
現有的 HStringReference 物件。

備註

現有 其他 物件的值會複製到目前的 HStringReference 物件,然後 終結另一個 物件。

HStringReference::operator==

指出兩個參數是否相等。

inline bool operator==(
               const HStringReference& lhs,
               const HStringReference& rhs) throw()

inline bool operator==(
               const HSTRING& lhs,
               const HStringReference& rhs) throw()

inline bool operator==(
               const HStringReference& lhs,
               const HSTRING& rhs) throw()

參數

lhs
要比較的第一個參數。 lhs 可以是 HStringReference 物件或 HSTRING 控制碼。

rhs
要比較的第二個參數。 rhs 可以是 HStringReference 物件或 HSTRING 控點。

傳回值

true如果 lhs rhs 參數相等,則為 ,否則為 false

HStringReference::operator!=

指出兩個參數是否不相等。

inline bool operator!=(
               const HStringReference& lhs,
               const HStringReference& rhs) throw()

inline bool operator!=(
               const HSTRING& lhs,
               const HStringReference& rhs) throw()

inline bool operator!=(
               const HStringReference& lhs,
               const HSTRING& rhs) throw()

參數

lhs
要比較的第一個參數。 lhs 可以是 HStringReference 物件或 HSTRING 控制碼。

rhs
要比較的第二個參數。 rhs 可以是 HStringReference 物件或 HSTRING 控點。

傳回值

true如果 lhs rhs 參數不相等,則為 ,否則為 false

HStringReference::operator<

指出第一個參數是否小於第二個參數。

inline bool operator<(
    const HStringReference& lhs,
    const HStringReference& rhs) throw()

參數

lhs
要比較的第一個參數。 lhs 可以是 的 HStringReference 參考。

rhs
要比較的第二個參數。 rhs 可以是 的 HStringReference 參考。

傳回值

true如果 lhs 參數小於 rhs 參數,則為 false 否則為 。