A COM variant object.
More...
#include <xentara/utils/windows/com/Variant.hpp>
|
class | Setter |
| Helper class for calling functions that take an output parameter. More...
|
|
|
template<VARTYPE Type> |
using | NativeType = typename variantTypes::detail::VariantNativeType< Type >::Type |
| Facility to determine the native type for a variant type.
|
|
|
| Variant () noexcept |
| Default constructor.
|
|
internal | Variant (VARIANT &&variant) noexcept |
| Constructor that takes ownership of a native variant.
|
|
auto | operator= (VARIANT &&variant) noexcept -> Variant & |
| Assignment operator that takes ownership of a native variant.
|
|
auto | type () const -> VARTYPE |
| Returns the variant type.
|
|
auto | convert (VARTYPE type) const -> Variant |
| Converts the variant to a different type.
|
|
template<VARTYPE kType> |
auto | get () const -> NativeType< kType > |
| Gets the value of the variant.
|
|
template<VARTYPE kType> |
auto | as () const -> NativeType< kType > |
| Converts the value of the variant to a certain type.
|
|
auto | setter () noexcept -> Setter |
| Gets a setter for use as an output parameter for C functions.
|
|
A COM variant object.
This class wraps a COM VARIANT structure.
◆ NativeType
Facility to determine the native type for a variant type.
◆ Variant() [1/2]
xentara::utils::windows::com::Variant::Variant |
( |
| ) |
|
|
noexcept |
Default constructor.
This constructor creates an empty variant
◆ Variant() [2/2]
internal xentara::utils::windows::com::Variant::Variant |
( |
VARIANT && |
variant | ) |
|
|
noexcept |
Constructor that takes ownership of a native variant.
variant The native variant. The variant is cleared.
◆ as()
template<VARTYPE kType>
auto xentara::utils::windows::com::Variant::as |
( |
| ) |
const -> NativeType< kType > |
Converts the value of the variant to a certain type.
- Returns
- The value as the given type
- Exceptions
-
◆ convert()
auto xentara::utils::windows::com::Variant::convert |
( |
VARTYPE |
type | ) |
const -> Variant |
Converts the variant to a different type.
- Returns
- The value as the given type
- Exceptions
-
◆ get()
template<VARTYPE kType>
auto xentara::utils::windows::com::Variant::get |
( |
| ) |
const -> NativeType< kType > |
Gets the value of the variant.
This function does not perform any type conversion. Use as() to get the type using conversion.
- Returns
- The value
- Exceptions
-
◆ operator=()
auto xentara::utils::windows::com::Variant::operator= |
( |
VARIANT && |
variant | ) |
-> Variant & |
|
noexcept |
Assignment operator that takes ownership of a native variant.
variant The native variant. The variant is cleared.
- Returns
- A reference to this object
◆ setter()
auto xentara::utils::windows::com::Variant::setter |
( |
| ) |
-> Setter |
|
noexcept |
Gets a setter for use as an output parameter for C functions.
This function returns a helper object that can be passed to a function that takes a VARIANT * as output parameter, like e.g. IWbemClassObject::Get(). This provides a safe way of creating objects using such a function without running the risk of leaking the created object.
IWbemClassObject::Get() can be called like this, for example:
object->Get(myPropertyName, 0, variant.
setter(),
nullptr,
nullptr);
A COM variant object.
Definition Variant.hpp:324
auto setter() noexcept -> Setter
Gets a setter for use as an output parameter for C functions.
Definition Variant.hpp:543
◆ type()
auto xentara::utils::windows::com::Variant::type |
( |
| ) |
const -> VARTYPE
|
Returns the variant type.
- Returns
- The variant type. The type will be one of the VT_* type codes, possibly ORed together with VT_ARRAY. The value VT_BYREF is masked out.