~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/util/convert.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
using namespace std;
29
29
 
30
 
namespace drizzled
31
 
{
 
30
namespace drizzled {
32
31
 
33
32
uint64_t drizzled_string_to_hex(char *to, const char *from, uint64_t from_size)
34
33
{
35
 
  static const char hex_map[]= "0123456789ABCDEF";
36
 
  const char *from_end;
37
 
 
38
 
  for (from_end= from + from_size; from != from_end; from++)
 
34
  static const char* hex_map= "0123456789ABCDEF";
 
35
  
 
36
  for (const char *from_end= from + from_size; from != from_end; from++)
39
37
  {
40
38
    *to++= hex_map[((unsigned char) *from) >> 4];
41
39
    *to++= hex_map[((unsigned char) *from) & 0xF];
60
58
void drizzled_hex_to_string(char *to, const char *from, uint64_t from_size)
61
59
{
62
60
  const char *from_end = from + from_size;
63
 
 
64
61
  while (from != from_end)
65
62
  {
66
63
    *to= hex_char_value(*from++) << 4;
71
68
 
72
69
void bytesToHexdumpFormat(string &to, const unsigned char *from, size_t from_length)
73
70
{
74
 
  static const char hex_map[]= "0123456789abcdef";
75
 
  unsigned int x, y;
 
71
  static const char* hex_map= "0123456789abcdef";
76
72
  ostringstream line_number;
77
73
 
78
 
  for (x= 0; x < from_length; x+= 16)
 
74
  for (size_t x= 0; x < from_length; x+= 16)
79
75
  {
80
 
    line_number << setfill('0') << setw(6);
81
 
    line_number << x;
 
76
    line_number << setfill('0') << setw(6) << x;
82
77
    to.append(line_number.str());
83
78
    to.append(": ", 2);
84
79
 
85
 
    for (y= 0; y < 16; y++)
 
80
    for (size_t y= 0; y < 16; y++)
86
81
    {
87
 
      if ((x + y) < from_length)
 
82
      if (x + y < from_length)
88
83
      {
89
84
        to.push_back(hex_map[(from[x+y]) >> 4]);
90
85
        to.push_back(hex_map[(from[x+y]) & 0xF]);
94
89
        to.append("   ");
95
90
    }
96
91
    to.push_back(' ');
97
 
    for (y= 0; y < 16; y++)
 
92
    for (size_t y= 0; y < 16; y++)
98
93
    {
99
 
      if ((x + y) < from_length)
 
94
      if (x + y < from_length)
100
95
        to.push_back(isprint(from[x + y]) ? from[x + y] : '.');
101
96
    }
102
97
    to.push_back('\n');