Drizzled Public API Documentation

datetime.h
00001 /* - mode: c++ c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 MySQL
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/field/str.h>
00024 
00025 namespace drizzled
00026 {
00027 
00028 class Field_datetime :public Field_str {
00029 public:
00030 
00031   using Field::store;
00032   using Field::val_int;
00033   using Field::val_str;
00034   using Field::cmp;
00035 
00036   Field_datetime(unsigned char *ptr_arg,
00037                  unsigned char *null_ptr_arg,
00038                  unsigned char null_bit_arg,
00039                  const char *field_name_arg) :
00040     Field_str(ptr_arg,
00041                19,
00042                null_ptr_arg,
00043                null_bit_arg,
00044                field_name_arg,
00045                &my_charset_bin)
00046   {}
00047 
00048   Field_datetime(bool maybe_null_arg,
00049                  const char *field_name_arg) :
00050     Field_str((unsigned char*) 0,
00051                19,
00052                maybe_null_arg ? (unsigned char*) "": 0,
00053                0,
00054                field_name_arg,
00055                &my_charset_bin) 
00056   {}
00057 
00058   enum_field_types type() const { return DRIZZLE_TYPE_DATETIME;}
00059   enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
00060   enum Item_result cmp_type () const { return INT_RESULT; }
00061   uint32_t decimals() const { return DATETIME_DEC; }
00062   int  store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
00063   int  store(double nr);
00064   int  store(int64_t nr, bool unsigned_val);
00065   int store_time(type::Time &ltime, type::timestamp_t type);
00066   int reset(void)
00067   {
00068     ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0;
00069     return 0;
00070   }
00071   double val_real(void) const;
00072   int64_t val_int(void) const;
00073   String *val_str(String*,String *) const;
00074   int cmp(const unsigned char *,const unsigned char *);
00075   void sort_string(unsigned char *buff,uint32_t length);
00076   uint32_t pack_length() const { return 8; }
00077   void sql_type(String &str) const;
00078   bool can_be_compared_as_int64_t() const { return true; }
00079   bool zero_pack() const { return 1; }
00080   bool get_date(type::Time &ltime,uint32_t fuzzydate) const;
00081   bool get_time(type::Time &ltime) const;
00082 };
00083 
00084 } /* namespace drizzled */
00085