27
27
int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
28
String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
29
uint32 copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
30
const char *from, uint32 from_length,
28
String *copy_if_not_alloced(String *a,String *b,uint32_t arg_length);
29
uint32_t copy_and_convert(char *to, uint32_t to_length, CHARSET_INFO *to_cs,
30
const char *from, uint32_t from_length,
31
31
CHARSET_INFO *from_cs, uint *errors);
32
uint32 well_formed_copy_nchars(CHARSET_INFO *to_cs,
32
uint32_t well_formed_copy_nchars(CHARSET_INFO *to_cs,
33
33
char *to, uint to_length,
34
34
CHARSET_INFO *from_cs,
35
35
const char *from, uint from_length,
63
63
Ptr=(char*) str; str_length=(uint) strlen(str); Alloced_length=0; alloced=0;
66
String(const char *str,uint32 len, CHARSET_INFO *cs)
66
String(const char *str,uint32_t len, CHARSET_INFO *cs)
68
68
Ptr=(char*) str; str_length=len; Alloced_length=0; alloced=0;
71
String(char *str,uint32 len, CHARSET_INFO *cs)
71
String(char *str,uint32_t len, CHARSET_INFO *cs)
73
73
Ptr=(char*) str; Alloced_length=str_length=len; alloced=0;
92
92
inline void set_charset(CHARSET_INFO *charset_arg)
93
93
{ str_charset= charset_arg; }
94
94
inline CHARSET_INFO *charset() const { return str_charset; }
95
inline uint32 length() const { return str_length;}
96
inline uint32 alloced_length() const { return Alloced_length;}
97
inline char& operator [] (uint32 i) const { return Ptr[i]; }
98
inline void length(uint32 len) { str_length=len ; }
95
inline uint32_t length() const { return str_length;}
96
inline uint32_t alloced_length() const { return Alloced_length;}
97
inline char& operator [] (uint32_t i) const { return Ptr[i]; }
98
inline void length(uint32_t len) { str_length=len ; }
99
99
inline bool is_empty() { return (str_length == 0); }
100
100
inline void mark_as_const() { Alloced_length= 0;}
101
101
inline const char *ptr() const { return Ptr; }
131
131
Alloced_length=0;
132
132
str_charset=str.str_charset;
134
inline void set(char *str,uint32 arg_length, CHARSET_INFO *cs)
134
inline void set(char *str,uint32_t arg_length, CHARSET_INFO *cs)
137
137
Ptr=(char*) str; str_length=Alloced_length=arg_length ; alloced=0;
140
inline void set(const char *str,uint32 arg_length, CHARSET_INFO *cs)
140
inline void set(const char *str,uint32_t arg_length, CHARSET_INFO *cs)
143
143
Ptr=(char*) str; str_length=arg_length; Alloced_length=0 ; alloced=0;
146
bool set_ascii(const char *str, uint32 arg_length);
147
inline void set_quick(char *str,uint32 arg_length, CHARSET_INFO *cs)
146
bool set_ascii(const char *str, uint32_t arg_length);
147
inline void set_quick(char *str,uint32_t arg_length, CHARSET_INFO *cs)
197
197
str_length=0; /* Safety */
200
inline bool alloc(uint32 arg_length)
200
inline bool alloc(uint32_t arg_length)
202
202
if (arg_length < Alloced_length)
204
204
return real_alloc(arg_length);
206
bool real_alloc(uint32 arg_length); // Empties old string
207
bool realloc(uint32 arg_length);
208
inline void shrink(uint32 arg_length) // Shrink buffer
206
bool real_alloc(uint32_t arg_length); // Empties old string
207
bool realloc(uint32_t arg_length);
208
inline void shrink(uint32_t arg_length) // Shrink buffer
210
210
if (arg_length < Alloced_length)
242
242
bool copy(); // Alloc string if not alloced
243
243
bool copy(const String &s); // Allocate new string
244
bool copy(const char *s,uint32 arg_length, CHARSET_INFO *cs); // Allocate new string
245
static bool needs_conversion(uint32 arg_length,
244
bool copy(const char *s,uint32_t arg_length, CHARSET_INFO *cs); // Allocate new string
245
static bool needs_conversion(uint32_t arg_length,
246
246
CHARSET_INFO *cs_from, CHARSET_INFO *cs_to,
248
bool copy_aligned(const char *s, uint32 arg_length, uint32 offset,
248
bool copy_aligned(const char *s, uint32_t arg_length, uint32_t offset,
249
249
CHARSET_INFO *cs);
250
bool set_or_copy_aligned(const char *s, uint32 arg_length, CHARSET_INFO *cs);
251
bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom,
250
bool set_or_copy_aligned(const char *s, uint32_t arg_length, CHARSET_INFO *cs);
251
bool copy(const char*s,uint32_t arg_length, CHARSET_INFO *csfrom,
252
252
CHARSET_INFO *csto, uint *errors);
253
253
bool append(const String &s);
254
254
bool append(const char *s);
255
bool append(const char *s,uint32 arg_length);
256
bool append(const char *s,uint32 arg_length, CHARSET_INFO *cs);
257
bool append(IO_CACHE* file, uint32 arg_length);
258
bool append_with_prefill(const char *s, uint32 arg_length,
259
uint32 full_length, char fill_char);
260
int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
261
int strrstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
262
bool replace(uint32 offset,uint32 arg_length,const char *to,uint32 length);
263
bool replace(uint32 offset,uint32 arg_length,const String &to);
255
bool append(const char *s,uint32_t arg_length);
256
bool append(const char *s,uint32_t arg_length, CHARSET_INFO *cs);
257
bool append(IO_CACHE* file, uint32_t arg_length);
258
bool append_with_prefill(const char *s, uint32_t arg_length,
259
uint32_t full_length, char fill_char);
260
int strstr(const String &search,uint32_t offset=0); // Returns offset to substring or -1
261
int strrstr(const String &search,uint32_t offset=0); // Returns offset to substring or -1
262
bool replace(uint32_t offset,uint32_t arg_length,const char *to,uint32_t length);
263
bool replace(uint32_t offset,uint32_t arg_length,const String &to);
264
264
inline bool append(char chr)
266
266
if (str_length < Alloced_length)
278
bool fill(uint32 max_length,char fill);
278
bool fill(uint32_t max_length,char fill);
280
280
friend int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
281
281
friend int stringcmp(const String *a,const String *b);
282
friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
284
int charpos(int i,uint32 offset=0);
282
friend String *copy_if_not_alloced(String *a,String *b,uint32_t arg_length);
284
int charpos(int i,uint32_t offset=0);
286
int reserve(uint32 space_needed)
286
int reserve(uint32_t space_needed)
288
288
return realloc(str_length + space_needed);
290
int reserve(uint32 space_needed, uint32 grow_by);
290
int reserve(uint32_t space_needed, uint32_t grow_by);
293
293
The following append operations do NOT check alloced memory
313
313
float8store(Ptr + str_length, *d);
316
void q_append(const char *data, uint32 data_len)
316
void q_append(const char *data, uint32_t data_len)
318
318
memcpy(Ptr + str_length, data, data_len);
319
319
str_length += data_len;
322
void write_at_position(int position, uint32 value)
322
void write_at_position(int position, uint32_t value)
324
324
int4store(Ptr + position,value);
327
void qs_append(const char *str, uint32 len);
327
void qs_append(const char *str, uint32_t len);
328
328
void qs_append(double d);
329
329
void qs_append(double *d);
330
330
inline void qs_append(const char c)
338
338
/* Inline (general) functions used by the protocol functions */
340
inline char *prep_append(uint32 arg_length, uint32 step_alloc)
340
inline char *prep_append(uint32_t arg_length, uint32_t step_alloc)
342
uint32 new_length= arg_length + str_length;
342
uint32_t new_length= arg_length + str_length;
343
343
if (new_length > Alloced_length)
345
345
if (realloc(new_length + step_alloc))
348
uint32 old_length= str_length;
348
uint32_t old_length= str_length;
349
349
str_length+= arg_length;
350
350
return Ptr+ old_length; /* Area to use */
353
inline bool append(const char *s, uint32 arg_length, uint32 step_alloc)
353
inline bool append(const char *s, uint32_t arg_length, uint32_t step_alloc)
355
uint32 new_length= arg_length + str_length;
355
uint32_t new_length= arg_length + str_length;
356
356
if (new_length > Alloced_length && realloc(new_length + step_alloc))
358
358
memcpy(Ptr+str_length, s, arg_length);