~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/float.h

  • Committer: Brian Aker
  • Date: 2010-02-07 01:33:54 UTC
  • Revision ID: brian@gaz-20100207013354-d2pg1n68u5c09pgo
Remove giant include header to its own file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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_ITEM_FLOAT_H
 
21
#define DRIZZLED_ITEM_FLOAT_H
 
22
 
 
23
#include <drizzled/item/num.h>
 
24
 
 
25
namespace drizzled
 
26
{
 
27
 
 
28
class Item_float :public Item_num
 
29
{
 
30
  char *presentation;
 
31
public:
 
32
  double value;
 
33
  // Item_real() :value(0) {}
 
34
  Item_float(const char *str_arg, uint32_t length);
 
35
  Item_float(const char *str,double val_arg,uint32_t decimal_par,uint32_t length)
 
36
    :value(val_arg)
 
37
  {
 
38
    presentation= name=(char*) str;
 
39
    decimals=(uint8_t) decimal_par;
 
40
    max_length=length;
 
41
    fixed= 1;
 
42
  }
 
43
  Item_float(double value_par, uint32_t decimal_par) :presentation(0), value(value_par)
 
44
  {
 
45
    decimals= (uint8_t) decimal_par;
 
46
    fixed= 1;
 
47
  }
 
48
  int save_in_field(Field *field, bool no_conversions);
 
49
  enum Type type() const { return REAL_ITEM; }
 
50
  enum_field_types field_type() const { return DRIZZLE_TYPE_DOUBLE; }
 
51
  double val_real() { assert(fixed == 1); return value; }
 
52
  int64_t val_int();
 
53
  String *val_str(String*);
 
54
  my_decimal *val_decimal(my_decimal *);
 
55
  bool basic_const_item() const { return 1; }
 
56
  Item *clone_item()
 
57
  { return new Item_float(name, value, decimals, max_length); }
 
58
  Item_num *neg() { value= -value; return this; }
 
59
  virtual void print(String *str, enum_query_type query_type);
 
60
  bool eq(const Item *, bool binary_cmp) const;
 
61
};
 
62
 
 
63
class Item_static_float_func :public Item_float
 
64
{
 
65
  const char *func_name;
 
66
public:
 
67
  Item_static_float_func(const char *str, double val_arg, uint32_t decimal_par,
 
68
                        uint32_t length)
 
69
    :Item_float(NULL, val_arg, decimal_par, length), func_name(str)
 
70
  {}
 
71
 
 
72
  virtual inline void print(String *str, enum_query_type)
 
73
  {
 
74
    str->append(func_name);
 
75
  }
 
76
 
 
77
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
 
78
};
 
79
 
 
80
} /* namespace drizzled */
 
81
 
 
82
#endif /* DRIZZLED_ITEM_FLOAT_H */
 
83