Qx v0.5.8
Qt Extensions Library
|
The Base85 class provides a Base85 encoded string. More...
#include <qx/core/qx-base85.h>
Public Member Functions | |
Base85 () | |
QByteArrayView | data () const |
QByteArray | decode () |
const Base85Encoding * | encoding () const |
bool | isEmpty () |
bool | isNull () |
bool | operator!= (const Base85 &other) const |
bool | operator== (const Base85 &other) const |
qsizetype | size () const |
QString | toString () |
Static Public Member Functions | |
static Base85 | encode (const QByteArray &data, const Base85Encoding *enc) |
static Base85 | fromEncoded (QAnyStringView base85, const Base85Encoding *enc, Base85ParseError *error=nullptr) |
Base85, sometimes referred to by the Adobe specific variant Ascii85, is a form of binary-to-text encoding in which sets of 5 ASCII characters are used to represent equivalent sets of 4 bytes of binary data. This results in the encoded data generally being 20% larger than the original, though some specific encodings support minimal compression techniques.
This encoding format is useful for passing arbitrary binary data over communication protocols that only support single byte, human-readable (English) text, and likely interpret non-glyph characters as control characters, making it impossible to transmit raw data directly.
The encoding gets its name from the fact that each 'digit' of a Base85 encoded string is one of 85 ASCII characters, comparable to how Base16 is composed of the 16 digits 0-9
and A-F
. The original Base85 encoding uses ASCII characters 0x21
('!') through 0x75
('u'), though it is possible to use other characters that aren't necessarily sequential.
Qx::Base85::Base85 | ( | ) |
Constructs a null Base85 encoded string with no encoding set.
QByteArrayView Qx::Base85::data | ( | ) | const |
Returns a view of the encoded data.
QByteArray Qx::Base85::decode | ( | ) |
Decodes the Base85 string to binary data using the same encoding that was used to encode it and returns it as a QByteArray.
|
static |
Encodes data as a Base85 string in accordance with the specific encoding enc and returns it, or a null Base85 if enc is not valid.
const Base85Encoding * Qx::Base85::encoding | ( | ) | const |
Returns a pointer to the encoding used to create this Base85.
|
static |
Parses base85 as a Base85 string that was encoded with enc and creates a Base85 object from it. Any whitespace within the original data will not be present in the resultant object.
Returns a valid (non-null) Base85 string if the parsing succeeds. If it fails, the returned string will be null, and the optional error variable will contain further details about the error.
bool Qx::Base85::isEmpty | ( | ) |
Returns true
if the encoded string is empty; otherwise, returns false
.
bool Qx::Base85::isNull | ( | ) |
Returns true
if the encoded string is null; otherwise, returns false
.
bool Qx::Base85::operator!= | ( | const Base85 & | other | ) | const |
bool Qx::Base85::operator== | ( | const Base85 & | other | ) | const |
qsizetype Qx::Base85::size | ( | ) | const |
Returns the size of the encoded data.
QString Qx::Base85::toString | ( | ) |
Returns the UTF-16 equivalent of the encoded data.