SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SGStringList.cpp
Go to the documentation of this file.
2 #include <shogun/lib/SGString.h>
3 #include <shogun/io/File.h>
4 #include <shogun/io/SGIO.h>
5 
6 namespace shogun
7 {
8 
9 template <class T>
11 {
12  init_data();
13 }
14 
15 template <class T>
17  bool ref_counting) :
18  SGReferencedData(ref_counting), num_strings(num_s),
19  max_string_length(max_length), strings(s)
20 {
21 }
22 
23 template <class T>
24 SGStringList<T>::SGStringList(index_t num_s, index_t max_length, bool ref_counting) :
25  SGReferencedData(ref_counting),
26  num_strings(num_s), max_string_length(max_length)
27 {
28  strings=SG_MALLOC(SGString<T>, num_strings);
29 }
30 
31 template <class T>
33  SGReferencedData(orig)
34 {
35  copy_data(orig);
36 }
37 
38 template <class T>
40 {
41  unref();
42 }
43 
44 template<class T> void SGStringList<T>::load(CFile* loader)
45 {
46  ASSERT(loader)
47  unref();
48 
50  loader->get_string_list(strings, num_strings, max_string_length);
52 }
53 
54 template<class T> void SGStringList<T>::save(CFile* saver)
55 {
56  ASSERT(saver)
57 
59  saver->set_string_list(strings, num_strings);
61 }
62 
63 
64 template <class T>
66 {
67  strings = ((SGStringList*)(&orig))->strings;
68  num_strings = ((SGStringList*)(&orig))->num_strings;
69  max_string_length = ((SGStringList*)(&orig))->max_string_length;
70 }
71 
72 template <class T>
74 {
75  strings = NULL;
76  num_strings = 0;
77  max_string_length = 0;
78 }
79 
80 template <class T>
82 {
83  SG_FREE(strings);
84 
85  strings = NULL;
86  num_strings = 0;
87  max_string_length = 0;
88 }
89 
90 template class SGStringList<bool>;
91 template class SGStringList<char>;
92 template class SGStringList<int8_t>;
93 template class SGStringList<uint8_t>;
94 template class SGStringList<int16_t>;
95 template class SGStringList<uint16_t>;
96 template class SGStringList<int32_t>;
97 template class SGStringList<uint32_t>;
98 template class SGStringList<int64_t>;
99 template class SGStringList<uint64_t>;
100 template class SGStringList<float32_t>;
101 template class SGStringList<float64_t>;
102 template class SGStringList<floatmax_t>;
103 }
#define SG_RESET_LOCALE
Definition: SGIO.h:86
template class SGStringList
Definition: SGObject.h:43
int32_t index_t
Definition: common.h:62
virtual void set_string_list(const SGString< bool > *strings, int32_t num_str)
Definition: File.cpp:163
void load(CFile *loader)
#define SG_SET_LOCALE_C
Definition: SGIO.h:85
shogun string
#define ASSERT(x)
Definition: SGIO.h:201
virtual void init_data()
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:18
SGString< T > * strings
Definition: SGStringList.h:88
void save(CFile *saver)
virtual void get_string_list(SGString< bool > *&strings, int32_t &num_str, int32_t &max_string_len)
Definition: File.cpp:140
virtual void copy_data(const SGReferencedData &orig)

SHOGUN Machine Learning Toolbox - Documentation