.TH "FBB::LDC" "3bobcat" "2005\-2023" "libbobcat\-dev_6\&.04\&.00" "Convert (large) digital values to characters" .PP .SH "NAME" FBB::LDC \- Converts (large) digital values to characters .PP .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lbobcat\fP .PP .SH "DESCRIPTION" Objects of the class \fILDC\fP (Large Digital Converter) convert (large) digital values (like values handled by the class \fIBigInt\fP (cf\&. \fBbigint\fP(3bobcat))) to character representations using radices from 2 through 36\&. For radices larger than 10 letters are used, using \fIa\fP through \fIz\fP to represent the (decimal) values 10 through 36\&. When specifying radices outside of this range an exception is thrown\&. .PP Alternatively, the digits of the converted number can be provided in a \fIstd::string\fP argument, where the string\(cq\&s first character (at index 0) is used for value 0, the next character for value 1, etc\&., until the string\(cq\&s last character\&. In that case the string\(cq\&s length defines the number system that is used for converting the (large) digital value\&. Usually the first 10 characters will be \fI\(dq\&0123456789\(dq\&\fP, but LDC doesn\(cq\&t enforce that\&. Instead, any series of characters can be specified, in which case the character at index \fIidx\fP is used to represent value \fIidx\fP in the converted value string\&. E\&.g\&., when specifying \fI\(dq\&abcdefghij\(dq\&\fP the hexadecimal value \fI\(dq\&deadbeef\(dq\&\fP is converted to \fI\(dq\&dhdfjciffj\(dq\&\fP instead of \fI\(dq\&3735928559\(dq\&\fP, which is the normally used decimal digit representation\&. Digit strings must at least contain two characters or an exception is thrown\&. .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" \- .PP .SH "CONSTRUCTORS" .IP o \fBLDC()\fP: .br The default constructor initializes its value to 0; .IP .IP o \fBLDC(std::string const &hexNr, size_t radix = 10)\fP: .br The bytes of the string \fIhexNr\fP contains the character representation of a hexadecimal value, which is converted to its equivalent representation using the \fIradix\fP number system\&. The string \fIhexNr\fP should not begin with \fI0x\fP, but its first character should be the value\(cq\&s most significant digit\&. E\&.g\&., \fILDC ldc{ \(dq\&12345\(dq\& }\fP is converted to decimal 74565 (in this example \fI\(dq\&12345\(dq\&\fP is first converted to a \fIstd::string\fP, which is then passed on to \fIldc\(cq\&s\fP constructor)\&. \fIhexNr\fP may not be empty or an exception is thrown; .IP .IP o \fBLDC(std::string const &hexNr, std::string const &digits)\fP: .br Same as the previous constructor, but the number system is inferred from \fIdigits\(cq\&s\fP length, using its first character to represent value 0, and its last character to represent the final digit of the inferred number system; .IP .IP o \fBLDC(size_t nBytes, char const *bytes, size_t radix = 10)\fP: .br The bytes of the string \fIbytes\fP contains the character representation of a hexadecimal value, which is converted to its equivalent representation using \fIradix\fP\&. The string \fIbytes\fP should not begin with \fI0x\fP, but its first character should be the value\(cq\&s most significant digit\&. E\&.g\&., \fILDC{ 5, \(dq\&12345\(dq\& }\fP is converted to decimal 74565\&. \fInBytes\fP must be at least 1 or an exception is thrown; .IP .IP o \fBLDC(size_t nBytes, char const *bytes, std::string const &digits)\fP: .br Same as the previous constructor, but the number system and the digit characters are inferred from \fIdigits\fP; .IP .IP o \fBLDC(BigInt const &bigInt, size_t radix = 10)\fP: .br \fIBigInt\(cq\&s\fP value is converted to its equivalent representation using \fIradix\fP; .IP .IP o \fBLDC(BigInt const &bigInt, std::string const &digits)\fP: .br Same as the previous constructor, but the number system and the digit characters are inferred from \fIdigits\fP\&. .PP Copy and move constructors (and assignment operators) are available\&. .PP .SH "OVERLOADED OPERATORS" .PP In addition to the standard copy\- and move\-assignment operators the following operators are available: .IP o \fBLDC &operator=(std::string const &hexNr)\fP: .br The operator\(cq\&s rhs is the character representation of a hexadecimal number, which is assigned to the \fILDC\fP object\&. The object converts \fIhexNr\fP to its decimal representation (see also the members \fIset\fP, below)\&. .br Example: .nf LDC ldc; // initialized with some value ldc = \(dq\&12345\(dq\&; // assign a new value cout << ldc << \(cq\&\en\(cq\& // displays 74655 .fi The rhs value may not be empty or an exception is thrown; .IP .IP o \fBstd::string operator()(size_t power, char sep = \(cq\&\e\(cq\&\(cq\&) const\fP: .br The converted value is returned using separator \fIsep\fP before each multiple of \fIpower\fP digits\&. E\&.g\&., when \fIldc\fP contains the converted value \fI3735928559\fP then \fIldc(3)\fP returns the string \fI3\&.735\&.928\&.559\fP\&. .PP .SH "FREE FUNCTION IN THE FBB NAMESPACE" .PP .IP o \fBstd::ostream &operator<<(std::ostream &out, LDC const &ldc)\fP: .br The insertion operator inserts the converted value into \fIout\fP, returning \fIout\fP\&. .PP .SH "MEMBER FUNCTIONS" .IP o \fBvoid set(std::string const &hexNr, size_t radix = 10)\fP: .br The \fILDC\fP object\(cq\&s converted value is set to the hexadecimal value \fIhexNr\fP, converted to number system \fIradix\fP\&. \fIhexNr\fP may not be empty or an exception is thrown ; .IP .IP o \fBvoid set(std::string const &hexNr, std::string const &digits)\fP: .br Same as the previous member, but converting \fIhexNr\fP to the number system and number characters defined by \fIdigits\fP; .IP .IP o \fBvoid set(size_t nBytes, char const *bytes, size_t radix = 10)\fP: .br The \fILDC\fP object\(cq\&s converted value is set to the hexadecimal value stored in the \fInBytes\fP bytes of \fIbytes\fP, converted to number system \fIradix\fP\&. \fInBytes\fP must be at least 1 or an exception is thrown; .IP .IP o \fBvoid set(size_t nBytes, char const *bytes, std::string const &digits)\fP: .br Same as the previous member, but converting \fIbytes\fP to the number system and number characters defined by \fIdigits\fP; .IP .IP o \fBstd::string const &str() const\fP: .br The \fILDC\fP object\(cq\&s converted value is returned; .IP .IP o \fBvoid swap(LDC &other)\fP: .br The \fIother\fP LDC object and the current \fILDC\fP object are swapped\&. .PP .SH "EXAMPLE" .nf #include #include using namespace std; using namespace FBB; int main(int argc, char **argv) { string value = \(dq\&1122334455667788aabbcc\(dq\&; size_t radix = 10; LDC digits{ value, \(dq\&0123456789ABCDEF\(dq\& }; LDC ldc{ value, radix }; cout << \(dq\&radix = \(dq\& << radix << \(dq\&\en\(dq\& \(dq\&value = \(dq\& << value << \(dq\&\en\(dq\& \(dq\&digits: \(dq\& << digits << \(dq\&\en\(dq\& \(dq\& LDC: \(dq\& << ldc << \(dq\&\en\(dq\& \(dq\& \(dq\& << ldc(3, \(cq\&\&.\(cq\&) << \(cq\&\en\(cq\&; } // shows: // radix = 10 // value = 1122334455667788aabbcc // digits: 1122334455667788AABBCC // LDC: 20713245101768454273940428 // 20\&.713\&.245\&.101\&.768\&.454\&.273\&.940\&.428 .fi .PP .SH "FILES" \fIbobcat/ldc\fP \- defines the class interface .PP .SH "SEE ALSO" \fBbobcat\fP(7) .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_6\&.04\&.00\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_6\&.04\&.00\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_6\&.04\&.00\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_6\&.04\&.00\-x_*\&.deb\fP: debian package containing the libraries; .IP o \fIlibbobcat1\-dev_6\&.04\&.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