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 #include <drizzled/util/test.h>
00024
00025 namespace drizzled
00026 {
00027
00028 class Item_int :public Item_num
00029 {
00030 public:
00031 int64_t value;
00032
00033 Item_int(int32_t i,uint32_t length= MY_INT32_NUM_DECIMAL_DIGITS) :
00034 value((int64_t) i)
00035 { max_length=length; fixed= 1; }
00036
00037 Item_int(int64_t i,uint32_t length= MY_INT64_NUM_DECIMAL_DIGITS) :
00038 value(i)
00039 { max_length=length; fixed= 1; }
00040
00041 Item_int(uint64_t i, uint32_t length= MY_INT64_NUM_DECIMAL_DIGITS) :
00042 value((int64_t)i)
00043 { max_length=length; fixed=1; }
00044
00045 Item_int(const char *str_arg,int64_t i,uint32_t length) :
00046 value(i)
00047 { max_length= length; name= const_cast<char *>(str_arg); fixed= 1; }
00048
00049 Item_int(const char *str_arg, uint32_t length=64);
00050
00051 enum Type type() const { return INT_ITEM; }
00052
00053 enum Item_result result_type () const { return INT_RESULT; }
00054
00055 enum_field_types field_type() const { return DRIZZLE_TYPE_LONGLONG; }
00056
00057 int64_t val_int() { assert(fixed == 1); return value; }
00058
00059 double val_real() { assert(fixed == 1); return (double) value; }
00060
00061 type::Decimal *val_decimal(type::Decimal *);
00062
00063 String *val_str(String*);
00064
00065 int save_in_field(Field *field, bool no_conversions);
00066
00067 bool basic_const_item() const { return 1; }
00068
00069 Item *clone_item() { return new Item_int(name,value,max_length); }
00070
00071 virtual void print(String *str);
00072
00073 Item_num *neg() { value= -value; return this; }
00074
00075 uint32_t decimal_precision() const
00076 { return (uint32_t)(max_length - test(value < 0)); }
00077
00078 bool eq(const Item *, bool binary_cmp) const;
00079 };
00080
00081 }
00082