(dbgmodel.h) 的 IDebugHostModule::EnumerateChildren 方法

EnumerateChildren 方法會傳回列舉值,它會列舉指定符號的所有子系。 例如,針對 C++ 類型,基類、欄位、成員函式等都會被視為類型符號的子系。

語法

HRESULT EnumerateChildren(
  SymbolKind                 kind,
  PCWSTR                     name,
  IDebugHostSymbolEnumerator **ppEnum
);

參數

kind

指出呼叫端想要列舉的子符號種類。 如果傳遞一般值 Symbol,則會列舉所有類型的子符號。

name

如果指定,則只會列舉具有此自變數中所指定名稱的子符號。

ppEnum

列舉值,列舉指定種類和名稱的子符號將會在此傳回。

傳回值

這個方法會傳回表示成功或失敗的 HRESULT。

備註

程式碼範例

ComPtr<IDebugHostType> spType; /* get the type of an object */

// Enumerate every field of this type.  Note that this *WILL NOT* enumerate 
// fields of base classes!
ComPtr<IDebugHostSymbolEnumerator> spEnum;
if (SUCCEEDED(spType->EnumerateChildren(SymbolField, nullptr, &spEnum)))
{
    ComPtr<IDebugHostSymbol> spFieldSymbol;
    HRESULT hr = S_OK;
    while (SUCCEEDED(hr))
    {
        hr = spEnum->GetNext(&spFieldSymbol);
        if (SUCCEEDED(hr))
        {
            ComPtr<IDebugHostField> spField;
            if (SUCCEEDED(spFieldSymbol.As(&spField))) /* should always succeed */
            {
                // spField is each field of the type in turn
            }
        }
    }

    // hr == E_BOUNDS : we hit the end of the enumerator
    // hr == E_ABORT  : user requested interruption, propagate upwards immediately
}

規格需求

需求
標頭 dbgmodel.h

另請參閱

IDebugHostModule 介面