FastUIDraw
Public Types | Public Member Functions | Friends | List of all members
fastuidraw::c_array< T > Class Template Reference

A c_array is a wrapper over a C pointer with a size parameter to facilitate bounds checking and provide an STL-like iterator interface. More...

#include <c_array.hpp>

Public Types

typedef const_pointer const_iterator
 iterator typedef to const_pointer
 
typedef T * const_pointer
 STL compliant typedef; notice that const_pointer is type T* and not const T*. This is because a c_array is just a HOLDER of a pointer and a length and thus the contents of the value behind the pointer are not part of the value of a c_array.
 
typedef T & const_reference
 STL compliant typedef; notice that const_pointer is type T& and not const T&. This is because a c_array is just a HOLDER of a pointer and a length and thus the contents of the value behind the pointer are not part of the value of a c_array.
 
typedef ptrdiff_t difference_type
 STL compliant typedef.
 
typedef pointer iterator
 iterator typedef to pointer
 
typedef T * pointer
 STL compliant typedef.
 
typedef T & reference
 STL compliant typedef.
 
typedef size_t size_type
 STL compliant typedef.
 
typedef T value_type
 STL compliant typedef.
 

Public Member Functions

 c_array (void)
 
template<typename U >
 c_array (U *pptr, size_type sz)
 
template<typename U , size_type N>
 c_array (vecN< U, N > &pptr)
 
template<typename U , size_type N>
 c_array (const vecN< U, N > &pptr)
 
template<typename U >
 c_array (const c_array< U > &obj)
 
 c_array (range_type< iterator > R)
 
reference back (size_type I) const
 
reference back (void) const
 
iterator begin (void) const
 
T * c_ptr (void) const
 
template<typename S >
c_array< S > const_cast_pointer (void) const
 
bool empty (void) const
 
iterator end (void) const
 
T * end_c_ptr (void) const
 
c_array< typename unvecN< T >::type > flatten_array (void) const
 
reference front (void) const
 
reference operator[] (size_type j) const
 
void pop_back (void)
 
void pop_front (void)
 
range_type< iteratorrange (void) const
 
template<typename S >
c_array< S > reinterpret_pointer (void) const
 
void reset (void)
 
template<typename U >
bool same_data (const c_array< U > &rhs) const
 
size_type size (void) const
 
c_array sub_array (size_type pos, size_type length) const
 
c_array sub_array (size_type pos) const
 
template<typename I >
c_array sub_array (range_type< I > R) const
 

Friends

template<typename >
class c_array
 

Detailed Description

template<typename T>
class fastuidraw::c_array< T >

A c_array is a wrapper over a C pointer with a size parameter to facilitate bounds checking and provide an STL-like iterator interface.

Definition at line 43 of file c_array.hpp.

Constructor & Destructor Documentation

◆ c_array() [1/6]

template<typename T>
fastuidraw::c_array< T >::c_array ( void  )
inline

Default ctor, initializing the pointer as nullptr with size 0.

Definition at line 115 of file c_array.hpp.

◆ c_array() [2/6]

template<typename T>
template<typename U >
fastuidraw::c_array< T >::c_array ( U *  pptr,
size_type  sz 
)
inline

Ctor initializing the pointer and size

Parameters
pptrpointer value
szsize, must be no more than the number of elements that pptr points to.

Definition at line 126 of file c_array.hpp.

◆ c_array() [3/6]

template<typename T>
template<typename U , size_type N>
fastuidraw::c_array< T >::c_array ( vecN< U, N > &  pptr)
inline

Ctor from a vecN, size is the size of the fixed size array

Parameters
pptrfixed size array that c_array references, must be in scope as until c_array is changed

Definition at line 139 of file c_array.hpp.

◆ c_array() [4/6]

template<typename T>
template<typename U , size_type N>
fastuidraw::c_array< T >::c_array ( const vecN< U, N > &  pptr)
inline

Ctor from a vecN, size is the size of the fixed size array

Parameters
pptrfixed size array that c_array references, must be in scope as until c_array is changed

Definition at line 152 of file c_array.hpp.

◆ c_array() [5/6]

template<typename T>
template<typename U >
fastuidraw::c_array< T >::c_array ( const c_array< U > &  obj)
inline

Ctor from another c_array object.

Template Parameters
Utype U* must be convertible to type T* AND the size of U must be the same as the size of T
Parameters
objvalue from which to copy

Definition at line 167 of file c_array.hpp.

◆ c_array() [6/6]

template<typename T>
fastuidraw::c_array< T >::c_array ( range_type< iterator R)
inline

Ctor from a range of pointers.

Parameters
RR.m_begin will be the pointer and R.m_end - R.m_begin the size.

Definition at line 178 of file c_array.hpp.

Member Function Documentation

◆ back() [1/2]

template<typename T>
reference fastuidraw::c_array< T >::back ( size_type  I) const
inline

Equivalent to

Parameters
Iindex from the back to retrieve, I=0 corrseponds to the back of the array.

Definition at line 325 of file c_array.hpp.

◆ back() [2/2]

template<typename T>
reference fastuidraw::c_array< T >::back ( void  ) const
inline

STL compliant function.

Definition at line 335 of file c_array.hpp.

◆ begin()

template<typename T>
iterator fastuidraw::c_array< T >::begin ( void  ) const
inline

STL compliant function.

Definition at line 292 of file c_array.hpp.

◆ c_ptr()

template<typename T>
T* fastuidraw::c_array< T >::c_ptr ( void  ) const
inline

Pointer of the c_array.

Definition at line 242 of file c_array.hpp.

◆ const_cast_pointer()

template<typename T>
template<typename S >
c_array<S> fastuidraw::c_array< T >::const_cast_pointer ( void  ) const
inline

Const style cast for c_array. It is required that the sizeof(T) is the same as sizeof(S).

Template Parameters
Stype to which to be const casted

Definition at line 218 of file c_array.hpp.

◆ empty()

template<typename T>
bool fastuidraw::c_array< T >::empty ( void  ) const
inline

STL compliant function.

Definition at line 274 of file c_array.hpp.

◆ end()

template<typename T>
iterator fastuidraw::c_array< T >::end ( void  ) const
inline

STL compliant function.

Definition at line 301 of file c_array.hpp.

◆ end_c_ptr()

template<typename T>
T* fastuidraw::c_array< T >::end_c_ptr ( void  ) const
inline

Pointer to the element one past the last element of the c_array.

Definition at line 252 of file c_array.hpp.

◆ flatten_array()

template<typename T>
c_array<typename unvecN<T>::type> fastuidraw::c_array< T >::flatten_array ( void  ) const
inline

For when T is vecN<S, N> for a type S, flattens the c_array<T> into a c_array<S> refering to the same data.

Definition at line 231 of file c_array.hpp.

◆ front()

template<typename T>
reference fastuidraw::c_array< T >::front ( void  ) const
inline

STL compliant function.

Definition at line 344 of file c_array.hpp.

◆ operator[]()

template<typename T>
reference fastuidraw::c_array< T >::operator[] ( size_type  j) const
inline

Access named element of c_array, under debug build also performs bounds checking.

Parameters
jindex

Definition at line 263 of file c_array.hpp.

◆ pop_back()

template<typename T>
void fastuidraw::c_array< T >::pop_back ( void  )
inline

Provided as a conveniance, equivalent to

*this = this->sub_array(0, size() - 1);

It is an error to call this when size() is 0.

Definition at line 406 of file c_array.hpp.

◆ pop_front()

template<typename T>
void fastuidraw::c_array< T >::pop_front ( void  )
inline

Provided as a conveniance, equivalent to

*this = this->sub_array(1, size() - 1);

It is an error to call this when size() is 0.

Definition at line 420 of file c_array.hpp.

◆ range()

template<typename T>
range_type<iterator> fastuidraw::c_array< T >::range ( void  ) const
inline

Returns the range of the c_array as an iterator range.

Definition at line 311 of file c_array.hpp.

◆ reinterpret_pointer()

template<typename T>
template<typename S >
c_array<S> fastuidraw::c_array< T >::reinterpret_pointer ( void  ) const
inline

Reinterpret style cast for c_array. It is required that the sizeof(T)*size() evenly divides sizeof(S).

Template Parameters
Stype to which to be reinterpreted casted

Definition at line 202 of file c_array.hpp.

◆ reset()

template<typename T>
void fastuidraw::c_array< T >::reset ( void  )
inline

Resets the c_array object to be equivalent to a nullptr, i.e. c_ptr() will return nullptr and size() will return 0.

Definition at line 189 of file c_array.hpp.

◆ same_data()

template<typename T>
template<typename U >
bool fastuidraw::c_array< T >::same_data ( const c_array< U > &  rhs) const
inline

Returns true if and only if the passed the c_array references exactly the same data as this c_array.

Parameters
rhsc_array to which to compare

Definition at line 435 of file c_array.hpp.

◆ size()

template<typename T>
size_type fastuidraw::c_array< T >::size ( void  ) const
inline

STL compliant function.

Definition at line 283 of file c_array.hpp.

◆ sub_array() [1/3]

template<typename T>
c_array fastuidraw::c_array< T >::sub_array ( size_type  pos,
size_type  length 
) const
inline

Returns a sub-array

Parameters
posposition of returned sub-array to start, i.e. returned c_array's c_ptr() will return this->c_ptr()+pos. It is an error if pos is negative.
lengthlength of sub array to return, note that it is an error if length+pos>size() or if length is negative.

Definition at line 360 of file c_array.hpp.

◆ sub_array() [2/3]

template<typename T>
c_array fastuidraw::c_array< T >::sub_array ( size_type  pos) const
inline

Returns a sub-array, equivalent to

sub_array(pos, size() - pos)
Parameters
posposition of returned sub-array to start, i.e. returned c_array's c_ptr() will return this->c_ptr() + pos. It is an error is pos is negative.

Definition at line 377 of file c_array.hpp.

◆ sub_array() [3/3]

template<typename T>
template<typename I >
c_array fastuidraw::c_array< T >::sub_array ( range_type< I >  R) const
inline

Returns a sub-array, equivalent to

sub_array(R.m_begin, R.m_end - R.m_begin)
Template Parameters
Itype convertible to size_type
Parameters
Rrange of returned sub-array

Definition at line 393 of file c_array.hpp.


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