libfacade 1.1
A library for manipulating PNG images with payloads.
Loading...
Searching...
No Matches
Namespaces | Classes | Functions | Variables
facade Namespace Reference

Namespaces

namespace  exception
 
namespace  ico
 
namespace  png
 

Classes

class  ICOPayload
 An icon file containing a payload. More...
 
class  PNGPayload
 A PNG-based payload helper class. More...
 

Functions

EXPORT std::uint16_t endian_swap_16 (std::uint16_t value)
 Swap the endianness of a 16-bit value.
 
EXPORT std::uint32_t endian_swap_32 (std::uint32_t value)
 Swap the endianness of a 32-bit value.
 
EXPORT std::uint32_t crc32 (const void *ptr, std::size_t size, std::uint32_t init_crc=0)
 Calculate the CRC32 value of a given buffer.
 
EXPORT std::vector< std::uint8_t > compress (const void *ptr, std::size_t size, int level)
 Compress the given data buffer with the given compression level.
 
EXPORT std::vector< std::uint8_t > compress (const std::vector< std::uint8_t > &vec, int level)
 Compress the given byte vector with the given compression level.
 
EXPORT std::vector< std::uint8_t > decompress (const void *ptr, std::size_t size)
 Decompress the given data buffer with zlib's inflate algorithm.
 
EXPORT std::vector< std::uint8_t > decompress (const std::vector< std::uint8_t > &vec)
 Decompress the given data vector with zlib's inflate algorithm.
 
EXPORT bool is_base64_string (const std::string &base64)
 Determine if the string is a base64 string.
 
EXPORT std::string base64_encode (const void *ptr, std::size_t size)
 Base64 encode the given buffer data.
 
EXPORT std::string base64_encode (const std::vector< std::uint8_t > &data)
 Base64 encode the given data vector.
 
EXPORT std::vector< std::uint8_t > base64_decode (const std::string &data)
 Base64-decode the given string into a byte vector.
 
EXPORT std::vector< std::uint8_t > read_file (const std::string &filename)
 Read a file into a byte vector.
 
EXPORT void write_file (const std::string &filename, const void *ptr, std::size_t size)
 Write a given buffer to the given filename.
 
EXPORT void write_file (const std::string &filename, const std::vector< std::uint8_t > &vec)
 Write a given byte vector to the given filename.
 

Variables

const std::uint32_t CRC32_TABLE [256]
 The table used for calculating a CRC32 value.
 
const std::string BASE64_ALPHA
 The alphabet of base64 data.
 

Function Documentation

◆ base64_decode()

std::vector< std::uint8_t > facade::base64_decode ( const std::string &  data)

Base64-decode the given string into a byte vector.

Parameters
dataThe base64-encoded string.
Returns
The decoded byte buffer.
Exceptions
facade::exception::InvalidBase64Character

◆ base64_encode() [1/2]

std::string facade::base64_encode ( const std::vector< std::uint8_t > &  data)

Base64 encode the given data vector.

Parameters
dataThe vector of bytes to encode.
Returns
A base64-encoded string.

◆ base64_encode() [2/2]

std::string facade::base64_encode ( const void *  ptr,
std::size_t  size 
)

Base64 encode the given buffer data.

Parameters
ptrThe data buffer to encode.
sizeThe size, in bytes, of the given pointer.
Returns
A base64-encoded string.

◆ compress() [1/2]

std::vector< std::uint8_t > facade::compress ( const std::vector< std::uint8_t > &  vec,
int  level 
)

Compress the given byte vector with the given compression level.

Parameters
vecThe byte vector to compress.
levelThe compression level to give to deflate, see the zlib manual for possible values.
See also
The root compression function: compress(const void *, std::size_t, int)

◆ compress() [2/2]

std::vector< std::uint8_t > facade::compress ( const void *  ptr,
std::size_t  size,
int  level 
)

Compress the given data buffer with the given compression level.

This utilizes zlib's deflate algorithm. For more on that, read zlib's documentation.

Parameters
ptrThe given data pointer to compress.
sizeThe size, in bytes, of the given data pointer.
levelThe compression level to pass to the deflate algorithm, see the zlib manual for possible values.
Returns
The compressed buffer.
Exceptions
facade::exception::ZLibError

◆ crc32()

std::uint32_t facade::crc32 ( const void *  ptr,
std::size_t  size,
std::uint32_t  init_crc = 0 
)

Calculate the CRC32 value of a given buffer.

Parameters
ptrA pointer to the data whose CRC you wish to calculate.
sizeThe size, in bytes, contained by the data pointer.
init_crcThe initial CRC value to use. The default is 0 for an initial value.
Returns
The calculated CRC32.

◆ decompress() [1/2]

std::vector< std::uint8_t > facade::decompress ( const std::vector< std::uint8_t > &  vec)

Decompress the given data vector with zlib's inflate algorithm.

Parameters
vecThe compressed data vector.
Returns
The decompressed buffer.
Exceptions
facade::exception::ZLibError
See also
The root decompress function: decompress(const void *, std::size_t)

◆ decompress() [2/2]

std::vector< std::uint8_t > facade::decompress ( const void *  ptr,
std::size_t  size 
)

Decompress the given data buffer with zlib's inflate algorithm.

Parameters
ptrThe compressed data pointer to decompress.
sizeThe size, in bytes, of the data pointer.
Returns
The decompressed buffer.
Exceptions
facade::exception::ZLibError

◆ endian_swap_16()

std::uint16_t facade::endian_swap_16 ( std::uint16_t  value)

Swap the endianness of a 16-bit value.

This converts big endian to little endian, or little endian to big endian.

Parameters
valueThe value whose endianness needs to be swapped.
Returns
The 16-bit endian-swapped value.

◆ endian_swap_32()

std::uint32_t facade::endian_swap_32 ( std::uint32_t  value)

Swap the endianness of a 32-bit value.

This converts big endian to little endian, or little endian to big endian.

Parameters
valueThe value whose endianness needs to be swapped.
Returns
The 32-bit endian-swapped value.

◆ is_base64_string()

bool facade::is_base64_string ( const std::string &  base64)

Determine if the string is a base64 string.

Parameters
base64The string of (alleged) base64 data.
Returns
Whether or not this string is base64 data.

◆ read_file()

std::vector< std::uint8_t > facade::read_file ( const std::string &  filename)

Read a file into a byte vector.

Parameters
filenameThe given filename to read.
Returns
The byte vector representing the file data.
Exceptions
facade::exception::OpenFileFailure

◆ write_file() [1/2]

void facade::write_file ( const std::string &  filename,
const std::vector< std::uint8_t > &  vec 
)

Write a given byte vector to the given filename.

Parameters
filenameThe filename to save to.
vecThe byte vector to write.
Exceptions
facade::exception::OpenFileFailure

◆ write_file() [2/2]

void facade::write_file ( const std::string &  filename,
const void *  ptr,
std::size_t  size 
)

Write a given buffer to the given filename.

Parameters
filenameThe filename to save to.
ptrThe data buffer to write.
sizeThe size, in bytes, of the pointed data buffer.
Exceptions
facade::exception::OpenFileFailure

Variable Documentation

◆ BASE64_ALPHA

const std::string facade::BASE64_ALPHA
Initial value:
= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/"

The alphabet of base64 data.

◆ CRC32_TABLE

const std::uint32_t facade::CRC32_TABLE[256]

The table used for calculating a CRC32 value.