23
23
/* This file is originally from the mysql distribution. Coded by monty */
25
#ifdef USE_PRAGMA_INTERFACE
26
#pragma interface /* gcc class implementation */
29
26
#ifndef NOT_FIXED_DEC
30
#define NOT_FIXED_DEC 31
27
#define NOT_FIXED_DEC (uint8_t)31
33
#include <libdrizzle/drizzle_com.h>
30
#include <drizzled/common.h>
31
#include <mysys/iocache.h>
36
int sortcmp(const String *a,const String *b, const CHARSET_INFO * const cs);
37
String *copy_if_not_alloced(String *a,String *b,uint32_t arg_length);
38
uint32_t copy_and_convert(char *to, uint32_t to_length, const CHARSET_INFO * const to_cs,
39
const char *from, uint32_t from_length,
40
const CHARSET_INFO * const from_cs, uint32_t *errors);
41
uint32_t well_formed_copy_nchars(const CHARSET_INFO * const to_cs,
42
char *to, uint32_t to_length,
43
const CHARSET_INFO * const from_cs,
44
const char *from, uint32_t from_length,
46
const char **well_formed_error_pos,
47
const char **cannot_convert_error_pos,
48
const char **from_end_pos);
49
size_t my_copy_with_hex_escaping(const CHARSET_INFO * const cs,
50
char *dst, size_t dstlen,
51
const char *src, size_t srclen);
37
#if defined(__cplusplus)
41
int sortcmp(const String *a,const String *b, const CHARSET_INFO * const cs);
42
int stringcmp(const String *a,const String *b);
43
String *copy_if_not_alloced(String *a,String *b,uint32_t arg_length);
44
uint32_t copy_and_convert(char *to, uint32_t to_length,
45
const CHARSET_INFO * const to_cs,
46
const char *from, uint32_t from_length,
47
const CHARSET_INFO * const from_cs,
49
uint32_t well_formed_copy_nchars(const CHARSET_INFO * const to_cs,
50
char *to, uint32_t to_length,
51
const CHARSET_INFO * const from_cs,
52
const char *from, uint32_t from_length,
54
const char **well_formed_error_pos,
55
const char **cannot_convert_error_pos,
56
const char **from_end_pos);
57
size_t my_copy_with_hex_escaping(const CHARSET_INFO * const cs,
58
char *dst, size_t dstlen,
59
const char *src, size_t srclen);
61
#if defined(__cplusplus)
56
68
uint32_t str_length,Alloced_length;
58
70
const CHARSET_INFO *str_charset;
62
Ptr=0; str_length=Alloced_length=0; alloced=0;
63
str_charset= &my_charset_bin;
75
Ptr=0; str_length=Alloced_length=0; alloced=0;
76
str_charset= &my_charset_bin;
65
78
String(uint32_t length_arg)
67
alloced=0; Alloced_length=0; (void) real_alloc(length_arg);
80
alloced=0; Alloced_length=0; (void) real_alloc(length_arg);
68
81
str_charset= &my_charset_bin;
70
83
String(const char *str, const CHARSET_INFO * const cs)
72
Ptr=(char*) str; str_length=(uint) strlen(str); Alloced_length=0; alloced=0;
85
Ptr=(char*) str; str_length=(uint32_t) strlen(str); Alloced_length=0; alloced=0;
75
88
String(const char *str,uint32_t len, const CHARSET_INFO * const cs)
77
90
Ptr=(char*) str; str_length=len; Alloced_length=0; alloced=0;
80
93
String(char *str,uint32_t len, const CHARSET_INFO * const cs)
82
95
Ptr=(char*) str; Alloced_length=str_length=len; alloced=0;
85
98
String(const String &str)
87
100
Ptr=str.Ptr ; str_length=str.str_length ;
88
Alloced_length=str.Alloced_length; alloced=0;
101
Alloced_length=str.Alloced_length; alloced=0;
89
102
str_charset=str.str_charset;
91
104
static void *operator new(size_t size, MEM_ROOT *mem_root)
92
{ return (void*) alloc_root(mem_root, (uint) size); }
93
static void operator delete(void *ptr_arg __attribute__((unused)),
94
size_t size __attribute__((unused)))
105
{ return (void*) alloc_root(mem_root, (uint32_t) size); }
106
static void operator delete(void *, size_t)
95
107
{ TRASH(ptr_arg, size); }
96
static void operator delete(void *ptr_arg __attribute__((unused)),
97
MEM_ROOT *mem_root __attribute__((unused)))
108
static void operator delete(void *, MEM_ROOT *)
98
109
{ /* never called */ }
99
110
~String() { free(); }
255
267
static bool needs_conversion(uint32_t arg_length,
256
268
const CHARSET_INFO * const cs_from, const CHARSET_INFO * const cs_to,
257
269
uint32_t *offset);
258
bool copy_aligned(const char *s, uint32_t arg_length, uint32_t offset,
259
const CHARSET_INFO * const cs);
260
270
bool set_or_copy_aligned(const char *s, uint32_t arg_length, const CHARSET_INFO * const cs);
261
271
bool copy(const char*s,uint32_t arg_length, const CHARSET_INFO * const csfrom,
262
272
const CHARSET_INFO * const csto, uint32_t *errors);
264
274
bool append(const char *s);
265
275
bool append(const char *s,uint32_t arg_length);
266
276
bool append(const char *s,uint32_t arg_length, const CHARSET_INFO * const cs);
267
bool append(IO_CACHE* file, uint32_t arg_length);
268
bool append_with_prefill(const char *s, uint32_t arg_length,
277
bool append_with_prefill(const char *s, uint32_t arg_length,
269
278
uint32_t full_length, char fill_char);
270
279
int strstr(const String &search,uint32_t offset=0); // Returns offset to substring or -1
271
280
int strrstr(const String &search,uint32_t offset=0); // Returns offset to substring or -1
333
341
int4store(Ptr + position,value);
336
void qs_append(const char *str, uint32_t len);
337
void qs_append(double d);
338
void qs_append(double *d);
339
inline void qs_append(const char c)
344
void qs_append(int i);
345
void qs_append(uint32_t i);
347
344
/* Inline (general) functions used by the protocol functions */
349
346
inline char *prep_append(uint32_t arg_length, uint32_t step_alloc)
382
static inline bool check_if_only_end_space(const CHARSET_INFO * const cs, char *str,
379
static inline bool check_if_only_end_space(const CHARSET_INFO * const cs, char *str,
385
382
return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end;
389
bool operator==(const String &s1, const String &s2)
391
return stringcmp(&s1,&s2) == 0;
395
bool operator!=(const String &s1, const String &s2)
386
bool operator==(const String &s1, const String &s2);
387
bool operator!=(const String &s1, const String &s2);
400
390
#endif /* DRIZZLE_SERVER_SQL_STRING_H */