~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_string.h

* Renames Ha_trx_info to drizzled::ResourceContext
* Renames Sesssion_TRANS to drizzled::TransactionContext
* Replaces homegrown linked-lists of Ha_trx_info pointers
  with vector<drizzled::ResourceContext> operations
* Renames Session::getEngineInfo() to Session::getResourceContext()

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
34
#include <string>
30
35
 
31
 
#ifndef NOT_FIXED_DEC
32
 
#define NOT_FIXED_DEC                   (uint8_t)31
33
 
#endif
34
 
 
35
 
namespace drizzled
36
 
{
37
 
 
38
36
class String;
39
37
 
40
38
extern String my_empty_string;
41
39
extern const String my_null_string;
42
 
namespace memory { class Root; }
 
40
namespace drizzled { namespace memory { class Root; } }
43
41
typedef struct charset_info_st CHARSET_INFO;
44
42
 
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
 
 
 
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
60
65
 
61
66
class String
62
67
{
73
78
  String(char *str, uint32_t len, const CHARSET_INFO * const cs);
74
79
  String(const String &str);
75
80
 
76
 
  static void *operator new(size_t size, memory::Root *mem_root);
 
81
  static void *operator new(size_t size, drizzled::memory::Root *mem_root);
77
82
  static void operator delete(void *, size_t)
78
83
  { }
79
 
  static void operator delete(void *, memory::Root *)
 
84
  static void operator delete(void *, drizzled::memory::Root *)
80
85
  { }
81
86
  ~String();
82
87
 
114
119
      (void) realloc(str_length);
115
120
    return Ptr;
116
121
  }
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
122
  void append_identifier(const char *name, uint32_t length);
126
123
 
127
124
  void set(String &str,uint32_t offset,uint32_t arg_length)
294
291
    q_*** methods writes values of parameters itself
295
292
    qs_*** methods writes string representation of value
296
293
  */
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);
 
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
  }
303
323
 
304
324
  /* Inline (general) functions used by the protocol functions */
305
325
 
339
359
bool check_if_only_end_space(const CHARSET_INFO * const cs, char *str,
340
360
                             char *end);
341
361
 
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
 
 
 
362
extern "C++" {
 
363
bool operator==(const String &s1, const String &s2);
 
364
bool operator!=(const String &s1, const String &s2);
 
365
}
347
366
 
348
367
#endif /* DRIZZLED_SQL_STRING_H */