Last change
on this file since 10788 was 10653, checked in by Michael Tänzer, 12 years ago |
Merge the ASIO branch back into trunk
|
File size:
1.0 KB
|
Line | |
---|
1 | //-----------------------------------------------------------------------------
|
---|
2 | // Part of reboost (http://reboost.org). Released under the
|
---|
3 | // BSD 2-clause license (http://www.opensource.org/licenses/bsd-license.php).
|
---|
4 | // Copyright 2012, Sebastian Mies <mies@reboost.org> --- All rights reserved.
|
---|
5 | //-----------------------------------------------------------------------------
|
---|
6 |
|
---|
7 | #include <cstdio>
|
---|
8 | #include <iostream>
|
---|
9 |
|
---|
10 | #include "buffer.hpp"
|
---|
11 |
|
---|
12 | namespace reboost {
|
---|
13 |
|
---|
14 | std::ostream& operator<<( std::ostream& os, const buffer_t& buf ) {
|
---|
15 | os << "{";
|
---|
16 | for (unsigned i=0; i<(buf.size()/8)+1; i++) {
|
---|
17 | if (i!=0) os << ",";
|
---|
18 | os << "[";
|
---|
19 | for (unsigned j=0; j<8; j++) {
|
---|
20 | if ((i*8+j) < buf.size()) {
|
---|
21 | if (j!=0) os << " ";
|
---|
22 | char str[8];
|
---|
23 | int v = buf.data()[i*8+j];
|
---|
24 | sprintf(str,"%02x", v);
|
---|
25 | os << str;
|
---|
26 | }
|
---|
27 | }
|
---|
28 | os << "|";
|
---|
29 | for (unsigned j=0; j<8; j++) {
|
---|
30 | if (i*8+j < buf.size()) {
|
---|
31 | char c = buf.data()[i*8+j];
|
---|
32 | if (c<32) c='.';
|
---|
33 | os << c;
|
---|
34 | }
|
---|
35 | }
|
---|
36 | os <<"]";
|
---|
37 | }
|
---|
38 | os << "}";
|
---|
39 | return os;
|
---|
40 | }
|
---|
41 |
|
---|
42 | } /* namespace reboost */
|
---|
Note:
See
TracBrowser
for help on using the repository browser.