CCIMXDesktop
 
Loading...
Searching...
No Matches
UserInfo::UserInfoBuilder Class Reference

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.
 
UserInfoBuilderset_name (QString name)
 Sets the name for the UserInfo object being built.
 
UserInfoBuilderset_email (QString email)
 Sets the email for the UserInfo object being built.
 
UserInfoBuilderset_phone_number (QString phone)
 Sets the phone number for the UserInfo object being built.
 
UserInfoBuilderset_avatar (QString path)
 Sets the avatar path for the UserInfo object being built.
 
std::unique_ptr< UserInfobuild ()
 Builds and returns a unique pointer to the constructed UserInfo object.
 

Static Public Member Functions

static std::unique_ptr< UserInfofromJson (const QString jsonString)
 Static method to construct a UserInfo object from a JSON string.
 

Detailed Description

A builder class for constructing UserInfo objects.

  • This nested class provides a fluent API for setting individual user information fields and then building a 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.

Member Function Documentation

◆ build()

std::unique_ptr< UserInfo > UserInfo::UserInfoBuilder::build ( )

Builds and returns a unique pointer to the constructed UserInfo object.

Returns
A std::unique_ptr<UserInfo> containing the newly created UserInfo object. Ownership of the UserInfo object is transferred to the caller.

◆ fromJson()

std::unique_ptr< UserInfo > UserInfo::UserInfoBuilder::fromJson ( const QString  jsonString)
static

Static method to construct a UserInfo object from a JSON string.

  • This method parses the provided JSON string and attempts to populate the fields of a new UserInfo object. It returns a std::unique_ptr to the created object. Error handling for malformed JSON or missing fields should be implemented internally.
    Parameters
    jsonStringThe JSON string containing user information.
    Returns
    A std::unique_ptr<UserInfo> if parsing is successful, otherwise a nullptr.

◆ set_avatar()

UserInfo::UserInfoBuilder & UserInfo::UserInfoBuilder::set_avatar ( QString  path)

Sets the avatar path for the UserInfo object being built.

Parameters
pathThe file path to the user's avatar image.
Returns
A reference to the current UserInfoBuilder instance for method chaining.

◆ set_email()

UserInfo::UserInfoBuilder & UserInfo::UserInfoBuilder::set_email ( QString  email)

Sets the email for the UserInfo object being built.

Parameters
emailThe user's email address.
Returns
A reference to the current UserInfoBuilder instance for method chaining.

◆ set_name()

UserInfo::UserInfoBuilder & UserInfo::UserInfoBuilder::set_name ( QString  name)

Sets the name for the UserInfo object being built.

Parameters
nameThe user's name.
Returns
A reference to the current UserInfoBuilder instance for method chaining.

◆ set_phone_number()

UserInfo::UserInfoBuilder & UserInfo::UserInfoBuilder::set_phone_number ( QString  phone)

Sets the phone number for the UserInfo object being built.

Parameters
phoneThe user's phone number.
Returns
A reference to the current UserInfoBuilder instance for method chaining.

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