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