Code Documentation¶
The Entry Point¶
The main file.
This file is the main file of the tool.
- Author
Andrea Esposito <github.com/espositoandrea>
The CLI¶
-
exit_codes
setup_options
(int argc, char **argv, std::vector<std::string> &images)¶ Set up the tool’s options and arguments.
This function is responsible of the CLI API of the tool. It sets and handles the available options and arguments.
- Return
An exit code:
exit_codes::OK If the given arguments are valid and no errors occurred.
exit_codes::HALT If the given arguments are valid but the argument combination stops the execution.
exit_codes::ARGUMENT_ERROR If the given arguments are invalid
exit_codes::UNKNOWN_ARGUMENT_ERROR If an unknown error occurred.
- Parameters
argc
: The length ofargv
.argv
: The array of arguments passed via CLI.images
: A variable that will contain the images passed through the CLI API.
The Exit Codes¶
-
enum
exit_codes
¶ A collection of all the exit codes of the tool.
This enum contains all the (expected) exit codes of the tool.
Values:
-
OK
= 0¶ The tool exited with no error completing its tasks.
-
HALT
= 1¶ The tool exited with no error, but without completing its tasks.
-
ARGUMENT_ERROR
= 2¶ The tool exited due to errors in the given arguments.
-
UNKNOWN_ARGUMENT_ERROR
= 3¶ The tool exited due to unknown errors while parsing the arguments.
-
The Data URI¶
-
class
data_uri
¶ A utility class to handle data URIs.
This class represents a data URI. A data URI is defined by MDN as a string with the followind sintax:
data:[<mediatype>][;base64],<data>
.Public Functions
-
data_uri
(const std::string &s)¶ The class constructor.
This constructor creates a data_uri from a string.
- Parameters
s
: The string representing the data uri.
- Exceptions
data_uri::string_not_uri
: ifs
is not a valid data URI.
-
std::string
get_type
() const¶ Get the media type.
This function returns the media type of the data URI.
- Return
The media type (
<mediatype>
indata:<mediatype>;base64,<data>
).
-
std::string
get_data
() const¶ Get the data.
This function returns the data contained in the data URI.
- Return
The data (
<data>
indata:<mediatype>;base64,<data>
).
-
std::string
get_uri
() const¶ Get the URI.
This function returns the entire URI as a string.
- Return
The URI as a string.
Public Static Functions
-
class
string_not_uri
: public exception¶ An exception raised if a string is not an URI.
This exception is thrown if a string, assumed to be one, is not a data URI.
-
The Base64 Utilities¶
-
namespace
base64
¶ Namespace for dealing with base64 strings.
This namespace contains utilities to deal with base64 strings.
Functions
-
std::string
encode
(const std::string &s)¶ Encode a string to base64.
This function encodes a string to a base64 string.
- Return
The encoded string.
- Parameters
s
: The string to be encoded.
-
std::string