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 class Item_decimal : public Item_num
00028 {
00029 protected:
00030 type::Decimal decimal_value;
00031 public:
00032 Item_decimal(const char *str_arg, uint32_t length, const charset_info_st*);
00033 Item_decimal(const char *str, const type::Decimal *val_arg, uint32_t decimal_par, uint32_t length);
00034 Item_decimal(type::Decimal *value_par);
00035 Item_decimal(int64_t val, bool unsig);
00036 Item_decimal(double val, int precision, int scale);
00037 Item_decimal(const unsigned char *bin, int precision, int scale);
00038
00039 enum Type type() const { return DECIMAL_ITEM; }
00040 enum Item_result result_type () const { return DECIMAL_RESULT; }
00041 enum_field_types field_type() const { return DRIZZLE_TYPE_DECIMAL; }
00042 int64_t val_int();
00043 double val_real();
00044 String *val_str(String*);
00045 type::Decimal *val_decimal(type::Decimal *)
00046 { return &decimal_value; }
00047 int save_in_field(Field *field, bool no_conversions);
00048 bool basic_const_item() const { return true; }
00049 Item *clone_item()
00050 {
00051 return new Item_decimal(name, &decimal_value, decimals, max_length);
00052 }
00053 virtual void print(String *str);
00054 Item_num *neg()
00055 {
00056 class_decimal_neg(&decimal_value);
00057 unsigned_flag= !decimal_value.sign();
00058 return this;
00059 }
00060 uint32_t decimal_precision() const { return decimal_value.precision(); }
00061 bool eq(const Item *, bool binary_cmp) const;
00062 void set_decimal_value(type::Decimal *value_par);
00063 };
00064
00065 }
00066