mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 09:21:57 -05:00
AK: Move FormatParser to a new header
Since it was intentionally removed from Format.h to untangle dependencies, this is a new small header that can be included by anyone needing custom format parsing.
This commit is contained in:
parent
edd85b1281
commit
606963bfa2
2 changed files with 29 additions and 15 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/FormatParser.h>
|
||||
#include <AK/GenericLexer.h>
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <AK/String.h>
|
||||
|
@ -35,21 +36,6 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
class FormatParser : public GenericLexer {
|
||||
public:
|
||||
struct FormatSpecifier {
|
||||
StringView flags;
|
||||
size_t index;
|
||||
};
|
||||
|
||||
explicit FormatParser(StringView input);
|
||||
|
||||
StringView consume_literal();
|
||||
bool consume_number(size_t& value);
|
||||
bool consume_specifier(FormatSpecifier& specifier);
|
||||
bool consume_replacement_field(size_t& index);
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
static constexpr size_t use_next_index = NumericLimits<size_t>::max();
|
||||
|
|
28
AK/FormatParser.h
Normal file
28
AK/FormatParser.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2024, kleines Filmröllchen <filmroellchen@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/GenericLexer.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
class FormatParser : public GenericLexer {
|
||||
public:
|
||||
struct FormatSpecifier {
|
||||
StringView flags;
|
||||
size_t index;
|
||||
};
|
||||
|
||||
explicit FormatParser(StringView input);
|
||||
|
||||
StringView consume_literal();
|
||||
bool consume_number(size_t& value);
|
||||
bool consume_specifier(FormatSpecifier& specifier);
|
||||
bool consume_replacement_field(size_t& index);
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue