A builder class for constructing UserInfo objects. More...
#include <UserInfo.h>
Public Member Functions | |
UserInfoBuilder () | |
Constructs a new UserInfoBuilder. Initializes an internal UserInfo object that will be populated. | |
UserInfoBuilder & | set_name (QString name) |
Sets the name for the UserInfo object being built. | |
UserInfoBuilder & | set_email (QString email) |
Sets the email for the UserInfo object being built. | |
UserInfoBuilder & | set_phone_number (QString phone) |
Sets the phone number for the UserInfo object being built. | |
UserInfoBuilder & | set_avatar (QString path) |
Sets the avatar path for the UserInfo object being built. | |
std::unique_ptr< UserInfo > | build () |
Builds and returns a unique pointer to the constructed UserInfo object. | |
Static Public Member Functions | |
static std::unique_ptr< UserInfo > | fromJson (const QString jsonString) |
Static method to construct a UserInfo object from a JSON string. | |
A builder class for constructing UserInfo objects.
UserInfo
object. It simplifies the construction process, especially when not all fields are known at once or when parsing from external data formats like JSON. std::unique_ptr< UserInfo > UserInfo::UserInfoBuilder::build | ( | ) |
|
static |
Static method to construct a UserInfo object from a JSON string.
UserInfo
object. It returns a std::unique_ptr
to the created object. Error handling for malformed JSON or missing fields should be implemented internally. jsonString | The JSON string containing user information. |
std::unique_ptr<UserInfo>
if parsing is successful, otherwise a nullptr. UserInfo::UserInfoBuilder & UserInfo::UserInfoBuilder::set_avatar | ( | QString | path | ) |
Sets the avatar path for the UserInfo object being built.
path | The file path to the user's avatar image. |
UserInfo::UserInfoBuilder & UserInfo::UserInfoBuilder::set_email | ( | QString | ) |
Sets the email for the UserInfo object being built.
The user's email address. |
UserInfo::UserInfoBuilder & UserInfo::UserInfoBuilder::set_name | ( | QString | name | ) |
Sets the name for the UserInfo object being built.
name | The user's name. |
UserInfo::UserInfoBuilder & UserInfo::UserInfoBuilder::set_phone_number | ( | QString | phone | ) |
Sets the phone number for the UserInfo object being built.
phone | The user's phone number. |