Drizzled Public API Documentation

epoch.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 namespace field {
00027 
00028 class Epoch :public Field_str {
00029 public:
00030 
00031   typedef Epoch* pointer;
00032 
00033   Epoch(unsigned char *ptr_arg,
00034         unsigned char *null_ptr_arg,
00035         unsigned char null_bit_arg,
00036         enum utype unireg_check_arg,
00037         const char *field_name_arg,
00038         drizzled::TableShare *share);
00039 
00040   Epoch(bool maybe_null_arg,
00041         const char *field_name_arg);
00042 
00043   enum_field_types type() const { return DRIZZLE_TYPE_TIMESTAMP;}
00044   enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
00045   enum Item_result cmp_type () const { return INT_RESULT; }
00046 
00047   int store(const char *to,uint32_t length,
00048             const charset_info_st * const charset);
00049   int store(double nr);
00050   int store(int64_t nr, bool unsigned_val);
00051   int store_decimal(const type::Decimal *value);
00052 
00053   int  reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; return 0; }
00054   double val_real(void) const;
00055   int64_t val_int(void) const;
00056   String *val_str(String*,String *) const;
00057   int cmp(const unsigned char *,const unsigned char *);
00058   void sort_string(unsigned char *buff,uint32_t length);
00059   uint32_t pack_length() const { return 8; }
00060   virtual bool can_be_compared_as_int64_t() const { return true; }
00061   bool zero_pack() const { return 0; }
00062   virtual void set_time();
00063   virtual void set_default();
00064 
00065   /* Get TIMESTAMP field value as seconds since begging of Unix Epoch */
00066   virtual long get_timestamp(bool *null_value) const;
00067 
00068   virtual bool is_timestamp() const
00069   {
00070     return true;
00071   }
00072 
00073 private:
00074   bool get_date(type::Time &ltime,uint32_t fuzzydate) const;
00075   bool get_time(type::Time &ltime) const;
00076 
00077 public:
00078   virtual timestamp_auto_set_type get_auto_set_type() const;
00079   static size_t max_string_length();
00080 };
00081 
00082 } /* namespace field */
00083 } /* namespace drizzled */
00084 
00085