Monado OpenXR Runtime
xrt::auxiliary::util::ExtensionListBuilder Class Reference

A builder for constructing ExtensionList objects. More...

#include <util/u_extension_list.hpp>

Public Member Functions

 ExtensionListBuilder ()=default
 Default constructor. More...
 
 ExtensionListBuilder (uint32_t capacity)
 Construct with capacity hint. More...
 
template<uint32_t N>
 ExtensionListBuilder (const char *(&arr)[N])
 Construct from an array of strings. More...
 
 ExtensionListBuilder (ExtensionListBuilder &&)=delete
 
 ExtensionListBuilder (ExtensionListBuilder const &)=delete
 
ExtensionListBuilderoperator= (ExtensionListBuilder &&)=delete
 
ExtensionListBuilderoperator= (ExtensionListBuilder const &)=delete
 
void append (std::string_view str)
 Append a new string to the builder. More...
 
bool appendUnique (std::string_view str)
 Append a new string to the builder if it doesn't match any existing string. More...
 
void sortForExtensions ()
 Sort the strings in the builder suitable for extension lists. More...
 
ExtensionList build () &&
 Build and return an immutable ExtensionList. More...
 

Detailed Description

A builder for constructing ExtensionList objects.

This class allows write-only operations to build up an extension list, which can then be converted to an immutable ExtensionList.

Constructor & Destructor Documentation

◆ ExtensionListBuilder() [1/3]

xrt::auxiliary::util::ExtensionListBuilder::ExtensionListBuilder ( )
default

Default constructor.

◆ ExtensionListBuilder() [2/3]

xrt::auxiliary::util::ExtensionListBuilder::ExtensionListBuilder ( uint32_t  capacity)
inlineexplicit

Construct with capacity hint.

◆ ExtensionListBuilder() [3/3]

template<uint32_t N>
xrt::auxiliary::util::ExtensionListBuilder::ExtensionListBuilder ( const char *(&)  arr[N])
inlineexplicit

Construct from an array of strings.

References append().

Member Function Documentation

◆ append()

void xrt::auxiliary::util::ExtensionListBuilder::append ( std::string_view  str)
inline

Append a new string to the builder.

Parameters
stra string view to append.
Exceptions
std::out_of_rangeif you have a ridiculous number of strings in your list already.

Referenced by ExtensionListBuilder(), and u_extension_list::u_extension_list_create_from_array().

◆ appendUnique()

bool xrt::auxiliary::util::ExtensionListBuilder::appendUnique ( std::string_view  str)
inline

Append a new string to the builder if it doesn't match any existing string.

(Comparing string contents)

Parameters
stra string view to append.
Returns
true if we added it
Exceptions
std::out_of_rangeif you have a ridiculous number of strings in your list already.

◆ build()

ExtensionList xrt::auxiliary::util::ExtensionListBuilder::build ( ) &&
inline

Build and return an immutable ExtensionList.

This function consumes the builder by moving its internal data into the returned ExtensionList. After calling this, the builder is left in a valid but empty state.

The && qualifier (rvalue reference qualifier) means this can only be called on rvalue references, i.e. on:

This prevents accidentally calling build() twice on the same builder, which would be a bug.

◆ sortForExtensions()

void ExtensionListBuilder::sortForExtensions ( )

Sort the strings in the builder suitable for extension lists.

The list will be sorted first by API (VK, XR, etc.), then all KHR extensions, then all EXT extensions, then all Vendor extensions, then all experimental extensions. (Alphabetical within each group.)

This modifies the builder in-place.

References get_extension_sort_key().


The documentation for this class was generated from the following files: