~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/field/blob.h

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#pragma once
22
22
 
23
23
#include <drizzled/field/str.h>
24
 
 
25
 
#include <drizzled/global_charset_info.h>
26
 
 
 
24
#include <drizzled/charset.h>
27
25
#include <string>
28
 
 
29
26
#include <drizzled/visibility.h>
30
27
 
31
 
namespace drizzled
32
 
{
 
28
namespace drizzled {
33
29
 
34
30
/**
35
31
 * Class representing a BLOB data type column
53
49
             unsigned char null_bit_arg,
54
50
             const char *field_name_arg,
55
51
             TableShare *share,
56
 
             const CHARSET_INFO * const cs);
 
52
             const charset_info_st * const cs);
57
53
  Field_blob(uint32_t len_arg,
58
54
             bool maybe_null_arg,
59
55
             const char *field_name_arg,
60
 
             const CHARSET_INFO * const cs)
 
56
             const charset_info_st * const cs)
61
57
    :Field_str((unsigned char*) NULL,
62
58
               len_arg,
63
59
               maybe_null_arg ? (unsigned char *) "": 0,
72
68
  enum ha_base_keytype key_type() const
73
69
    { return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
74
70
  int  store(const char *to,uint32_t length,
75
 
             const CHARSET_INFO * const charset);
 
71
             const charset_info_st * const charset);
76
72
  int  store(double nr);
77
73
  int  store(int64_t nr, bool unsigned_val);
78
74
 
135
131
  DRIZZLED_API uint32_t get_length(const unsigned char *ptr, bool low_byte_first) const;
136
132
  DRIZZLED_API uint32_t get_length(const unsigned char *ptr_arg) const;
137
133
  void put_length(unsigned char *pos, uint32_t length);
138
 
  inline void get_ptr(unsigned char **str)
139
 
    {
140
 
      memcpy(str,ptr+sizeof(uint32_t),sizeof(unsigned char*));
141
 
    }
142
 
  inline void get_ptr(unsigned char **str, uint32_t row_offset)
143
 
    {
144
 
      memcpy(str,ptr+sizeof(uint32_t)+row_offset,sizeof(char*));
 
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;
145
139
    }
146
140
  inline void set_ptr(unsigned char *length, unsigned char *data)
147
141
    {
161
155
  uint32_t get_key_image(unsigned char *buff,uint32_t length);
162
156
  uint32_t get_key_image(std::basic_string<unsigned char> &buff, uint32_t length);
163
157
  void set_key_image(const unsigned char *buff,uint32_t length);
164
 
  void sql_type(String &str) const;
165
 
  inline bool copy()
 
158
  inline void copy()
166
159
  {
167
 
    unsigned char *tmp;
168
 
    get_ptr(&tmp);
169
 
    if (value.copy((char*) tmp, get_length(), charset()))
170
 
    {
171
 
      Field_blob::reset();
172
 
      return 1;
173
 
    }
174
 
    tmp=(unsigned char*) value.ptr();
175
 
    memcpy(ptr+sizeof(uint32_t),&tmp,sizeof(char*));
176
 
    return 0;
 
160
    value.copy((char*)get_ptr(), get_length(), charset());
 
161
    char* tmp= value.ptr();
 
162
    memcpy(ptr + sizeof(uint32_t), &tmp, sizeof(char*));
177
163
  }
178
 
  virtual unsigned char *pack(unsigned char *to, const unsigned char *from,
179
 
                      uint32_t max_length, bool low_byte_first);
180
 
  unsigned char *pack_key(unsigned char *to, const unsigned char *from,
181
 
                  uint32_t max_length, bool low_byte_first);
182
 
  virtual const unsigned char *unpack(unsigned char *to, const unsigned char *from,
183
 
                              uint32_t , bool low_byte_first);
 
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);
184
167
  void free() { value.free(); }
185
 
  inline void clear_temporary() { memset(&value, 0, sizeof(value)); }
186
168
  friend int field_conv(Field *to,Field *from);
187
169
  uint32_t size_of() const { return sizeof(*this); }
188
170
  bool has_charset(void) const
189
 
  { return charset() == &my_charset_bin ? false : true; }
 
171
  { return charset() != &my_charset_bin; }
190
172
  uint32_t max_display_length();
191
173
};
192
174