Drizzled Public API Documentation

enum.h
1 /* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2008 MySQL
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #pragma once
22 
23 #include <drizzled/field/str.h>
24 
25 namespace drizzled
26 {
27 
28 class Field_enum :public Field_str
29 {
30 public:
31 
32  using Field::store;
33  using Field::val_int;
34  using Field::val_str;
35  using Field::cmp;
36 
37  static const int max_supported_elements = 0x10000;
38 
41  Field_enum(unsigned char *ptr_arg,
42  uint32_t len_arg,
43  unsigned char *null_ptr_arg,
44  unsigned char null_bit_arg,
45  const char *field_name_arg,
46  TYPELIB *typelib_arg,
47  const charset_info_st * const charset_arg)
48  :Field_str(ptr_arg,
49  len_arg,
50  null_ptr_arg,
51  null_bit_arg,
52  field_name_arg,
53  charset_arg),
54  typelib(typelib_arg)
55  {
56  flags|= ENUM_FLAG;
57  }
58  Field *new_field(memory::Root *root, Table *new_table, bool keep_type);
59  enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
60  int store(const char *to, uint32_t length, const charset_info_st * const);
61  int store(double nr);
62  int store(int64_t nr, bool unsigned_val);
63  double val_real(void) const;
64  int64_t val_int(void) const;
65  String *val_str(String*, String *) const;
66  int cmp(const unsigned char *, const unsigned char *);
67  void sort_string(unsigned char *buff, uint32_t length);
68  void store_type(uint64_t value);
69  bool eq_def(Field *field);
70  enum_field_types type() const
71  {
72  return DRIZZLE_TYPE_ENUM;
73  }
74  enum Item_result cmp_type () const
75  {
76  return INT_RESULT;
77  }
78  enum Item_result cast_to_int_type () const
79  {
80  return INT_RESULT;
81  }
82  uint32_t pack_length() const { return 4; }
83  uint32_t size_of() const
84  {
85  return sizeof(*this);
86  }
87  enum_field_types real_type() const
88  {
89  return DRIZZLE_TYPE_ENUM;
90  }
91  virtual bool zero_pack() const
92  {
93  return false;
94  }
95  bool optimize_range(uint32_t, uint32_t)
96  {
97  return false;
98  }
99  bool has_charset(void) const
100  {
101  return true;
102  }
103  /* enum and set are sorted as integers */
104  const charset_info_st *sort_charset(void) const { return &my_charset_bin; }
105 };
106 
107 } /* namespace drizzled */
108 
Field(unsigned char *ptr_arg, uint32_t length_arg, unsigned char *null_ptr_arg, unsigned char null_bit_arg, utype unireg_check_arg, const char *field_name_arg)
This is used as a table name when the table structure is not set up.
Definition: field.cc:892
TYPELIB * typelib
Definition: enum.h:40
int store(const char *to, uint32_t length, const charset_info_st *const)
Definition: enum.cc:59
uint32_t pack_length() const
Definition: enum.h:82
bool eq_def(Field *field)
Definition: field.cc:1151