Regina 7.0 Calculation Engine
|
General helper tools for signatures that use base64 encodings. More...
#include <utilities/sigutils.h>
Static Public Member Functions | |
static constexpr unsigned | decodeSingle (char c) |
Determine the integer value represented by the given base64 character. More... | |
static constexpr char | encodeSingle (unsigned c) |
Determine the base64 character that represents the given integer value. More... | |
static constexpr bool | isValid (char c) |
Is the given character a valid base64 character? More... | |
template<typename IntType > | |
static void | encodeInt (std::string &s, IntType val, unsigned nChars) |
Append a base64 encoding of the given integer to the given string. More... | |
template<typename IntType > | |
static IntType | decodeInt (const char *s, unsigned nChars) |
Read the integer that is encoded at the beginning of the given base64 string. More... | |
template<typename InputIterator > | |
static char | encodeTrits (InputIterator trits, unsigned nTrits) |
Returns a single base64 character that encodes up to three trits, given using an input iterator. More... | |
template<int nTrits> | |
static constexpr char | encodeTrits (const std::array< uint8_t, nTrits > &trits) |
Returns a single base64 character that encodes up to three trits, given using a fixed-size array. More... | |
template<typename OutputIterator > | |
static void | decodeTrits (char c, OutputIterator result) |
Decodes a single base64 character into three trits, and returns these using an output iterator. More... | |
static constexpr std::array< uint8_t, 3 > | decodeTrits (char c) |
Decodes a single base64 character into three trits, and returns these as a fixed-size array. More... | |
General helper tools for signatures that use base64 encodings.
These are (in particular) used in the default encodings for Regina's own isomorphism signatures and knot signatures.
This base64 encoding uses the characters: a..zA..Z0..9+-
|
inlinestatic |
Read the integer that is encoded at the beginning of the given base64 string.
It will be assumed that the integer is encoded using nChars base64 characters, each containing 6 bits of the integer, with the lowest-significance bits encoded in the first characters.
The inverse to this routine is encodeInt().
long
.IntType | a native C++ integer type, such as uint8_t , or unsigned , or long long . The result will be assembled using bitwise OR and bitwise shift lefts, and it is assumed that the programmer has chosen an integer type large enough to contain whatever values they expect to read. |
s | the string from which the encoded base64 characters should be read. |
nChars | the number of base64 characters to read. |
|
inlinestaticconstexpr |
Determine the integer value represented by the given base64 character.
The inverse to this routine is encodeSingle().
c | a base64 character, which must be one of the 64 printable characters described in the class notes. |
|
inlinestaticconstexpr |
Decodes a single base64 character into three trits, and returns these as a fixed-size array.
A trit is either 0, 1 or 2.
The inverse to this routine is encodeTrits(); see that routine for details of the encoding.
c | the base64 character to decode. |
|
inlinestatic |
Decodes a single base64 character into three trits, and returns these using an output iterator.
A trit is either 0, 1 or 2.
The inverse to this routine is encodeTrits(); see that routine for details of the encoding.
c | the base64 character to decode. |
result | an output iterator pointing to the location where the resulting trits will be stored; it must be possible to write and advance this iterator at least three times. Each trit will be written as a uint8_t . |
|
inlinestatic |
Append a base64 encoding of the given integer to the given string.
The integer will be broken into nChars distinct 6-bit blocks, and the lowest-significance blocks will be written first.
The inverse to this routine is decodeInt().
long
.IntType | a native C++ integer type, such as uint8_t , or unsigned , or long long . |
s | the string that resulting characters should be appended to. |
val | the integer to encode. |
nChars | the number of base64 characters to use. |
|
inlinestaticconstexpr |
Determine the base64 character that represents the given integer value.
The inverse to this routine is decodeSingle().
c | an integer between 0 and 63 inclusive. |
|
inlinestaticconstexpr |
Returns a single base64 character that encodes up to three trits, given using a fixed-size array.
A trit is either 0, 1 or 2.
The given trits will be packed into a single base64 character, with the first trit representing the lowest-significance bits of the underlying integer and so on.
The inverse to this routine is decodeTrits().
mTrits | the number of trits to encode; this must be between 0 and 3 inclusive. |
trits | the array of trits to encode. Each trit must take the value 0, 1 or 2. |
|
inlinestatic |
Returns a single base64 character that encodes up to three trits, given using an input iterator.
A trit is either 0, 1 or 2.
The given trits will be packed into a single base64 character, with the first trit representing the lowest-significance bits of the underlying integer and so on.
The inverse to this routine is decodeTrits().
trits | an input iterator pointing to the first trit to encode; it must be possible to read and advance this iterator at least nTrits times. Each trit will be cast to a uint8_t , and must take the value 0, 1 or 2. |
nTrits | the number of trits to encode; this must be at most 3. |
|
inlinestaticconstexpr |
Is the given character a valid base64 character?
true
if and only if the given character is one of the 64 printable characters described in the class notes.