~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/numhybrid.h

  • Committer: Monty Taylor
  • Date: 2008-08-02 00:06:32 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080802000632-jsse0zdd9r6ic5ku
Actually turn gettext on...

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