~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/enum.h

Merge Stewarts cleanup for proto on tinyint

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
39
  Field_enum(unsigned char *ptr_arg,
44
41
             unsigned char *null_ptr_arg,
45
42
             unsigned char null_bit_arg,
46
43
             const char *field_name_arg,
 
44
             uint32_t packlength_arg,
47
45
             TYPELIB *typelib_arg,
48
46
             const CHARSET_INFO * const charset_arg)
49
47
    :Field_str(ptr_arg,
52
50
               null_bit_arg,
53
51
                     field_name_arg,
54
52
               charset_arg),
 
53
    packlength(packlength_arg),
55
54
    typelib(typelib_arg)
56
55
  {
57
56
    flags|= ENUM_FLAG;
58
57
  }
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; }
 
58
  Field *new_field(MEM_ROOT *root, Table *new_table, bool keep_type);
 
59
  enum ha_base_keytype key_type() const;
61
60
  int  store(const char *to, uint32_t length, const CHARSET_INFO * const);
62
61
  int  store(double nr);
63
62
  int  store(int64_t nr, bool unsigned_val);
81
80
  {
82
81
    return INT_RESULT;
83
82
  }
84
 
  uint32_t pack_length() const { return 4; }
 
83
  uint32_t pack_length() const
 
84
  {
 
85
    return (uint32_t) packlength;
 
86
  }
85
87
  uint32_t size_of() const
86
88
  {
87
89
    return sizeof(*this);
90
92
  {
91
93
    return DRIZZLE_TYPE_ENUM;
92
94
  }
 
95
  uint32_t pack_length_from_metadata(uint32_t field_metadata)
 
96
  {
 
97
    return (field_metadata & 0x00ff);
 
98
  }
 
99
  uint32_t row_pack_length()
 
100
  { 
 
101
    return pack_length();
 
102
  }
93
103
  virtual bool zero_pack() const
94
104
  {
95
105
    return false;
96
106
  }
97
 
  bool optimize_range(uint32_t, uint32_t)
 
107
  bool optimize_range(uint32_t, uint32_t) 
98
108
  {
99
109
    return false;
100
110
  }
104
114
  }
105
115
  /* enum and set are sorted as integers */
106
116
  const CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; }
 
117
private:
 
118
  int do_save_field_metadata(unsigned char *first_byte);
107
119
};
108
120
 
109
 
} /* namespace drizzled */
110
 
 
111
121
#endif /* DRIZZLED_FIELD_ENUM_H */