Driver Code Matcher Templates

class DriverCode
#include <dag_driverCode.h>

Stores which D3D driver is currently active.

Public Functions

DriverCode() = default

Enables support for default construction, using any operation on a default constructed DriverCode is undefined behavior.

DriverCode(const DriverCode&) = default

Enables copy construction support.

DriverCode &operator=(const DriverCode&) = default

Enables copy operation support.

inline unsigned asFourCC() const

Returns the currently stored id value.

Note

For Null and Undefined driver this is either all 0 or all 0xFF.

Returns:

Currently stored id value as four character code integer.

template<typename T>
inline constexpr bool is(T t) const

Runs the matcher of t on the currently stored id value and returns its result.

Parameters:

t – Matcher that should be run with the stored id value.

Returns:

Returns the result of the matcher of t.

template<typename T>
inline constexpr bool operator==(T t) const

Runs the matcher of t on the currently stored id value and returns its result.

Parameters:

t – Matcher that should be run with the stored id value.

Returns:

Returns the result of the matcher of t.

template<typename T>
inline constexpr bool operator!=(T t) const

Runs the matcher of t on the currently stored id value and returns its inverted result.

Parameters:

t – Matcher that should be run with the stored id value.

Returns:

Returns the inverted result of the matcher of t.

template<typename T>
inline d3d::drivercode::matcher::Map<T> map() const

Creates a d3d::drivercode::matcher::Map to map driver code matchers to values.

Template Parameters:

T – The type of the value that should be generated by a match.

Returns:

A d3d::drivercode::matcher::Map value that can be used to chain matchers and value pairs and check if anything was matched and retrieve the value.

template<typename T, typename D>
inline d3d::drivercode::matcher::Map<T> map(D d, T &&v) const

Creates a d3d::drivercode::matcher::Map to with directly passing in the first map expression.

Parameters:
  • d – The matcher that should match the driver code value against.

  • v – The value that should be moved into d3d::drivercode::matcher::Map storage should the matcher of d return true.

Returns:

A d3d::drivercode::matcher::Map value that can be used to chain matchers and value pairs and check if anything was matched and retrieve the value.

template<typename T, typename D>
inline d3d::drivercode::matcher::Map<T> map(D d, const T &v) const

Creates a d3d::drivercode::matcher::Map to with directly passing in the first map expression.

Parameters:
  • d – The matcher that should match the driver code value against.

  • v – The value that should be moved into the d3d::drivercode::matcher::Map storage should the matcher of d return true.

Returns:

A d3d::drivercode::matcher::Map value that can be used to chain matchers and value pairs and check if anything was matched and retrieve the value.

template<typename D, size_t N>
inline d3d::drivercode::matcher::Map<const char*> map(D d, const char (&v)[N]) const

Creates a d3d::drivercode::matcher::Map to with directly passing in the first map expression. This is a specialized version for strings, it will yield a const char * and takes an const array of chars.

Parameters:
  • d – The matcher that should match the driver code value against.

  • v – The string of which the pointer should be stored in d3d::drivercode::matcher::Map storage should the matcher of d return true.

Returns:

A d3d::drivercode::matcher::Map value that can be used to chain matchers and value pairs and check if anything was matched and retrieve the value.

template<typename T, typename D, typename C>
inline d3d::drivercode::matcher::EnableIf<!d3d::drivercode::matcher::SameAs<T, C>::value, d3d::drivercode::matcher::Map<T>>::Type map(D d, C &&callable) const

Creates a d3d::drivercode::matcher::Map to with directly passing in the first map expression.

Parameters:
  • d – The matcher that should match the driver code value against.

  • callable – A generator callable that is invoked when the matcher of d returns true. Its returned value will be passed to the constructor of T.

Returns:

A d3d::drivercode::matcher::Map value that can be used to chain matchers and value pairs and check if anything was matched and retrieve the value.

template<typename T, typename D, typename A1, typename A2, typename ...As>
inline d3d::drivercode::matcher::Map<T> map(D d, A1 &&a1, A2 &&a2, As&&... as)

Creates a d3d::drivercode::matcher::Map to with directly passing in the first map expression.

Invokes the constructor of T should the matcher of d return true for a in-place construction of T in the storage of the returned d3d::drivercode::matcher::Map.

Parameters:
  • d – The matcher that should match the driver code value against.

  • a1, a2, as – Arguments passed to the constructor of T should the matcher of d return true.

Returns:

A d3d::drivercode::matcher::Map value that can be used to chain matchers and value pairs and check if anything was matched and retrieve the value.

inline d3d::drivercode::matcher::FirstMatch match() const

Creates a DriverCodeFirstMatch to match matchers against the driver code value.

Returns:

A DriverCodeFirstMatch value that can be used to chain matchers and check if a callable was called.

template<typename D, typename T>
inline d3d::drivercode::matcher::FirstMatch match(D d, T &&callable) const

Creates a DriverCodeFirstMatch with directly passing in the first match expression.

Parameters:
  • d – The matcher that should match the driver code value against.

  • callable – The callable that is called should the matcher of d return true.

Returns:

A DriverCodeFirstMatch value that can be used to chain additional matchers and check if a callable was called.

inline d3d::drivercode::matcher::FirstMatch matchFirst() const

Creates a DriverCodeFirstMatch to match matchers against the driver code value.

Returns:

A DriverCodeFirstMatch value that can be used to chain matchers and check if a callable was called.

template<typename D, typename T>
inline d3d::drivercode::matcher::FirstMatch matchFirst(D d, T &&callable) const

Creates a DriverCodeFirstMatch with directly passing in the first match expression.

Parameters:
  • d – The matcher that should match the driver code value against.

  • callable – The callable that is called should the matcher of d return true.

Returns:

A DriverCodeFirstMatch value that can be used to chain additional matchers and check if a callable was called.

inline d3d::drivercode::matcher::AllMatch matchAll() const

Creates a DriverCodeAllMatch to match matchers against the driver code value.

Returns:

A DriverCodeAllMatch value that can be used to chain matchers and check if any callable was called.

template<typename D, typename T>
inline d3d::drivercode::matcher::AllMatch matchAll(D d, T &&callable) const

Creates a DriverCodeAllMatch with directly passing in the first match expression.

Parameters:
  • d – The matcher that should match the driver code value against.

  • callable – The callable that is called should the matcher of d return true.

Returns:

A DriverCodeAllMatch value that can be used to chain additional matchers and check if any callable was called.

Public Static Functions

template<typename D>
static inline constexpr DriverCode make(D d)

Creates a DriverCode value with the ID of the given driver matcher.

Parameters:

d – The matcher that should be used to generate the driver id value, only id matchers work (drivercode::matcher::ID and drivercode::matcher::ConstID).

Returns:

A DriverCode value that will match true for the matcher of the input parameter.

Protected Functions

inline constexpr DriverCode(int v)

Private constructor, use make to create DriverCode instances.

Protected Attributes

int value

Stores the id value of the currently active driver.

namespace d3d

Variables

constexpr drivercode::matcher::Unsupported xboxOne

Matches to true when the current platform is \xbone and otherwise false.

constexpr drivercode::matcher::Unsupported scarlett

Matches to true when the current platform is \scarlett and otherwise false.

constexpr drivercode::matcher::Unsupported iOS

Matches to true when the current platform is \ios and otherwise false.

constexpr drivercode::matcher::Unsupported tvOS

Matches to true when the current platform is \tvos and otherwise false.

constexpr drivercode::matcher::Unsupported nintendoSwitch

Matches to true when the current platform is \nswitch and otherwise false.

constexpr drivercode::matcher::Unsupported android

Matches to true when the current platform is \android and otherwise false.

constexpr drivercode::matcher::Unsupported macOSX

Matches to true when the current platform is \mac and otherwise false.

constexpr drivercode::matcher::Unsupported linux

Matches to true when the current platform is \linux and otherwise false.

constexpr drivercode::matcher::Unsupported windows

Matches to true when the current platform is \win32 and otherwise false.

constexpr drivercode::matcher::Unsupported dx11

Matches to true when the current driver is \dx11 and otherwise false.

constexpr drivercode::matcher::Unsupported dx12

Matches to true when the current driver is \dx12 and otherwise false.

constexpr drivercode::matcher::Unsupported vulkan

Matches to true when the current driver is \vk and otherwise false.

constexpr drivercode::matcher::Unsupported ps4

Matches to true when the current platform / driver is \ps4 and otherwise false.

constexpr drivercode::matcher::Unsupported ps5

Matches to true when the current platform / driver is \ps5 and otherwise false.

constexpr drivercode::matcher::Unsupported metal

Matches to true when the current driver is \metal and otherwise false.

constexpr drivercode::matcher::Unsupported null

Matches to true when the current driver is null and otherwise false.

constexpr drivercode::matcher::Unsupported stub

Matches to true when the current driver is stub and otherwise false.

constexpr auto anyXbox = xboxOne || scarlett

Matches true when either \xbone or \scarlett matches true, otherwise false.

constexpr auto anyPS = ps4 || ps5

Matches true when either \ps4 or \ps5 matches true, otherwise false.

constexpr auto anyPC = macOSX || linux || windows

Matches true when either \mac, \linux or \win32 matches true, otherwise false.

constexpr d3d::drivercode::matcher::Undefined undefined

Matches true when no driver could be matched, otherwise false.

Note

On platforms with a fixed driver, this will always match false.

constexpr drivercode::matcher::Any any

Matches always true, has special meaning for some uses, like map.

constexpr auto apple = iOS || tvOS || macOSX

Matches true when either \ios, \tvos or \mac matches true, otherwise false.

constexpr drivercode::matcher::Const<true> bit32

Matches true when the build of the project targets a 32 bit architecture.

constexpr drivercode::matcher::Const<false> bit64

Matches true when the build of the project targets a 64 bit architecture.

namespace drivercode
namespace matcher

This namespace holds the matcher types and operations.

Typedefs

using NotAnyDriver = decltype(!(d3d::dx11 || d3d::dx12 || d3d::vulkan || d3d::ps4 || d3d::ps5 || d3d::metal || d3d::null || d3d::stub))

Helper type for doxygen, do not use!

Functions

inline constexpr int make_foucc(int value)

Helper to generate the IDs correctly so they can be used as four character codes. This helper is needed as _MAKE4C macro may not be available here.

Parameters:

value – 4 character code as integer. \retruns Platform specific encoded 4 character code as integer.

template<typename T, typename T1>
constexpr auto operator&&(const Inverted<T> &l, const T1 &r)

Logical and operator, allows combining multiple matchers.

Parameters:
  • l – First matcher to be combined.

  • r – Second matcher to be combined.

Returns:

A new BinaryOp type of this type and T1 with an operator OpAnd.

template<typename T, typename T1>
constexpr auto operator||(const Inverted<T> &l, const T1 &r)

Logical or operator, allows combining multiple matchers.

Parameters:
  • l – First matcher to be combined.

  • r – Second matcher to be combined.

Returns:

A new BinaryOp type of this type and T1 with an operator OpOr.

template<typename T0, typename T1, typename Operator, typename TO>
constexpr auto operator&&(const BinaryOp<T0, T1, Operator> &l, const TO &r)

Logical and operator, allows combining multiple matchers.

Parameters:
  • l – First matcher to be combined.

  • r – Second matcher to be combined.

Returns:

A new BinaryOp type of this type and T1 with an operator OpAnd.

template<typename T0, typename T1, typename Operator, typename TO>
constexpr auto operator||(const BinaryOp<T0, T1, Operator> &l, const TO &r)

Logical or operator, allows combining multiple matchers.

Parameters:
  • l – First matcher to be combined.

  • r – Second matcher to be combined.

Returns:

A new BinaryOp type of this type and T1 with an operator OpOr.

template<int Ident, typename T1>
constexpr auto operator&&(const ID<Ident> &l, const T1 &r)

Logical and operator, allows combining multiple matchers.

Template Parameters:

T1 – is the type of the second operand.

Returns:

A new BinaryOp type of this type and T1 with an operator OpAnd.

template<int Ident, typename T1>
constexpr auto operator||(const ID<Ident> &l, const T1 &r)

Logical or operator, allows combining multiple matchers.

Template Parameters:

T1 – is the type of the second operand.

Returns:

A new BinaryOp type of this type and T1 with an operator OpOr.

template<typename T1>
constexpr const T1 &operator&&(const Const<true> &l, const T1 &r)

Logical and operator, allows combining multiple matchers.

Parameters:
  • l – First matcher to be combined.

  • r – Second matcher to be combined.

Returns:

The matercher of r, as logical and with constant true can be short circuited to just evaluating the second parameter.

template<typename T1>
constexpr const Const<true> &operator||(const Const<true> &l, const T1 &r)

Logical or operator, allows combining multiple matchers.

Parameters:
  • l – First matcher to be combined.

  • r – Second matcher to be combined.

Returns:

A true matcher, as logical or with a constant true can be short circuited to just the constant true.

template<typename T1>
constexpr const Const<false> &operator&&(const Const<false> &l, const T1 &r)

Logical and operator, allows combining multiple matchers.

Parameters:
  • l – First matcher to be combined.

  • r – Second matcher to be combined.

Returns:

A constant false matcher, as logical and with a constant false can be short circuited to just the constant false.

template<typename T1>
constexpr const T1 &operator||(const Const<false> &l, const T1 &r)

Logical or operator, allows combining multiple matchers.

Parameters:
  • l – First matcher to be combined.

  • r – Second matcher to be combined.

Returns:

The matercher of r, as logical or with constant false can be short circuited to just evaluating the second parameter.

template<typename T1>
constexpr const T1 &operator&&(Any, T1) = delete

Disallow operations with any, any should only be used on its own.

template<typename T1>
constexpr Any operator||(Any, T1) = delete

Disallow operations with any, any should only be used on its own.

template<typename T1>
constexpr const T1 &operator&&(T1, Any) = delete

Disallow operations with any, any should only be used on its own.

template<typename T1>
constexpr Any operator||(T1, Any) = delete

Disallow operations with any, any should only be used on its own.

class AllMatch
#include <dag_driverCode.h>

Public Functions

AllMatch() = delete

Default construction is not allowed.

AllMatch(const AllMatch&) = delete

Disallow copying.

AllMatch(AllMatch &&other) = default

Allow moving.

AllMatch &operator=(const AllMatch&) = delete

Disallow copy assignment.

AllMatch &operator=(AllMatch&&) = delete

Disallow move assignment.

template<typename D, typename T>
inline AllMatch &operator()(D d, T &&callable)

Executes the matcher of d with the driver code state and if it yields a match it will execute the callable of callable.

Parameters:
  • d – The matcher that should match the driver code value against.

  • callable – The callable that is called should the matcher of d return true.

Returns:

A reference to this, so that multiple matches can be chained.

template<typename D, typename T>
inline AllMatch &match(D d, T &&callable)

Executes the matcher of d with the driver code state and if it yields a match it will execute the callable of callable.

Parameters:
  • d – The matcher that should match the driver code value against.

  • callable – The callable that is called should the matcher of d return true.

Returns:

A reference to this, so that multiple matches can be chained.

inline explicit operator bool() const

Explicit bool operator allows easy checking if any matcher was matched and any callable was executed.

Returns:

True when any matcher was matched and any callable was called.

inline bool operator!() const

Not operator overload allows easy checking if no matcher was matched and no callable was executed.

Returns:

True when no matcher was matched and no callable was called.

Protected Functions

inline AllMatch(int v)

Create a new object with a stored driver code value.

Parameters:

v – Driver code value that is used on the matchers.

template<typename D, typename T>
inline AllMatch(int v, D d, T &&callable)

Create a new object with a stored driver code value and a initial match call.

Parameters:
  • v – Driver code value that is used on the matchers.

  • d – The matcher that should be immediately be matched on v.

  • callable – The callable that should be executed when the matcher d matches the driver code value v.

Private Functions

template<typename T>
inline void onMatch(bool did_match, T &&callable)

Match execution handler, will update internal state and call callable when did_match is true.

Parameters:
  • did_match – Indicator if a match was found, when true callable will be called and the internal state is updated to indicate that there was a match.

  • callable – Is called when did_match is true.

template<typename D>
inline constexpr bool is(D d) const

Helper to shorten matcher invocation.

Parameters:

d – Matcher to invoke with the driver code state value.

Returns:

The value returned by the matchers d is method.

Private Members

int value

Driver code value, stored as a int to break up dependency to the DriverCode type.

bool wasMatched = false

Keeps track if anything was matched.

Friends

friend class ::DriverCode
struct Any : public d3d::drivercode::matcher::Const<true>
#include <dag_driverCode.h>

The any matcher behaves like a constant true matcher, matching always to true.

Any has some special meaning in some context (like map), where it result in different type / code-gen.

Public Functions

constexpr Inverted<Any> operator!() const = delete

Disallow operations with any, any should only be used on its own.

template<typename T0, typename T1, typename Operator>
struct BinaryOp
#include <dag_driverCode.h>

Combines two matchers with a binary operator.

Combines two matchers with a binary operation.

Template Parameters:
  • T0 – Type of the first matcher.

  • T1 – Type of the second matcher.

  • Operator – The binary operator that should combine the two matchers.

  • T0 – Type of the first operand.

  • T1 – Type of the second operand.

  • Operator – Type of the binary operator.

Public Types

using ThisType = BinaryOp<T0, T1, Operator>

Shorthand for this type.

Public Functions

inline constexpr bool is(int value)

Executes matchers for both T1 and T2 and combines the result with the operator Operator.

Parameters:

value – Is the driver code value that should be matched by the matchers.

Returns:

Combined result of the matchers T1 and T2, combined by Operator.

inline constexpr Inverted<ThisType> operator!() const

Creates the inverted matcher of this matcher.

Returns:

Inverted matcher of this matcher.

Public Members

T0 first

State of the first matcher.

T1 second

State of the second matcher.

template<bool Constant>
struct Const
#include <dag_driverCode.h>

A constant matcher, which will always yield the value of Constant.

Template Parameters:

Constant – The value the matcher should yield during matching.

Subclassed by d3d::drivercode::matcher::ConstID< Ident, Constant >

Public Functions

inline constexpr Const<!Constant> operator!() const

Creates the inverted matcher of this matcher, will always yield the opposite of Constant.

Returns:

Inverted matcher of this matcher.

Public Static Functions

static inline constexpr bool is(int)

Matches always Constant.

Returns:

Always Constant.

template<int Ident, bool Constant>
struct ConstID : public d3d::drivercode::matcher::Const<Constant>
#include <dag_driverCode.h>

A matcher with a matching id, but matching will always yield the value of Constant.

Template Parameters:
  • Ident – The ID the matcher is associated with.

  • Constant – The value the matcher should yield during matching.

Public Types

using ThisType = ConstID<Ident, Constant>

Public Functions

inline constexpr Const<!Constant> operator!() const

Creates the inverted matcher of this matcher, will always yield false.

Returns:

A const false matcher.

Public Static Attributes

static constexpr int value = make_foucc(Ident)

The value of Ident. This value is used by DriverCode::make to initialize the driver code state.

template<bool B, typename T = void>
struct EnableIf
#include <dag_driverCode.h>
template<typename T>
struct EnableIf<true, T>
#include <dag_driverCode.h>

Public Types

using Type = T
class FirstMatch
#include <dag_driverCode.h>

Public Functions

FirstMatch() = delete

Default construction is not allowed.

FirstMatch(const FirstMatch&) = delete

Disallow copying.

FirstMatch(FirstMatch &&other) = default

Allow moving.

FirstMatch &operator=(const FirstMatch&) = delete

Disallow copy assignment.

FirstMatch &operator=(FirstMatch&&) = delete

Disallow move assignment.

template<typename D, typename T>
inline FirstMatch &operator()(D d, T &&callable)

Executes the matcher of d with the driver code state and if it yields a match and there was no previous match it will execute the callable of callable.

Parameters:
  • d – The matcher that should match the driver code value against.

  • callable – The callable that is called should the matcher of d return true and no matcher was found in previous matches.

Returns:

A reference to this, so that multiple matches can be chained.

template<typename D, typename T>
inline FirstMatch &match(D d, T &&callable)

Executes the matcher of d with the driver code state and if it yields a match and there was no previous match it will execute the callable of callable.

Parameters:
  • d – The matcher that should match the driver code value against.

  • callable – The callable that is called should the matcher of d return true and no matcher was found in previous matches.

Returns:

A reference to this, so that multiple matches can be chained.

inline explicit operator bool() const

Explicit bool operator allows easy checking if a matcher was matched and a callable was executed.

Returns:

True when a matcher was matched and a callable was called.

inline bool operator!() const

Not operator overload allows easy checking if no matcher was matched and no callable was executed.

Returns:

True when no matcher was matched and no callable was called.

Protected Functions

inline FirstMatch(int v)

Create a new object with a stored driver code value.

Parameters:

v – Driver code value that is used on the matchers.

template<typename D, typename T>
inline FirstMatch(int v, D d, T &&callable)

Create a new object with a stored driver code value and a initial match call.

Parameters:
  • v – Driver code value that is used on the matchers.

  • d – The matcher that should be immediately be matched on v.

  • callable – The callable that should be executed when the matcher d matches the driver code value v.

Private Functions

template<typename T>
inline void onMatch(bool did_match, T &&callable)

Match execution handler, will update internal state and call callable when did_match is true and its internal state indicated that no matcher did match in previous match attempts.

Parameters:
  • did_match – Indicator if a match was found.

  • callable – Is called when did_match is true and the internal state indicated that no matcher did match in previous match attempts.

template<typename D>
inline constexpr bool is(D d) const

Helper to shorten matcher invocation.

Parameters:

d – Matcher to invoke with the driver code state value.

Returns:

The value returned by the matchers d is method.

Private Members

int value

Driver code value, stored as a int to break up dependency to the DriverCode type.

bool wasMatched = false

Keeps track if anything was matched.

Friends

friend class ::DriverCode
template<int Ident>
struct ID
#include <dag_driverCode.h>

Matcher that matches a given ID. This matcher can be used by DriverCode::make.

Template Parameters:

TheID value the matcher should match to true.

Public Types

using ThisType = ID<Ident>

Shorthand for this type.

Public Functions

inline constexpr Inverted<ThisType> operator!() const

Creates the inverted matcher of this matcher.

Returns:

Inverted matcher of this matcher.

Public Static Functions

static inline constexpr bool is(int cmp)

Matches true when the driver code values is equal to Ident

Parameters:

cmp – Is the driver code state that should be compared to Ident.

Returns:

Returns true when the driver code state is equal to Ident.

Public Static Attributes

static constexpr int value = make_foucc(Ident)

The value of Ident. This value is used by DriverCode::make to initialize the driver code state.

template<typename T>
struct Inverted
#include <dag_driverCode.h>

This matcher inverts the input matcher of template parameter T.

Template Parameters:

T – is the matcher type that should be inverted.

Public Types

using ThisType = Inverted<T>

Shorthand for this type.

Public Functions

inline constexpr bool is(int value)

Invers the result of the matcher T.

Parameters:

value – Is the driver code value that should be matched by the matcher.

Returns:

The inverted result of the matcher of type T.

inline constexpr T operator!() const

Creates the inverted matcher of this, which is just T.

Public Members

T base

State of the base type.

template<typename T>
class Map
#include <dag_driverCode.h>

This type allows easy mappings of driver matchers to a value of the given type T.

The map maps the first mapping, not the most accurate mapping. So order the mapping accordingly. Mappings can either be values directly, emplacement constructor parameters or generators (lambda).

Template Parameters:

T – Is the type of the value the map should store. Must be move or copyable and either be able to be constructed by copy, move or emplace.

Public Functions

Map() = delete

Default construction is not allowed.

Map(const Map&) = delete

Disallow copying.

inline Map(Map &&other)

Move constructor, will move internally stored object when needed.

Map &operator=(const Map&) = delete

Disallow copy assignment.

Map &operator=(Map&&) = delete

Disallow move assignment.

inline ~Map()

Destructor will invoke the destructor of the stored object when any was constructed.

template<typename D>
inline Map &operator()(D d, T &&v)

Maps a matcher to a value.

Parameters:
  • d – The matcher that should match the driver code value against.

  • v – The value that should be stored should the matcher indicate a match.

Returns:

A reference to this, so that multiple matches can be chained.

template<typename D, typename C>
inline EnableIf<!SameAs<T, C>::value, Map&>::Type operator()(D d, C &&callable)

Maps a matcher to a generator.

Parameters:
  • d – The matcher that should match the driver code value against.

  • callable – Invoked to generate a input parameter for the constructor of T in case when a new instance of T is instantiated.

Returns:

A reference to this, so that multiple matches can be chained.

template<typename D, typename ...Vs>
inline Map &operator()(D d, Vs&&... vs)

Maps a matcher to a set of parameters for the constructor of T.

Parameters:
  • d – The matcher that should match the driver code value against.

  • vs – Values passed to the constructor of T in case when a new instance of T is instantiated.

Returns:

A reference to this, so that multiple matches can be chained.

inline T &&operator()(Any, T &&v)

Maps the drivercode::matcher::Any matcher to a value.

Parameters:

v – A alternative value that may be used when no value of T is stored in this map.

Returns:

Either the lvalue reference to the maps stored object or the parameter v.

inline T &&operator()(Any, const T &v)

Maps the drivercode::matcher::Any matcher to a value.

Parameters:

v – A alternative value that may be used when no value of T is stored in this map.

Returns:

A lvalue reference to the maps stored object.

template<typename C>
inline EnableIf<!SameAs<T, C>::value, T&&>::Type operator()(Any, C &&callable)

Maps the drivercode::matcher::Any matcher to a generator.

Parameters:

callable – Invoked to generate a input parameter for the constructor of T in case when a new instance of T is instantiated.

Returns:

A lvalue reference to the maps stored object.

template<typename ...Vs>
inline T &&operator()(Any, Vs&&... vs)

Maps the drivercode::matcher::Any matcher to a set of parameters for the constructor of T.

Parameters:

vs – Values passed to the constructor of T in case when a new instance of T is instantiated.

Returns:

A lvalue reference to the maps stored object.

template<typename D>
inline Map &map(D d, T &&v)

Maps a matcher to a value.

Parameters:
  • d – The matcher that should match the driver code value against.

  • v – The value that should be stored should the matcher indicate a match.

Returns:

A reference to this, so that multiple matches can be chained.

template<typename D, typename C>
inline EnableIf<!SameAs<T, C>::value, Map&>::Type map(D d, C &&callable)

Maps a matcher to a generator.

Parameters:
  • d – The matcher that should match the driver code value against.

  • callable – Invoked to generate a input parameter for the constructor of T in case when a new instance of T is instantiated.

Returns:

A reference to this, so that multiple matches can be chained.

template<typename D, typename ...Vs>
inline Map &map(D d, Vs&&... vs)

Maps a matcher to a set of parameters for the constructor of T.

Parameters:
  • d – The matcher that should match the driver code value against.

  • vs – Values passed to the constructor of T in case when a new instance of T is instantiated.

Returns:

A reference to this, so that multiple matches can be chained.

inline T &&map(Any, T &&v)

Maps the drivercode::matcher::Any matcher to the driver code.

Parameters:

v – A alternative value that may be used when no value of T is stored in this map.

Returns:

Either the lvalue reference to the maps stored object or the parameter v.

inline T &&map(Any, const T &v)

Maps the drivercode::matcher::Any matcher to a value.

Parameters:

v – A alternative value that may be used when no value of T is stored in this map.

Returns:

A lvalue reference to the maps stored object.

template<typename C>
inline EnableIf<!SameAs<T, C>::value, T&&>::Type map(Any, C &&callable)

Maps the drivercode::matcher::Any matcher to a generator.

Parameters:

callable – Invoked to generate a input parameter for the constructor of T in case when a new instance of T is instantiated.

Returns:

A lvalue reference to the maps stored object.

template<typename ...Vs>
inline T &&map(matcher::Any, Vs&&... vs)

Maps the drivercode::matcher::Any matcher to a set of parameters for the constructor of T.

Parameters:

vs – Values passed to the constructor of T in case when a new instance of T is instantiated.

Returns:

A lvalue reference to the maps stored object.

template<typename R>
inline bool get(R &&receiver)

When a value was generated by any match, receiver will be invoked and the value will be moved into its input parameter.

Parameters:

receiver – A callable that will be invoked when a value was generated by any match, otherwise it will not be invoked.

Returns:

When receiver was invoked true, otherwise false.

template<typename A>
inline bool get(A &target)

When a value was generated by any match, this will move the value into target and return true. Otherwise nothing will be done to target and false will be returned.

Parameters:

target – When a value was generated by any match, the value will move the value into this parameter.

Returns:

When a value was moved to target true, otherwise false.

template<typename R>
inline bool operator>>(R &&receiver)

When a value was generated by any match, receiver will be invoked and the value will be moved into its input parameter.

Parameters:

receiver – A callable that will be invoked when a value was generated by any match, otherwise it will not be invoked.

Returns:

When receiver was invoked true, otherwise false.

template<typename A>
inline bool operator>>(A &target)

When a value was generated by any match, this will move the value into target and return true. Otherwise nothing will be done to target and false will be returned.

Parameters:

target – When a value was generated by any match, the value will move the value into this parameter.

Returns:

When a value was moved to target true, otherwise false.

template<typename R>
inline bool operator()(R &&receiver)

When a value was generated by any match, receiver will be invoked and the value will be moved into its input parameter.

Parameters:

receiver – A callable that will be invoked when a value was generated by any match, otherwise it will not be invoked.

Returns:

When receiver was invoked true, otherwise false.

template<typename A>
inline bool operator()(A &target)

When a value was generated by any match, this will move the value into target and return true. Otherwise nothing will be done to target and false will be returned.

Parameters:

target – When a value was generated by any match, the value will move the value into this parameter.

Returns:

When a value was moved to target true, otherwise false.

Protected Functions

inline Map(int v)

Create a new object with a stored driver code value.

Parameters:

v – Driver code value that is used on the matchers.

template<typename D>
inline Map(int v, D d, T &&val)
template<typename D>
inline Map(int v, D d, const T &val)
template<typename D, typename C>
inline Map(int v, D d, C &&callable)
template<typename D, typename ...Vs>
inline Map(int v, D d, Vs&&... vs)

Private Functions

inline T &object()

Helper to retrieve the stored instance of T.

Returns:

Reference to the store instance of T.

inline void cMove(bool should_construct, T &&v)

Conditional move constructor helper.

A new instance of T is going to be instantiated when should_construct is true and the internal state indicates that there is no instance stored yet. In this case v will be moved into the parameter of the move constructor of T for the new instance.

Parameters:
  • should_construct – Indicates if a instance of T should be instantiated or not.

  • v – May be used as a input for the move constructor of T.

template<typename C>
inline void cContruct(bool should_construct, C &&generator)

Conditional constructor helper.

A new instance of T is going to be instantiated when should_construct is true and the internal state indicates that there is no instance stored yet. In this case generator will be invoked to generate the input of the constructor of T for the new instance.

Parameters:
  • should_construct – Indicates if a instance of T should be instantiated or not.

  • generator – When invoked it should generate valid input for the constructor of T.

template<typename ...Vs>
inline void cEmplace(bool should_construct, Vs&&... vs)

Conditional emplace constructor helper.

A new instance of T is going to be instantiated when should_construct is true and the internal state indicates that there is no instance stored yet. In this case vs will be moved into the parameter of the constructor of T for the new instance.

Parameters:
  • should_construct – Indicates if a instance of T should be instantiated or not.

  • vs – May be used as a input for the constructor of T.

template<typename D>
inline constexpr bool is(D d) const

Helper to shorten matcher invocation.

Parameters:

d – Matcher to invoke with the driver code state value.

Returns:

The value returned by the matchers d is method.

Private Members

int value

Driver code value, stored as a int to break up dependency to the DriverCode type.

bool wasMatched = false

Keeps track if anything was matched.

unsigned char memory[sizeof(T)]

Raw bytes to store T.

Friends

friend class ::DriverCode
struct OpAnd
#include <dag_driverCode.h>

A binary operator that implements the logical and operator to combine the result of two matchers.

Public Static Functions

static inline constexpr bool invoke(bool a, bool b)

Combines two matcher results with a logical and.

Parameters:
  • a – Result of the first matcher.

  • b – Result of the second matcher.

Returns:

The logical and of both and .

struct OpOr
#include <dag_driverCode.h>

A binary operator that implements the logical or operator to combine the result of two matchers.

Public Static Functions

static inline constexpr bool invoke(bool a, bool b)

Combines two matcher results with a logical or.

Parameters:
  • a – Result of the first matcher.

  • b – Result of the second matcher.

Returns:

The logical or of both and .

template<typename A, typename B>
struct SameAs
#include <dag_driverCode.h>

Public Static Attributes

static constexpr bool value = false
template<typename T>
struct SameAs<T, T>
#include <dag_driverCode.h>

Public Static Attributes

static constexpr bool value = true
struct Undefined : public NotAnyDriver
#include <dag_driverCode.h>

The undefined matcher is special, compared to other composed matchers.

This matcher matches against all known drivers, and when none of those matchers evaluate to true, it will return true, otherwise to false. The difference to a normal inverted matcher of all known drivers, is that it has a value that can be used for initialization of the driver code state value.

Public Static Attributes

static constexpr int value = ~0L

Value of undefined driver state, matchers that are not constant matchers have to match false to this value.

struct Unsupported
#include <dag_driverCode.h>

This matcher type is just to result in compilation errors on not yet supported platforms and help doxygen.

So when the compiler is yelling at you about this type, then you may want to add a new set of matchers for that _TARGET_* you want to build. Use a existing target as a template and alter they types of the matchers to model the behavior of that target.

Public Functions

Unsupported() = delete

No one should be able to instance this type, it is supposed to fail the build.