SHOGUN
v3.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
lib
SGStringList.cpp
Go to the documentation of this file.
1
#include <
shogun/lib/SGStringList.h
>
2
#include <
shogun/lib/SGString.h
>
3
#include <
shogun/io/File.h
>
4
5
namespace
shogun
6
{
7
8
template
<
class
T>
9
SGStringList<T>::SGStringList
() :
SGReferencedData
()
10
{
11
init_data
();
12
}
13
14
template
<
class
T>
15
SGStringList<T>::SGStringList
(
SGString<T>
* s,
index_t
num_s,
index_t
max_length,
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>
31
SGStringList<T>::SGStringList
(
const
SGStringList
&orig) :
32
SGReferencedData
(orig)
33
{
34
copy_data
(orig);
35
}
36
37
template
<
class
T>
38
SGStringList<T>::~SGStringList
()
39
{
40
unref();
41
}
42
43
template
<
class
T>
void
SGStringList<T>::load
(
CFile
* loader)
44
{
45
ASSERT
(loader)
46
unref();
47
48
SG_SET_LOCALE_C
;
49
loader->
get_string_list
(strings, num_strings, max_string_length);
50
SG_RESET_LOCALE
;
51
}
52
53
template
<
class
T>
void
SGStringList<T>::save
(
CFile
* saver)
54
{
55
ASSERT
(saver)
56
57
SG_SET_LOCALE_C
;
58
saver->
set_string_list
(strings, num_strings);
59
SG_RESET_LOCALE
;
60
}
61
62
63
template
<
class
T>
64
void
SGStringList<T>::copy_data
(
const
SGReferencedData
&orig)
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>
72
void
SGStringList<T>::init_data
()
73
{
74
strings = NULL;
75
num_strings = 0;
76
max_string_length = 0;
77
}
78
79
template
<
class
T>
80
void
SGStringList<T>::free_data
()
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
}
SHOGUN
Machine Learning Toolbox - Documentation