Drizzled Public API Documentation

null.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 /*
00029  * Everything saved in this will disappear. It will always return NULL
00030  */
00031 
00032 class Field_null :public Field_str
00033 {
00034   static unsigned char null[1];
00035 public:
00036 
00037   using Field::store;
00038   using Field::val_str;
00039   using Field::cmp;
00040   using Field::val_int;
00041 
00042   Field_null(unsigned char *ptr_arg,
00043              uint32_t len_arg,
00044              const char *field_name_arg) :
00045     Field_str(ptr_arg,
00046               len_arg,
00047               null,
00048               1,
00049               field_name_arg,
00050               &my_charset_bin)
00051   {}
00052 
00053   enum_field_types type() const
00054   {
00055     return DRIZZLE_TYPE_NULL;
00056   }
00057   int  store(const char *, uint32_t, const CHARSET_INFO * const)
00058   {
00059     null[0]= 1;
00060     return 0;
00061   }
00062   int store(double)
00063   {
00064     null[0]= 1;
00065     return 0;
00066   }
00067   int store(int64_t, bool)
00068   {
00069     null[0]= 1;
00070     return 0;
00071   }
00072   int store_decimal(const type::Decimal *)
00073   {
00074     null[0]= 1;
00075     return 0;
00076   }
00077   int reset(void)
00078   {
00079     return 0;
00080   }
00081   double val_real(void) const
00082   {
00083     return 0.0;
00084   }
00085   int64_t val_int(void) const
00086   {
00087     return 0;
00088   }
00089   type::Decimal *val_decimal(type::Decimal *) const
00090   {
00091     return 0;
00092   }
00093   String *val_str(String *, String *value2) const
00094   {
00095     value2->length(0);
00096     return value2;
00097   }
00098   int cmp(const unsigned char *, const unsigned char *)
00099   {
00100     return 0;
00101   }
00102   void sort_string(unsigned char *, uint32_t)
00103   {}
00104   uint32_t pack_length() const
00105   {
00106     return 0;
00107   }
00108   void sql_type(String &str) const;
00109   uint32_t size_of() const
00110   {
00111     return sizeof(*this);
00112   }
00113   uint32_t max_display_length()
00114   {
00115     return 4;
00116   }
00117 };
00118 
00119 } /* namespace drizzled */
00120