CCIMXDesktop
 
Loading...
Searching...
No Matches
UserInfo.h
Go to the documentation of this file.
1
6#ifndef USERINFO_H
7#define USERINFO_H
8
9#include <QString> // For QString to hold string data
10#include <memory> // For std::unique_ptr
11
22class UserInfo {
23public:
33 public:
39
45 UserInfoBuilder& set_name(QString name);
46
52 UserInfoBuilder& set_email(QString email);
53
59 UserInfoBuilder& set_phone_number(QString phone);
60
66 UserInfoBuilder& set_avatar(QString path);
67
73 std::unique_ptr<UserInfo> build();
74
84 static std::unique_ptr<UserInfo> fromJson(const QString jsonString);
85
86 private:
91 std::unique_ptr<UserInfo> internal_info;
92 };
93
98 const QString& get_name() const;
99
104 const QString& get_email() const;
105
110 const QString& get_phone_number() const;
111
116 const QString& get_avatar() const;
117
122 void set_avator(const QString& av_path);
123
128 void set_name(const QString& name);
129
134 void set_email(const QString& email);
135
140 void set_phone(const QString& phone);
141
146 QString serialized() const;
147
148 // Delete copy constructor and copy assignment operator to prevent unintended copying.
149 UserInfo(const UserInfo&) = delete;
150 UserInfo& operator=(const UserInfo&) = delete;
151
155 ~UserInfo() = default;
156
157private:
163 friend class UserInfoBuilder;
164
169 UserInfo() = default;
170
171 QString name;
172 QString phone_number;
173 QString email;
174 QString av_path;
175};
176
177#endif // USERINFO_H
A builder class for constructing UserInfo objects.
Definition UserInfo.h:32
std::unique_ptr< UserInfo > build()
Builds and returns a unique pointer to the constructed UserInfo object.
Definition UserInfo.cpp:26
UserInfoBuilder & set_name(QString name)
Sets the name for the UserInfo object being built.
Definition UserInfo.cpp:11
UserInfoBuilder & set_avatar(QString path)
Sets the avatar path for the UserInfo object being built.
Definition UserInfo.cpp:6
UserInfoBuilder & set_phone_number(QString phone)
Sets the phone number for the UserInfo object being built.
Definition UserInfo.cpp:21
UserInfoBuilder()
Constructs a new UserInfoBuilder. Initializes an internal UserInfo object that will be populated.
Definition UserInfo.cpp:3
static std::unique_ptr< UserInfo > fromJson(const QString jsonString)
Static method to construct a UserInfo object from a JSON string.
Definition UserInfo.cpp:67
UserInfoBuilder & set_email(QString email)
Sets the email for the UserInfo object being built.
Definition UserInfo.cpp:16
Represents a user's profile information, including name, email, phone number, and avatar path.
Definition UserInfo.h:22
const QString & get_email() const
Gets the user's email address.
Definition UserInfo.cpp:34
void set_name(const QString &name)
Sets the user's name.
Definition UserInfo.cpp:50
QString serialized() const
Serializes the UserInfo object into a JSON string.
Definition UserInfo.cpp:85
void set_email(const QString &email)
Sets the user's email address.
Definition UserInfo.cpp:54
void set_phone(const QString &phone)
Sets the user's phone number.
Definition UserInfo.cpp:58
~UserInfo()=default
Default destructor for UserInfo.
void set_avator(const QString &av_path)
Sets the file path for the user's avatar.
Definition UserInfo.cpp:46
const QString & get_name() const
Gets the user's name.
Definition UserInfo.cpp:30
const QString & get_phone_number() const
Gets the user's phone number.
Definition UserInfo.cpp:38
const QString & get_avatar() const
Gets the file path to the user's avatar.
Definition UserInfo.cpp:42