Represents the metadata and content for a toast notification. More...
#include <ToastMetaProtocol.h>
Public Member Functions | |
ToastMetaProtocol ()=default | |
Default constructor for ToastMetaProtocol. Initializes members to their default values (empty strings, null QDateTime). | |
ToastMetaProtocol (const QString meta_app, const QString displayMessage, const QDateTime t=QDateTime::currentDateTime()) | |
Constructs a ToastMetaProtocol with specified application name and message. | |
ToastMetaProtocol (const QString &json_string) | |
Constructs a ToastMetaProtocol from a JSON string. | |
QString | toString () const |
Converts the ToastMetaProtocol object into its JSON string representation. | |
Static Public Member Functions | |
static std::optional< ToastMetaProtocol > | from_json_string (const QString &json_string) |
Creates an optional ToastMetaProtocol object from a JSON string. | |
Represents the metadata and content for a toast notification.
This struct holds information necessary to display a toast notification, including the originating application's name, the message to display, and the time the notification was announced. It provides constructors for easy initialization and methods for serialization to/from JSON strings.
ToastMetaProtocol::ToastMetaProtocol | ( | const QString | meta_app, |
const QString | displayMessage, | ||
const QDateTime | t = QDateTime::currentDateTime() |
||
) |
Constructs a ToastMetaProtocol with specified application name and message.
meta_app | The name of the application. |
displayMessage | The message to be displayed. |
t | The announcement time. Defaults to the current system time if not provided. |
ToastMetaProtocol::ToastMetaProtocol | ( | const QString & | json_string | ) |
Constructs a ToastMetaProtocol from a JSON string.
from_json_string
for safer parsing. json_string | The JSON string representing a ToastMetaProtocol. |
|
static |
Creates an optional ToastMetaProtocol object from a JSON string.
std::nullopt
if the parsing fails (e.g., invalid JSON format, missing required fields), providing a safe way to deserialize the object. json_string | The JSON string to parse. |
std::optional<ToastMetaProtocol>
containing the parsed object if successful, otherwise std::nullopt
. QString ToastMetaProtocol::toString | ( | ) | const |
Converts the ToastMetaProtocol object into its JSON string representation.