11#ifndef CLIENT_SQL_STRING_INCLUDED
22#define CLIENT_SQL_STRING_INCLUDED
33
4- /* Copyright (C ) 2000 MySQL AB
4+ /* Copyright (c ) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
55
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
1414
1515 You should have received a copy of the GNU General Public License
1616 along with this program; if not, write to the Free Software
17- Foundation, Inc., 59 Temple Place, Suite 330 , Boston, MA 02111-1307 USA */
17+ Foundation, Inc., 51 Franklin St, Fifth Floor , Boston, MA 02110-1301 USA */
1818
1919/* This file is originally from the mysql distribution. Coded by monty */
2020
2323#endif
2424
2525class String ;
26- int sortcmp (const String *a,const String *b, CHARSET_INFO *cs);
26+ int sortcmp (const String *a,const String *b, const CHARSET_INFO *cs);
2727String *copy_if_not_alloced (String *a,String *b,uint32 arg_length);
28- inline uint32 copy_and_convert (char *to, uint32 to_length, CHARSET_INFO *to_cs,
28+ inline uint32 copy_and_convert (char *to, uint32 to_length,
29+ const CHARSET_INFO *to_cs,
2930 const char *from, uint32 from_length,
30- CHARSET_INFO *from_cs, uint *errors)
31+ const CHARSET_INFO *from_cs, uint *errors)
3132{
3233 return my_convert (to, to_length, to_cs, from, from_length, from_cs, errors);
3334}
@@ -37,7 +38,7 @@ class String
3738 char *Ptr;
3839 uint32 str_length,Alloced_length;
3940 bool alloced;
40- CHARSET_INFO *str_charset;
41+ const CHARSET_INFO *str_charset;
4142public:
4243 String ()
4344 {
@@ -49,17 +50,17 @@ class String
4950 alloced=0 ; Alloced_length=0 ; (void ) real_alloc (length_arg);
5051 str_charset= &my_charset_bin;
5152 }
52- String (const char *str, CHARSET_INFO *cs)
53+ String (const char *str, const CHARSET_INFO *cs)
5354 {
5455 Ptr=(char *) str; str_length=(uint) strlen (str); Alloced_length=0 ; alloced=0 ;
5556 str_charset=cs;
5657 }
57- String (const char *str,uint32 len, CHARSET_INFO *cs)
58+ String (const char *str,uint32 len, const CHARSET_INFO *cs)
5859 {
5960 Ptr=(char *) str; str_length=len; Alloced_length=0 ; alloced=0 ;
6061 str_charset=cs;
6162 }
62- String (char *str,uint32 len, CHARSET_INFO *cs)
63+ String (char *str,uint32 len, const CHARSET_INFO *cs)
6364 {
6465 Ptr=(char *) str; Alloced_length=str_length=len; alloced=0 ;
6566 str_charset=cs;
@@ -82,9 +83,9 @@ class String
8283 { /* never called */ }
8384 ~String () { free (); }
8485
85- inline void set_charset (CHARSET_INFO *charset_arg)
86+ inline void set_charset (const CHARSET_INFO *charset_arg)
8687 { str_charset= charset_arg; }
87- inline CHARSET_INFO *charset () const { return str_charset; }
88+ inline const CHARSET_INFO *charset () const { return str_charset; }
8889 inline uint32 length () const { return str_length;}
8990 inline uint32 alloced_length () const { return Alloced_length;}
9091 inline char & operator [] (uint32 i) const { return Ptr[i]; }
@@ -124,30 +125,30 @@ class String
124125 Alloced_length=0 ;
125126 str_charset=str.str_charset ;
126127 }
127- inline void set (char *str,uint32 arg_length, CHARSET_INFO *cs)
128+ inline void set (char *str,uint32 arg_length, const CHARSET_INFO *cs)
128129 {
129130 free ();
130131 Ptr=(char *) str; str_length=Alloced_length=arg_length ; alloced=0 ;
131132 str_charset=cs;
132133 }
133- inline void set (const char *str,uint32 arg_length, CHARSET_INFO *cs)
134+ inline void set (const char *str,uint32 arg_length, const CHARSET_INFO *cs)
134135 {
135136 free ();
136137 Ptr=(char *) str; str_length=arg_length; Alloced_length=0 ; alloced=0 ;
137138 str_charset=cs;
138139 }
139140 bool set_ascii (const char *str, uint32 arg_length);
140- inline void set_quick (char *str,uint32 arg_length, CHARSET_INFO *cs)
141+ inline void set_quick (char *str,uint32 arg_length, const CHARSET_INFO *cs)
141142 {
142143 if (!alloced)
143144 {
144145 Ptr=(char *) str; str_length=Alloced_length=arg_length;
145146 }
146147 str_charset=cs;
147148 }
148- bool set (longlong num, CHARSET_INFO *cs);
149- bool set (ulonglong num, CHARSET_INFO *cs);
150- bool set (double num,uint decimals, CHARSET_INFO *cs);
149+ bool set (longlong num, const CHARSET_INFO *cs);
150+ bool set (ulonglong num, const CHARSET_INFO *cs);
151+ bool set (double num,uint decimals, const CHARSET_INFO *cs);
151152
152153 /*
153154 PMG 2004.11.12
@@ -231,19 +232,21 @@ class String
231232
232233 bool copy (); // Alloc string if not alloced
233234 bool copy (const String &s); // Allocate new string
234- bool copy (const char *s,uint32 arg_length, CHARSET_INFO *cs); // Allocate new string
235+ // / Allocate new string
236+ bool copy (const char *s,uint32 arg_length, const CHARSET_INFO *cs);
235237 static bool needs_conversion (uint32 arg_length,
236- CHARSET_INFO *cs_from, CHARSET_INFO *cs_to,
238+ const CHARSET_INFO *cs_from, const CHARSET_INFO *cs_to,
237239 uint32 *offset);
238240 bool copy_aligned (const char *s, uint32 arg_length, uint32 offset,
239- CHARSET_INFO *cs);
240- bool set_or_copy_aligned (const char *s, uint32 arg_length, CHARSET_INFO *cs);
241- bool copy (const char *s,uint32 arg_length, CHARSET_INFO *csfrom,
242- CHARSET_INFO *csto, uint *errors);
241+ const CHARSET_INFO *cs);
242+ bool set_or_copy_aligned (const char *s, uint32 arg_length,
243+ const CHARSET_INFO *cs);
244+ bool copy (const char *s,uint32 arg_length, const CHARSET_INFO *csfrom,
245+ const CHARSET_INFO *csto, uint *errors);
243246 bool append (const String &s);
244247 bool append (const char *s);
245248 bool append (const char *s,uint32 arg_length);
246- bool append (const char *s,uint32 arg_length, CHARSET_INFO *cs);
249+ bool append (const char *s,uint32 arg_length, const CHARSET_INFO *cs);
247250 bool append (IO_CACHE* file, uint32 arg_length);
248251 bool append_with_prefill (const char *s, uint32 arg_length,
249252 uint32 full_length, char fill_char);
@@ -267,7 +270,7 @@ class String
267270 }
268271 bool fill (uint32 max_length,char fill);
269272 void strip_sp ();
270- friend int sortcmp (const String *a,const String *b, CHARSET_INFO *cs);
273+ friend int sortcmp (const String *a,const String *b, const CHARSET_INFO *cs);
271274 friend int stringcmp (const String *a,const String *b);
272275 friend String *copy_if_not_alloced (String *a,String *b,uint32 arg_length);
273276 uint32 numchars ();
0 commit comments