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 Sun Microsystems, Inc.
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; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <drizzled/charset.h>
00023 #include <drizzled/item/basic_constant.h>
00024 
00025 namespace drizzled {
00026 
00027 class Item_null : public Item_basic_constant
00028 {
00029 public:
00030 
00031   Item_null(const char *name_par=0)
00032   {
00033     maybe_null= null_value= true;
00034     max_length= 0;
00035     name= name_par ? name_par : "NULL";
00036     fixed= 1;
00037     collation.set(&my_charset_bin, DERIVATION_IGNORABLE);
00038   }
00039   Type type() const { return NULL_ITEM; }
00040   bool eq(const Item *item, bool binary_cmp) const;
00041   double val_real();
00042   int64_t val_int();
00043   String *val_str(String *str);
00044   type::Decimal *val_decimal(type::Decimal *);
00045   int save_in_field(Field *field, bool no_conversions);
00046   int save_safe_in_field(Field *field);
00047   void send(plugin::Client *client, String *str);
00048   enum Item_result result_type () const { return STRING_RESULT; }
00049   enum_field_types field_type() const   { return DRIZZLE_TYPE_NULL; }
00050   bool basic_const_item() const { return 1; }
00051   Item *clone_item() { return new Item_null(name); }
00052   bool is_null() { return true; }
00053 
00054   virtual void print(String *str);
00055 
00056   Item *safe_charset_converter(const charset_info_st * const tocs);
00057 };
00058 
00059 class Item_null_result :public Item_null
00060 {
00061 public:
00062   Field *result_field;
00063   Item_null_result() : Item_null(), result_field(0) {}
00064   bool is_result_field() { return result_field != 0; }
00065   void save_in_result_field(bool no_conversions)
00066   {
00067     save_in_field(result_field, no_conversions);
00068   }
00069 };
00070 
00071 } /* namespace drizzled */
00072