Monado OpenXR Runtime
u_vector.cpp File Reference

Expose std::vector to C. More...

#include "u_vector.h"
#include <vector>
Include dependency graph for u_vector.cpp:

Macros

#define U_VECTOR_IMPLEMENTATION(TYPE)
 

Functions

u_vector_int u_vector_int_create ()
 
void u_vector_int_push_back (u_vector_int uv, int e)
 
int u_vector_int_at (u_vector_int uv, size_t i)
 
void u_vector_int_destroy (u_vector_int *uv)
 
u_vector_float u_vector_float_create ()
 
void u_vector_float_push_back (u_vector_float uv, float e)
 
float u_vector_float_at (u_vector_float uv, size_t i)
 
void u_vector_float_destroy (u_vector_float *uv)
 

Detailed Description

Expose std::vector to C.

Author
Mateo de Mayo mateo.nosp@m..dem.nosp@m.ayo@c.nosp@m.olla.nosp@m.bora..nosp@m.com

Macro Definition Documentation

◆ U_VECTOR_IMPLEMENTATION

#define U_VECTOR_IMPLEMENTATION (   TYPE)
Value:
u_vector_##TYPE u_vector_##TYPE##_create() \
{ \
u_vector_##TYPE uv{new vector<TYPE>}; \
return uv; \
} \
\
void u_vector_##TYPE##_push_back(u_vector_##TYPE uv, TYPE e) \
{ \
vector<TYPE> *v = static_cast<vector<TYPE> *>(uv.ptr); \
v->push_back(e); \
} \
\
TYPE u_vector_##TYPE##_at(u_vector_##TYPE uv, size_t i) \
{ \
vector<TYPE> *v = static_cast<vector<TYPE> *>(uv.ptr); \
return v->at(i); \
} \
\
void u_vector_##TYPE##_destroy(u_vector_##TYPE *uv) \
{ \
vector<TYPE> *v = static_cast<vector<TYPE> *>(uv->ptr); \
delete v; \
uv->ptr = nullptr; \
}