~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/blob.h

Merge Monty - Updates to pandora-build to support features of gcc 4.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#pragma once
 
21
#ifndef DRIZZLED_FIELD_BLOB_H
 
22
#define DRIZZLED_FIELD_BLOB_H
22
23
 
23
24
#include <drizzled/field/str.h>
24
 
#include <drizzled/charset.h>
 
25
 
 
26
#include "drizzled/global_charset_info.h"
 
27
 
25
28
#include <string>
26
 
#include <drizzled/visibility.h>
27
29
 
28
 
namespace drizzled {
 
30
namespace drizzled
 
31
{
29
32
 
30
33
/**
31
34
 * Class representing a BLOB data type column
32
35
 */
33
 
class DRIZZLED_API Field_blob :
34
 
  public Field_str
35
 
{
 
36
class Field_blob :public Field_str {
36
37
protected:
37
38
  String value;                         // For temporaries
38
39
public:
49
50
             unsigned char null_bit_arg,
50
51
             const char *field_name_arg,
51
52
             TableShare *share,
52
 
             const charset_info_st * const cs);
 
53
             const CHARSET_INFO * const cs);
53
54
  Field_blob(uint32_t len_arg,
54
55
             bool maybe_null_arg,
55
56
             const char *field_name_arg,
56
 
             const charset_info_st * const cs)
 
57
             const CHARSET_INFO * const cs)
57
58
    :Field_str((unsigned char*) NULL,
58
59
               len_arg,
59
60
               maybe_null_arg ? (unsigned char *) "": 0,
68
69
  enum ha_base_keytype key_type() const
69
70
    { return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
70
71
  int  store(const char *to,uint32_t length,
71
 
             const charset_info_st * const charset);
 
72
             const CHARSET_INFO * const charset);
72
73
  int  store(double nr);
73
74
  int  store(int64_t nr, bool unsigned_val);
74
75
 
75
 
  double val_real(void) const;
76
 
  int64_t val_int(void) const;
77
 
  String *val_str(String*,String *) const;
78
 
  type::Decimal *val_decimal(type::Decimal *) const;
 
76
  double val_real(void);
 
77
  int64_t val_int(void);
 
78
  String *val_str(String*,String *);
 
79
  my_decimal *val_decimal(my_decimal *);
79
80
  int cmp_max(const unsigned char *, const unsigned char *, uint32_t max_length);
80
81
  int cmp(const unsigned char *a,const unsigned char *b)
81
82
    { return cmp_max(a, b, UINT32_MAX); }
127
128
  */
128
129
  uint32_t get_packed_size(const unsigned char *ptr_arg, bool low_byte_first);
129
130
 
130
 
  DRIZZLED_API uint32_t get_length(uint32_t row_offset= 0) const;
131
 
  DRIZZLED_API uint32_t get_length(const unsigned char *ptr, bool low_byte_first) const;
132
 
  DRIZZLED_API uint32_t get_length(const unsigned char *ptr_arg) const;
 
131
  uint32_t get_length(uint32_t row_offset= 0);
 
132
  uint32_t get_length(const unsigned char *ptr, bool low_byte_first);
 
133
  uint32_t get_length(const unsigned char *ptr_arg);
133
134
  void put_length(unsigned char *pos, uint32_t length);
134
 
  inline unsigned char* get_ptr() const
135
 
    {
136
 
      unsigned char* str;
137
 
      memcpy(&str, ptr + sizeof(uint32_t), sizeof(unsigned char*));
138
 
      return str;
 
135
  inline void get_ptr(unsigned char **str)
 
136
    {
 
137
      memcpy(str,ptr+sizeof(uint32_t),sizeof(unsigned char*));
 
138
    }
 
139
  inline void get_ptr(unsigned char **str, uint32_t row_offset)
 
140
    {
 
141
      memcpy(str,ptr+sizeof(uint32_t)+row_offset,sizeof(char*));
139
142
    }
140
143
  inline void set_ptr(unsigned char *length, unsigned char *data)
141
144
    {
155
158
  uint32_t get_key_image(unsigned char *buff,uint32_t length);
156
159
  uint32_t get_key_image(std::basic_string<unsigned char> &buff, uint32_t length);
157
160
  void set_key_image(const unsigned char *buff,uint32_t length);
158
 
  inline void copy()
 
161
  void sql_type(String &str) const;
 
162
  inline bool copy()
159
163
  {
160
 
    value.copy((char*)get_ptr(), get_length(), charset());
161
 
    char* tmp= value.ptr();
162
 
    memcpy(ptr + sizeof(uint32_t), &tmp, sizeof(char*));
 
164
    unsigned char *tmp;
 
165
    get_ptr(&tmp);
 
166
    if (value.copy((char*) tmp, get_length(), charset()))
 
167
    {
 
168
      Field_blob::reset();
 
169
      return 1;
 
170
    }
 
171
    tmp=(unsigned char*) value.ptr();
 
172
    memcpy(ptr+sizeof(uint32_t),&tmp,sizeof(char*));
 
173
    return 0;
163
174
  }
164
 
  virtual unsigned char *pack(unsigned char *to, const unsigned char *from, uint32_t max_length, bool low_byte_first);
165
 
  unsigned char *pack_key(unsigned char *to, const unsigned char *from, uint32_t max_length, bool low_byte_first);
166
 
  virtual const unsigned char *unpack(unsigned char *to, const unsigned char *from, uint32_t , bool low_byte_first);
 
175
  virtual unsigned char *pack(unsigned char *to, const unsigned char *from,
 
176
                      uint32_t max_length, bool low_byte_first);
 
177
  unsigned char *pack_key(unsigned char *to, const unsigned char *from,
 
178
                  uint32_t max_length, bool low_byte_first);
 
179
  virtual const unsigned char *unpack(unsigned char *to, const unsigned char *from,
 
180
                              uint32_t , bool low_byte_first);
167
181
  void free() { value.free(); }
 
182
  inline void clear_temporary() { memset(&value, 0, sizeof(value)); }
168
183
  friend int field_conv(Field *to,Field *from);
169
184
  uint32_t size_of() const { return sizeof(*this); }
170
185
  bool has_charset(void) const
171
 
  { return charset() != &my_charset_bin; }
 
186
  { return charset() == &my_charset_bin ? false : true; }
172
187
  uint32_t max_display_length();
173
188
};
174
189
 
175
190
} /* namespace drizzled */
176
191
 
 
192
#endif /* DRIZZLED_FIELD_BLOB_H */
177
193