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