ladybird/Applications/IRCClient/IRCLogBuffer.h
Andreas Kling aa19735c5a IRCClient: Start working on a simple graphical IRC client.
This will be a nice way to exercise both LibGUI and the TCP/IP support. :^)
2019-03-15 12:14:23 +01:00

32 lines
687 B
C++

#pragma once
#include <AK/AKString.h>
#include <AK/CircularQueue.h>
#include <AK/Retainable.h>
#include <AK/RetainPtr.h>
class IRCLogBuffer : public Retainable<IRCLogBuffer> {
public:
static Retained<IRCLogBuffer> create();
~IRCLogBuffer();
struct Message {
time_t timestamp { 0 };
char prefix { 0 };
String sender;
String text;
};
int count() const { return m_messages.size(); }
const Message& at(int index) const { return m_messages.at(index); }
void add_message(char prefix, const String& name, const String& text);
void dump() const;
private:
IRCLogBuffer();
CircularQueue<Message, 1000> m_messages;
};