CCIMXDesktop
 
Loading...
Searching...
No Matches
ToastMetaProtocol Struct Reference

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< ToastMetaProtocolfrom_json_string (const QString &json_string)
 Creates an optional ToastMetaProtocol object from a JSON string.
 

Public Attributes

QString meta_appName
 The name of the application that generated the toast notification. This can be used to identify the source of the toast.
 
QDateTime announceTime
 The exact date and time when the toast notification was announced. This helps in ordering or time-stamping notifications.
 
QString meta_displayMessage
 The main message content to be displayed in the toast notification. This is the primary textual information for the user.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ToastMetaProtocol() [1/2]

ToastMetaProtocol::ToastMetaProtocol ( const QString  meta_app,
const QString  displayMessage,
const QDateTime  t = QDateTime::currentDateTime() 
)

Constructs a ToastMetaProtocol with specified application name and message.

Parameters
meta_appThe name of the application.
displayMessageThe message to be displayed.
tThe announcement time. Defaults to the current system time if not provided.

◆ ToastMetaProtocol() [2/2]

ToastMetaProtocol::ToastMetaProtocol ( const QString &  json_string)

Constructs a ToastMetaProtocol from a JSON string.

  • This constructor attempts to parse the provided JSON string and populate the struct members accordingly. It's generally recommended to use from_json_string for safer parsing.
    Parameters
    json_stringThe JSON string representing a ToastMetaProtocol.

Member Function Documentation

◆ from_json_string()

std::optional< ToastMetaProtocol > ToastMetaProtocol::from_json_string ( const QString &  json_string)
static

Creates an optional ToastMetaProtocol object from a JSON string.

  • This static method attempts to parse a JSON string and construct a ToastMetaProtocol object. It returns std::nullopt if the parsing fails (e.g., invalid JSON format, missing required fields), providing a safe way to deserialize the object.
    Parameters
    json_stringThe JSON string to parse.
    Returns
    An std::optional<ToastMetaProtocol> containing the parsed object if successful, otherwise std::nullopt.

◆ toString()

QString ToastMetaProtocol::toString ( ) const

Converts the ToastMetaProtocol object into its JSON string representation.

Returns
A QString containing the JSON representation of the object.

The documentation for this struct was generated from the following files: