~drizzle-trunk/drizzle/development

466 by Monty Taylor
Fixed modelines... these files are c++.
1
/* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
438.4.1 by Lee
breaking out enum field classes
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
#ifndef DRIZZLE_SERVER_FIELD_ENUM
22
#define DRIZZLE_SERVER_FIELD_ENUM
23
584.5.1 by Monty Taylor
Removed field includes from field.h.
24
#include <drizzled/field/str.h>
25
438.4.1 by Lee
breaking out enum field classes
26
class Field_enum :public Field_str {
27
protected:
482 by Brian Aker
Remove uint.
28
  uint32_t packlength;
438.4.1 by Lee
breaking out enum field classes
29
public:
892.1.2 by Monty Taylor
Fixed solaris warnings.
30
31
  using Field::store;
32
  using Field::val_int;
33
  using Field::val_str;
34
  using Field::cmp;
35
438.4.1 by Lee
breaking out enum field classes
36
  TYPELIB *typelib;
481 by Brian Aker
Remove all of uchar.
37
  Field_enum(unsigned char *ptr_arg, uint32_t len_arg, unsigned char *null_ptr_arg,
38
             unsigned char null_bit_arg,
438.4.1 by Lee
breaking out enum field classes
39
             enum utype unireg_check_arg, const char *field_name_arg,
482 by Brian Aker
Remove uint.
40
             uint32_t packlength_arg,
438.4.1 by Lee
breaking out enum field classes
41
             TYPELIB *typelib_arg,
42
             const CHARSET_INFO * const charset_arg)
43
    :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
44
	       unireg_check_arg, field_name_arg, charset_arg),
45
    packlength(packlength_arg),typelib(typelib_arg)
46
  {
47
      flags|=ENUM_FLAG;
48
  }
49
  Field *new_field(MEM_ROOT *root, Table *new_table, bool keep_type);
50
  enum_field_types type() const { return DRIZZLE_TYPE_ENUM; }
51
  enum Item_result cmp_type () const { return INT_RESULT; }
52
  enum Item_result cast_to_int_type () const { return INT_RESULT; }
53
  enum ha_base_keytype key_type() const;
482 by Brian Aker
Remove uint.
54
  int  store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
438.4.1 by Lee
breaking out enum field classes
55
  int  store(double nr);
56
  int  store(int64_t nr, bool unsigned_val);
57
  double val_real(void);
58
  int64_t val_int(void);
59
  String *val_str(String*,String *);
481 by Brian Aker
Remove all of uchar.
60
  int cmp(const unsigned char *,const unsigned char *);
482 by Brian Aker
Remove uint.
61
  void sort_string(unsigned char *buff,uint32_t length);
438.4.1 by Lee
breaking out enum field classes
62
  uint32_t pack_length() const { return (uint32_t) packlength; }
63
  void store_type(uint64_t value);
64
  void sql_type(String &str) const;
482 by Brian Aker
Remove uint.
65
  uint32_t size_of() const { return sizeof(*this); }
438.4.1 by Lee
breaking out enum field classes
66
  enum_field_types real_type() const { return DRIZZLE_TYPE_ENUM; }
482 by Brian Aker
Remove uint.
67
  uint32_t pack_length_from_metadata(uint32_t field_metadata)
438.4.1 by Lee
breaking out enum field classes
68
  { return (field_metadata & 0x00ff); }
482 by Brian Aker
Remove uint.
69
  uint32_t row_pack_length() { return pack_length(); }
438.4.1 by Lee
breaking out enum field classes
70
  virtual bool zero_pack() const { return 0; }
646 by Brian Aker
Next pass through attribute.
71
  bool optimize_range(uint32_t, uint32_t)
438.4.1 by Lee
breaking out enum field classes
72
  { return 0; }
73
  bool eq_def(Field *field);
74
  bool has_charset(void) const { return true; }
75
  /* enum and set are sorted as integers */
76
  const CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; }
77
private:
481 by Brian Aker
Remove all of uchar.
78
  int do_save_field_metadata(unsigned char *first_byte);
438.4.1 by Lee
breaking out enum field classes
79
};
80
81
#endif