OHexBuf is a specialization of FBB::OFilterBuf inserting all the characters it receives to a destination file as 2-character wide hexadecimal values. Optionally a maximum linelength can be specified.
Note that all information received by an OHexBuf object is inserted as (a series of) hexadecimal values, not only plain characters. E.g., when inserting the value 123 the characters '1', '2' and '3' are successively inserted and so this will result in the string 313233 being inserted into the destination stream.
Copy and move constructors (and assignment operators) are not available.
The destructor writes any buffered information to the destination stream and then flushes the destination stream. Finally, the destructor restores the original formatting flags of the receiving ostream.
This member's return value is undefined if no maximum line length was requested.
This function does not verify whether its argument is properly formed. A properly formed argument consists of an even number of hexadecimal number characters ('0' until '9', 'a' until 'f' (or uppercase)). For improperly formed arguments the return value is undefined.
#include <iostream>
#include <bobcat/ohexbuf>
using namespace std;
using namespace FBB;
int main()
{
OHexBuf ohex(cout, 40);
ostream out(&ohex);
out << cin.rdbuf();
if (ohex.size())
cout << '\n';
}
Debian Bobcat project files: