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