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/charset.h>
00023 #include <drizzled/item/field.h>
00024 #include <drizzled/item/ident.h>
00025
00026 namespace drizzled {
00027
00028 class Item_copy_string : public Item
00029 {
00030 enum enum_field_types cached_field_type;
00031 public:
00032 Item *item;
00033 Item_copy_string(Item *i) :item(i)
00034 {
00035 null_value= maybe_null= item->maybe_null;
00036 decimals=item->decimals;
00037 max_length=item->max_length;
00038 name=item->name;
00039 cached_field_type= item->field_type();
00040 }
00041 enum Type type() const { return COPY_STR_ITEM; }
00042 enum Item_result result_type () const { return STRING_RESULT; }
00043 enum_field_types field_type() const { return cached_field_type; }
00044 double val_real()
00045 {
00046 int err_not_used;
00047 char *end_not_used;
00048 return (null_value ? 0.0 :
00049 my_strntod(str_value.charset(), (char*) str_value.ptr(),
00050 str_value.length(), &end_not_used, &err_not_used));
00051 }
00052 int64_t val_int()
00053 {
00054 int err;
00055 return null_value ? 0 : my_strntoll(str_value.charset(),str_value.ptr(),
00056 str_value.length(),10, (char**) 0,
00057 &err);
00058 }
00059 String *val_str(String*);
00060 type::Decimal *val_decimal(type::Decimal *);
00061 void make_field(SendField *field) { item->make_field(field); }
00062 void copy();
00063 int save_in_field(Field *field, bool)
00064 {
00065 return save_str_value_in_field(field, &str_value);
00066 }
00067 table_map used_tables() const { return (table_map) 1; }
00068 bool const_item() const { return false; }
00069 bool is_null() { return null_value; }
00070 };
00071
00072 }
00073