2017-06-06 21:18:05 +02:00
|
|
|
#pragma once
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "messages/Message.hpp"
|
2017-06-06 21:18:05 +02:00
|
|
|
|
2017-07-26 09:08:19 +02:00
|
|
|
#include <QRegularExpression>
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-07-31 00:57:42 +02:00
|
|
|
#include <ctime>
|
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2018-01-28 03:48:15 +01:00
|
|
|
struct MessageBuilder {
|
2017-04-12 17:46:44 +02:00
|
|
|
public:
|
|
|
|
MessageBuilder();
|
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
MessagePtr getMessage();
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-09-24 18:43:24 +02:00
|
|
|
void setHighlight(bool value);
|
2018-01-28 03:48:15 +01:00
|
|
|
void append(MessageElement *element);
|
|
|
|
void appendTimestamp();
|
|
|
|
void appendTimestamp(const QTime &time);
|
|
|
|
QString matchLink(const QString &string);
|
2018-01-11 20:16:25 +01:00
|
|
|
|
2018-01-28 15:28:02 +01:00
|
|
|
template <typename T, typename... Args>
|
2018-01-22 14:39:24 +01:00
|
|
|
T *emplace(Args &&... args)
|
2018-01-11 20:16:25 +01:00
|
|
|
{
|
2018-08-06 21:17:03 +02:00
|
|
|
static_assert(std::is_base_of<MessageElement, T>::value,
|
|
|
|
"T must extend MessageElement");
|
2018-01-11 20:16:25 +01:00
|
|
|
|
|
|
|
T *element = new T(std::forward<Args>(args)...);
|
2018-01-28 03:48:15 +01:00
|
|
|
this->append(element);
|
2018-01-11 20:16:25 +01:00
|
|
|
return element;
|
|
|
|
}
|
|
|
|
|
2017-12-17 17:48:46 +01:00
|
|
|
protected:
|
2018-07-06 19:23:47 +02:00
|
|
|
MessagePtr message_;
|
2017-04-12 17:46:44 +02:00
|
|
|
};
|
|
|
|
|
2017-06-06 21:18:05 +02:00
|
|
|
} // namespace chatterino
|