1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1
/* Copyright (C) 2000 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
20
16
#ifndef DRIZZLE_SERVER_SQL_STRING_H
21
17
#define DRIZZLE_SERVER_SQL_STRING_H
23
19
/* This file is originally from the mysql distribution. Coded by monty */
21
#ifdef USE_PRAGMA_INTERFACE
22
#pragma interface /* gcc class implementation */
26
25
#ifndef NOT_FIXED_DEC
27
26
#define NOT_FIXED_DEC 31
30
#include <drizzled/common.h>
31
#include <mysys/iocache.h>
35
#if defined(__cplusplus)
39
int sortcmp(const String *a,const String *b, const CHARSET_INFO * const cs);
40
int stringcmp(const String *a,const String *b);
41
String *copy_if_not_alloced(String *a,String *b,uint32_t arg_length);
42
uint32_t copy_and_convert(char *to, uint32_t to_length,
43
const CHARSET_INFO * const to_cs,
44
const char *from, uint32_t from_length,
45
const CHARSET_INFO * const from_cs,
47
uint32_t well_formed_copy_nchars(const CHARSET_INFO * const to_cs,
48
char *to, uint32_t to_length,
49
const CHARSET_INFO * const from_cs,
50
const char *from, uint32_t from_length,
52
const char **well_formed_error_pos,
53
const char **cannot_convert_error_pos,
54
const char **from_end_pos);
55
size_t my_copy_with_hex_escaping(const CHARSET_INFO * const cs,
56
char *dst, size_t dstlen,
57
const char *src, size_t srclen);
59
#if defined(__cplusplus)
30
int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
31
String *copy_if_not_alloced(String *a,String *b,uint32_t arg_length);
32
uint32_t copy_and_convert(char *to, uint32_t to_length, CHARSET_INFO *to_cs,
33
const char *from, uint32_t from_length,
34
CHARSET_INFO *from_cs, uint *errors);
35
uint32_t well_formed_copy_nchars(CHARSET_INFO *to_cs,
36
char *to, uint to_length,
37
CHARSET_INFO *from_cs,
38
const char *from, uint from_length,
40
const char **well_formed_error_pos,
41
const char **cannot_convert_error_pos,
42
const char **from_end_pos);
43
size_t my_copy_with_hex_escaping(CHARSET_INFO *cs,
44
char *dst, size_t dstlen,
45
const char *src, size_t srclen);
66
50
uint32_t str_length,Alloced_length;
68
const CHARSET_INFO *str_charset;
52
CHARSET_INFO *str_charset;
77
61
alloced=0; Alloced_length=0; (void) real_alloc(length_arg);
78
62
str_charset= &my_charset_bin;
80
String(const char *str, const CHARSET_INFO * const cs)
64
String(const char *str, CHARSET_INFO *cs)
82
66
Ptr=(char*) str; str_length=(uint) strlen(str); Alloced_length=0; alloced=0;
85
String(const char *str,uint32_t len, const CHARSET_INFO * const cs)
69
String(const char *str,uint32_t len, CHARSET_INFO *cs)
87
71
Ptr=(char*) str; str_length=len; Alloced_length=0; alloced=0;
90
String(char *str,uint32_t len, const CHARSET_INFO * const cs)
74
String(char *str,uint32_t len, CHARSET_INFO *cs)
92
76
Ptr=(char*) str; Alloced_length=str_length=len; alloced=0;
151
134
Alloced_length=0;
152
135
str_charset=str.str_charset;
154
inline void set(char *str,uint32_t arg_length, const CHARSET_INFO * const cs)
137
inline void set(char *str,uint32_t arg_length, CHARSET_INFO *cs)
157
140
Ptr=(char*) str; str_length=Alloced_length=arg_length ; alloced=0;
160
inline void set(const char *str,uint32_t arg_length, const CHARSET_INFO * const cs)
143
inline void set(const char *str,uint32_t arg_length, CHARSET_INFO *cs)
163
146
Ptr=(char*) str; str_length=arg_length; Alloced_length=0 ; alloced=0;
166
149
bool set_ascii(const char *str, uint32_t arg_length);
167
inline void set_quick(char *str,uint32_t arg_length, const CHARSET_INFO * const cs)
150
inline void set_quick(char *str,uint32_t arg_length, CHARSET_INFO *cs)
175
bool set_int(int64_t num, bool unsigned_flag, const CHARSET_INFO * const cs);
176
bool set(int64_t num, const CHARSET_INFO * const cs)
158
bool set_int(int64_t num, bool unsigned_flag, CHARSET_INFO *cs);
159
bool set(int64_t num, CHARSET_INFO *cs)
177
160
{ return set_int(num, false, cs); }
178
bool set(uint64_t num, const CHARSET_INFO * const cs)
161
bool set(uint64_t num, CHARSET_INFO *cs)
179
162
{ return set_int((int64_t)num, true, cs); }
180
bool set_real(double num,uint32_t decimals, const CHARSET_INFO * const cs);
163
bool set_real(double num,uint decimals, CHARSET_INFO *cs);
262
245
bool copy(); // Alloc string if not alloced
263
246
bool copy(const String &s); // Allocate new string
264
bool copy(const char *s,uint32_t arg_length, const CHARSET_INFO * const cs); // Allocate new string
247
bool copy(const char *s,uint32_t arg_length, CHARSET_INFO *cs); // Allocate new string
265
248
static bool needs_conversion(uint32_t arg_length,
266
const CHARSET_INFO * const cs_from, const CHARSET_INFO * const cs_to,
249
CHARSET_INFO *cs_from, CHARSET_INFO *cs_to,
267
250
uint32_t *offset);
268
251
bool copy_aligned(const char *s, uint32_t arg_length, uint32_t offset,
269
const CHARSET_INFO * const cs);
270
bool set_or_copy_aligned(const char *s, uint32_t arg_length, const CHARSET_INFO * const cs);
271
bool copy(const char*s,uint32_t arg_length, const CHARSET_INFO * const csfrom,
272
const CHARSET_INFO * const csto, uint32_t *errors);
253
bool set_or_copy_aligned(const char *s, uint32_t arg_length, CHARSET_INFO *cs);
254
bool copy(const char*s,uint32_t arg_length, CHARSET_INFO *csfrom,
255
CHARSET_INFO *csto, uint *errors);
273
256
bool append(const String &s);
274
257
bool append(const char *s);
275
258
bool append(const char *s,uint32_t arg_length);
276
bool append(const char *s,uint32_t arg_length, const CHARSET_INFO * const cs);
259
bool append(const char *s,uint32_t arg_length, CHARSET_INFO *cs);
277
260
bool append(IO_CACHE* file, uint32_t arg_length);
278
261
bool append_with_prefill(const char *s, uint32_t arg_length,
279
262
uint32_t full_length, char fill_char);