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