~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/util/convert.cc

  • Committer: Monty Taylor
  • Date: 2009-04-20 14:42:34 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 1003.
  • Revision ID: mordred@inaugust.com-20090420144234-4k1x60fiag2l1y0n
Ported InnoDB to register_plugins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
#include <drizzled/util/convert.h>
22
 
#include <string>
23
 
#include <iomanip>
24
 
#include <sstream>
25
 
 
26
 
using namespace std;
27
22
 
28
23
uint64_t drizzled_string_to_hex(char *to, const char *from, uint64_t from_size)
29
24
{
40
35
 
41
36
  return from_size * 2;
42
37
}
43
 
 
44
 
void bytesToHexdumpFormat(string &to, const unsigned char *from, size_t from_length)
45
 
{
46
 
  static const char hex_map[]= "0123456789abcdef";
47
 
  unsigned int x, y;
48
 
  ostringstream line_number;
49
 
 
50
 
  for (x= 0; x < from_length; x+= 16)
51
 
  {
52
 
    line_number << setfill('0') << setw(6);
53
 
    line_number << x;
54
 
    to.append(line_number.str());
55
 
    to.append(": ", 2);
56
 
 
57
 
    for (y= 0; y < 16; y++)
58
 
    {
59
 
      if ((x + y) < from_length)
60
 
      {
61
 
        to.push_back(hex_map[(from[x+y]) >> 4]);
62
 
        to.push_back(hex_map[(from[x+y]) & 0xF]);
63
 
        to.push_back(' ');
64
 
      }
65
 
      else
66
 
        to.append("   ");
67
 
    }
68
 
    to.push_back(' ');
69
 
    for (y= 0; y < 16; y++)
70
 
    {
71
 
      if ((x + y) < from_length)
72
 
        to.push_back(isprint(from[x + y]) ? from[x + y] : '.');
73
 
    }
74
 
    to.push_back('\n');
75
 
    line_number.str("");
76
 
  }
77
 
}