foobar2000 SDK  2015-01-14
Public Member Functions | Private Types | Private Member Functions | Private Attributes
pfc::__array_fast_helper_t< t_item >

#include <alloc.h>

Public Member Functions

 __array_fast_helper_t ()
 
 ~__array_fast_helper_t ()
 
t_item * get_ptr ()
 
const t_item * get_ptr () const
 
t_size get_size () const
 
t_size get_size_total () const
 
bool is_ptr_owned (const void *p_item) const
 
void move_from (t_self &other)
 
const t_item & operator[] (t_size p_index) const
 
t_item & operator[] (t_size p_index)
 
void set_size (t_size p_size, t_size p_size_total)
 

Private Types

typedef __array_fast_helper_t< t_item > t_self
 

Private Member Functions

 __array_fast_helper_t (const t_self &)
 
const t_selfoperator= (const t_self &)
 
void resize_content (t_size p_size)
 
void resize_storage (t_size p_size)
 

Private Attributes

t_item * m_buffer
 
t_size m_size
 
t_size m_size_total
 

Detailed Description

template<typename t_item>
class pfc::__array_fast_helper_t< t_item >

Definition at line 137 of file alloc.h.

Member Typedef Documentation

template<typename t_item>
typedef __array_fast_helper_t<t_item> pfc::__array_fast_helper_t< t_item >::t_self
private

Definition at line 139 of file alloc.h.

Constructor & Destructor Documentation

template<typename t_item>
pfc::__array_fast_helper_t< t_item >::__array_fast_helper_t ( )
inline

Definition at line 141 of file alloc.h.

141 : m_buffer(NULL), m_size_total(0), m_size(0) {}
template<typename t_item>
pfc::__array_fast_helper_t< t_item >::~__array_fast_helper_t ( )
inline

Definition at line 162 of file alloc.h.

162  {
163  set_size(0,0);
164  }
void set_size(t_size p_size, t_size p_size_total)
Definition: alloc.h:144
template<typename t_item>
pfc::__array_fast_helper_t< t_item >::__array_fast_helper_t ( const t_self )
inlineprivate

Definition at line 177 of file alloc.h.

177 {throw pfc::exception_not_implemented();}

Member Function Documentation

template<typename t_item>
t_item* pfc::__array_fast_helper_t< t_item >::get_ptr ( )
inline

Definition at line 165 of file alloc.h.

165 {return m_buffer;}
template<typename t_item>
const t_item* pfc::__array_fast_helper_t< t_item >::get_ptr ( ) const
inline

Definition at line 166 of file alloc.h.

166 {return m_buffer;}
template<typename t_item>
t_size pfc::__array_fast_helper_t< t_item >::get_size ( ) const
inline

Definition at line 158 of file alloc.h.

158 {return m_size;}
template<typename t_item>
t_size pfc::__array_fast_helper_t< t_item >::get_size_total ( ) const
inline

Definition at line 159 of file alloc.h.

159 {return m_size_total;}
template<typename t_item>
bool pfc::__array_fast_helper_t< t_item >::is_ptr_owned ( const void *  p_item) const
inline

Definition at line 167 of file alloc.h.

167 {return is_pointer_in_range(m_buffer,m_size_total,p_item);}
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>
void pfc::__array_fast_helper_t< t_item >::move_from ( t_self other)
inline

Definition at line 169 of file alloc.h.

169  {
170  set_size(0,0);
171  m_buffer = replace_null_t(other.m_buffer);
172  m_size = replace_null_t(other.m_size);
173  m_size_total = replace_null_t(other.m_size_total);
174  }
void set_size(t_size p_size, t_size p_size_total)
Definition: alloc.h:144
t_type replace_null_t(t_type &p_var)
Definition: primitives.h:688
template<typename t_item>
const t_self& pfc::__array_fast_helper_t< t_item >::operator= ( const t_self )
inlineprivate

Definition at line 176 of file alloc.h.

176 {throw pfc::exception_not_implemented();}
template<typename t_item>
const t_item& pfc::__array_fast_helper_t< t_item >::operator[] ( t_size  p_index) const
inline

Definition at line 160 of file alloc.h.

160 {PFC_ASSERT(p_index < m_size); return m_buffer[p_index];}
template<typename t_item>
t_item& pfc::__array_fast_helper_t< t_item >::operator[] ( t_size  p_index)
inline

Definition at line 161 of file alloc.h.

161 {PFC_ASSERT(p_index < m_size); return m_buffer[p_index];}
template<typename t_item>
void pfc::__array_fast_helper_t< t_item >::resize_content ( t_size  p_size)
inlineprivate

Definition at line 180 of file alloc.h.

180  {
182  if (p_size > m_size) {//expand
183  do {
185  m_size++;
186  } while(m_size < p_size);
187  } else if (p_size < m_size) {
189  m_size = p_size;
190  }
191  } else {
192  m_size = p_size;
193  }
194  }
void __unsafe__in_place_destructor_array_t(t_type *p_items, t_size p_count)
Definition: primitives.h:123
void __unsafe__in_place_constructor_t(t_type &p_item)
Definition: primitives.h:115
template<typename t_item>
void pfc::__array_fast_helper_t< t_item >::resize_storage ( t_size  p_size)
inlineprivate

Definition at line 196 of file alloc.h.

196  {
197  PFC_ASSERT( m_size <= m_size_total );
198  PFC_ASSERT( m_size <= p_size );
199  if (m_size_total != p_size) {
202  m_size_total = p_size;
203  } else if (__raw_realloc_inplace_t(m_buffer,p_size)) {
204  //success
205  m_size_total = p_size;
206  } else {
207  t_item * newbuffer = pfc::__raw_malloc_t<t_item>(p_size);
208  try {
210  } catch(...) {
211  pfc::__raw_free_t(newbuffer);
212  throw;
213  }
216  m_buffer = newbuffer;
217  m_size_total = p_size;
218  }
219  }
220  }
void __unsafe__in_place_destructor_array_t(t_type *p_items, t_size p_count)
Definition: primitives.h:123
t_type * __unsafe__in_place_constructor_array_copy_t(t_type *p_items, t_size p_count, const t_copy *p_copyfrom)
Definition: primitives.h:159
void __raw_free_t(T *p_block)
Definition: alloc.h:36
bool __raw_realloc_inplace_t(T *p_block, t_size p_size)
Definition: alloc.h:46
T * __raw_realloc_t(T *p_block, t_size p_size)
Definition: alloc.h:41
template<typename t_item>
void pfc::__array_fast_helper_t< t_item >::set_size ( t_size  p_size,
t_size  p_size_total 
)
inline

Definition at line 144 of file alloc.h.

144  {
145  PFC_ASSERT(p_size <= p_size_total);
146  PFC_ASSERT(m_size <= m_size_total);
147  if (p_size_total > m_size_total) {
148  resize_storage(p_size_total);
149  resize_content(p_size);
150  } else {
151  resize_content(p_size);
152  resize_storage(p_size_total);
153  }
154  }
void resize_content(t_size p_size)
Definition: alloc.h:180
void resize_storage(t_size p_size)
Definition: alloc.h:196

Field Documentation

template<typename t_item>
t_item* pfc::__array_fast_helper_t< t_item >::m_buffer
private

Definition at line 222 of file alloc.h.

template<typename t_item>
t_size pfc::__array_fast_helper_t< t_item >::m_size
private

Definition at line 223 of file alloc.h.

template<typename t_item>
t_size pfc::__array_fast_helper_t< t_item >::m_size_total
private

Definition at line 223 of file alloc.h.


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