~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/hex_string.cc

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
21
 
 
 
20
#include "config.h"
22
21
#include <drizzled/error.h>
23
 
#include <drizzled/field.h>
 
22
#include <drizzled/item/string.h>
24
23
#include <drizzled/item/hex_string.h>
25
 
#include <drizzled/item/string.h>
26
 
#include <drizzled/type/decimal.h>
27
24
 
28
25
#include <algorithm>
29
26
 
 
27
using namespace drizzled;
30
28
using namespace std;
31
29
 
32
 
namespace drizzled
33
 
{
34
 
 
35
30
static char _dig_vec_lower[] =
36
31
  "0123456789abcdefghijklmnopqrstuvwxyz";
37
32
 
68
63
  // following assert is redundant, because fixed=1 assigned in constructor
69
64
  assert(fixed == 1);
70
65
  char *end= (char*) str_value.ptr()+str_value.length(),
71
 
       *ptr= end - min(str_value.length(), sizeof(int64_t));
 
66
       *ptr= end - min(str_value.length(),(uint32_t)sizeof(int64_t));
72
67
 
73
68
  uint64_t value=0;
74
69
  for (; ptr != end ; ptr++)
77
72
}
78
73
 
79
74
 
80
 
type::Decimal *Item_hex_string::val_decimal(type::Decimal *decimal_value)
 
75
my_decimal *Item_hex_string::val_decimal(my_decimal *decimal_value)
81
76
{
82
77
  // following assert is redundant, because fixed=1 assigned in constructor
83
78
  assert(fixed == 1);
84
79
  uint64_t value= (uint64_t)val_int();
85
 
  int2_class_decimal(E_DEC_FATAL_ERROR, value, true, decimal_value);
 
80
  int2my_decimal(E_DEC_FATAL_ERROR, value, true, decimal_value);
86
81
  return (decimal_value);
87
82
}
88
83
 
118
113
void Item_hex_string::print(String *str, enum_query_type)
119
114
{
120
115
  char *end= (char*) str_value.ptr() + str_value.length(),
121
 
       *ptr= end - min(str_value.length(), sizeof(int64_t));
 
116
       *ptr= end - min(str_value.length(), (uint32_t)sizeof(int64_t));
122
117
  str->append("0x");
123
118
  for (; ptr != end ; ptr++)
124
119
  {
152
147
}
153
148
 
154
149
 
155
 
} /* namespace drizzled */