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 |
||
934.4.1
by Jay Pipes
Fixes ENUM field type to throw an error on bad data input. 0 is now not |
21 |
#ifndef DRIZZLED_FIELD_ENUM_H
|
22 |
#define DRIZZLED_FIELD_ENUM_H
|
|
23 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
24 |
#include <drizzled/field/str.h> |
934.4.1
by Jay Pipes
Fixes ENUM field type to throw an error on bad data input. 0 is now not |
25 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
26 |
namespace drizzled |
27 |
{
|
|
28 |
||
1579.3.1
by Stewart Smith
fix trailing whitespace in field/enum |
29 |
class Field_enum :public Field_str |
934.4.1
by Jay Pipes
Fixes ENUM field type to throw an error on bad data input. 0 is now not |
30 |
{
|
438.4.1
by Lee
breaking out enum field classes |
31 |
public: |
892.1.2
by Monty Taylor
Fixed solaris warnings. |
32 |
|
33 |
using Field::store; |
|
34 |
using Field::val_int; |
|
35 |
using Field::val_str; |
|
36 |
using Field::cmp; |
|
37 |
||
1579.3.14
by Stewart Smith
have a constant for the maximum number of enum elements |
38 |
static const int max_supported_elements = 0x10000; |
39 |
||
934.4.1
by Jay Pipes
Fixes ENUM field type to throw an error on bad data input. 0 is now not |
40 |
/** Internal storage for the string values of the ENUM */
|
438.4.1
by Lee
breaking out enum field classes |
41 |
TYPELIB *typelib; |
1119.9.12
by Jay Pipes
First phase removal of MTYP_TYPENR() macro. This removes the unireg_check argument for all Field types where it is irrelevant (everything but numeric types and timestamp. |
42 |
Field_enum(unsigned char *ptr_arg, |
43 |
uint32_t len_arg, |
|
44 |
unsigned char *null_ptr_arg, |
|
481
by Brian Aker
Remove all of uchar. |
45 |
unsigned char null_bit_arg, |
1119.9.12
by Jay Pipes
First phase removal of MTYP_TYPENR() macro. This removes the unireg_check argument for all Field types where it is irrelevant (everything but numeric types and timestamp. |
46 |
const char *field_name_arg, |
438.4.1
by Lee
breaking out enum field classes |
47 |
TYPELIB *typelib_arg, |
48 |
const CHARSET_INFO * const charset_arg) |
|
1119.9.12
by Jay Pipes
First phase removal of MTYP_TYPENR() macro. This removes the unireg_check argument for all Field types where it is irrelevant (everything but numeric types and timestamp. |
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) |
|
438.4.1
by Lee
breaking out enum field classes |
56 |
{
|
1119.9.14
by Jay Pipes
Style cleanups after review. Thanks Monty :) |
57 |
flags|= ENUM_FLAG; |
438.4.1
by Lee
breaking out enum field classes |
58 |
}
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
59 |
Field *new_field(memory::Root *root, Table *new_table, bool keep_type); |
1782.4.4
by Brian Aker
Fix enum at being an intefer (which is what PG did, and it saves on |
60 |
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } |
934.4.1
by Jay Pipes
Fixes ENUM field type to throw an error on bad data input. 0 is now not |
61 |
int store(const char *to, uint32_t length, const CHARSET_INFO * const); |
438.4.1
by Lee
breaking out enum field classes |
62 |
int store(double nr); |
63 |
int store(int64_t nr, bool unsigned_val); |
|
2181.2.1
by Brian Aker
Protect all of the val_* methods from modification. |
64 |
double val_real(void) const; |
65 |
int64_t val_int(void) const; |
|
66 |
String *val_str(String*, String *) const; |
|
934.4.1
by Jay Pipes
Fixes ENUM field type to throw an error on bad data input. 0 is now not |
67 |
int cmp(const unsigned char *, const unsigned char *); |
68 |
void sort_string(unsigned char *buff, uint32_t length); |
|
438.4.1
by Lee
breaking out enum field classes |
69 |
void store_type(uint64_t value); |
70 |
void sql_type(String &str) const; |
|
934.4.1
by Jay Pipes
Fixes ENUM field type to throw an error on bad data input. 0 is now not |
71 |
bool eq_def(Field *field); |
72 |
enum_field_types type() const |
|
73 |
{
|
|
74 |
return DRIZZLE_TYPE_ENUM; |
|
75 |
}
|
|
76 |
enum Item_result cmp_type () const |
|
77 |
{
|
|
78 |
return INT_RESULT; |
|
79 |
}
|
|
80 |
enum Item_result cast_to_int_type () const |
|
81 |
{
|
|
82 |
return INT_RESULT; |
|
83 |
}
|
|
1782.4.4
by Brian Aker
Fix enum at being an intefer (which is what PG did, and it saves on |
84 |
uint32_t pack_length() const { return 4; } |
934.4.1
by Jay Pipes
Fixes ENUM field type to throw an error on bad data input. 0 is now not |
85 |
uint32_t size_of() const |
86 |
{
|
|
87 |
return sizeof(*this); |
|
88 |
}
|
|
89 |
enum_field_types real_type() const |
|
90 |
{
|
|
91 |
return DRIZZLE_TYPE_ENUM; |
|
92 |
}
|
|
93 |
virtual bool zero_pack() const |
|
94 |
{
|
|
95 |
return false; |
|
96 |
}
|
|
1579.3.4
by Stewart Smith
fix trailing whitespace in field/enum |
97 |
bool optimize_range(uint32_t, uint32_t) |
934.4.1
by Jay Pipes
Fixes ENUM field type to throw an error on bad data input. 0 is now not |
98 |
{
|
99 |
return false; |
|
100 |
}
|
|
101 |
bool has_charset(void) const |
|
102 |
{
|
|
103 |
return true; |
|
104 |
}
|
|
438.4.1
by Lee
breaking out enum field classes |
105 |
/* enum and set are sorted as integers */
|
106 |
const CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; } |
|
107 |
};
|
|
108 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
109 |
} /* namespace drizzled */ |
110 |
||
934.4.1
by Jay Pipes
Fixes ENUM field type to throw an error on bad data input. 0 is now not |
111 |
#endif /* DRIZZLED_FIELD_ENUM_H */ |