foobar2000 SDK  2015-08-03
string_list.h
Go to the documentation of this file.
1 #ifndef _PFC_STRING_LIST_H_
2 #define _PFC_STRING_LIST_H_
3 
4 namespace pfc {
5 
7 
8  class string_list_impl : public string_list_const
9  {
10  public:
11  t_size get_count() const {return m_data.get_size();}
12  void get_item_ex(const char* & p_out, t_size n) const {p_out = m_data[n];}
13 
14  const char * operator[] (t_size n) const {return m_data[n];}
15  void add_item(const char * p_string) {pfc::append_t(m_data, p_string);}
16 
17  template<typename t_what> void add_items(const t_what & p_source) {_append(p_source);}
18 
19  void remove_all() {m_data.set_size(0);}
20 
22  template<typename t_what> string_list_impl(const t_what & p_source) {_copy(p_source);}
23  template<typename t_what> string_list_impl & operator=(const t_what & p_source) {_copy(p_source); return *this;}
24  template<typename t_what> string_list_impl & operator|=(const string_list_impl & p_source) {_append(p_source); return *this;}
25  template<typename t_what> string_list_impl & operator+=(const t_what & p_source) {pfc::append_t(m_data, p_source); return *this;}
26 
27  private:
28  template<typename t_what> void _append(const t_what & p_source) {
29  const t_size toadd = p_source.get_size(), base = m_data.get_size();
30  m_data.set_size(base+toadd);
31  for(t_size n=0;n<toadd;n++) m_data[base+n] = p_source[n];
32  }
33 
34  template<typename t_what> void _copy(const t_what & p_source) {
35  const t_size newcount = p_source.get_size();
36  m_data.set_size(newcount);
37  for(t_size n=0;n<newcount;n++) m_data[n] = p_source[n];
38  }
39 
41  };
42 }
43 
44 #endif //_PFC_STRING_LIST_H_
pfc::array_t< pfc::string8, pfc::alloc_fast > m_data
Definition: string_list.h:40
void add_items(const t_what &p_source)
Definition: string_list.h:17
void add_item(const char *p_string)
Definition: string_list.h:15
t_size append_t(t_array &p_array, const T &p_item)
Definition: primitives.h:473
list_base_const_t< const char * > string_list_const
Definition: string_list.h:6
void get_item_ex(const char *&p_out, t_size n) const
Definition: string_list.h:12
size_t t_size
Definition: int_types.h:48
t_size get_count() const
Definition: string_list.h:11
void _copy(const t_what &p_source)
Definition: string_list.h:34
const char * operator[](t_size n) const
Definition: string_list.h:14
string_list_impl & operator+=(const t_what &p_source)
Definition: string_list.h:25
string_list_impl & operator|=(const string_list_impl &p_source)
Definition: string_list.h:24
string_list_impl(const t_what &p_source)
Definition: string_list.h:22
string_list_impl & operator=(const t_what &p_source)
Definition: string_list.h:23
void _append(const t_what &p_source)
Definition: string_list.h:28