Drizzled Public API Documentation

float.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/item/num.h>
00023 
00024 namespace drizzled
00025 {
00026 
00027 class Item_float :public Item_num
00028 {
00029   char *presentation;
00030 public:
00031   double value;
00032   // Item_real() :value(0) {}
00033   Item_float(const char *str_arg, uint32_t length);
00034   Item_float(const char *str,double val_arg,uint32_t decimal_par,uint32_t length)
00035     :value(val_arg)
00036   {
00037     presentation= name=(char*) str;
00038     decimals=(uint8_t) decimal_par;
00039     max_length=length;
00040     fixed= 1;
00041   }
00042   Item_float(double value_par, uint32_t decimal_par) :presentation(0), value(value_par)
00043   {
00044     decimals= (uint8_t) decimal_par;
00045     fixed= 1;
00046   }
00047   int save_in_field(Field *field, bool no_conversions);
00048   enum Type type() const { return REAL_ITEM; }
00049   enum_field_types field_type() const { return DRIZZLE_TYPE_DOUBLE; }
00050   double val_real() { assert(fixed == 1); return value; }
00051   int64_t val_int();
00052   String *val_str(String*);
00053   type::Decimal *val_decimal(type::Decimal *);
00054   bool basic_const_item() const { return 1; }
00055   Item *clone_item()
00056   { return new Item_float(name, value, decimals, max_length); }
00057   Item_num *neg() { value= -value; return this; }
00058   virtual void print(String *str);
00059   bool eq(const Item *, bool binary_cmp) const;
00060 };
00061 
00062 class Item_static_float_func :public Item_float
00063 {
00064   const char *func_name;
00065 public:
00066   Item_static_float_func(const char *str, double val_arg, uint32_t decimal_par,
00067                         uint32_t length)
00068     :Item_float(NULL, val_arg, decimal_par, length), func_name(str)
00069   {}
00070 
00071   virtual inline void print(String *str)
00072   {
00073     str->append(func_name);
00074   }
00075 
00076   Item *safe_charset_converter(const CHARSET_INFO * const tocs);
00077 };
00078 
00079 } /* namespace drizzled */
00080 
00081