D++ (DPP)
C++ Discord API Bot Library
|
Image to be received or sent to API calls. More...
Public Member Functions | |
image_data ()=default | |
Construct an empty image. More... | |
image_data (const image_data &rhs) | |
Copy an image. More... | |
image_data (image_data &&rhs) noexcept=default | |
Move an image. More... | |
image_data (image_type format, std::string_view bytes) | |
Construct from string buffer. More... | |
image_data (image_type format, const std::byte *bytes, uint32_t byte_size) | |
Construct from byte buffer. More... | |
image_data & | operator= (const image_data &rhs) |
Copy an image data. More... | |
image_data & | operator= (image_data &&rhs) noexcept=default |
Move an image data. More... | |
void | set (image_type format, std::string_view bytes) |
Set image data. More... | |
void | set (image_type format, const std::byte *bytes, uint32_t byte_size) |
Set image data. More... | |
std::string | base64_encode () const |
Encode to base64. More... | |
std::string | get_file_extension () const |
Get the file extension. More... | |
std::string | get_mime_type () const |
Get the mime type. More... | |
bool | empty () const noexcept |
Check if this is an empty image. More... | |
json | to_nullable_json () const |
Build a data URI scheme suitable for sending to Discord. More... | |
Public Attributes | |
std::unique_ptr< std::byte[]> | data = nullptr |
Data in bytes of the image. More... | |
uint32_t | size = 0 |
Size of the data in bytes. More... | |
image_type | type = {} |
Type of the image. More... | |
Image to be received or sent to API calls.
This class is carefully crafted to be 16 bytes, this is why we use a ptr + 4 byte size instead of a vector. We want this class to be substitutable with iconhash in data structures.
|
default |
Construct an empty image.
dpp::utility::image_data::image_data | ( | const image_data & | rhs | ) |
Copy an image.
rhs | Image to copy |
|
defaultnoexcept |
Move an image.
rhs | Image to copy |
dpp::utility::image_data::image_data | ( | image_type | format, |
std::string_view | bytes | ||
) |
Construct from string buffer.
format | Image format |
bytes | Data in a string |
dpp::utility::image_data::image_data | ( | image_type | format, |
const std::byte * | bytes, | ||
uint32_t | byte_size | ||
) |
Construct from byte buffer.
format | Image format |
bytes | Data of the image |
byte_size | Image size in bytes |
std::string dpp::utility::image_data::base64_encode | ( | ) | const |
Encode to base64.
|
noexcept |
Check if this is an empty image.
std::string dpp::utility::image_data::get_file_extension | ( | ) | const |
std::string dpp::utility::image_data::get_mime_type | ( | ) | const |
image_data& dpp::utility::image_data::operator= | ( | const image_data & | rhs | ) |
Copy an image data.
rhs | Image to copy |
|
defaultnoexcept |
Move an image data.
rhs | Image to move from |
void dpp::utility::image_data::set | ( | image_type | format, |
const std::byte * | bytes, | ||
uint32_t | byte_size | ||
) |
Set image data.
format | Format of the image |
bytes | Data of the image |
byte_size | Image size in bytes |
void dpp::utility::image_data::set | ( | image_type | format, |
std::string_view | bytes | ||
) |
Set image data.
format | Image format |
bytes | Data of the image |
json dpp::utility::image_data::to_nullable_json | ( | ) | const |
Build a data URI scheme suitable for sending to Discord.
std::unique_ptr<std::byte[]> dpp::utility::image_data::data = nullptr |
Data in bytes of the image.
uint32_t dpp::utility::image_data::size = 0 |
Size of the data in bytes.
image_type dpp::utility::image_data::type = {} |
Type of the image.