Drizzled Public API Documentation

time.h

00001 /* - mode: c++ c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2010 Brian Aker
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #pragma once
00022 
00023 #include <drizzled/function/str/strfunc.h>
00024 #include <drizzled/function/time/typecast.h>
00025 #include <drizzled/temporal.h>
00026 
00027 namespace drizzled {
00028 namespace function {
00029 namespace cast {
00030 
00031 class Time :public Item_typecast_maybe_null
00032 {
00033 public:
00034   using Item_func::tmp_table_field;
00035 
00036   Time(Item *a) :
00037     Item_typecast_maybe_null(a)
00038   {}
00039 
00040   const char *func_name() const { return "cast_as_time"; }
00041   String *val_str(String *str);
00042   bool get_time(type::Time &ltime);
00043   const char *cast_type() const { return "time"; }
00044   enum_field_types field_type() const { return DRIZZLE_TYPE_TIME; }
00045 
00046   Field *tmp_table_field(Table *table)
00047   {
00048     return tmp_table_field_from_field_type(table, 0);
00049   }
00050 
00051   void fix_length_and_dec()
00052   {
00053     collation.set(&my_charset_bin);
00054     max_length= 10;
00055     maybe_null= 1;
00056   }
00057 
00058   bool result_as_int64_t() { return true; }
00059   int64_t val_int();
00060   double val_real() { return (double) val_int(); }
00061 
00062   type::Decimal *val_decimal(type::Decimal *decimal_value)
00063   {
00064     assert(fixed == 1);
00065     return  val_decimal_from_date(decimal_value);
00066   }
00067 
00068   int save_in_field(Field *field, bool )
00069   {
00070     return save_date_in_field(field);
00071   }
00072 };
00073 
00074 } // namespace cast
00075 } // namespace function
00076 } // namespace drizzled
00077