~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/hex_string.cc

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

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"
21
 
 
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
22
22
#include <drizzled/error.h>
23
23
#include <drizzled/item/string.h>
24
24
#include <drizzled/item/hex_string.h>
25
25
 
26
 
#include <algorithm>
27
 
 
28
 
using namespace std;
29
 
 
30
 
namespace drizzled
31
 
{
32
 
 
33
 
static char _dig_vec_lower[] =
34
 
  "0123456789abcdefghijklmnopqrstuvwxyz";
35
 
 
36
26
inline uint32_t char_val(char X)
37
27
{
38
28
  return (uint32_t) (X >= '0' && X <= '9' ? X-'0' :
43
33
Item_hex_string::Item_hex_string(const char *str, uint32_t str_length)
44
34
{
45
35
  max_length=(str_length+1)/2;
46
 
  char *ptr=(char*) memory::sql_alloc(max_length+1);
 
36
  char *ptr=(char*) sql_alloc(max_length+1);
47
37
  if (!ptr)
48
38
    return;
49
39
  str_value.set(ptr,max_length,&my_charset_bin);
65
55
{
66
56
  // following assert is redundant, because fixed=1 assigned in constructor
67
57
  assert(fixed == 1);
68
 
  char *end= (char*) str_value.ptr()+str_value.length(),
69
 
       *ptr= end - min(str_value.length(),(uint32_t)sizeof(int64_t));
 
58
  char *end=(char*) str_value.ptr()+str_value.length(),
 
59
       *ptr=end-cmin(str_value.length(),(uint32_t)sizeof(int64_t));
70
60
 
71
61
  uint64_t value=0;
72
62
  for (; ptr != end ; ptr++)
116
106
void Item_hex_string::print(String *str, enum_query_type)
117
107
{
118
108
  char *end= (char*) str_value.ptr() + str_value.length(),
119
 
       *ptr= end - min(str_value.length(), (uint32_t)sizeof(int64_t));
 
109
       *ptr= end - cmin(str_value.length(), (uint32_t)sizeof(int64_t));
120
110
  str->append("0x");
121
111
  for (; ptr != end ; ptr++)
122
112
  {
150
140
}
151
141
 
152
142
 
153
 
} /* namespace drizzled */