~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/functions/time/date.h

  • Committer: Monty Taylor
  • Date: 2008-11-16 20:15:33 UTC
  • mto: (584.1.9 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116201533-d0f19s1bk1h95iyw
Removed a big bank of includes from item.h.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_FUNCTION_TIME_DATE_H
21
 
#define DRIZZLED_FUNCTION_TIME_DATE_H
22
 
 
23
 
#include "drizzled/function/func.h"
24
 
#include "drizzled/function/str/strfunc.h"
25
 
#include <drizzled/temporal.h>
26
 
 
27
 
namespace drizzled
28
 
{
29
 
 
30
 
/* A function which evaluates to a Date */
 
20
#ifndef DRIZZLED_FUNCTIONS_TIME_DATE_H
 
21
#define DRIZZLED_FUNCTIONS_TIME_DATE_H
 
22
 
 
23
#include <drizzled/functions/func.h>
 
24
#include <drizzled/functions/str/strfunc.h>
 
25
/*
 
26
  This can't be a Item_str_func, because the val_real() functions are special
 
27
*/
 
28
 
31
29
class Item_date :public Item_func
32
30
{
33
31
public:
34
 
  using Item_func::tmp_table_field;
35
 
 
36
32
  Item_date() :Item_func() {}
37
33
  Item_date(Item *a) :Item_func(a) {}
38
34
  enum Item_result result_type () const { return STRING_RESULT; }
39
 
  enum_field_types field_type() const { return DRIZZLE_TYPE_DATE; }
 
35
  enum_field_types field_type() const { return DRIZZLE_TYPE_NEWDATE; }
40
36
  String *val_str(String *str);
41
37
  int64_t val_int();
42
38
  double val_real() { return val_real_from_decimal(); }
45
41
  {
46
42
    collation.set(&my_charset_bin);
47
43
    decimals=0;
48
 
    max_length=Date::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN;
 
44
    max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
49
45
  }
50
 
  /**
51
 
   * All functions which inherit from Item_date must implement
52
 
   * their own get_temporal() method, which takes a supplied
53
 
   * Date reference and populates it with a correct
54
 
   * date based on the semantics of the function.
55
 
   *
56
 
   * Returns whether the function was able to correctly fill
57
 
   * the supplied date temporal with a proper date.
58
 
   *
59
 
   * @param Reference to a Date to populate
60
 
   */
61
 
  virtual bool get_temporal(Date &temporal)= 0;
62
46
  Field *tmp_table_field(Table *table)
63
47
  {
64
48
    return tmp_table_field_from_field_type(table, 0);
70
54
    return  val_decimal_from_date(decimal_value);
71
55
  }
72
56
  int save_in_field(Field *field,
73
 
                    bool )
 
57
                    bool no_conversions __attribute__((unused)))
74
58
  {
75
59
    return save_date_in_field(field);
76
60
  }
84
68
  Item_date_func(Item *a,Item *b) :Item_str_func(a,b) {}
85
69
  Item_date_func(Item *a,Item *b, Item *c) :Item_str_func(a,b,c) {}
86
70
  enum_field_types field_type() const { return DRIZZLE_TYPE_DATETIME; }
87
 
 
88
 
  using Item_func::tmp_table_field;
89
71
  Field *tmp_table_field(Table *table)
90
72
  {
91
73
    return tmp_table_field_from_field_type(table, 0);
98
80
    return  val_decimal_from_date(decimal_value);
99
81
  }
100
82
  int save_in_field(Field *field,
101
 
                    bool )
 
83
                    bool no_conversions __attribute__((unused)))
102
84
  {
103
85
    return save_date_in_field(field);
104
86
  }
105
87
};
106
88
 
107
 
} /* namespace drizzled */
108
 
 
109
 
#endif /* DRIZZLED_FUNCTION_TIME_DATE_H */
 
89
#endif /* DRIZZLED_FUNCTIONS_TIME_DATE_H */