~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_string.h

  • Committer: Tim Penhey
  • Date: 2010-01-20 02:39:01 UTC
  • mto: This revision was merged to the branch mainline in revision 1275.
  • Revision ID: tim.penhey@canonical.com-20100120023901-8teeunid6gwlthzx
Add in a rot 13 function.

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
 
25
30
#include <drizzled/common.h>
26
31
#include <cassert>
27
32
#include <cstdlib>
28
33
#include <cstring>
29
 
#include <string>
30
 
 
31
 
#ifndef NOT_FIXED_DEC
32
 
#define NOT_FIXED_DEC                   (uint8_t)31
33
 
#endif
34
 
 
35
 
namespace drizzled
36
 
{
37
34
 
38
35
class String;
39
36
 
40
37
extern String my_empty_string;
41
38
extern const String my_null_string;
42
 
namespace memory { class Root; }
 
39
namespace drizzled { namespace memory { class Root; } }
43
40
typedef struct charset_info_st CHARSET_INFO;
44
41
 
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
 
 
 
42
#if defined(__cplusplus)
 
43
extern "C" {
 
44
#endif
 
45
 
 
46
  int sortcmp(const String *a,const String *b, const CHARSET_INFO * const cs);
 
47
  int stringcmp(const String *a,const String *b);
 
48
  String *copy_if_not_alloced(String *a,String *b,uint32_t arg_length);
 
49
  uint32_t well_formed_copy_nchars(const CHARSET_INFO * const to_cs,
 
50
                                   char *to, uint32_t to_length,
 
51
                                   const CHARSET_INFO * const from_cs,
 
52
                                   const char *from, uint32_t from_length,
 
53
                                   uint32_t nchars,
 
54
                                   const char **well_formed_error_pos,
 
55
                                   const char **cannot_convert_error_pos,
 
56
                                   const char **from_end_pos);
 
57
 
 
58
#if defined(__cplusplus)
 
59
}
 
60
#endif
60
61
 
61
62
class String
62
63
{
73
74
  String(char *str, uint32_t len, const CHARSET_INFO * const cs);
74
75
  String(const String &str);
75
76
 
76
 
  static void *operator new(size_t size, memory::Root *mem_root);
 
77
  static void *operator new(size_t size, drizzled::memory::Root *mem_root);
77
78
  static void operator delete(void *, size_t)
78
79
  { }
79
 
  static void operator delete(void *, memory::Root *)
 
80
  static void operator delete(void *, drizzled::memory::Root *)
80
81
  { }
81
82
  ~String();
82
83
 
114
115
      (void) realloc(str_length);
115
116
    return Ptr;
116
117
  }
117
 
  inline char *c_str()
118
 
  {
119
 
    if (Ptr && str_length < Alloced_length)
120
 
      Ptr[str_length]=0;
121
 
    else
122
 
      (void) realloc(str_length);
123
 
    return Ptr;
124
 
  }
125
118
  void append_identifier(const char *name, uint32_t length);
126
119
 
127
120
  void set(String &str,uint32_t offset,uint32_t arg_length)
294
287
    q_*** methods writes values of parameters itself
295
288
    qs_*** methods writes string representation of value
296
289
  */
297
 
  void q_append(const char c);
298
 
  void q_append(const uint32_t n);
299
 
  void q_append(double d);
300
 
  void q_append(double *d);
301
 
  void q_append(const char *data, uint32_t data_len);
302
 
  void write_at_position(int position, uint32_t value);
 
290
  void q_append(const char c)
 
291
  {
 
292
    Ptr[str_length++] = c;
 
293
  }
 
294
  void q_append(const uint32_t n)
 
295
  {
 
296
    int4store(Ptr + str_length, n);
 
297
    str_length += 4;
 
298
  }
 
299
  void q_append(double d)
 
300
  {
 
301
    float8store(Ptr + str_length, d);
 
302
    str_length += 8;
 
303
  }
 
304
  void q_append(double *d)
 
305
  {
 
306
    float8store(Ptr + str_length, *d);
 
307
    str_length += 8;
 
308
  }
 
309
  void q_append(const char *data, uint32_t data_len)
 
310
  {
 
311
    memcpy(Ptr + str_length, data, data_len);
 
312
    str_length += data_len;
 
313
  }
 
314
 
 
315
  void write_at_position(int position, uint32_t value)
 
316
  {
 
317
    int4store(Ptr + position,value);
 
318
  }
303
319
 
304
320
  /* Inline (general) functions used by the protocol functions */
305
321
 
339
355
bool check_if_only_end_space(const CHARSET_INFO * const cs, char *str,
340
356
                             char *end);
341
357
 
342
 
} /* namespace drizzled */
343
 
 
344
 
bool operator==(const drizzled::String &s1, const drizzled::String &s2);
345
 
bool operator!=(const drizzled::String &s1, const drizzled::String &s2);
346
 
 
 
358
extern "C++" {
 
359
bool operator==(const String &s1, const String &s2);
 
360
bool operator!=(const String &s1, const String &s2);
 
361
}
347
362
 
348
363
#endif /* DRIZZLED_SQL_STRING_H */