pairpal
Loading...
Searching...
No Matches
message.hpp
1#ifndef MESSAGE_HPP
2#define MESSAGE_HPP
3
4#include <chrono>
5#include <string>
6
11class Message {
12 public:
19 Message(std::string from, std::string to, std::string message);
20
25
30 [[nodiscard]] std::string getFromUser() const;
31
36 [[nodiscard]] std::string getToUser() const;
37
42 [[nodiscard]] std::string getMessage() const;
43
48 [[nodiscard]] std::string toString() const;
49
54 [[nodiscard]] std::chrono::system_clock::time_point getTimestamp() const;
55
56
61 [[nodiscard]] std::string getFormatTimestamp() const;
62
63private:
64 std::string from; // Sender's username
65 std::string to; // Receiver's username
66 std::string message; // Content of the message
67 std::chrono::system_clock::time_point timestamp; // Timestamp of the message
68};
69#endif // MESSAGE_HPP
Represents a message exchanged between two users.
Definition message.hpp:11
std::string toString() const
Converts the message to a string representation.
~Message()
destroy the Message object
std::string getFormatTimestamp() const
Converts the timestamp to a string representation.
std::string getFromUser() const
Gets the username of the sender.
std::string getToUser() const
Gets the username of the receiver.
std::string getMessage() const
Gets the content of the message.
std::chrono::system_clock::time_point getTimestamp() const
Gets the timestamp of when the message was sent.
Message(std::string from, std::string to, std::string message)
construct a Message object