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
27
#define NOT_FIXED_DEC 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)
58
70
const CHARSET_INFO *str_charset;
62
Ptr=0; str_length=Alloced_length=0; alloced=0;
63
str_charset= &my_charset_bin;
74
Ptr=0; str_length=Alloced_length=0; alloced=0;
75
str_charset= &my_charset_bin;
65
77
String(uint32_t length_arg)
67
alloced=0; Alloced_length=0; (void) real_alloc(length_arg);
79
alloced=0; Alloced_length=0; (void) real_alloc(length_arg);
68
80
str_charset= &my_charset_bin;
70
82
String(const char *str, const CHARSET_INFO * const cs)
72
84
Ptr=(char*) str; str_length=(uint) strlen(str); Alloced_length=0; alloced=0;
75
87
String(const char *str,uint32_t len, const CHARSET_INFO * const cs)
77
89
Ptr=(char*) str; str_length=len; Alloced_length=0; alloced=0;
80
92
String(char *str,uint32_t len, const CHARSET_INFO * const cs)
82
94
Ptr=(char*) str; Alloced_length=str_length=len; alloced=0;
85
97
String(const String &str)
87
99
Ptr=str.Ptr ; str_length=str.str_length ;
88
Alloced_length=str.Alloced_length; alloced=0;
100
Alloced_length=str.Alloced_length; alloced=0;
89
101
str_charset=str.str_charset;
91
103
static void *operator new(size_t size, MEM_ROOT *mem_root)
92
104
{ 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
static void operator delete(void *, size_t)
95
106
{ TRASH(ptr_arg, size); }
96
static void operator delete(void *ptr_arg __attribute__((unused)),
97
MEM_ROOT *mem_root __attribute__((unused)))
107
static void operator delete(void *, MEM_ROOT *)
98
108
{ /* never called */ }
99
109
~String() { free(); }
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
277
bool append(IO_CACHE* file, uint32_t arg_length);
268
bool append_with_prefill(const char *s, uint32_t arg_length,
278
bool append_with_prefill(const char *s, uint32_t arg_length,
269
279
uint32_t full_length, char fill_char);
270
280
int strstr(const String &search,uint32_t offset=0); // Returns offset to substring or -1
271
281
int strrstr(const String &search,uint32_t offset=0); // Returns offset to substring or -1
382
static inline bool check_if_only_end_space(const CHARSET_INFO * const cs, char *str,
392
static inline bool check_if_only_end_space(const CHARSET_INFO * const cs, char *str,
385
395
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)
399
bool operator==(const String &s1, const String &s2);
400
bool operator!=(const String &s1, const String &s2);
400
403
#endif /* DRIZZLE_SERVER_SQL_STRING_H */