~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_func.h

code clean up to moving functions into drizzled/functions directory - Item_num_op and Item_numhybrid

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
#include <drizzled/functions/func.h>
34
34
#include <drizzled/functions/int.h>
 
35
#include <drizzled/functions/numhybrid.h>
 
36
#include <drizzled/functions/num_op.h>
35
37
#include <drizzled/functions/real.h>
36
38
 
37
39
 
38
 
class Item_func_numhybrid: public Item_func
39
 
{
40
 
protected:
41
 
  Item_result hybrid_type;
42
 
public:
43
 
  Item_func_numhybrid(Item *a) :Item_func(a), hybrid_type(REAL_RESULT)
44
 
  {}
45
 
  Item_func_numhybrid(Item *a,Item *b)
46
 
    :Item_func(a,b), hybrid_type(REAL_RESULT)
47
 
  {}
48
 
  Item_func_numhybrid(List<Item> &list)
49
 
    :Item_func(list), hybrid_type(REAL_RESULT)
50
 
  {}
51
 
 
52
 
  enum Item_result result_type () const { return hybrid_type; }
53
 
  void fix_length_and_dec();
54
 
  void fix_num_length_and_dec();
55
 
  virtual void find_num_type()= 0; /* To be called from fix_length_and_dec */
56
 
 
57
 
  double val_real();
58
 
  int64_t val_int();
59
 
  my_decimal *val_decimal(my_decimal *);
60
 
  String *val_str(String*str);
61
 
 
62
 
  /**
63
 
     @brief Performs the operation that this functions implements when the
64
 
     result type is INT.
65
 
 
66
 
     @return The result of the operation.
67
 
  */
68
 
  virtual int64_t int_op()= 0;
69
 
 
70
 
  /**
71
 
     @brief Performs the operation that this functions implements when the
72
 
     result type is REAL.
73
 
 
74
 
     @return The result of the operation.
75
 
  */
76
 
  virtual double real_op()= 0;
77
 
 
78
 
  /**
79
 
     @brief Performs the operation that this functions implements when the
80
 
     result type is DECIMAL.
81
 
 
82
 
     @param A pointer where the DECIMAL value will be allocated.
83
 
     @return 
84
 
       - 0 If the result is NULL
85
 
       - The same pointer it was given, with the area initialized to the
86
 
         result of the operation.
87
 
  */
88
 
  virtual my_decimal *decimal_op(my_decimal *)= 0;
89
 
 
90
 
  /**
91
 
     @brief Performs the operation that this functions implements when the
92
 
     result type is a string type.
93
 
 
94
 
     @return The result of the operation.
95
 
  */
96
 
  virtual String *str_op(String *)= 0;
97
 
  bool is_null() { update_null_value(); return null_value; }
98
 
};
99
 
 
100
40
/* function where type of result detected by first argument */
101
41
class Item_func_num1: public Item_func_numhybrid
102
42
{
111
51
};
112
52
 
113
53
 
114
 
/* Base class for operations like '+', '-', '*' */
115
 
class Item_num_op :public Item_func_numhybrid
116
 
{
117
 
 public:
118
 
  Item_num_op(Item *a,Item *b) :Item_func_numhybrid(a, b) {}
119
 
  virtual void result_precision()= 0;
120
 
 
121
 
  virtual inline void print(String *str, enum_query_type query_type)
122
 
  {
123
 
    print_op(str, query_type);
124
 
  }
125
 
 
126
 
  void find_num_type();
127
 
  String *str_op(String *str __attribute__((unused)))
128
 
  { assert(0); return 0; }
129
 
};
130
 
 
131
 
 
132
54
class Item_func_connection_id :public Item_int_func
133
55
{
134
56
  int64_t value;