Drizzled Public API Documentation

decimal.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/item/num.h>
00023 
00024 namespace drizzled {
00025 
00026 /* decimal (fixed point) constant */
00027 class Item_decimal : public Item_num
00028 {
00029 protected:
00030   type::Decimal decimal_value;
00031 public:
00032   Item_decimal(const char *str_arg, uint32_t length, const charset_info_st*);
00033   Item_decimal(const char *str, const type::Decimal *val_arg, uint32_t decimal_par, uint32_t length);
00034   Item_decimal(type::Decimal *value_par);
00035   Item_decimal(int64_t val, bool unsig);
00036   Item_decimal(double val, int precision, int scale);
00037   Item_decimal(const unsigned char *bin, int precision, int scale);
00038 
00039   enum Type type() const { return DECIMAL_ITEM; }
00040   enum Item_result result_type () const { return DECIMAL_RESULT; }
00041   enum_field_types field_type() const { return DRIZZLE_TYPE_DECIMAL; }
00042   int64_t val_int();
00043   double val_real();
00044   String *val_str(String*);
00045   type::Decimal *val_decimal(type::Decimal *)
00046   { return &decimal_value; }
00047   int save_in_field(Field *field, bool no_conversions);
00048   bool basic_const_item() const { return true; }
00049   Item *clone_item()
00050   {
00051     return new Item_decimal(name, &decimal_value, decimals, max_length);
00052   }
00053   virtual void print(String *str);
00054   Item_num *neg()
00055   {
00056     class_decimal_neg(&decimal_value);
00057     unsigned_flag= !decimal_value.sign();
00058     return this;
00059   }
00060   uint32_t decimal_precision() const { return decimal_value.precision(); }
00061   bool eq(const Item *, bool binary_cmp) const;
00062   void set_decimal_value(type::Decimal *value_par);
00063 };
00064 
00065 } /* namespace drizzled */
00066