comparison foosdk/sdk/pfc/string_list.h @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #pragma once
2
3 #include "list.h"
4
5 namespace pfc {
6
7 typedef list_base_const_t<const char*> string_list_const;
8
9 class string_list_impl : public string_list_const
10 {
11 public:
12 t_size get_count() const {return m_data.get_size();}
13 void get_item_ex(const char* & p_out, t_size n) const {p_out = m_data[n];}
14
15 const char * operator[] (t_size n) const {return m_data[n];}
16 void add_item(const char * p_string) {pfc::append_t(m_data, p_string);}
17
18 template<typename t_what> void add_items(const t_what & p_source) {_append(p_source);}
19
20 void remove_all() {m_data.set_size(0);}
21
22 string_list_impl() {}
23 template<typename t_what> string_list_impl(const t_what & p_source) {_copy(p_source);}
24 template<typename t_what> string_list_impl & operator=(const t_what & p_source) {_copy(p_source); return *this;}
25 template<typename t_what> string_list_impl & operator|=(const string_list_impl & p_source) {_append(p_source); return *this;}
26 template<typename t_what> string_list_impl & operator+=(const t_what & p_source) {pfc::append_t(m_data, p_source); return *this;}
27
28 void set_item(size_t idx, const char* str) { m_data[idx] = str; }
29
30 void remove_mask(bit_array const& mask) { pfc::remove_mask_t(m_data, mask); }
31 private:
32 template<typename t_what> void _append(const t_what & p_source) {
33 const t_size toadd = p_source.get_size(), base = m_data.get_size();
34 m_data.set_size(base+toadd);
35 for(t_size n=0;n<toadd;n++) m_data[base+n] = p_source[n];
36 }
37
38 template<typename t_what> void _copy(const t_what & p_source) {
39 const t_size newcount = p_source.get_size();
40 m_data.set_size(newcount);
41 for(t_size n=0;n<newcount;n++) m_data[n] = p_source[n];
42 }
43
44 pfc::array_t<pfc::string8,pfc::alloc_fast> m_data;
45 };
46 }