Drizzled Public API Documentation

copy_string.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
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 } /* namespace drizzled */
00074