41
struct charset_info_st;
42
43
extern DRIZZLED_API String my_empty_string;
43
44
extern const String my_null_string;
44
45
namespace memory { class Root; }
45
typedef struct charset_info_st CHARSET_INFO;
47
47
DRIZZLED_API std::string String_to_std_string(String const& s);
48
48
DRIZZLED_API String* set_String_from_std_string(String* s, std::string const& cs);
50
int sortcmp(const String *a,const String *b, const CHARSET_INFO * const cs);
50
int sortcmp(const String *a,const String *b, const charset_info_st * const cs);
51
51
int stringcmp(const String *a,const String *b);
52
52
String *copy_if_not_alloced(String *a,String *b,size_t arg_length);
53
size_t well_formed_copy_nchars(const CHARSET_INFO * const to_cs,
53
size_t well_formed_copy_nchars(const charset_info_st * const to_cs,
54
54
char *to, size_t to_length,
55
const CHARSET_INFO * const from_cs,
55
const charset_info_st * const from_cs,
56
56
const char *from, size_t from_length,
58
58
const char **well_formed_error_pos,
66
66
size_t str_length,Alloced_length;
68
const CHARSET_INFO *str_charset;
68
const charset_info_st *str_charset;
72
72
String(size_t length_arg);
73
String(const char *str, const CHARSET_INFO * const cs);
74
String(const char *str, size_t len, const CHARSET_INFO * const cs);
75
String(char *str, size_t len, const CHARSET_INFO * const cs);
73
String(const char *str, const charset_info_st * const cs);
74
String(const char *str, size_t len, const charset_info_st * const cs);
75
String(char *str, size_t len, const charset_info_st * const cs);
76
76
String(const String &str);
78
78
static void *operator new(size_t size, memory::Root *mem_root);
85
inline void set_charset(const CHARSET_INFO * const charset_arg)
85
inline void set_charset(const charset_info_st * const charset_arg)
86
86
{ str_charset= charset_arg; }
87
inline const CHARSET_INFO *charset() const { return str_charset; }
87
inline const charset_info_st *charset() const { return str_charset; }
88
88
inline size_t length() const { return str_length;}
89
89
inline size_t alloced_length() const { return Alloced_length;}
90
90
inline char& operator [] (size_t i) const { return Ptr[i]; }
137
137
Alloced_length=0;
138
138
str_charset=str.str_charset;
140
inline void set(char *str,size_t arg_length, const CHARSET_INFO * const cs)
140
inline void set(char *str,size_t arg_length, const charset_info_st * const cs)
143
143
Ptr= str; str_length=Alloced_length=arg_length ; alloced=0;
146
inline void set(const char *str,size_t arg_length, const CHARSET_INFO * const cs)
146
inline void set(const char *str,size_t arg_length, const charset_info_st * const cs)
149
149
Ptr= const_cast<char*>(str);
153
153
bool set_ascii(const char *str, size_t arg_length);
154
inline void set_quick(char *str,size_t arg_length, const CHARSET_INFO * const cs)
154
inline void set_quick(char *str,size_t arg_length, const charset_info_st * const cs)
162
bool set_int(int64_t num, bool unsigned_flag, const CHARSET_INFO * const cs);
163
bool set(int64_t num, const CHARSET_INFO * const cs)
162
bool set_int(int64_t num, bool unsigned_flag, const charset_info_st * const cs);
163
bool set(int64_t num, const charset_info_st * const cs)
164
164
{ return set_int(num, false, cs); }
165
bool set(uint64_t num, const CHARSET_INFO * const cs)
165
bool set(uint64_t num, const charset_info_st * const cs)
166
166
{ return set_int(static_cast<int64_t>(num), true, cs); }
167
bool set_real(double num,size_t decimals, const CHARSET_INFO * const cs);
167
bool set_real(double num,size_t decimals, const charset_info_st * const cs);
249
249
bool copy(); // Alloc string if not alloced
250
250
bool copy(const String &s); // Allocate new string
251
bool copy(const std::string&, const CHARSET_INFO * const cs); // Allocate new string
252
bool copy(const char *s,size_t arg_length, const CHARSET_INFO * const cs); // Allocate new string
251
bool copy(const std::string&, const charset_info_st * const cs); // Allocate new string
252
bool copy(const char *s,size_t arg_length, const charset_info_st * const cs); // Allocate new string
253
253
static bool needs_conversion(size_t arg_length,
254
const CHARSET_INFO * const cs_from, const CHARSET_INFO * const cs_to,
254
const charset_info_st * const cs_from, const charset_info_st * const cs_to,
256
bool set_or_copy_aligned(const char *s, size_t arg_length, const CHARSET_INFO * const cs);
257
bool copy(const char*s,size_t arg_length, const CHARSET_INFO * const csfrom,
258
const CHARSET_INFO * const csto, size_t *errors);
256
bool set_or_copy_aligned(const char *s, size_t arg_length, const charset_info_st * const cs);
257
bool copy(const char*s,size_t arg_length, const charset_info_st * const csfrom,
258
const charset_info_st * const csto, size_t *errors);
259
259
bool append(const String &s);
260
260
bool append(const char *s);
261
261
bool append(const char *s,size_t arg_length);
262
bool append(const char *s,size_t arg_length, const CHARSET_INFO * const cs);
262
bool append(const char *s,size_t arg_length, const charset_info_st * const cs);
263
263
bool append_with_prefill(const char *s, size_t arg_length,
264
264
size_t full_length, char fill_char);
265
265
int strstr(const String &search,size_t offset=0); // Returns offset to substring or -1
283
friend int sortcmp(const String *a,const String *b, const CHARSET_INFO * const cs);
283
friend int sortcmp(const String *a,const String *b, const charset_info_st * const cs);
284
284
friend int stringcmp(const String *a,const String *b);
285
285
friend String *copy_if_not_alloced(String *a,String *b,size_t arg_length);
286
286
size_t numchars();
342
bool check_if_only_end_space(const CHARSET_INFO * const cs, char *str,
342
bool check_if_only_end_space(const charset_info_st * const cs, char *str,
345
345
std::ostream& operator<<(std::ostream& output, const String &str);