Skip to content

enum TypeDefOrRef

Raymond Chen edited this page Apr 3, 2019 · 5 revisions

The xmr::TypeDefOrRef enum is defined in meta_reader.h (via impl/enum.h). It describes an entity which could be a TypeDef, TypeRef, or TypeSpec. (Yes, TypeSpec is not mentioned in the name of the enum. That's because TypeSpec is not used in xlang databases, I don't think.)

The TypeDefOrRef is often a template parameter to other types.

coded_index, typed_index

A typed_index<TypeDefOrRef> represents a value which could be a TypeDef, a TypeRef, a TypeSpec, or nothing. A coded_index<TypeDefOrRef> is a typed_index<TypeDefOrRef> that can tell you what's inside. You will almost always be working with coded_index.

operator bool()

The Boolean conversion operator returns true if the typed_index contains anything at all. It returns false if the typed_index is empty. If the typed_index is empty, then no other method calls are valid.

type method

xmr TypeDefOrRef type() const;

The type method tells you what is inside the coded_index.

TypeDef, TypeRef, and TypeSpec methods

xmr::TypeDef TypeDef() const;
xmr::TypeDef TypeRef() const;
xmr::TypeDef TypeSpec() const;

The TypeDef() method returns the TypeDef that the typed_index refers to. It is illegal to call this method if the type() of the typed_index is not TypeDef.

The TypeRef() and TypeSpec() methods behave analogously.

CustomAttribute method

std::pair<xmr::CustomAttribute, xmr::CustomAttribute>
CustomAttribute() const;

Returns a range (pair of iterators) that represents the custom attributes associated with the TypeDef, TypeRef or TypeSpec.

Complexity: O(log n), where n is the size of the CustomAttributes table.

Exceptions: Throws std::invalid_argument if the database is corrupted.

Clone this wiki locally