~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/varstring.h

  • Committer: Monty Taylor
  • Date: 2009-09-30 07:01:32 UTC
  • mto: This revision was merged to the branch mainline in revision 1184.
  • Revision ID: mordred@inaugust.com-20090930070132-b1ol1xu1rpajdddy
Small namespace cleanup.

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
 
#ifndef DRIZZLE_SERVER_FIELD_VARSTRING
22
 
#define DRIZZLE_SERVER_FIELD_VARSTRING
23
 
 
24
 
class Field_varstring :public Field_longstr {
 
21
#ifndef DRIZZLED_FIELD_VARSTRING_H
 
22
#define DRIZZLED_FIELD_VARSTRING_H
 
23
 
 
24
#include <drizzled/field/str.h>
 
25
#include <string>
 
26
 
 
27
class Field_varstring :public Field_str {
25
28
public:
 
29
 
 
30
  using Field::store;
 
31
  using Field::pack;
 
32
  using Field::unpack;
 
33
  using Field::val_int;
 
34
  using Field::val_str;
 
35
 
26
36
  /*
27
37
    The maximum space available in a Field_varstring, in bytes. See
28
38
    length_bytes.
33
43
  Field_varstring(unsigned char *ptr_arg,
34
44
                  uint32_t len_arg, uint32_t length_bytes_arg,
35
45
                  unsigned char *null_ptr_arg, unsigned char null_bit_arg,
36
 
                  enum utype unireg_check_arg, const char *field_name_arg,
37
 
                  TABLE_SHARE *share, const CHARSET_INFO * const cs)
38
 
    :Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
39
 
                   unireg_check_arg, field_name_arg, cs),
40
 
     length_bytes(length_bytes_arg)
41
 
  {
42
 
    share->varchar_fields++;
43
 
  }
 
46
                  enum utype unireg_check_arg, const char *field_name_arg,
 
47
                  TableShare *share, const CHARSET_INFO * const cs);
44
48
  Field_varstring(uint32_t len_arg,bool maybe_null_arg,
45
49
                  const char *field_name_arg,
46
 
                  TABLE_SHARE *share, const CHARSET_INFO * const cs)
47
 
    :Field_longstr((unsigned char*) 0,len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
48
 
                   NONE, field_name_arg, cs),
49
 
     length_bytes(len_arg < 256 ? 1 :2)
50
 
  {
51
 
    share->varchar_fields++;
52
 
  }
 
50
                  TableShare *share, const CHARSET_INFO * const cs);
53
51
 
54
52
  enum_field_types type() const { return DRIZZLE_TYPE_VARCHAR; }
55
53
  enum ha_base_keytype key_type() const;
64
62
                                    length_bytes : 0);
65
63
  }
66
64
  int  store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
 
65
 
 
66
 
67
67
  int  store(int64_t nr, bool unsigned_val);
68
68
  int  store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
69
69
  double val_real(void);
70
70
  int64_t val_int(void);
71
71
  String *val_str(String*,String *);
 
72
  inline String *val_str(String *str) { return val_str(str, str); }
72
73
  my_decimal *val_decimal(my_decimal *);
73
74
  int cmp_max(const unsigned char *, const unsigned char *, uint32_t max_length);
 
75
  inline  int cmp(const unsigned char *str) { return cmp(ptr,str); }
74
76
  int cmp(const unsigned char *a,const unsigned char *b)
75
77
  {
76
78
    return cmp_max(a, b, UINT32_MAX);
77
79
  }
78
80
  void sort_string(unsigned char *buff,uint32_t length);
79
 
  uint32_t get_key_image(unsigned char *buff,uint32_t length, imagetype type);
 
81
  uint32_t get_key_image(unsigned char *buff,uint32_t length);
 
82
  uint32_t get_key_image(std::basic_string <unsigned char> &buff, uint32_t length);
80
83
  void set_key_image(const unsigned char *buff,uint32_t length);
81
84
  void sql_type(String &str) const;
82
 
  virtual unsigned char *pack(unsigned char *to, const unsigned char *from,
83
 
                      uint32_t max_length, bool low_byte_first);
 
85
  virtual unsigned char *pack(unsigned char *to, 
 
86
                              const unsigned char *from,
 
87
                              uint32_t max_length,
 
88
                              bool low_byte_first);
 
89
 
84
90
  unsigned char *pack_key(unsigned char *to, const unsigned char *from, uint32_t max_length, bool low_byte_first);
85
 
  unsigned char *pack_key_from_key_image(unsigned char* to, const unsigned char *from,
86
 
                                 uint32_t max_length, bool low_byte_first);
87
 
  virtual const unsigned char *unpack(unsigned char* to, const unsigned char *from,
88
 
                              uint32_t param_data, bool low_byte_first);
 
91
  unsigned char *pack_key_from_key_image(unsigned char* to,
 
92
                                         const unsigned char *from,
 
93
                                         uint32_t max_length,
 
94
                                         bool low_byte_first);
 
95
  virtual const unsigned char *unpack(unsigned char* to,
 
96
                                      const unsigned char *from,
 
97
                                      uint32_t param_data,
 
98
                                      bool low_byte_first);
 
99
 
89
100
  const unsigned char *unpack_key(unsigned char* to, const unsigned char *from,
90
101
                          uint32_t max_length, bool low_byte_first);
91
102
  int pack_cmp(const unsigned char *a, const unsigned char *b, uint32_t key_length,
106
117
  Field *new_key_field(MEM_ROOT *root, Table *new_table,
107
118
                       unsigned char *new_ptr, unsigned char *new_null_ptr,
108
119
                       uint32_t new_null_bit);
109
 
  uint32_t is_equal(Create_field *new_field);
 
120
  uint32_t is_equal(CreateField *new_field);
110
121
  void hash(uint32_t *nr, uint32_t *nr2);
111
122
private:
112
123
  int do_save_field_metadata(unsigned char *first_byte);
113
124
};
114
125
 
115
 
#endif
 
126
#endif /* DRIZZLED_FIELD_VARSTRING_H */
116
127