1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 21:34:59 +00:00
serenity/Userland/Libraries/LibIMAP/Parser.h
Ali Mohammad Pur 5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30

74 lines
2.2 KiB
C++

/*
* Copyright (c) 2021, Kyle Pereira <hey@xylepereira.me>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/Result.h>
#include <LibIMAP/Objects.h>
namespace IMAP {
class Client;
struct ParseStatus {
bool successful;
Optional<Response> response;
};
class Parser {
public:
ParseStatus parse(ByteBuffer&& buffer, bool expecting_tag);
private:
static MailboxFlag parse_mailbox_flag(StringView);
ErrorOr<ParseStatus> try_parse(ByteBuffer&& buffer, bool expecting_tag);
ErrorOr<void> consume(StringView);
bool consume_if(StringView);
StringView consume_while(Function<bool(u8)> should_consume);
StringView consume_until_end_of_line();
bool at_end() { return m_position >= m_buffer.size(); }
ErrorOr<unsigned> parse_number();
Optional<unsigned> try_parse_number();
ErrorOr<void> parse_response_done();
ErrorOr<void> parse_untagged();
ErrorOr<void> parse_capability_response();
ErrorOr<StringView> parse_atom();
ErrorOr<StringView> parse_quoted_string();
ErrorOr<StringView> parse_literal_string();
ErrorOr<StringView> parse_string();
ErrorOr<StringView> parse_astring();
ErrorOr<StringView> parse_nstring();
ErrorOr<ResponseStatus> parse_status();
ErrorOr<ListItem> parse_list_item();
ErrorOr<FetchCommand::DataItem> parse_fetch_data_item();
ErrorOr<FetchResponseData> parse_fetch_response();
ErrorOr<Vector<Address>> parse_address_list();
ErrorOr<Address> parse_address();
ErrorOr<HashMap<ByteString, ByteString>> parse_body_fields_params();
ErrorOr<BodyStructure> parse_body_structure();
ErrorOr<BodyStructure> parse_one_part_body();
ErrorOr<BodyExtension> parse_body_extension();
ErrorOr<Tuple<ByteString, HashMap<ByteString, ByteString>>> parse_disposition();
ErrorOr<Vector<ByteString>> parse_langs();
ErrorOr<Envelope> parse_envelope();
template<typename T>
ErrorOr<Vector<T>> parse_list(T (*converter)(StringView));
// To retain state if parsing is not finished
ByteBuffer m_buffer;
SolidResponse m_response;
unsigned m_position { 0 };
bool m_incomplete { false };
};
}