Drizzled Public API Documentation

user_var_entry.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 
00021 #pragma once
00022 
00023 #include <drizzled/dtcollation.h>
00024 #include <drizzled/query_id.h>
00025 
00026 namespace drizzled
00027 {
00028 
00029 namespace type { class Decimal; }
00030 
00031 // this is needed for user_vars hash
00032 class user_var_entry
00033 {
00034  public:
00035   user_var_entry(const char *arg, query_id_t id) :
00036     value(0),
00037     length(0),
00038     size(0),
00039     update_query_id(0),
00040     used_query_id(id),
00041     type(STRING_RESULT),
00042     unsigned_flag(false),
00043     collation(NULL, DERIVATION_IMPLICIT)
00044   { 
00045     name.str= strdup(arg);
00046     name.length= strlen(arg);
00047   }
00048 
00049   ~user_var_entry()
00050   {
00051     if (name.str) 
00052       free(name.str);
00053 
00054     if (value) 
00055       free(value);
00056   }
00057   LEX_STRING name;
00058   char *value;
00059   ulong length;
00060   size_t size;
00061   query_id_t update_query_id;
00062   query_id_t used_query_id;
00063   Item_result type;
00064   bool unsigned_flag;
00065 
00066   double val_real(bool *null_value);
00067   int64_t val_int(bool *null_value) const;
00068   String *val_str(bool *null_value, String *str, uint32_t decimals);
00069   type::Decimal *val_decimal(bool *null_value, type::Decimal *result);
00070   DTCollation collation;
00071 
00072   bool update_hash(bool set_null, void *ptr, uint32_t length,
00073                    Item_result type, const CHARSET_INFO * const cs, Derivation dv,
00074                    bool unsigned_arg);
00075 };
00076 
00077 } /* namespace drizzled */
00078