492.3.2
by Lee
code clean up to moving functions into drizzled/functions directory - Item_num_op and Item_numhybrid |
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
|
|
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 |
||
670.1.20
by Monty Taylor
Renamed functions to function... everything else is singular. |
20 |
#ifndef DRIZZLED_FUNCTION_NUMHYBRID_H
|
21 |
#define DRIZZLED_FUNCTION_NUMHYBRID_H
|
|
492.3.2
by Lee
code clean up to moving functions into drizzled/functions directory - Item_num_op and Item_numhybrid |
22 |
|
670.1.20
by Monty Taylor
Renamed functions to function... everything else is singular. |
23 |
#include <drizzled/function/func.h> |
492.3.2
by Lee
code clean up to moving functions into drizzled/functions directory - Item_num_op and Item_numhybrid |
24 |
|
25 |
class Item_func_numhybrid: public Item_func |
|
26 |
{
|
|
27 |
protected: |
|
28 |
Item_result hybrid_type; |
|
29 |
public: |
|
30 |
Item_func_numhybrid(Item *a) :Item_func(a), hybrid_type(REAL_RESULT) |
|
31 |
{}
|
|
32 |
Item_func_numhybrid(Item *a,Item *b) |
|
33 |
:Item_func(a,b), hybrid_type(REAL_RESULT) |
|
34 |
{}
|
|
35 |
Item_func_numhybrid(List<Item> &list) |
|
36 |
:Item_func(list), hybrid_type(REAL_RESULT) |
|
37 |
{}
|
|
38 |
||
39 |
enum Item_result result_type () const { return hybrid_type; } |
|
40 |
void fix_length_and_dec(); |
|
41 |
void fix_num_length_and_dec(); |
|
42 |
virtual void find_num_type()= 0; /* To be called from fix_length_and_dec */ |
|
43 |
||
44 |
double val_real(); |
|
45 |
int64_t val_int(); |
|
46 |
my_decimal *val_decimal(my_decimal *); |
|
47 |
String *val_str(String*str); |
|
48 |
||
49 |
/**
|
|
50 |
@brief Performs the operation that this functions implements when the
|
|
51 |
result type is INT.
|
|
52 |
||
53 |
@return The result of the operation.
|
|
54 |
*/
|
|
55 |
virtual int64_t int_op()= 0; |
|
56 |
||
57 |
/**
|
|
58 |
@brief Performs the operation that this functions implements when the
|
|
59 |
result type is REAL.
|
|
60 |
||
61 |
@return The result of the operation.
|
|
62 |
*/
|
|
63 |
virtual double real_op()= 0; |
|
64 |
||
65 |
/**
|
|
66 |
@brief Performs the operation that this functions implements when the
|
|
67 |
result type is DECIMAL.
|
|
68 |
||
69 |
@param A pointer where the DECIMAL value will be allocated.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
70 |
@return
|
492.3.2
by Lee
code clean up to moving functions into drizzled/functions directory - Item_num_op and Item_numhybrid |
71 |
- 0 If the result is NULL
|
72 |
- The same pointer it was given, with the area initialized to the
|
|
73 |
result of the operation.
|
|
74 |
*/
|
|
75 |
virtual my_decimal *decimal_op(my_decimal *)= 0; |
|
76 |
||
77 |
/**
|
|
78 |
@brief Performs the operation that this functions implements when the
|
|
79 |
result type is a string type.
|
|
80 |
||
81 |
@return The result of the operation.
|
|
82 |
*/
|
|
83 |
virtual String *str_op(String *)= 0; |
|
84 |
bool is_null() { update_null_value(); return null_value; } |
|
85 |
};
|
|
86 |
||
670.1.20
by Monty Taylor
Renamed functions to function... everything else is singular. |
87 |
#endif /* DRIZZLED_FUNCTION_NUMHYBRID_H */ |