xentara-utils v2.0.4
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::windows::wmi::ResultSet Class Referencefinal

A result set of a WMI query. More...

#include <xentara/utils/windows/wmi/ResultSet.hpp>

Public Types

using value_type = Object
 The value type.
 
using difference_type = std::ptrdiff_t
 Dummy type for non-existend difference type.
 
using pointer = Object *
 A pointer to a value.
 
using reference = Object &
 A reference to a value.
 
using iterator_concept = std::input_iterator_tag
 The iterator concept.
 
using iterator_category = iterator_concept
 The iterator category, for use in pre-C++20 code.
 

Public Member Functions

constexpr ResultSet () noexcept=default
 Default constructor.
 
constexpr ResultSet (std::default_sentinel_t) noexcept
 Constructor for a sentinel.
 
auto singleObject () -> Object
 Returns the object contained in a result set containing exactly one object.
 
auto operator== (const ResultSet &rhs) const noexcept
 Equality operator.
 
auto operator== (std::default_sentinel_t) const noexcept
 Comparison with a sentinel.
 
auto operator* () const noexcept -> const Object &
 Accesses the current object.
 
auto operator* () noexcept -> Object &
 Accesses the current object.
 
auto operator-> () const noexcept -> Object *
 Accesses the current object.
 
auto operator++ () -> ResultSet &
 Fetches the next object in the result set.
 

Related Symbols

(Note that these are not member symbols.)

auto begin (ResultSet resultSet) -> ResultSet
 Gets an end iterator for a result set.
 
auto end (ResultSet) -> std::default_sentinel_t
 Gets an end iterator for a result set.
 

Detailed Description

A result set of a WMI query.

This is an enumerator object that can be used to retreive all the objects in the result set one by one. Result sets are input iterators and can be used in algorithms that take an input iterator. Result sets also supply freestanding [begin()](xentara::utils::windows::wmi::begin(ResultSet)) and [end()](xentara::utils::windows::wmi::end(ResultSet)) functions, so they can be used in range-based for loops:

for (auto &&object : wmiNamespace.query("SELECT * FROM __Namespace"))
{
...
}
See also
Namespace::query()

Member Typedef Documentation

◆ difference_type

Dummy type for non-existend difference type.

◆ iterator_category

The iterator category, for use in pre-C++20 code.

◆ iterator_concept

◆ pointer

◆ reference

◆ value_type

Constructor & Destructor Documentation

◆ ResultSet() [1/2]

constexpr xentara::utils::windows::wmi::ResultSet::ResultSet ( )
constexprdefaultnoexcept

Default constructor.

This constructor constructs a result set that contains no objects.

Default constructed Result sets compare equal to exhaused result sets, so they can be used as sentinels in algorithms that require the iterator and sentinel to be of the same type.

◆ ResultSet() [2/2]

constexpr xentara::utils::windows::wmi::ResultSet::ResultSet ( std::default_sentinel_t  )
constexprnoexcept

Constructor for a sentinel.

This constructor constructs an object that compares equal to exhaused result sets, so it can be used as a sentinel in algorithms that require the iterator and sentinel to be of the same type.

This constructor is identical to the default constructor.

Member Function Documentation

◆ operator*() [1/2]

auto xentara::utils::windows::wmi::ResultSet::operator* ( ) const -> const Object &
noexcept

Accesses the current object.

Precondition
Must not be called on an exhaused result set

◆ operator*() [2/2]

auto xentara::utils::windows::wmi::ResultSet::operator* ( ) -> Object &
noexcept

Accesses the current object.

Precondition
Must not be called on an exhaused result set

◆ operator++()

auto xentara::utils::windows::wmi::ResultSet::operator++ ( ) -> ResultSet &

Fetches the next object in the result set.

Precondition
Must not be called on an exhaused result set
Exceptions
std::runtime_errorAn error occurred trying to fetch the next object

◆ operator->()

auto xentara::utils::windows::wmi::ResultSet::operator-> ( ) const -> Object *
noexcept

Accesses the current object.

Precondition
Must not be called on an exhaused result set

◆ operator==() [1/2]

auto xentara::utils::windows::wmi::ResultSet::operator== ( const ResultSet rhs) const
noexcept

Equality operator.

A result set only compares equal to itself, except exhaused result sets, that compare equal to all other exhaused result sets, including default constructed result sets. This allows using default constructed result sets as sentinels in algorithms that require the iterator and sentinel to be of the same type.

◆ operator==() [2/2]

auto xentara::utils::windows::wmi::ResultSet::operator== ( std::default_sentinel_t  ) const
noexcept

Comparison with a sentinel.

Returns
Returns true if the result set is exhaused, or false if it contains a valid object.

◆ singleObject()

auto xentara::utils::windows::wmi::ResultSet::singleObject ( ) -> Object

Returns the object contained in a result set containing exactly one object.

Returns
The object
Exceptions
std::runtime_errorThe result set is empty, or contains more than one object.

Friends And Related Symbol Documentation

◆ begin()

auto begin ( ResultSet  resultSet) -> ResultSet
related

Gets an end iterator for a result set.

This function enables the use of ResultSet in range-based for loops

Parameters
resultSetThe result set to iterate over
Returns
Returns a copy of the result set, since the result is its own iterator

◆ end()

auto end ( ResultSet  ) -> std::default_sentinel_t
related

Gets an end iterator for a result set.

This function enables the use of ResultSet in range-based for loops

Returns
The global default sentinel