~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_string.h

  • Committer: Monty Taylor
  • Date: 2008-10-05 01:41:06 UTC
  • Revision ID: monty@inaugust.com-20081005014106-bulqe4kp7i6ipts1
Moved qsort declarations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
/* This file is originally from the mysql distribution. Coded by monty */
24
24
 
 
25
#ifdef USE_PRAGMA_INTERFACE
 
26
#pragma interface                       /* gcc class implementation */
 
27
#endif
25
28
 
26
29
#ifndef NOT_FIXED_DEC
27
30
#define NOT_FIXED_DEC                   31
28
31
#endif
29
32
 
30
33
#include <libdrizzle/drizzle_com.h>
31
 
#include <mysys/iocache.h>
32
34
 
33
35
class String;
34
36
int sortcmp(const String *a,const String *b, const CHARSET_INFO * const cs);
35
37
String *copy_if_not_alloced(String *a,String *b,uint32_t arg_length);
36
38
uint32_t copy_and_convert(char *to, uint32_t to_length, const CHARSET_INFO * const to_cs,
37
39
                        const char *from, uint32_t from_length,
38
 
                        const CHARSET_INFO * const from_cs, uint32_t *errors);
 
40
                        const CHARSET_INFO * const from_cs, uint *errors);
39
41
uint32_t well_formed_copy_nchars(const CHARSET_INFO * const to_cs,
40
 
                               char *to, uint32_t to_length,
 
42
                               char *to, uint to_length,
41
43
                               const CHARSET_INFO * const from_cs,
42
 
                               const char *from, uint32_t from_length,
43
 
                               uint32_t nchars,
 
44
                               const char *from, uint from_length,
 
45
                               uint nchars,
44
46
                               const char **well_formed_error_pos,
45
47
                               const char **cannot_convert_error_pos,
46
48
                               const char **from_end_pos);
50
52
 
51
53
class String
52
54
{
53
 
  const char *Ptr;
 
55
  char *Ptr;
54
56
  uint32_t str_length,Alloced_length;
55
57
  bool alloced;
56
58
  const CHARSET_INFO *str_charset;
57
59
public:
58
 
  String() :
59
 
    Ptr(NULL), str_length(0), Alloced_length(0),
60
 
    alloced(false), str_charset(&my_charset_bin)
61
 
  {}
62
 
 
63
 
  String(uint32_t length_arg) :
64
 
    Ptr(NULL), str_length(0), Alloced_length(0),
65
 
    alloced(false), str_charset(&my_charset_bin)
66
 
  {
67
 
    (void) real_alloc(length_arg);
68
 
  }
69
 
 
70
 
  String(const char *str, const CHARSET_INFO * const cs) :
71
 
    Ptr(str), str_length(0), Alloced_length(0),
72
 
    alloced(false), str_charset(cs)
73
 
  {
74
 
    str_length= strlen(str);
75
 
  }
76
 
 
77
 
  String(const char *str,uint32_t len, const CHARSET_INFO * const cs) :
78
 
    str_length(len), Alloced_length(0), alloced(false),
79
 
    Ptr(str), str_charset(cs)
80
 
  {
81
 
  }
82
 
 
 
60
  String()
 
61
  { 
 
62
    Ptr=0; str_length=Alloced_length=0; alloced=0; 
 
63
    str_charset= &my_charset_bin; 
 
64
  }
 
65
  String(uint32_t length_arg)
 
66
  { 
 
67
    alloced=0; Alloced_length=0; (void) real_alloc(length_arg); 
 
68
    str_charset= &my_charset_bin;
 
69
  }
 
70
  String(const char *str, const CHARSET_INFO * const cs)
 
71
  { 
 
72
    Ptr=(char*) str; str_length=(uint) strlen(str); Alloced_length=0; alloced=0;
 
73
    str_charset=cs;
 
74
  }
 
75
  String(const char *str,uint32_t len, const CHARSET_INFO * const cs)
 
76
  { 
 
77
    Ptr=(char*) str; str_length=len; Alloced_length=0; alloced=0;
 
78
    str_charset=cs;
 
79
  }
 
80
  String(char *str,uint32_t len, const CHARSET_INFO * const cs)
 
81
  { 
 
82
    Ptr=(char*) str; Alloced_length=str_length=len; alloced=0;
 
83
    str_charset=cs;
 
84
  }
83
85
  String(const String &str)
84
 
    str_length(str.Ptr), Alloced_length(0), alloced(false),
85
 
    Ptr(str), str_charset(cs)
86
 
  {
 
86
  { 
87
87
    Ptr=str.Ptr ; str_length=str.str_length ;
88
 
    Alloced_length=str.Alloced_length; alloced=0;
 
88
    Alloced_length=str.Alloced_length; alloced=0; 
89
89
    str_charset=str.str_charset;
90
90
  }
91
91
  static void *operator new(size_t size, MEM_ROOT *mem_root)
167
167
  { return set_int(num, false, cs); }
168
168
  bool set(uint64_t num, const CHARSET_INFO * const cs)
169
169
  { return set_int((int64_t)num, true, cs); }
170
 
  bool set_real(double num,uint32_t decimals, const CHARSET_INFO * const cs);
 
170
  bool set_real(double num,uint decimals, const CHARSET_INFO * const cs);
171
171
 
172
172
  /*
173
173
    PMG 2004.11.12
202
202
    {
203
203
      alloced=0;
204
204
      Alloced_length=0;
205
 
      ::free(Ptr);
 
205
      my_free(Ptr,MYF(0));
206
206
      Ptr=0;
207
207
      str_length=0;                             /* Safety */
208
208
    }
259
259
                    const CHARSET_INFO * const cs);
260
260
  bool set_or_copy_aligned(const char *s, uint32_t arg_length, const CHARSET_INFO * const cs);
261
261
  bool copy(const char*s,uint32_t arg_length, const CHARSET_INFO * const csfrom,
262
 
            const CHARSET_INFO * const csto, uint32_t *errors);
 
262
            const CHARSET_INFO * const csto, uint *errors);
263
263
  bool append(const String &s);
264
264
  bool append(const char *s);
265
265
  bool append(const char *s,uint32_t arg_length);
342
342
     str_length++;
343
343
  }
344
344
  void qs_append(int i);
345
 
  void qs_append(uint32_t i);
 
345
  void qs_append(uint i);
346
346
 
347
347
  /* Inline (general) functions used by the protocol functions */
348
348