~drizzle-trunk/drizzle/development

642.1.6 by Lee
move functions from item.cc/item.h to item directory
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_DECIMAL_H
21
#define DRIZZLED_ITEM_DECIMAL_H
22
23
#include <drizzled/item/num.h>
24
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
25
namespace drizzled
26
{
27
642.1.6 by Lee
move functions from item.cc/item.h to item directory
28
/* decimal (fixed point) constant */
29
class Item_decimal :public Item_num
30
{
31
protected:
32
  my_decimal decimal_value;
33
public:
34
  Item_decimal(const char *str_arg, uint32_t length, const CHARSET_INFO * const charset);
35
  Item_decimal(const char *str, const my_decimal *val_arg,
36
               uint32_t decimal_par, uint32_t length);
37
  Item_decimal(my_decimal *value_par);
38
  Item_decimal(int64_t val, bool unsig);
39
  Item_decimal(double val, int precision, int scale);
40
  Item_decimal(const unsigned char *bin, int precision, int scale);
41
42
  enum Type type() const { return DECIMAL_ITEM; }
43
  enum Item_result result_type () const { return DECIMAL_RESULT; }
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
44
  enum_field_types field_type() const { return DRIZZLE_TYPE_DECIMAL; }
642.1.6 by Lee
move functions from item.cc/item.h to item directory
45
  int64_t val_int();
46
  double val_real();
47
  String *val_str(String*);
48
  my_decimal *val_decimal(my_decimal *)
49
  { return &decimal_value; }
50
  int save_in_field(Field *field, bool no_conversions);
51
  bool basic_const_item() const { return 1; }
52
  Item *clone_item()
53
  {
54
    return new Item_decimal(name, &decimal_value, decimals, max_length);
55
  }
56
  virtual void print(String *str, enum_query_type query_type);
57
  Item_num *neg()
58
  {
59
    my_decimal_neg(&decimal_value);
60
    unsigned_flag= !decimal_value.sign();
61
    return this;
62
  }
63
  uint32_t decimal_precision() const { return decimal_value.precision(); }
64
  bool eq(const Item *, bool binary_cmp) const;
65
  void set_decimal_value(my_decimal *value_par);
66
};
67
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
68
} /* namespace drizzled */
69
642.1.6 by Lee
move functions from item.cc/item.h to item directory
70
#endif /* DRIZZLED_ITEM_DECIMAL_H */