SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
lib
SGStringList.cpp
浏览该文件的文档.
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
机器学习工具包 - 项目文档