Drizzled Public API Documentation

cache_decimal.cc
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2008 Sun Microsystems, Inc.
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 
20 #include <config.h>
21 
22 #include <drizzled/item/cache_decimal.h>
23 
24 namespace drizzled {
25 
26 void Item_cache_decimal::store(Item *item)
27 {
28  type::Decimal *val= item->val_decimal_result(&decimal_value);
29  if (!(null_value= item->null_value) && val != &decimal_value)
30  class_decimal2decimal(val, &decimal_value);
31 }
32 
34 {
35  assert(fixed);
36  double res;
37  class_decimal2double(E_DEC_FATAL_ERROR, &decimal_value, &res);
38  return res;
39 }
40 
42 {
43  assert(fixed);
44  int64_t res;
45  decimal_value.val_int32(E_DEC_FATAL_ERROR, unsigned_flag, &res);
46  return res;
47 }
48 
50 {
51  assert(fixed);
52  class_decimal_round(E_DEC_FATAL_ERROR, &decimal_value, decimals, false, &decimal_value);
53  class_decimal2string(&decimal_value, 0, str);
54  return str;
55 }
56 
58 {
59  assert(fixed);
60  return &decimal_value;
61 }
62 
63 
64 } /* namespace drizzled */
type::Decimal * val_decimal(type::Decimal *)
String * val_str(String *)
bool fixed
Definition: item.h:120
TODO: Rename this file - func.h is stupid.
bool null_value
Definition: item.h:122
int class_decimal2string(const type::Decimal *d, uint32_t fixed_dec, String *str)
Converting decimal to string.
Definition: decimal.cc:197