~drizzle-trunk/drizzle/development

642.1.11 by Lee
move functions from item.cc/item.h to item directory
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
642.1.11 by Lee
move functions from item.cc/item.h to item directory
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
20
#include <config.h>
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
21
642.1.11 by Lee
move functions from item.cc/item.h to item directory
22
#include <drizzled/item/cache_decimal.h>
23
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
24
namespace drizzled
25
{
26
642.1.11 by Lee
move functions from item.cc/item.h to item directory
27
void Item_cache_decimal::store(Item *item)
28
{
2030.1.4 by Brian Aker
Change my_decimal to Decimal
29
  type::Decimal *val= item->val_decimal_result(&decimal_value);
642.1.11 by Lee
move functions from item.cc/item.h to item directory
30
  if (!(null_value= item->null_value) && val != &decimal_value)
2030.1.3 by Brian Aker
Second pass through function names.
31
    class_decimal2decimal(val, &decimal_value);
642.1.11 by Lee
move functions from item.cc/item.h to item directory
32
}
33
34
double Item_cache_decimal::val_real()
35
{
36
  assert(fixed);
37
  double res;
2030.1.3 by Brian Aker
Second pass through function names.
38
  class_decimal2double(E_DEC_FATAL_ERROR, &decimal_value, &res);
642.1.11 by Lee
move functions from item.cc/item.h to item directory
39
  return res;
40
}
41
42
int64_t Item_cache_decimal::val_int()
43
{
44
  assert(fixed);
45
  int64_t res;
2034.2.1 by Brian Aker
Move class_decimal2int to a method on Decimal.
46
  decimal_value.val_int32(E_DEC_FATAL_ERROR, unsigned_flag, &res);
642.1.11 by Lee
move functions from item.cc/item.h to item directory
47
  return res;
48
}
49
50
String* Item_cache_decimal::val_str(String *str)
51
{
52
  assert(fixed);
2030.1.2 by Brian Aker
First pass in refactoring of the name of my_decimal.
53
  class_decimal_round(E_DEC_FATAL_ERROR, &decimal_value, decimals, false,
642.1.11 by Lee
move functions from item.cc/item.h to item directory
54
                   &decimal_value);
2137.1.8 by Brian Aker
Remove error type from str convert since we always want an error.
55
  class_decimal2string(&decimal_value, 0, str);
642.1.11 by Lee
move functions from item.cc/item.h to item directory
56
  return str;
57
}
58
2030.1.4 by Brian Aker
Change my_decimal to Decimal
59
type::Decimal *Item_cache_decimal::val_decimal(type::Decimal *)
642.1.11 by Lee
move functions from item.cc/item.h to item directory
60
{
61
  assert(fixed);
62
  return &decimal_value;
63
}
64
65
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
66
} /* namespace drizzled */