LDC(3bobcat)

✨ FBB::LDC ✨

okay bestie, welcome to the bobcat section 3 man page for FBB::LDC β€” yes that's the manual name, we're not typing the whole (3bobcat) thing twice, iykyk 🫢


🌸 NAME 🌸

FBB::LDC β€” Converts (large) digital values to characters


πŸŽ€ SYNOPSIS πŸŽ€

#include <bobcat/LDC>
Linking option: -lbobcat

πŸ’… DESCRIPTION πŸ’…

so like. Objects of the class LDC (Large Digital Converter) convert (large) digital values β€” think the kind of values the class BigInt handles, cf. bigint(3bobcat) β€” into character representations using radices from 2 through 36. For radices bigger than 10 we use letters, a through z, to represent the (decimal) values 10 through 36. And if you go specifying radices outside that range? exception thrown, bestie. πŸ’€

Alternatively, the digits of the converted number can be handed over in a std::string argument, where the string's first character (at index 0) is used for value 0, the next character for value 1, etc., all the way to the string's last character. In that case the string's length defines the number system used for converting the (large) digital value. Usually the first 10 characters will be "0123456789", but LDC doesn't enforce that. Nope! Instead, literally any series of characters can be specified, and the character at index idx is used to represent value idx in the converted value string. E.g., when you specify "abcdefghij" the hexadecimal value "deadbeef" gets converted to "dhdfjciffj" instead of "3735928559" β€” which is the normally used decimal digit representation. And digit strings must contain at least two characters or an exception is thrown. periodt.


🌈 NAMESPACE 🌈

FBB

All constructors, members, operators and manipulators mentioned in this man-page are defined in the namespace FBB.


🌟 INHERITS FROM 🌟

-


πŸ¦‹ CONSTRUCTORS πŸ¦‹

  • LDC() β€” the default constructor initializes its value to 0;
  • LDC(std::string const &hexNr, size_t radix = 10) β€” the bytes of the string hexNr contain the character representation of a hexadecimal value, which gets converted to its equivalent representation using the radix number system. The string hexNr should not begin with 0x, but its first character should be the value's most significant digit. E.g., LDC ldc{ "12345" } is converted to decimal 74565 (in this example "12345" is first converted to a std::string, which is then passed on to ldc's constructor). hexNr may not be empty or an exception is thrown;
  • LDC(std::string const &hexNr, std::string const &digits) β€” same as the previous constructor, but the number system is inferred from digits's length, using its first character to represent value 0, and its last character to represent the final digit of the inferred number system;
  • LDC(size_t nBytes, char const *bytes, size_t radix = 10) β€” the bytes of the string bytes contain the character representation of a hexadecimal value, which is converted to its equivalent representation using radix. The string bytes should not begin with 0x, but its first character should be the value's most significant digit. E.g., LDC{ 5, "12345" } is converted to decimal 74565. And nBytes must be at least 1 or an exception is thrown;
  • LDC(size_t nBytes, char const *bytes, std::string const &digits) β€” same as the previous constructor, but the number system and the digit characters are inferred from digits;
  • LDC(BigInt const &bigInt, size_t radix = 10) β€” BigInt's value is converted to its equivalent representation using radix;
  • LDC(BigInt const &bigInt, std::string const &digits) β€” same as the previous constructor, but the number system and the digit characters are inferred from digits.

Copy and move constructors (and assignment operators) are available. 🫢


πŸ‘‘ OVERLOADED OPERATORS πŸ‘‘

In addition to the standard copy- and move-assignment operators, the following operators are available:

  • LDC &operator=(std::string const &hexNr) β€” the operator's rhs is the character representation of a hexadecimal number, which gets assigned to the LDC object. The object converts hexNr to its decimal representation (see also the members set, below).

Example:

LDC ldc;            // initialized with some value
ldc = "12345";      // assign a new value
cout << ldc << '\n' // displays 74655

And yeah, the rhs value may not be empty or an exception is thrown;

  • std::string operator()(size_t power, char sep = '\'') const β€” the converted value is returned using separator sep before each multiple of power digits. E.g., when ldc contains the converted value 3735928559 then ldc(3) returns the string 3.735.928.559. iconic honestly.

πŸ“ FREE FUNCTION IN THE FBB NAMESPACE πŸ“

  • std::ostream &operator<<(std::ostream &out, LDC const &ldc) β€” the insertion operator inserts the converted value into out, and returns out.

πŸ’– MEMBER FUNCTIONS πŸ’–

  • void set(std::string const &hexNr, size_t radix = 10) β€” the LDC object's converted value is set to the hexadecimal value hexNr, converted to number system radix. hexNr may not be empty or an exception is thrown;
  • void set(std::string const &hexNr, std::string const &digits) β€” same as the previous member, but converting hexNr to the number system and number characters defined by digits;
  • void set(size_t nBytes, char const *bytes, size_t radix = 10) β€” the LDC object's converted value is set to the hexadecimal value stored in the nBytes bytes of bytes, converted to number system radix. nBytes must be at least 1 or an exception is thrown;
  • void set(size_t nBytes, char const *bytes, std::string const &digits) β€” same as the previous member, but converting bytes to the number system and number characters defined by digits;
  • std::string const &str() const β€” the LDC object's converted value is returned;
  • void swap(LDC &other) β€” the other LDC object and the current LDC object are swapped.

⭐ EXAMPLE ⭐

#include <iostream>

#include <bobcat/ldc>

using namespace std;
using namespace FBB;

int main(int argc, char **argv)
{
    string value = "1122334455667788aabbcc";

    size_t radix = 10;

    LDC digits{ value, "0123456789ABCDEF" };

    LDC ldc{ value, radix };

    cout << "radix = " << radix << "\n"
            "value = " << value << "\n"
            "digits: " << digits << "\n"
            "   LDC: " << ldc << "\n"
            "        " << ldc(3, '.') << '\n';
}

// shows:
//     radix = 10
//     value = 1122334455667788aabbcc
//     digits: 1122334455667788AABBCC
//        LDC: 20713245101768454273940428
//             20.713.245.101.768.454.273.940.428

🧚 FILES 🧚

bobcat/ldc β€” defines the class interface


πŸ”₯ SEE ALSO πŸ”₯

bobcat(7)


πŸ™ˆ BUGS πŸ™ˆ

None Reported. (we love a clean slate πŸ’…)


🌸 BOBCAT PROJECT FILES 🌸

Debian Bobcat project files:

  • libbobcat6 : debian package containing the shared library, changelog and copyright note;
  • libbobcat-dev : debian package containing the static library, headers, manual pages, and developer info;

πŸ’œ BOBCAT πŸ’œ

Bobcat is an acronym of Brokken's Own Base Classes And Templates.


This is free software, distributed under the terms of the GNU General Public License (GPL).


🫢 AUTHOR 🫢

Frank B. Brokken (f.b.brokken@rug.nl).


okay that's the whole page bestie, no notes, ate and left no crumbs πŸ’…βœ¨ this was libbobcat-dev_6.15.01, dated 2005-2026, and the page itself is FBB::LDC(3bobcat) β€” go forth and convert some large digital values, mwah πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from