~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cache_decimal.cc

  • Committer: Olaf van der Spek
  • Date: 2011-10-10 09:27:50 UTC
  • mto: (2430.1.6 rf)
  • mto: This revision was merged to the branch mainline in revision 2436.
  • Revision ID: olafvdspek@gmail.com-20111010092750-ryxgmn7zj5yvxfkf
Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <config.h>
21
21
 
22
22
#include <drizzled/item/cache_decimal.h>
23
23
 
24
 
namespace drizzled
25
 
{
 
24
namespace drizzled {
26
25
 
27
26
void Item_cache_decimal::store(Item *item)
28
27
{
29
 
  my_decimal *val= item->val_decimal_result(&decimal_value);
 
28
  type::Decimal *val= item->val_decimal_result(&decimal_value);
30
29
  if (!(null_value= item->null_value) && val != &decimal_value)
31
 
    my_decimal2decimal(val, &decimal_value);
 
30
    class_decimal2decimal(val, &decimal_value);
32
31
}
33
32
 
34
33
double Item_cache_decimal::val_real()
35
34
{
36
35
  assert(fixed);
37
36
  double res;
38
 
  my_decimal2double(E_DEC_FATAL_ERROR, &decimal_value, &res);
 
37
  class_decimal2double(E_DEC_FATAL_ERROR, &decimal_value, &res);
39
38
  return res;
40
39
}
41
40
 
43
42
{
44
43
  assert(fixed);
45
44
  int64_t res;
46
 
  my_decimal2int(E_DEC_FATAL_ERROR, &decimal_value, unsigned_flag, &res);
 
45
  decimal_value.val_int32(E_DEC_FATAL_ERROR, unsigned_flag, &res);
47
46
  return res;
48
47
}
49
48
 
50
49
String* Item_cache_decimal::val_str(String *str)
51
50
{
52
51
  assert(fixed);
53
 
  my_decimal_round(E_DEC_FATAL_ERROR, &decimal_value, decimals, false,
54
 
                   &decimal_value);
55
 
  my_decimal2string(E_DEC_FATAL_ERROR, &decimal_value, 0, 0, 0, str);
 
52
  class_decimal_round(E_DEC_FATAL_ERROR, &decimal_value, decimals, false, &decimal_value);
 
53
  class_decimal2string(&decimal_value, 0, str);
56
54
  return str;
57
55
}
58
56
 
59
 
my_decimal *Item_cache_decimal::val_decimal(my_decimal *)
 
57
type::Decimal *Item_cache_decimal::val_decimal(type::Decimal *)
60
58
{
61
59
  assert(fixed);
62
60
  return &decimal_value;