1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
20
#ifndef DRIZZLED_FUNCTIONS_NUMHYBRID_H
21
#define DRIZZLED_FUNCTIONS_NUMHYBRID_H
23
#include <drizzled/item.h>
24
#include <drizzled/functions/func.h>
26
class Item_func_numhybrid: public Item_func
29
Item_result hybrid_type;
31
Item_func_numhybrid(Item *a) :Item_func(a), hybrid_type(REAL_RESULT)
33
Item_func_numhybrid(Item *a,Item *b)
34
:Item_func(a,b), hybrid_type(REAL_RESULT)
36
Item_func_numhybrid(List<Item> &list)
37
:Item_func(list), hybrid_type(REAL_RESULT)
40
enum Item_result result_type () const { return hybrid_type; }
41
void fix_length_and_dec();
42
void fix_num_length_and_dec();
43
virtual void find_num_type()= 0; /* To be called from fix_length_and_dec */
47
my_decimal *val_decimal(my_decimal *);
48
String *val_str(String*str);
51
@brief Performs the operation that this functions implements when the
54
@return The result of the operation.
56
virtual int64_t int_op()= 0;
59
@brief Performs the operation that this functions implements when the
62
@return The result of the operation.
64
virtual double real_op()= 0;
67
@brief Performs the operation that this functions implements when the
68
result type is DECIMAL.
70
@param A pointer where the DECIMAL value will be allocated.
72
- 0 If the result is NULL
73
- The same pointer it was given, with the area initialized to the
74
result of the operation.
76
virtual my_decimal *decimal_op(my_decimal *)= 0;
79
@brief Performs the operation that this functions implements when the
80
result type is a string type.
82
@return The result of the operation.
84
virtual String *str_op(String *)= 0;
85
bool is_null() { update_null_value(); return null_value; }
88
#endif /* DRIZZLED_FUNCTIONS_NUMHYBRID_H */