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 class Item_float : public Item_num
00027 {
00028 const char *presentation;
00029 public:
00030 double value;
00031 Item_float(const char *str_arg, uint32_t length);
00032 Item_float(const char *str,double val_arg,uint32_t decimal_par,uint32_t length)
00033 :value(val_arg)
00034 {
00035 presentation= name= str;
00036 decimals=(uint8_t) decimal_par;
00037 max_length=length;
00038 fixed= 1;
00039 }
00040 Item_float(double value_par, uint32_t decimal_par) :presentation(0), value(value_par)
00041 {
00042 decimals= (uint8_t) decimal_par;
00043 fixed= 1;
00044 }
00045 int save_in_field(Field *field, bool no_conversions);
00046 enum Type type() const { return REAL_ITEM; }
00047 enum_field_types field_type() const { return DRIZZLE_TYPE_DOUBLE; }
00048 double val_real() { assert(fixed == 1); return value; }
00049 int64_t val_int();
00050 String *val_str(String*);
00051 type::Decimal *val_decimal(type::Decimal *);
00052 bool basic_const_item() const { return 1; }
00053 Item *clone_item()
00054 { return new Item_float(name, value, decimals, max_length); }
00055 Item_num *neg() { value= -value; return this; }
00056 virtual void print(String *str);
00057 bool eq(const Item *, bool binary_cmp) const;
00058 };
00059
00060 class Item_static_float_func :public Item_float
00061 {
00062 const char *func_name;
00063 public:
00064 Item_static_float_func(const char *str, double val_arg, uint32_t decimal_par,
00065 uint32_t length)
00066 :Item_float(NULL, val_arg, decimal_par, length), func_name(str)
00067 {}
00068
00069 virtual inline void print(String *str)
00070 {
00071 str->append(func_name);
00072 }
00073
00074 Item *safe_charset_converter(const charset_info_st * const tocs);
00075 };
00076
00077 }
00078
00079