SHOGUN  v3.2.0
SGStringList.cpp
Go to the documentation of this file.
2 #include <shogun/lib/SGString.h>
3 #include <shogun/io/File.h>
4 
5 namespace shogun
6 {
7 
8 template <class T>
10 {
11  init_data();
12 }
13 
14 template <class T>
16  bool ref_counting) :
17  SGReferencedData(ref_counting), num_strings(num_s),
18  max_string_length(max_length), strings(s)
19 {
20 }
21 
22 template <class T>
23 SGStringList<T>::SGStringList(index_t num_s, index_t max_length, bool ref_counting) :
24  SGReferencedData(ref_counting),
25  num_strings(num_s), max_string_length(max_length)
26 {
27  strings=SG_MALLOC(SGString<T>, num_strings);
28 }
29 
30 template <class T>
32  SGReferencedData(orig)
33 {
34  copy_data(orig);
35 }
36 
37 template <class T>
39 {
40  unref();
41 }
42 
43 template<class T> void SGStringList<T>::load(CFile* loader)
44 {
45  ASSERT(loader)
46  unref();
47 
49  loader->get_string_list(strings, num_strings, max_string_length);
51 }
52 
53 template<class T> void SGStringList<T>::save(CFile* saver)
54 {
55  ASSERT(saver)
56 
58  saver->set_string_list(strings, num_strings);
60 }
61 
62 
63 template <class T>
65 {
66  strings = ((SGStringList*)(&orig))->strings;
67  num_strings = ((SGStringList*)(&orig))->num_strings;
68  max_string_length = ((SGStringList*)(&orig))->max_string_length;
69 }
70 
71 template <class T>
73 {
74  strings = NULL;
75  num_strings = 0;
76  max_string_length = 0;
77 }
78 
79 template <class T>
81 {
82  SG_FREE(strings);
83 
84  strings = NULL;
85  num_strings = 0;
86  max_string_length = 0;
87 }
88 
89 template class SGStringList<bool>;
90 template class SGStringList<char>;
91 template class SGStringList<int8_t>;
92 template class SGStringList<uint8_t>;
93 template class SGStringList<int16_t>;
94 template class SGStringList<uint16_t>;
95 template class SGStringList<int32_t>;
96 template class SGStringList<uint32_t>;
97 template class SGStringList<int64_t>;
98 template class SGStringList<uint64_t>;
99 template class SGStringList<float32_t>;
100 template class SGStringList<float64_t>;
101 template class SGStringList<floatmax_t>;
102 }
void load(CFile *loader)
#define SG_RESET_LOCALE
Definition: SGIO.h:88
SGString< T > * strings
Definition: SGStringList.h:86
int32_t index_t
Definition: common.h:60
virtual void set_string_list(const SGString< bool > *strings, int32_t num_str)
Definition: File.cpp:155
#define SG_SET_LOCALE_C
Definition: SGIO.h:87
shogun string
virtual void init_data()
#define ASSERT(x)
Definition: SGIO.h:203
shogun reference count managed data
A File access base class.
Definition: File.h:34
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:16
virtual void get_string_list(SGString< bool > *&strings, int32_t &num_str, int32_t &max_string_len)
Definition: File.cpp:132
virtual void copy_data(const SGReferencedData &orig)
void save(CFile *saver)
template class SGStringList
Definition: SGObject.h:44

SHOGUN Machine Learning Toolbox - Documentation