.TH "FBB::OHexBuf" "3bobcat" "2005\-2020" "libbobcat\-dev_5\&.07\&.00" "Write hex values" .PP .SH "NAME" FBB::OHexBuf \- Writes characters written to an ostream as hex values .PP .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lbobcat\fP .PP .SH "DESCRIPTION" .PP \fBOHexBuf\fP is a specialization of \fIFBB::OFilterBuf\fP inserting all the characters it receives to a destination file as 2\-character wide hexadecimal values\&. Optionally a maximum linelength can be specified\&. .PP Note that all information received by an \fIOHexBuf\fP object is inserted as (a series of) hexadecimal values, not only plain characters\&. E\&.g\&., when inserting the value 123 the characters \fI\(cq\&1\(cq\&, \(cq\&2\(cq\&\fP and \fI\(cq\&3\(cq\&\fP are successively inserted and so this will result in the string \fI313233\fP being inserted into the destination stream\&. .PP .SH "NAMESPACE" \fBFBB\fP .br All constructors, members, operators and manipulators, mentioned in this man\-page, are defined in the namespace \fBFBB\fP\&. .PP .SH "INHERITS FROM" \fIFBB::OFilterBuf\fP .PP .SH "CONSTRUCTOR" .IP o \fBOHexBuf(std::ostream &stream, size_t width = 0, std::string const &separator = \(dq\&\(dq\&)\fP: .br The hexadecimal characters produced by the \fIOFilterBuf\fP object are inserted into \fIstream\fP\&. Optionally the maximum line width (in number of characters) may be specified using \fIwidth\fP\&. The (default) value 0 indicates that no line breaks are requested\&. The parameter \fIseparator\fP defines the separator that\(cq\&s inserted between hexadecimal character values\&. By default no separator is used\&. .PP Copy and move constructors (and assignment operators) are not available\&. .PP 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 \fIostream\fP\&. .PP .SH "MEMBER FUNCTIONS" All members of \fBFBB::OFilterBuf\fP, in particular its \fIout()\fP and \fIreset\fP members are available, as \fBFBB::OHexBuf\fP inherits from this class\&. .IP o \fBvoid eoi()\fP: .br This member completes the current hexadecimal character conversion, clears the separator, and no longer uses a the maximum output line width\&. Instead of calling this member the \fIeoi\fP manipulator (see below) can be used\&. .IP .IP o \fBvoid separator(bool reset = true)\fP: .br This member clears the separator that\(cq\&s inserted between hexadecimal character values\&. When the \fIreset\fP parameter is set to \fItrue\fP (which is the default) the currently used output width is reset to 0\&. .IP .IP o \fBvoid separator(std::string const &separator, bool reset = true)\fP: .br This member resets the separator that\(cq\&s inserted between hexadecimal character values to \fIseparator\(cq\&s\fP value\&. When the \fIreset\fP parameter is set to \fItrue\fP (which is the default) the currently used output width is reset to 0\&. .IP .IP o \fBvoid setWidth(size_t width)\fP: .br This member sets the width of the generated output lines to \fIwidth\fP characters\&. No maximum line width is used when \fIwidth = 0\fP is specified\&. .IP .IP o \fBsize_t size() const\fP: .br This member returns the next column offset where the next hexadecimal character will appear\&. If a maximum line length is requested and \fIsize()\fP does not return 0 then the last line inserted was not terminated by a \fI\(cq\&\en\(cq\&\fP character\&. See also the example below\&. .IP This member\(cq\&s return value is undefined if no maximum line length was requested\&. .PP .SH "MANIPULATOR" .IP o \fBFBB::eoi\fP: .br The \fIeoi\fP manipulator can be inserted into the \fIostream\fP to complete the hexaecimal conversion\&. It acts identically to calling the \fIend\fP member\&. If inserted into a plain \fIstd::ostream\fP nothing happens\&. .PP .SH "STATIC MEMBER" .IP o \fBstd::string text2bin(std::string const &in)\fP: .br This static member converts a series of hexadecimal characters generated by a \fIOHexBuf\fP object back to their binary form\&. E\&.g, when called as \fIOHexBuf::text2bin(\(dq\&736d616c6c206976\(dq\&)\fP then the returned \fIstd::string\fP will contain 8 characters, having respectively the binary values 0x73, 0x6d, 0x61, 0x6c, 0x6c, 0x20, 0x69, and 0x76\&. .IP This function does \fInot\fP verify whether its argument is properly formed\&. A properly formed argument consists of an even number of hexadecimal number characters (\(cq\&0\(cq\& until \(cq\&9\(cq\&, \(cq\&a\(cq\& until \(cq\&f\(cq\& (or uppercase))\&. For improperly formed arguments the return value is undefined\&. .IP .SH "EXAMPLE" .nf #include #include using namespace std; using namespace FBB; int main() { OHexBuf ohex(cout, 40); ostream out(&ohex); out << cin\&.rdbuf(); if (ohex\&.size()) cout << \(cq\&\en\(cq\&; } .fi .PP .SH "FILES" \fIbobcat/ohexbuf\fP \- defines the class interface .PP .SH "SEE ALSO" \fBbobcat\fP(7), \fBofilterbuf\fP(3bobcat) .PP .SH "BUGS" None Reported\&. .PP .SH "BOBCAT PROJECT FILES" .PP .IP o \fIhttps://fbb\-git\&.gitlab\&.io/bobcat/\fP: gitlab project page; .IP o \fIbobcat_5\&.07\&.00\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_5\&.07\&.00\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_5\&.07\&.00\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_5\&.07\&.00\-x_*\&.deb\fP: debian package containing the libraries; .IP o \fIlibbobcat1\-dev_5\&.07\&.00\-x_*\&.deb\fP: debian package containing the libraries, headers and manual pages; .PP .SH "BOBCAT" Bobcat is an acronym of `Brokken\(cq\&s Own Base Classes And Templates\(cq\&\&. .PP .SH "COPYRIGHT" This is free software, distributed under the terms of the GNU General Public License (GPL)\&. .PP .SH "AUTHOR" Frank B\&. Brokken (\fBf\&.b\&.brokken@rug\&.nl\fP)\&. .PP