~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
2318.7.17 by Olaf van der Spek
Refactor Items
24
namespace drizzled {
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
25
642.1.11 by Lee
move functions from item.cc/item.h to item directory
26
void Item_cache_decimal::store(Item *item)
27
{
2030.1.4 by Brian Aker
Change my_decimal to Decimal
28
  type::Decimal *val= item->val_decimal_result(&decimal_value);
642.1.11 by Lee
move functions from item.cc/item.h to item directory
29
  if (!(null_value= item->null_value) && val != &decimal_value)
2030.1.3 by Brian Aker
Second pass through function names.
30
    class_decimal2decimal(val, &decimal_value);
642.1.11 by Lee
move functions from item.cc/item.h to item directory
31
}
32
33
double Item_cache_decimal::val_real()
34
{
35
  assert(fixed);
36
  double res;
2030.1.3 by Brian Aker
Second pass through function names.
37
  class_decimal2double(E_DEC_FATAL_ERROR, &decimal_value, &res);
642.1.11 by Lee
move functions from item.cc/item.h to item directory
38
  return res;
39
}
40
41
int64_t Item_cache_decimal::val_int()
42
{
43
  assert(fixed);
44
  int64_t res;
2034.2.1 by Brian Aker
Move class_decimal2int to a method on Decimal.
45
  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
46
  return res;
47
}
48
49
String* Item_cache_decimal::val_str(String *str)
50
{
51
  assert(fixed);
2318.7.17 by Olaf van der Spek
Refactor Items
52
  class_decimal_round(E_DEC_FATAL_ERROR, &decimal_value, decimals, false, &decimal_value);
2137.1.8 by Brian Aker
Remove error type from str convert since we always want an error.
53
  class_decimal2string(&decimal_value, 0, str);
642.1.11 by Lee
move functions from item.cc/item.h to item directory
54
  return str;
55
}
56
2030.1.4 by Brian Aker
Change my_decimal to Decimal
57
type::Decimal *Item_cache_decimal::val_decimal(type::Decimal *)
642.1.11 by Lee
move functions from item.cc/item.h to item directory
58
{
59
  assert(fixed);
60
  return &decimal_value;
61
}
62
63
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
64
} /* namespace drizzled */