~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/numhybrid.h

  • Committer: Stewart Smith
  • Date: 2008-07-13 06:56:15 UTC
  • mto: (210.1.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 211.
  • Revision ID: stewart@flamingspork.com-20080713065615-vzok75kgnnviokl9
Move MD5() into a UDF

Show diffs side-by-side

added added

removed removed

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