Drizzled Public API Documentation

ref_null_helper.cc
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 #include <config.h>
00021 
00022 #include <drizzled/item/ref.h>
00023 #include <drizzled/item/ref_null_helper.h>
00024 #include <drizzled/item/subselect.h>
00025 #include <drizzled/lex_string.h>
00026 
00027 namespace drizzled
00028 {
00029 
00030 double Item_ref_null_helper::val_real()
00031 {
00032   assert(fixed == 1);
00033   double tmp= (*ref)->val_result();
00034   owner->was_null|= null_value= (*ref)->null_value;
00035   return tmp;
00036 }
00037 
00038 
00039 int64_t Item_ref_null_helper::val_int()
00040 {
00041   assert(fixed == 1);
00042   int64_t tmp= (*ref)->val_int_result();
00043   owner->was_null|= null_value= (*ref)->null_value;
00044   return tmp;
00045 }
00046 
00047 
00048 type::Decimal *Item_ref_null_helper::val_decimal(type::Decimal *decimal_value)
00049 {
00050   assert(fixed == 1);
00051   type::Decimal *val= (*ref)->val_decimal_result(decimal_value);
00052   owner->was_null|= null_value= (*ref)->null_value;
00053   return val;
00054 }
00055 
00056 bool Item_ref_null_helper::val_bool()
00057 {
00058   assert(fixed == 1);
00059   bool val= (*ref)->val_bool_result();
00060   owner->was_null|= null_value= (*ref)->null_value;
00061   return val;
00062 }
00063 
00064 
00065 String* Item_ref_null_helper::val_str(String* s)
00066 {
00067   assert(fixed == 1);
00068   String* tmp= (*ref)->str_result(s);
00069   owner->was_null|= null_value= (*ref)->null_value;
00070   return tmp;
00071 }
00072 
00073 bool Item_ref_null_helper::get_date(type::Time &ltime, uint32_t fuzzydate)
00074 {
00075   return (owner->was_null|= null_value= (*ref)->get_date(ltime, fuzzydate));
00076 }
00077 
00078 void Item_ref_null_helper::print(String *str)
00079 {
00080   str->append(STRING_WITH_LEN("<ref_null_helper>("));
00081   if (ref)
00082     (*ref)->print(str);
00083   else
00084     str->append('?');
00085   str->append(')');
00086 }
00087 
00088 } /* namespace drizzled */