~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/enum.h

  • Committer: Brian Aker
  • Date: 2009-08-04 06:21:17 UTC
  • mfrom: (1108.2.2 merge)
  • Revision ID: brian@gaz-20090804062117-fef8x6y3ydzrvab3
Merge Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "drizzled/field/str.h"
25
25
 
26
 
namespace drizzled
27
 
{
28
 
 
29
 
class Field_enum :public Field_str
30
 
{
 
26
class Field_enum :public Field_str 
 
27
{
 
28
protected:
 
29
  uint32_t packlength;
31
30
public:
32
31
 
33
32
  using Field::store;
35
34
  using Field::val_str;
36
35
  using Field::cmp;
37
36
 
38
 
  static const int max_supported_elements = 0x10000;
39
 
 
40
37
  /** Internal storage for the string values of the ENUM */
41
38
  TYPELIB *typelib;
42
 
  Field_enum(unsigned char *ptr_arg,
43
 
             uint32_t len_arg,
44
 
             unsigned char *null_ptr_arg,
 
39
  Field_enum(unsigned char *ptr_arg, uint32_t len_arg, unsigned char *null_ptr_arg,
45
40
             unsigned char null_bit_arg,
46
 
             const char *field_name_arg,
 
41
             enum utype unireg_check_arg, const char *field_name_arg,
 
42
             uint32_t packlength_arg,
47
43
             TYPELIB *typelib_arg,
48
44
             const CHARSET_INFO * const charset_arg)
49
 
    :Field_str(ptr_arg,
50
 
               len_arg,
51
 
               null_ptr_arg,
52
 
               null_bit_arg,
53
 
                     field_name_arg,
54
 
               charset_arg),
55
 
    typelib(typelib_arg)
 
45
    :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
 
46
               unireg_check_arg, field_name_arg, charset_arg),
 
47
    packlength(packlength_arg),typelib(typelib_arg)
56
48
  {
57
 
    flags|= ENUM_FLAG;
 
49
      flags|=ENUM_FLAG;
58
50
  }
59
 
  Field *new_field(memory::Root *root, Table *new_table, bool keep_type);
60
 
  enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
 
51
  Field *new_field(MEM_ROOT *root, Table *new_table, bool keep_type);
 
52
  enum ha_base_keytype key_type() const;
61
53
  int  store(const char *to, uint32_t length, const CHARSET_INFO * const);
62
54
  int  store(double nr);
63
55
  int  store(int64_t nr, bool unsigned_val);
81
73
  {
82
74
    return INT_RESULT;
83
75
  }
84
 
  uint32_t pack_length() const { return 4; }
 
76
  uint32_t pack_length() const
 
77
  {
 
78
    return (uint32_t) packlength;
 
79
  }
85
80
  uint32_t size_of() const
86
81
  {
87
82
    return sizeof(*this);
90
85
  {
91
86
    return DRIZZLE_TYPE_ENUM;
92
87
  }
 
88
  uint32_t pack_length_from_metadata(uint32_t field_metadata)
 
89
  {
 
90
    return (field_metadata & 0x00ff);
 
91
  }
 
92
  uint32_t row_pack_length()
 
93
  { 
 
94
    return pack_length();
 
95
  }
93
96
  virtual bool zero_pack() const
94
97
  {
95
98
    return false;
96
99
  }
97
 
  bool optimize_range(uint32_t, uint32_t)
 
100
  bool optimize_range(uint32_t, uint32_t) 
98
101
  {
99
102
    return false;
100
103
  }
104
107
  }
105
108
  /* enum and set are sorted as integers */
106
109
  const CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; }
 
110
private:
 
111
  int do_save_field_metadata(unsigned char *first_byte);
107
112
};
108
113
 
109
 
} /* namespace drizzled */
110
 
 
111
114
#endif /* DRIZZLED_FIELD_ENUM_H */