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