diff --git a/AK/CMakeLists.txt b/AK/CMakeLists.txt index 72e513c60a9..5d6539ffbe0 100644 --- a/AK/CMakeLists.txt +++ b/AK/CMakeLists.txt @@ -2,9 +2,9 @@ set(AK_SOURCES Assertions.cpp Base64.cpp CircularBuffer.cpp + DOSPackedTime.cpp DeprecatedFlyString.cpp DeprecatedString.cpp - DOSPackedTime.cpp Error.cpp FloatingPointStringConversions.cpp FlyString.cpp @@ -16,10 +16,10 @@ set(AK_SOURCES JsonParser.cpp JsonPath.cpp JsonValue.cpp - kmalloc.cpp LexicalPath.cpp MemoryStream.cpp NumberFormat.cpp + OptionParser.cpp Random.cpp StackInfo.cpp Stream.cpp @@ -32,10 +32,11 @@ set(AK_SOURCES Time.cpp URL.cpp URLParser.cpp + UUID.cpp Utf16View.cpp Utf32View.cpp Utf8View.cpp - UUID.cpp + kmalloc.cpp ) # AK sources are included from many different places, such as the Kernel, LibC, and Loader list(TRANSFORM AK_SOURCES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/") diff --git a/AK/OptionParser.cpp b/AK/OptionParser.cpp new file mode 100644 index 00000000000..681e24fa26e --- /dev/null +++ b/AK/OptionParser.cpp @@ -0,0 +1,283 @@ +/* + * Copyright (c) 2023, Ali Mohammad Pur + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +namespace AK { + +void OptionParser::reset_state() +{ + m_arg_index = 0; + m_consumed_args = 0; + m_index_into_multioption_argument = 0; + m_stop_on_first_non_option = false; +} + +OptionParser::GetOptResult OptionParser::getopt(Span args, StringView short_options, Span