Drizzled Public API Documentation

float.h
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2008 Sun Microsystems, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #pragma once
21 
22 #include <drizzled/item/num.h>
23 
24 namespace drizzled {
25 
26 class Item_float : public Item_num
27 {
28  const char *presentation;
29 public:
30  double value;
31  Item_float(const char *str_arg, uint32_t length);
32  Item_float(const char *str,double val_arg,uint32_t decimal_par,uint32_t length)
33  :value(val_arg)
34  {
35  presentation= name= str;
36  decimals=(uint8_t) decimal_par;
37  max_length=length;
38  fixed= 1;
39  }
40  Item_float(double value_par, uint32_t decimal_par) :presentation(0), value(value_par)
41  {
42  decimals= (uint8_t) decimal_par;
43  fixed= 1;
44  }
45  int save_in_field(Field *field, bool no_conversions);
46  enum Type type() const { return REAL_ITEM; }
47  enum_field_types field_type() const { return DRIZZLE_TYPE_DOUBLE; }
48  double val_real() { assert(fixed == 1); return value; }
49  int64_t val_int();
52  bool basic_const_item() const { return 1; }
53  Item *clone_item()
54  { return new Item_float(name, value, decimals, max_length); }
55  Item_num *neg() { value= -value; return this; }
56  virtual void print(String *str);
57  bool eq(const Item *, bool binary_cmp) const;
58 };
59 
61 {
62  const char *func_name;
63 public:
64  Item_static_float_func(const char *str, double val_arg, uint32_t decimal_par,
65  uint32_t length)
66  :Item_float(NULL, val_arg, decimal_par, length), func_name(str)
67  {}
68 
69  virtual inline void print(String *str)
70  {
71  str->append(func_name, strlen(func_name));
72  }
73 
74  Item *safe_charset_converter(const charset_info_st * const tocs);
75 };
76 
77 } /* namespace drizzled */
78 
79 
const char * name
Definition: item.h:110
virtual void print(String *str)
Definition: float.h:69
Item_float(const char *str_arg, uint32_t length)
Definition: float.cc:92
bool basic_const_item() const
Definition: float.h:52
bool eq(const Item *, bool binary_cmp) const
Definition: float.cc:142
bool fixed
Definition: item.h:120
TODO: Rename this file - func.h is stupid.
double val_real()
Definition: float.h:48
String * val_str(String *)
Definition: float.cc:56
int64_t val_int()
Definition: float.cc:65
type::Decimal * val_decimal(type::Decimal *)
Definition: float.cc:79
virtual void print(String *str)
Definition: float.cc:123