~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_string.cc

  • Committer: Andrew Hutchings
  • Date: 2011-03-29 20:45:43 UTC
  • mfrom: (2257 drizzle)
  • mto: (2257.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2258.
  • Revision ID: andrew@linuxjedi.co.uk-20110329204543-ssex0nuo8knncgwx
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
#include <config.h>
19
19
 
 
20
#include <drizzled/definitions.h>
20
21
#include <drizzled/internal/my_sys.h>
21
22
#include <drizzled/internal/m_string.h>
 
23
#include <drizzled/memory/root.h>
 
24
#include <drizzled/charset_info.h>
22
25
#include <drizzled/charset.h>
23
26
#include <drizzled/global_charset_info.h>
24
27
 
68
71
  (void) real_alloc(length_arg);
69
72
}
70
73
 
71
 
String::String(const char *str, const CHARSET_INFO * const cs)
 
74
String::String(const char *str, const charset_info_st * const cs)
72
75
  : Ptr(const_cast<char *>(str)),
73
76
    str_length(static_cast<size_t>(strlen(str))),
74
77
    Alloced_length(0),
77
80
{ }
78
81
 
79
82
 
80
 
String::String(const char *str, size_t len, const CHARSET_INFO * const cs)
 
83
String::String(const char *str, size_t len, const charset_info_st * const cs)
81
84
  : Ptr(const_cast<char *>(str)),
82
85
    str_length(len),
83
86
    Alloced_length(0),
86
89
{ }
87
90
 
88
91
 
89
 
String::String(char *str, size_t len, const CHARSET_INFO * const cs)
 
92
String::String(char *str, size_t len, const charset_info_st * const cs)
90
93
  : Ptr(str),
91
94
    str_length(len),
92
95
    Alloced_length(len),
166
169
  return false;
167
170
}
168
171
 
169
 
bool String::set_int(int64_t num, bool unsigned_flag, const CHARSET_INFO * const cs)
 
172
bool String::set_int(int64_t num, bool unsigned_flag, const charset_info_st * const cs)
170
173
{
171
174
  size_t l=20*cs->mbmaxlen+1;
172
175
  int base= unsigned_flag ? 10 : -10;
178
181
  return false;
179
182
}
180
183
 
181
 
bool String::set_real(double num,size_t decimals, const CHARSET_INFO * const cs)
 
184
bool String::set_real(double num,size_t decimals, const charset_info_st * const cs)
182
185
{
183
186
  char buff[FLOATING_POINT_BUFFER];
184
187
  size_t dummy_errors;
219
222
  return false;
220
223
}
221
224
 
222
 
bool String::copy(const std::string& arg, const CHARSET_INFO * const cs)        // Allocate new string
 
225
bool String::copy(const std::string& arg, const charset_info_st * const cs)     // Allocate new string
223
226
{
224
227
  if (alloc(arg.size()))
225
228
    return true;
233
236
  return false;
234
237
}
235
238
 
236
 
bool String::copy(const char *str,size_t arg_length, const CHARSET_INFO * const cs)
 
239
bool String::copy(const char *str,size_t arg_length, const charset_info_st * const cs)
237
240
{
238
241
  if (alloc(arg_length))
239
242
    return true;
267
270
*/
268
271
 
269
272
bool String::needs_conversion(size_t arg_length,
270
 
                              const CHARSET_INFO * const from_cs,
271
 
                              const CHARSET_INFO * const to_cs,
 
273
                              const charset_info_st * const from_cs,
 
274
                              const charset_info_st * const to_cs,
272
275
                              size_t *offset)
273
276
{
274
277
  *offset= 0;
286
289
 
287
290
 
288
291
bool String::set_or_copy_aligned(const char *str,size_t arg_length,
289
 
                                 const CHARSET_INFO * const cs)
 
292
                                 const charset_info_st * const cs)
290
293
{
291
294
  /* How many bytes are in incomplete character */
292
295
  size_t offset= (arg_length % cs->mbminlen);
300
303
        /* Copy with charset conversion */
301
304
 
302
305
bool String::copy(const char *str, size_t arg_length,
303
 
                          const CHARSET_INFO * const,
304
 
                                  const CHARSET_INFO * const to_cs, size_t *errors)
 
306
                          const charset_info_st * const,
 
307
                                  const charset_info_st * const to_cs, size_t *errors)
305
308
{
306
309
  *errors= 0;
307
310
  return copy(str, arg_length, to_cs);
386
389
  with character set recoding
387
390
*/
388
391
 
389
 
bool String::append(const char *s,size_t arg_length, const CHARSET_INFO * const)
 
392
bool String::append(const char *s,size_t arg_length, const charset_info_st * const)
390
393
{
391
394
  if (realloc(str_length + arg_length))
392
395
    return true;
546
549
*/
547
550
 
548
551
 
549
 
int sortcmp(const String *s,const String *t, const CHARSET_INFO * const cs)
 
552
int sortcmp(const String *s,const String *t, const charset_info_st * const cs)
550
553
{
551
554
 return cs->coll->strnncollsp(cs,
552
555
                              (unsigned char *) s->ptr(),s->length(),
630
633
 
631
634
 
632
635
size_t
633
 
well_formed_copy_nchars(const CHARSET_INFO * const to_cs,
 
636
well_formed_copy_nchars(const charset_info_st * const to_cs,
634
637
                        char *to, size_t to_length,
635
 
                        const CHARSET_INFO * const from_cs,
 
638
                        const charset_info_st * const from_cs,
636
639
                        const char *from, size_t from_length,
637
640
                        size_t nchars,
638
641
                        const char **well_formed_error_pos,
745
748
*/
746
749
 
747
750
/* Factor the extern out */
748
 
extern const CHARSET_INFO *system_charset_info, *files_charset_info;
 
751
extern const charset_info_st *system_charset_info, *files_charset_info;
749
752
 
750
753
void String::append_identifier(const char *name, size_t in_length)
751
754
{
827
830
{
828
831
  int8store(Ptr + position,value);
829
832
}
830
 
bool check_if_only_end_space(const CHARSET_INFO * const cs, char *str,
 
833
bool check_if_only_end_space(const charset_info_st * const cs, char *str,
831
834
                             char *end)
832
835
{
833
836
  return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end;