Honeycomb  0.1
Component-Model Framework
Functions | Variables
honey::encode Namespace Reference

Bytes to string encodings. More...

Functions

bool reg (const Id &id, const function< ostream &(ostream &os, const Bytes &val)> &encode, const function< istream &(istream &os, Bytes &val)> &decode)
 Register an encoding. More...
 
String hex_encode (ByteBufConst bs)
 Convert bytes to string using hexadecimal encoding (high-nibble-first) More...
 
Bytes hex_decode (const String &string)
 Convert string to bytes using hexadecimal decoding (high-nibble-first) More...
 
String dec_encode (ByteBufConst bs)
 Convert bytes to string using decimal encoding (big-endian integer) More...
 
Bytes dec_decode (const String &string)
 Convert string to bytes using decimal decoding (big-endian integer) More...
 
String base32_encode (ByteBufConst bs)
 Convert bytes to string using base32 encoding. More...
 
Bytes base32_decode (const String &string)
 Convert string to bytes using base32 decoding. More...
 
String base64_encode (ByteBufConst bs)
 Convert bytes to string using base64 encoding. More...
 
Bytes base64_decode (const String &string)
 Convert string to bytes using base64 decoding. More...
 
bool isHex (Char c)
 Check if character is in hexadecimal charset (numeric and case-insensitive [a-f]) More...
 
Char toHex (byte b)
 Convert byte to hexadecimal character. More...
 
byte fromHex (Char c)
 Convert hexadecimal character to byte. More...
 
ostream & hex (ostream &os)
 Use hexadecimal encoding (high-nibble-first) when writing bytes to a string stream. More...
 
istream & hex (istream &is)
 Use hexadecimal decoding (high-nibble-first) when reading bytes from a string stream. More...
 
bool isDec (Char c)
 Check if character is in decimal charset (numeric) More...
 
Char toDec (byte b)
 Convert byte to decimal character. More...
 
byte fromDec (Char c)
 Convert decimal character to byte. More...
 
ostream & dec (ostream &os)
 Use decimal encoding (big-endian integer) when writing bytes to a string stream. More...
 
istream & dec (istream &is)
 Use decimal decoding (big-endian integer) when reading bytes from a string stream. More...
 
ostream & u8 (ostream &os)
 Use UTF-8 encoding when writing bytes to a string stream. More...
 
istream & u8 (istream &is)
 Use UTF-8 decoding when reading bytes from a string stream. More...
 
bool isBase32 (Char c)
 Check if character is in base32 charset (case-insensitive [a-z], numeric [2-7], and padding '=') More...
 
Char toBase32 (byte b)
 Convert byte to base32 character. More...
 
byte fromBase32 (Char c)
 Convert base32 character to byte. More...
 
ostream & base32 (ostream &os)
 Use base32 encoding when writing bytes to a string stream. More...
 
istream & base32 (istream &is)
 Use base32 decoding when reading bytes from a string stream. More...
 
bool isBase64 (Char c)
 Check if character is in base64 charset (alphanumeric, symbols [+/], and padding '=') More...
 
Char toBase64 (byte b)
 Convert byte to base64 character. More...
 
byte fromBase64 (Char c)
 Convert base64 character to byte. More...
 
ostream & base64 (ostream &os)
 Use base64 encoding when writing bytes to a string stream. More...
 
istream & base64 (istream &is)
 Use base64 decoding when reading bytes from a string stream. More...
 

Variables

static auto __hex
 
static auto __dec
 
static auto __u8
 
static auto __base32
 
static auto __base64
 

Detailed Description

Bytes to string encodings.

Function Documentation

ostream& honey::encode::base32 ( ostream &  os)
inline

Use base32 encoding when writing bytes to a string stream.

istream& honey::encode::base32 ( istream &  is)
inline

Use base32 decoding when reading bytes from a string stream.

Bytes honey::encode::base32_decode ( const String string)

Convert string to bytes using base32 decoding.

String honey::encode::base32_encode ( ByteBufConst  bs)

Convert bytes to string using base32 encoding.

ostream& honey::encode::base64 ( ostream &  os)
inline

Use base64 encoding when writing bytes to a string stream.

istream& honey::encode::base64 ( istream &  is)
inline

Use base64 decoding when reading bytes from a string stream.

Bytes honey::encode::base64_decode ( const String string)

Convert string to bytes using base64 decoding.

String honey::encode::base64_encode ( ByteBufConst  bs)

Convert bytes to string using base64 encoding.

ostream& honey::encode::dec ( ostream &  os)
inline

Use decimal encoding (big-endian integer) when writing bytes to a string stream.

istream& honey::encode::dec ( istream &  is)
inline

Use decimal decoding (big-endian integer) when reading bytes from a string stream.

Bytes honey::encode::dec_decode ( const String string)

Convert string to bytes using decimal decoding (big-endian integer)

String honey::encode::dec_encode ( ByteBufConst  bs)

Convert bytes to string using decimal encoding (big-endian integer)

byte honey::encode::fromBase32 ( Char  c)
inline

Convert base32 character to byte.

byte honey::encode::fromBase64 ( Char  c)
inline

Convert base64 character to byte.

byte honey::encode::fromDec ( Char  c)
inline

Convert decimal character to byte.

byte honey::encode::fromHex ( Char  c)
inline

Convert hexadecimal character to byte.

ostream& honey::encode::hex ( ostream &  os)
inline

Use hexadecimal encoding (high-nibble-first) when writing bytes to a string stream.

istream& honey::encode::hex ( istream &  is)
inline

Use hexadecimal decoding (high-nibble-first) when reading bytes from a string stream.

Bytes honey::encode::hex_decode ( const String string)

Convert string to bytes using hexadecimal decoding (high-nibble-first)

String honey::encode::hex_encode ( ByteBufConst  bs)

Convert bytes to string using hexadecimal encoding (high-nibble-first)

bool honey::encode::isBase32 ( Char  c)
inline

Check if character is in base32 charset (case-insensitive [a-z], numeric [2-7], and padding '=')

bool honey::encode::isBase64 ( Char  c)
inline

Check if character is in base64 charset (alphanumeric, symbols [+/], and padding '=')

bool honey::encode::isDec ( Char  c)
inline

Check if character is in decimal charset (numeric)

bool honey::encode::isHex ( Char  c)
inline

Check if character is in hexadecimal charset (numeric and case-insensitive [a-f])

bool honey::encode::reg ( const Id id,
const function< ostream &(ostream &os, const Bytes &val)> &  encode,
const function< istream &(istream &os, Bytes &val)> &  decode 
)

Register an encoding.

Char honey::encode::toBase32 ( byte  b)
inline

Convert byte to base32 character.

Char honey::encode::toBase64 ( byte  b)
inline

Convert byte to base64 character.

Char honey::encode::toDec ( byte  b)
inline

Convert byte to decimal character.

Char honey::encode::toHex ( byte  b)
inline

Convert byte to hexadecimal character.

ostream& honey::encode::u8 ( ostream &  os)
inline

Use UTF-8 encoding when writing bytes to a string stream.

istream& honey::encode::u8 ( istream &  is)
inline

Use UTF-8 decoding when reading bytes from a string stream.

Variable Documentation

auto honey::encode::__base32
static
Initial value:
= reg("base32"_id,
[](ostream& os, const Bytes& val) -> ostream& { return os << base32_encode(val); },
[](istream& is, Bytes& val) -> istream&
{
String str;
auto flags = is.flags();
is >> std::ws >> std::noskipws;
while (isBase32(is.peek()))
{
char c;
is >> c;
str += c;
}
is.flags(flags);
val = base32_decode(str);
return is;
})
Bytes base32_decode(const String &string)
Convert string to bytes using base32 decoding.
Definition: Encode.cpp:294
String base32_encode(ByteBufConst bs)
Convert bytes to string using base32 encoding.
Definition: Encode.cpp:238
bool isBase32(Char c)
Check if character is in base32 charset (case-insensitive [a-z], numeric [2-7], and padding '=') ...
Definition: Encode.h:76
bool reg(const Id &id, const function< ostream &(ostream &os, const Bytes &val)> &encode, const function< istream &(istream &os, Bytes &val)> &decode)
Register an encoding.
Definition: Encode.cpp:61
auto honey::encode::__base64
static
Initial value:
= reg("base64"_id,
[](ostream& os, const Bytes& val) -> ostream& { return os << base64_encode(val); },
[](istream& is, Bytes& val) -> istream&
{
String str;
auto flags = is.flags();
is >> std::ws >> std::noskipws;
while (isBase64(is.peek()))
{
char c;
is >> c;
str += c;
}
is.flags(flags);
val = base64_decode(str);
return is;
})
Bytes base64_decode(const String &string)
Convert string to bytes using base64 decoding.
Definition: Encode.cpp:410
String base64_encode(ByteBufConst bs)
Convert bytes to string using base64 encoding.
Definition: Encode.cpp:373
bool isBase64(Char c)
Check if character is in base64 charset (alphanumeric, symbols [+/], and padding '=') ...
Definition: Encode.h:91
bool reg(const Id &id, const function< ostream &(ostream &os, const Bytes &val)> &encode, const function< istream &(istream &os, Bytes &val)> &decode)
Register an encoding.
Definition: Encode.cpp:61
auto honey::encode::__dec
static
Initial value:
= reg("dec"_id,
[](ostream& os, const Bytes& val) -> ostream& { return os << dec_encode(val); },
[](istream& is, Bytes& val) -> istream&
{
String str;
auto flags = is.flags();
is >> std::ws >> std::noskipws;
while (isDec(is.peek()))
{
char c;
is >> c;
str += c;
}
is.flags(flags);
val = dec_decode(str);
return is;
})
bool isDec(Char c)
Check if character is in decimal charset (numeric)
Definition: Encode.h:56
String dec_encode(ByteBufConst bs)
Convert bytes to string using decimal encoding (big-endian integer)
Definition: Encode.cpp:131
Bytes dec_decode(const String &string)
Convert string to bytes using decimal decoding (big-endian integer)
Definition: Encode.cpp:166
bool reg(const Id &id, const function< ostream &(ostream &os, const Bytes &val)> &encode, const function< istream &(istream &os, Bytes &val)> &decode)
Register an encoding.
Definition: Encode.cpp:61
auto honey::encode::__hex
static
Initial value:
= reg("hex"_id,
[](ostream& os, const Bytes& val) -> ostream& { return os << hex_encode(val); },
[](istream& is, Bytes& val) -> istream&
{
String str;
auto flags = is.flags();
is >> std::ws >> std::noskipws;
while (isHex(is.peek()))
{
char c;
is >> c;
str += c;
}
is.flags(flags);
val = hex_decode(str);
return is;
})
Bytes hex_decode(const String &string)
Convert string to bytes using hexadecimal decoding (high-nibble-first)
Definition: Encode.cpp:100
String hex_encode(ByteBufConst bs)
Convert bytes to string using hexadecimal encoding (high-nibble-first)
Definition: Encode.cpp:87
bool isHex(Char c)
Check if character is in hexadecimal charset (numeric and case-insensitive [a-f]) ...
Definition: Encode.h:41
bool reg(const Id &id, const function< ostream &(ostream &os, const Bytes &val)> &encode, const function< istream &(istream &os, Bytes &val)> &decode)
Register an encoding.
Definition: Encode.cpp:61
auto honey::encode::__u8
static
Initial value:
= reg("u8"_id,
[](ostream& os, const Bytes& val) -> ostream& { return os << std::string(val.begin(), val.end()); },
[](istream& is, Bytes& val) -> istream&
{
String str;
auto flags = is.flags();
is >> std::noskipws;
while (is.peek() != std::stringstream::traits_type::eof())
{
char c;
is >> c;
str += c;
}
is.flags(flags);
val = Bytes(str.begin(), str.end());
return is;
})
bool reg(const Id &id, const function< ostream &(ostream &os, const Bytes &val)> &encode, const function< istream &(istream &os, Bytes &val)> &decode)
Register an encoding.
Definition: Encode.cpp:61