mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
040947ee47
Fixes #407 Depends on #530 to run reliably.
33 lines
554 B
C++
33 lines
554 B
C++
#pragma once
|
|
|
|
#include <AK/Function.h>
|
|
#include <AK/String.h>
|
|
#include <AK/StringView.h>
|
|
#include <AK/Types.h>
|
|
|
|
#include "Command.h"
|
|
|
|
#define IAC 0xff
|
|
|
|
class Parser {
|
|
public:
|
|
Function<void(const Command&)> on_command;
|
|
Function<void(const StringView&)> on_data;
|
|
Function<void()> on_error;
|
|
|
|
void write(const StringView&);
|
|
|
|
protected:
|
|
enum State {
|
|
Free,
|
|
ReadCommand,
|
|
ReadSubcommand,
|
|
Error,
|
|
};
|
|
|
|
void write(const String& str);
|
|
|
|
private:
|
|
State m_state { State::Free };
|
|
u8 m_command { 0 };
|
|
};
|