~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_string.h

Merge Monty

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
 
 
26
 
#ifndef NOT_FIXED_DEC
27
 
#define NOT_FIXED_DEC                   (uint8_t)31
28
 
#endif
29
 
 
30
25
#include <drizzled/common.h>
31
26
#include <cassert>
32
27
#include <cstdlib>
33
28
#include <cstring>
34
29
#include <string>
35
30
 
 
31
#ifndef NOT_FIXED_DEC
 
32
#define NOT_FIXED_DEC                   (uint8_t)31
 
33
#endif
 
34
 
 
35
namespace drizzled
 
36
{
 
37
 
36
38
class String;
37
39
 
38
40
extern String my_empty_string;
39
41
extern const String my_null_string;
40
 
namespace drizzled { namespace memory { class Root; } }
 
42
namespace memory { class Root; }
41
43
typedef struct charset_info_st CHARSET_INFO;
42
44
 
43
 
#if defined(__cplusplus)
44
 
extern "C" {
45
 
#endif
46
 
 
47
 
  std::string String_to_std_string(String const& s);
48
 
  String* set_String_from_std_string(String* s, std::string const& cs);
49
 
 
50
 
  int sortcmp(const String *a,const String *b, const CHARSET_INFO * const cs);
51
 
  int stringcmp(const String *a,const String *b);
52
 
  String *copy_if_not_alloced(String *a,String *b,uint32_t arg_length);
53
 
  uint32_t well_formed_copy_nchars(const CHARSET_INFO * const to_cs,
54
 
                                   char *to, uint32_t to_length,
55
 
                                   const CHARSET_INFO * const from_cs,
56
 
                                   const char *from, uint32_t from_length,
57
 
                                   uint32_t nchars,
58
 
                                   const char **well_formed_error_pos,
59
 
                                   const char **cannot_convert_error_pos,
60
 
                                   const char **from_end_pos);
61
 
 
62
 
#if defined(__cplusplus)
63
 
}
64
 
#endif
 
45
std::string String_to_std_string(String const& s);
 
46
String* set_String_from_std_string(String* s, std::string const& cs);
 
47
 
 
48
int sortcmp(const String *a,const String *b, const CHARSET_INFO * const cs);
 
49
int stringcmp(const String *a,const String *b);
 
50
String *copy_if_not_alloced(String *a,String *b,uint32_t arg_length);
 
51
uint32_t well_formed_copy_nchars(const CHARSET_INFO * const to_cs,
 
52
                                 char *to, uint32_t to_length,
 
53
                                 const CHARSET_INFO * const from_cs,
 
54
                                 const char *from, uint32_t from_length,
 
55
                                 uint32_t nchars,
 
56
                                 const char **well_formed_error_pos,
 
57
                                 const char **cannot_convert_error_pos,
 
58
                                 const char **from_end_pos);
 
59
 
65
60
 
66
61
class String
67
62
{
78
73
  String(char *str, uint32_t len, const CHARSET_INFO * const cs);
79
74
  String(const String &str);
80
75
 
81
 
  static void *operator new(size_t size, drizzled::memory::Root *mem_root);
 
76
  static void *operator new(size_t size, memory::Root *mem_root);
82
77
  static void operator delete(void *, size_t)
83
78
  { }
84
 
  static void operator delete(void *, drizzled::memory::Root *)
 
79
  static void operator delete(void *, memory::Root *)
85
80
  { }
86
81
  ~String();
87
82
 
291
286
    q_*** methods writes values of parameters itself
292
287
    qs_*** methods writes string representation of value
293
288
  */
294
 
  void q_append(const char c)
295
 
  {
296
 
    Ptr[str_length++] = c;
297
 
  }
298
 
  void q_append(const uint32_t n)
299
 
  {
300
 
    int4store(Ptr + str_length, n);
301
 
    str_length += 4;
302
 
  }
303
 
  void q_append(double d)
304
 
  {
305
 
    float8store(Ptr + str_length, d);
306
 
    str_length += 8;
307
 
  }
308
 
  void q_append(double *d)
309
 
  {
310
 
    float8store(Ptr + str_length, *d);
311
 
    str_length += 8;
312
 
  }
313
 
  void q_append(const char *data, uint32_t data_len)
314
 
  {
315
 
    memcpy(Ptr + str_length, data, data_len);
316
 
    str_length += data_len;
317
 
  }
318
 
 
319
 
  void write_at_position(int position, uint32_t value)
320
 
  {
321
 
    int4store(Ptr + position,value);
322
 
  }
 
289
  void q_append(const char c);
 
290
  void q_append(const uint32_t n);
 
291
  void q_append(double d);
 
292
  void q_append(double *d);
 
293
  void q_append(const char *data, uint32_t data_len);
 
294
  void write_at_position(int position, uint32_t value);
323
295
 
324
296
  /* Inline (general) functions used by the protocol functions */
325
297
 
359
331
bool check_if_only_end_space(const CHARSET_INFO * const cs, char *str,
360
332
                             char *end);
361
333
 
362
 
extern "C++" {
363
 
bool operator==(const String &s1, const String &s2);
364
 
bool operator!=(const String &s1, const String &s2);
365
 
}
 
334
} /* namespace drizzled */
 
335
 
 
336
bool operator==(const drizzled::String &s1, const drizzled::String &s2);
 
337
bool operator!=(const drizzled::String &s1, const drizzled::String &s2);
 
338
 
366
339
 
367
340
#endif /* DRIZZLED_SQL_STRING_H */