foobar2000 SDK  2015-08-03
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
pfc::array_staticsize_t< _t_item >

#include <array.h>

Public Types

typedef _t_item t_item
 

Public Member Functions

 array_staticsize_t ()
 
 array_staticsize_t (t_size p_size)
 
 array_staticsize_t (const t_self &p_source)
 
 ~array_staticsize_t ()
 
template<typename t_out >
void enumerate (t_out &out) const
 
const t_itemget_ptr () const
 
t_itemget_ptr ()
 
t_size get_size () const
 
template<typename t_source >
bool is_owned (const t_source &p_item)
 
const t_selfoperator= (const t_self &p_source)
 
const t_itemoperator[] (t_size p_index) const
 
t_itemoperator[] (t_size p_index)
 
template<typename t_source >
void set_data_fromptr (const t_source *p_buffer, t_size p_count)
 
void set_size_discard (t_size p_size)
 

Private Types

typedef array_staticsize_t< t_itemt_self
 

Private Member Functions

void release_ ()
 

Private Attributes

t_itemm_array
 
t_size m_size
 

Detailed Description

template<typename _t_item>
class pfc::array_staticsize_t< _t_item >

Special simplififed version of array class that avoids stepping on landmines with classes without public copy operators/constructors.

Definition at line 11 of file array.h.

Member Typedef Documentation

template<typename _t_item>
typedef _t_item pfc::array_staticsize_t< _t_item >::t_item

Definition at line 12 of file array.h.

template<typename _t_item>
typedef array_staticsize_t<t_item> pfc::array_staticsize_t< _t_item >::t_self
private

Definition at line 13 of file array.h.

Constructor & Destructor Documentation

template<typename _t_item>
pfc::array_staticsize_t< _t_item >::array_staticsize_t ( )
inline

Definition at line 15 of file array.h.

15 : m_array(NULL), m_size(0) {}
t_item * m_array
Definition: array.h:66
template<typename _t_item>
pfc::array_staticsize_t< _t_item >::array_staticsize_t ( t_size  p_size)
inline

Definition at line 16 of file array.h.

16 : m_array(new t_item[p_size]), m_size(p_size) {}
t_item * m_array
Definition: array.h:66
template<typename _t_item>
pfc::array_staticsize_t< _t_item >::~array_staticsize_t ( )
inline

Definition at line 17 of file array.h.

17 {release_();}
template<typename _t_item>
pfc::array_staticsize_t< _t_item >::array_staticsize_t ( const t_self p_source)
inline

Copy constructor nonfunctional when data type is not copyable.

Definition at line 20 of file array.h.

20  : m_size(0), m_array(NULL) {
21  *this = p_source;
22  }
t_item * m_array
Definition: array.h:66

Member Function Documentation

template<typename _t_item>
template<typename t_out >
void pfc::array_staticsize_t< _t_item >::enumerate ( t_out &  out) const
inline

Definition at line 60 of file array.h.

60 { for(t_size walk = 0; walk < m_size; ++walk) out(m_array[walk]); }
t_item * m_array
Definition: array.h:66
size_t t_size
Definition: int_types.h:48
template<typename _t_item>
const t_item* pfc::array_staticsize_t< _t_item >::get_ptr ( ) const
inline

Definition at line 52 of file array.h.

52 {return m_array;}
t_item * m_array
Definition: array.h:66
template<typename _t_item>
t_item* pfc::array_staticsize_t< _t_item >::get_ptr ( )
inline

Definition at line 53 of file array.h.

53 {return m_array;}
t_item * m_array
Definition: array.h:66
template<typename _t_item>
t_size pfc::array_staticsize_t< _t_item >::get_size ( ) const
inline

Definition at line 51 of file array.h.

51 {return m_size;}
template<typename _t_item>
template<typename t_source >
bool pfc::array_staticsize_t< _t_item >::is_owned ( const t_source &  p_item)
inline

Definition at line 58 of file array.h.

58 {return pfc::is_pointer_in_range(get_ptr(),get_size(),&p_item);}
const t_item * get_ptr() const
Definition: array.h:52
t_size get_size() const
Definition: array.h:51
bool is_pointer_in_range(const t_item *p_buffer, t_size p_buffer_size, const void *p_pointer)
Definition: alloc.h:84
template<typename _t_item>
const t_self& pfc::array_staticsize_t< _t_item >::operator= ( const t_self p_source)
inline

Copy operator nonfunctional when data type is not copyable.

Definition at line 25 of file array.h.

25  {
26  release_();
27 
28  //m_array = pfc::malloc_copy_t(p_source.get_size(),p_source.get_ptr());
29  const t_size newsize = p_source.get_size();
30  m_array = new t_item[newsize];
31  m_size = newsize;
32  for(t_size n = 0; n < newsize; n++) m_array[n] = p_source[n];
33  return *this;
34  }
t_item * m_array
Definition: array.h:66
size_t t_size
Definition: int_types.h:48
template<typename _t_item>
const t_item& pfc::array_staticsize_t< _t_item >::operator[] ( t_size  p_index) const
inline

Definition at line 55 of file array.h.

55 {PFC_ASSERT(p_index < get_size());return m_array[p_index];}
t_item * m_array
Definition: array.h:66
t_size get_size() const
Definition: array.h:51
template<typename _t_item>
t_item& pfc::array_staticsize_t< _t_item >::operator[] ( t_size  p_index)
inline

Definition at line 56 of file array.h.

56 {PFC_ASSERT(p_index < get_size());return m_array[p_index];}
t_item * m_array
Definition: array.h:66
t_size get_size() const
Definition: array.h:51
template<typename _t_item>
void pfc::array_staticsize_t< _t_item >::release_ ( )
inlineprivate

Definition at line 62 of file array.h.

62  {
63  m_size = 0;
64  delete[] pfc::replace_null_t(m_array);
65  }
t_type replace_null_t(t_type &p_var)
Definition: primitives.h:688
t_item * m_array
Definition: array.h:66
template<typename _t_item>
template<typename t_source >
void pfc::array_staticsize_t< _t_item >::set_data_fromptr ( const t_source *  p_buffer,
t_size  p_count 
)
inline

Warning: buffer pointer must not point to buffer allocated by this array (fixme).

Definition at line 45 of file array.h.

45  {
46  set_size_discard(p_count);
47  pfc::copy_array_loop_t(*this,p_buffer,p_count);
48  }
void copy_array_loop_t(t_dst &p_dst, const t_src &p_src, t_size p_count)
Definition: primitives.h:616
void set_size_discard(t_size p_size)
Definition: array.h:36
template<typename _t_item>
void pfc::array_staticsize_t< _t_item >::set_size_discard ( t_size  p_size)
inline

Definition at line 36 of file array.h.

36  {
37  release_();
38  if (p_size > 0) {
39  m_array = new t_item[p_size];
40  m_size = p_size;
41  }
42  }
t_item * m_array
Definition: array.h:66

Field Documentation

template<typename _t_item>
t_item* pfc::array_staticsize_t< _t_item >::m_array
private

Definition at line 66 of file array.h.

template<typename _t_item>
t_size pfc::array_staticsize_t< _t_item >::m_size
private

Definition at line 67 of file array.h.


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