mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
41 lines
906 B
C++
41 lines
906 B
C++
#pragma once
|
|
|
|
#include "messages/message.hpp"
|
|
|
|
#include <QRegularExpression>
|
|
|
|
#include <ctime>
|
|
|
|
namespace chatterino {
|
|
namespace messages {
|
|
|
|
struct MessageBuilder {
|
|
public:
|
|
MessageBuilder();
|
|
|
|
MessagePtr getMessage();
|
|
|
|
void setHighlight(bool value);
|
|
void append(MessageElement *element);
|
|
void appendTimestamp();
|
|
void appendTimestamp(const QTime &time);
|
|
QString matchLink(const QString &string);
|
|
|
|
template <typename T, typename... Args,
|
|
typename _ = std::enable_if<std::is_base_of<MessageElement, T>::value>::type>
|
|
T *emplace(Args &&... args)
|
|
{
|
|
static_assert(std::is_base_of<MessageElement, T>::value, "T must extend MessageElement");
|
|
|
|
T *element = new T(std::forward<Args>(args)...);
|
|
this->append(element);
|
|
return element;
|
|
}
|
|
|
|
protected:
|
|
MessagePtr message;
|
|
};
|
|
|
|
} // namespace messages
|
|
} // namespace chatterino
|