~drizzle-trunk/drizzle/development

584.4.10 by Monty Taylor
Broke out cached_item.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
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; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
20
#ifndef DRIZZLED_CACHED_ITEM_H
21
#define DRIZZLED_CACHED_ITEM_H
22
23
#include <drizzled/sql_alloc.h>
24
#include <drizzled/sql_string.h>
25
26
class Item;
27
class Session;
28
29
class Cached_item :public Sql_alloc
30
{
31
public:
32
  bool null_value;
33
  Cached_item() :null_value(0) {}
34
  virtual bool cmp(void)=0;
35
  virtual ~Cached_item(); /*line -e1509 */
36
};
37
38
class Cached_item_str :public Cached_item
39
{
40
  Item *item;
41
  String value,tmp_value;
42
public:
43
  Cached_item_str(Session *session, Item *arg);
44
  bool cmp(void);
45
  ~Cached_item_str();                           // Deallocate String:s
46
};
47
48
49
class Cached_item_real :public Cached_item
50
{
51
  Item *item;
52
  double value;
53
public:
54
  Cached_item_real(Item *item_par) :item(item_par),value(0.0) {}
55
  bool cmp(void);
56
};
57
58
class Cached_item_int :public Cached_item
59
{
60
  Item *item;
61
  int64_t value;
62
public:
63
  Cached_item_int(Item *item_par) :item(item_par),value(0) {}
64
  bool cmp(void);
65
};
66
67
68
class Cached_item_decimal :public Cached_item
69
{
70
  Item *item;
71
  my_decimal value;
72
public:
73
  Cached_item_decimal(Item *item_par);
74
  bool cmp(void);
75
};
76
77
class Cached_item_field :public Cached_item
78
{
79
  unsigned char *buff;
80
  Field *field;
81
  uint32_t length;
82
83
public:
84
  Cached_item_field(Field *arg_field) : field(arg_field)
85
  {
86
    field= arg_field;
87
    /* TODO: take the memory allocation below out of the constructor. */
88
    buff= (unsigned char*) sql_calloc(length=field->pack_length());
89
  }
90
  bool cmp(void);
91
};
92
93
Cached_item *new_Cached_item(Session *session, Item *item,
94
                             bool use_result_field);
95
96
#endif /* DRIZZLED_CACHED_ITEM_H */