00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021
00022 #include <drizzled/item/num.h>
00023
00024 namespace drizzled
00025 {
00026
00027
00028 class Item_decimal :public Item_num
00029 {
00030 protected:
00031 type::Decimal decimal_value;
00032 public:
00033 Item_decimal(const char *str_arg, uint32_t length, const CHARSET_INFO * const charset);
00034 Item_decimal(const char *str, const type::Decimal *val_arg,
00035 uint32_t decimal_par, uint32_t length);
00036 Item_decimal(type::Decimal *value_par);
00037 Item_decimal(int64_t val, bool unsig);
00038 Item_decimal(double val, int precision, int scale);
00039 Item_decimal(const unsigned char *bin, int precision, int scale);
00040
00041 enum Type type() const { return DECIMAL_ITEM; }
00042 enum Item_result result_type () const { return DECIMAL_RESULT; }
00043 enum_field_types field_type() const { return DRIZZLE_TYPE_DECIMAL; }
00044 int64_t val_int();
00045 double val_real();
00046 String *val_str(String*);
00047 type::Decimal *val_decimal(type::Decimal *)
00048 { return &decimal_value; }
00049 int save_in_field(Field *field, bool no_conversions);
00050 bool basic_const_item() const { return 1; }
00051 Item *clone_item()
00052 {
00053 return new Item_decimal(name, &decimal_value, decimals, max_length);
00054 }
00055 virtual void print(String *str);
00056 Item_num *neg()
00057 {
00058 class_decimal_neg(&decimal_value);
00059 unsigned_flag= !decimal_value.sign();
00060 return this;
00061 }
00062 uint32_t decimal_precision() const { return decimal_value.precision(); }
00063 bool eq(const Item *, bool binary_cmp) const;
00064 void set_decimal_value(type::Decimal *value_par);
00065 };
00066
00067 }
00068