~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/functions/numhybrid.h

Renamed strings to mystrings, for include/lib naming consistency.

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_FUNCTIONS_NUMHYBRID_H
21
 
#define DRIZZLED_FUNCTIONS_NUMHYBRID_H
22
 
 
23
 
#include <drizzled/item.h>
24
 
#include <drizzled/functions/func.h>
25
 
 
26
 
class Item_func_numhybrid: public Item_func
27
 
{
28
 
protected:
29
 
  Item_result hybrid_type;
30
 
public:
31
 
  Item_func_numhybrid(Item *a) :Item_func(a), hybrid_type(REAL_RESULT)
32
 
  {}
33
 
  Item_func_numhybrid(Item *a,Item *b)
34
 
    :Item_func(a,b), hybrid_type(REAL_RESULT)
35
 
  {}
36
 
  Item_func_numhybrid(List<Item> &list)
37
 
    :Item_func(list), hybrid_type(REAL_RESULT)
38
 
  {}
39
 
 
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 */
44
 
 
45
 
  double val_real();
46
 
  int64_t val_int();
47
 
  my_decimal *val_decimal(my_decimal *);
48
 
  String *val_str(String*str);
49
 
 
50
 
  /**
51
 
     @brief Performs the operation that this functions implements when the
52
 
     result type is INT.
53
 
 
54
 
     @return The result of the operation.
55
 
  */
56
 
  virtual int64_t int_op()= 0;
57
 
 
58
 
  /**
59
 
     @brief Performs the operation that this functions implements when the
60
 
     result type is REAL.
61
 
 
62
 
     @return The result of the operation.
63
 
  */
64
 
  virtual double real_op()= 0;
65
 
 
66
 
  /**
67
 
     @brief Performs the operation that this functions implements when the
68
 
     result type is DECIMAL.
69
 
 
70
 
     @param A pointer where the DECIMAL value will be allocated.
71
 
     @return 
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.
75
 
  */
76
 
  virtual my_decimal *decimal_op(my_decimal *)= 0;
77
 
 
78
 
  /**
79
 
     @brief Performs the operation that this functions implements when the
80
 
     result type is a string type.
81
 
 
82
 
     @return The result of the operation.
83
 
  */
84
 
  virtual String *str_op(String *)= 0;
85
 
  bool is_null() { update_null_value(); return null_value; }
86
 
};
87
 
 
88
 
#endif /* DRIZZLED_FUNCTIONS_NUMHYBRID_H */