Drizzled Public API Documentation

int32.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/num.h>
00024 
00025 namespace drizzled
00026 {
00027 
00028 namespace field
00029 {
00030 
00031 class Int32 :public Field_num {
00032 public:
00033 
00034   using Field::val_int;
00035   using Field::val_str;
00036   using Field::cmp;
00037   using Field::pack;
00038   using Field::store;
00039   using Field::unpack;
00040 
00041   Int32(unsigned char *ptr_arg, uint32_t len_arg, unsigned char *null_ptr_arg,
00042         unsigned char null_bit_arg,
00043         enum utype unireg_check_arg,
00044         const char *field_name_arg) :
00045     Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
00046               unireg_check_arg, field_name_arg,
00047               0, false, false)
00048   {}
00049 
00050   Int32(uint32_t len_arg,bool maybe_null_arg, const char *field_name_arg,
00051         bool unsigned_arg) :
00052     Field_num((unsigned char*) 0, len_arg, maybe_null_arg ? (unsigned char*) "": 0,0,
00053               NONE, field_name_arg,0,0,unsigned_arg)
00054     {}
00055 
00056   enum Item_result result_type () const { return INT_RESULT; }
00057   enum_field_types type() const { return DRIZZLE_TYPE_LONG;}
00058   enum ha_base_keytype key_type() const
00059   { return unsigned_flag ? HA_KEYTYPE_ULONG_INT : HA_KEYTYPE_LONG_INT; }
00060   int store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
00061   int store(double nr);
00062   int store(int64_t nr, bool unsigned_val);
00063   int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
00064   double val_real(void) const;
00065   int64_t val_int(void) const;
00066   String *val_str(String*,String *) const;
00067   int cmp(const unsigned char *,const unsigned char *);
00068   void sort_string(unsigned char *buff,uint32_t length);
00069   uint32_t pack_length() const { return 4; }
00070   void sql_type(String &str) const;
00071   uint32_t max_display_length() { return MY_INT32_NUM_DECIMAL_DIGITS; }
00072   virtual unsigned char *pack(unsigned char* to, const unsigned char *from,
00073                               uint32_t max_length,
00074                               bool low_byte_first);
00075 
00076   virtual const unsigned char *unpack(unsigned char* to, const unsigned char *from,
00077                                       uint32_t param_data,
00078                                       bool low_byte_first);
00079 };
00080 
00081 } /* namespace field */
00082 } /* namespace drizzled */
00083 
00084