hdk-grid 0.0.1
Header-only foundational library for the Hollow Development Kit.
Loading...
Searching...
No Matches
hdk::grid::PrimitiveWrapper< T > Class Template Reference

Lightweight wrapper for primitive C types. More...

#include <PrimitiveWrapper.hpp>

Public Member Functions

 PrimitiveWrapper ()=delete
 PrimitiveWrapper (T value)
 Construct with a primitive value.
 operator T () const
 Implicit conversion to the wrapped primitive type.
PrimitiveWrapperoperator= (T newValue)
 Assign a new primitive value.

Detailed Description

template<typename T>
class hdk::grid::PrimitiveWrapper< T >

Lightweight wrapper for primitive C types.

Template Parameters
TThe primitive type being wrapped (e.g., SDL_PixelFormat, SDL_DisplayID, SDL_PropertiesID)

PrimitiveWrapper provides a simple, zero-overhead wrapper for primitive types. Unlike SharedPtrWrapper, PrimitiveWrapper is designed for types that don't need lifetime management—they're either simple IDs or owned by SDL or other external systems.

PrimitiveWrapper provides:

  • Type safety: Prevents accidental mixing of different ID types
  • Consistency: Uniform interface with SharedPtrWrapper
  • Zero overhead: Compiles down to the primitive type itself
  • Implicit conversion: Can be used anywhere the primitive type is expected

Common uses:

  • Wrapping ID types (SDL_WindowID, SDL_DisplayID, SDL_TextureID)
  • Wrapping enumerated types (SDL_PixelFormat, SDL_BlendMode)
  • Wrapping other primitive types (SDL_PropertiesID)
See also
SharedPtrWrapper

Definition at line 7 of file PrimitiveWrapper.hpp.

Constructor & Destructor Documentation

◆ PrimitiveWrapper() [1/2]

template<typename T>
hdk::grid::PrimitiveWrapper< T >::PrimitiveWrapper ( )
delete

Referenced by operator=().

◆ PrimitiveWrapper() [2/2]

template<typename T>
hdk::grid::PrimitiveWrapper< T >::PrimitiveWrapper ( T value)
inline

Construct with a primitive value.

Parameters
valueThe primitive value to wrap

Example:

hdk::sdl::PixelFormat format(SDL_PIXELFORMAT_RGBA8888);

Definition at line 12 of file PrimitiveWrapper.hpp.

Member Function Documentation

◆ operator T()

template<typename T>
hdk::grid::PrimitiveWrapper< T >::operator T ( ) const
inline

Implicit conversion to the wrapped primitive type.

Allows the wrapper to be used anywhere the primitive type is expected, providing seamless compatibility with C APIs.

Returns
T The wrapped primitive value

Example:

hdk::sdl::PixelFormat format = ...;
const char* name = SDL_GetPixelFormatName(format); // implicit conversion to SDL_PixelFormat

Definition at line 13 of file PrimitiveWrapper.hpp.

◆ operator=()

template<typename T>
PrimitiveWrapper & hdk::grid::PrimitiveWrapper< T >::operator= ( T newValue)
inline

Assign a new primitive value.

Parameters
newValueThe new value to assign
Returns
Reference to this wrapper

Definition at line 14 of file PrimitiveWrapper.hpp.

References PrimitiveWrapper().


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