-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
SGString.h
81 lines (65 loc) · 1.59 KB
/
SGString.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* This software is distributed under BSD 3-clause license (see LICENSE file).
*
* Authors: Soeren Sonnenburg, Sergey Lisitsyn, Jacob Walker, Thoralf Klein,
* Björn Esser
*/
#ifndef __SGSTRING_H__
#define __SGSTRING_H__
#include <shogun/lib/config.h>
#include <shogun/lib/common.h>
namespace shogun
{
template<class T> class SGVector;
class CFile;
/** @brief shogun string */
template<class T> class SGString
{
public:
/** default constructor */
SGString();
/** constructor for setting params */
SGString(T* s, index_t l, bool free_s=false);
/** constructor for setting params from a SGVector*/
SGString(SGVector<T> v);
/** constructor to create new string in memory */
SGString(index_t len, bool free_s=false);
/** copy constructor */
SGString(const SGString &orig);
/** @return true iff pointer and size are equal */
bool operator==(const SGString & other) const;
/** @return true iff content is equal */
bool equals(const SGString& other) const;
/** free string */
void free_string();
/** destroy string */
void destroy_string();
/**
* get the string (no copying is done here)
*
* @return the refcount increased string
*/
inline SGString<T> get()
{
return *this;
}
/** load string from file
*
* @param loader File object via which to load data
*/
void load(CFile* loader);
/** save string to file
*
* @param saver File object via which to save data
*/
void save(CFile* saver);
public:
/** string */
T* string;
/** length of string */
index_t slen;
/** whether string needs to be freed */
bool do_free;
};
}
#endif // __SGSTRING_H__