diff --git a/AK/MACAddress.h b/AK/MACAddress.h index 27ae58909c9..bcac9c8eecb 100644 --- a/AK/MACAddress.h +++ b/AK/MACAddress.h @@ -11,6 +11,7 @@ #include #include #include +#include class [[gnu::packed]] MACAddress { static constexpr size_t s_mac_address_length = 6u; diff --git a/AK/String.cpp b/AK/String.cpp index 66b61767c7e..a37ab8095a0 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -479,4 +479,9 @@ String String::vformatted(StringView fmtstr, TypeErasedFormatParams& params) return builder.to_string(); } +Vector String::find_all(StringView needle) const +{ + return StringUtils::find_all(*this, needle); +} + } diff --git a/AK/String.h b/AK/String.h index d5c47e1dab1..97d8dab0cc0 100644 --- a/AK/String.h +++ b/AK/String.h @@ -149,7 +149,7 @@ public: [[nodiscard]] Optional find(StringView const& needle, size_t start = 0) const { return StringUtils::find(*this, needle, start); } [[nodiscard]] Optional find_last(char needle) const { return StringUtils::find_last(*this, needle); } // FIXME: Implement find_last(StringView const&) for API symmetry. - [[nodiscard]] Vector find_all(StringView const& needle) const { return StringUtils::find_all(*this, needle); } + Vector find_all(StringView needle) const; using SearchDirection = StringUtils::SearchDirection; [[nodiscard]] Optional find_any_of(StringView const& needles, SearchDirection direction) const { return StringUtils::find_any_of(*this, needles, direction); } diff --git a/AK/StringView.cpp b/AK/StringView.cpp index 205f282d703..3bd40ac06be 100644 --- a/AK/StringView.cpp +++ b/AK/StringView.cpp @@ -8,9 +8,11 @@ #include #include #include +#include #include #include #include +#include namespace AK { @@ -252,4 +254,31 @@ String StringView::replace(const StringView& needle, const StringView& replaceme return StringUtils::replace(*this, needle, replacement, all_occurrences); } +Vector StringView::find_all(StringView needle) const +{ + return StringUtils::find_all(*this, needle); +} + +Vector StringView::split_view_if(Function const& predicate, bool keep_empty) const +{ + if (is_empty()) + return {}; + + Vector v; + size_t substart = 0; + for (size_t i = 0; i < length(); ++i) { + char ch = characters_without_null_termination()[i]; + if (predicate(ch)) { + size_t sublen = i - substart; + if (sublen != 0 || keep_empty) + v.append(substring_view(substart, sublen)); + substart = i + 1; + } + } + size_t taillen = length() - substart; + if (taillen != 0 || keep_empty) + v.append(substring_view(substart, taillen)); + return v; +} + } diff --git a/AK/StringView.h b/AK/StringView.h index fa1905d8858..0ba49a5d545 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -9,11 +9,11 @@ #include #include #include +#include #include #include #include #include -#include namespace AK { @@ -96,7 +96,7 @@ public: [[nodiscard]] Optional find_last(char needle) const { return StringUtils::find_last(*this, needle); } // FIXME: Implement find_last(StringView const&) for API symmetry. - [[nodiscard]] Vector find_all(StringView const& needle) const { return StringUtils::find_all(*this, needle); } + [[nodiscard]] Vector find_all(StringView needle) const; using SearchDirection = StringUtils::SearchDirection; [[nodiscard]] Optional find_any_of(StringView const& needles, SearchDirection direction = SearchDirection::Forward) { return StringUtils::find_any_of(*this, needles, direction); } @@ -116,28 +116,7 @@ public: [[nodiscard]] Vector split_view(char, bool keep_empty = false) const; [[nodiscard]] Vector split_view(const StringView&, bool keep_empty = false) const; - template - [[nodiscard]] Vector split_view_if(UnaryPredicate&& predicate, bool keep_empty = false) const - { - if (is_empty()) - return {}; - - Vector v; - size_t substart = 0; - for (size_t i = 0; i < length(); ++i) { - char ch = characters_without_null_termination()[i]; - if (predicate(ch)) { - size_t sublen = i - substart; - if (sublen != 0 || keep_empty) - v.append(substring_view(substart, sublen)); - substart = i + 1; - } - } - size_t taillen = length() - substart; - if (taillen != 0 || keep_empty) - v.append(substring_view(substart, taillen)); - return v; - } + [[nodiscard]] Vector split_view_if(Function const& predicate, bool keep_empty = false) const; // Create a Vector of StringViews split by line endings. As of CommonMark // 0.29, the spec defines a line ending as "a newline (U+000A), a carriage diff --git a/AK/URL.h b/AK/URL.h index ffcb5b5e405..7e8d9ac9b28 100644 --- a/AK/URL.h +++ b/AK/URL.h @@ -9,6 +9,7 @@ #include #include +#include namespace AK { diff --git a/Kernel/Firmware/ACPI/MultiProcessorParser.h b/Kernel/Firmware/ACPI/MultiProcessorParser.h index dcbed5950a8..26094c8ab4b 100644 --- a/Kernel/Firmware/ACPI/MultiProcessorParser.h +++ b/Kernel/Firmware/ACPI/MultiProcessorParser.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include #include diff --git a/Kernel/KLexicalPath.cpp b/Kernel/KLexicalPath.cpp index f3ed1b13354..8167cdb3f3a 100644 --- a/Kernel/KLexicalPath.cpp +++ b/Kernel/KLexicalPath.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include namespace Kernel::KLexicalPath { diff --git a/Tests/AK/TestAllOf.cpp b/Tests/AK/TestAllOf.cpp index f8b23f71ce1..1dce469e2d7 100644 --- a/Tests/AK/TestAllOf.cpp +++ b/Tests/AK/TestAllOf.cpp @@ -8,6 +8,7 @@ #include #include +#include TEST_CASE(should_determine_if_predicate_applies_to_all_elements_in_container) { diff --git a/Tests/AK/TestAnyOf.cpp b/Tests/AK/TestAnyOf.cpp index 5b7400c5d21..7be265fc0be 100644 --- a/Tests/AK/TestAnyOf.cpp +++ b/Tests/AK/TestAnyOf.cpp @@ -8,6 +8,7 @@ #include #include +#include TEST_CASE(should_determine_if_predicate_applies_to_any_element_in_container) { diff --git a/Tests/AK/TestBinarySearch.cpp b/Tests/AK/TestBinarySearch.cpp index 3e5d65c2404..bf7cdb76ae8 100644 --- a/Tests/AK/TestBinarySearch.cpp +++ b/Tests/AK/TestBinarySearch.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/Tests/AK/TestDisjointChunks.cpp b/Tests/AK/TestDisjointChunks.cpp index 5c8f982d365..0d6c1d1f21b 100644 --- a/Tests/AK/TestDisjointChunks.cpp +++ b/Tests/AK/TestDisjointChunks.cpp @@ -8,6 +8,7 @@ #include #include +#include TEST_CASE(basic) { diff --git a/Tests/AK/TestIndexSequence.cpp b/Tests/AK/TestIndexSequence.cpp index 31b94016515..1b897ff6b8b 100644 --- a/Tests/AK/TestIndexSequence.cpp +++ b/Tests/AK/TestIndexSequence.cpp @@ -8,6 +8,7 @@ #include #include +#include template F for_each_argument(F f, Args&&... args) diff --git a/Tests/AK/TestOptional.cpp b/Tests/AK/TestOptional.cpp index 006fe207165..2e71ce7f322 100644 --- a/Tests/AK/TestOptional.cpp +++ b/Tests/AK/TestOptional.cpp @@ -9,6 +9,7 @@ #include #include +#include TEST_CASE(basic_optional) { diff --git a/Tests/AK/TestString.cpp b/Tests/AK/TestString.cpp index fc55df1a5a4..0b3d859fa68 100644 --- a/Tests/AK/TestString.cpp +++ b/Tests/AK/TestString.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include TEST_CASE(construct_empty) diff --git a/Tests/AK/TestStringUtils.cpp b/Tests/AK/TestStringUtils.cpp index 948adde861b..e634778e2a1 100644 --- a/Tests/AK/TestStringUtils.cpp +++ b/Tests/AK/TestStringUtils.cpp @@ -7,6 +7,7 @@ #include #include +#include TEST_CASE(matches_null) { diff --git a/Tests/AK/TestStringView.cpp b/Tests/AK/TestStringView.cpp index a01b908a4dd..7b1d6435dc5 100644 --- a/Tests/AK/TestStringView.cpp +++ b/Tests/AK/TestStringView.cpp @@ -7,6 +7,7 @@ #include #include +#include TEST_CASE(construct_empty) { @@ -157,7 +158,7 @@ TEST_CASE(split_view) EXPECT_EQ(test_string_view.split_view("xx", true), Vector({ "a", "bc", "d", "" })); test_string_view = "ax_b_cxd"; - auto predicate = [](char ch) { return ch == 'x' || ch == '_'; }; + Function predicate = [](char ch) { return ch == 'x' || ch == '_'; }; EXPECT_EQ(test_string_view.split_view_if(predicate), Vector({ "a", "b", "c", "d" })); EXPECT_EQ(test_string_view.split_view_if(predicate, true), Vector({ "a", "", "b", "c", "d" })); EXPECT_EQ(test_string_view.split_view_if(predicate), Vector({ "a", "b", "c", "d" })); diff --git a/Tests/LibRegex/RegexLibC.cpp b/Tests/LibRegex/RegexLibC.cpp index 04794dbc08b..2b212c23d9e 100644 --- a/Tests/LibRegex/RegexLibC.cpp +++ b/Tests/LibRegex/RegexLibC.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include diff --git a/Userland/Libraries/LibDiff/Format.cpp b/Userland/Libraries/LibDiff/Format.cpp index 147eab48df3..ee28282183a 100644 --- a/Userland/Libraries/LibDiff/Format.cpp +++ b/Userland/Libraries/LibDiff/Format.cpp @@ -7,6 +7,7 @@ #include "Format.h" #include #include +#include namespace Diff { String generate_only_additions(const String& text) diff --git a/Userland/Libraries/LibGfx/BitmapFont.h b/Userland/Libraries/LibGfx/BitmapFont.h index ab70bd9db60..73b79b01353 100644 --- a/Userland/Libraries/LibGfx/BitmapFont.h +++ b/Userland/Libraries/LibGfx/BitmapFont.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/Userland/Libraries/LibGfx/Color.cpp b/Userland/Libraries/LibGfx/Color.cpp index 2c2a288a812..aeae569155d 100644 --- a/Userland/Libraries/LibGfx/Color.cpp +++ b/Userland/Libraries/LibGfx/Color.cpp @@ -311,6 +311,30 @@ Optional Color::from_string(StringView const& string) return Color(r.value(), g.value(), b.value(), a.value()); } +Vector Color::shades(u32 steps, float max) const +{ + float shade = 1.f; + float step = max / steps; + Vector shades; + for (u32 i = 0; i < steps; i++) { + shade -= step; + shades.append(this->darkened(shade)); + } + return shades; +} + +Vector Color::tints(u32 steps, float max) const +{ + float shade = 1.f; + float step = max / steps; + Vector tints; + for (u32 i = 0; i < steps; i++) { + shade += step; + tints.append(this->lightened(shade)); + } + return tints; +} + } bool IPC::encode(IPC::Encoder& encoder, Color const& color) diff --git a/Userland/Libraries/LibGfx/Color.h b/Userland/Libraries/LibGfx/Color.h index cdd1262498a..d8ed58f4f25 100644 --- a/Userland/Libraries/LibGfx/Color.h +++ b/Userland/Libraries/LibGfx/Color.h @@ -242,29 +242,8 @@ public: return Color(min(255, (int)((float)red() * amount)), min(255, (int)((float)green() * amount)), min(255, (int)((float)blue() * amount)), alpha()); } - Vector shades(u32 steps, float max = 1.f) const - { - float shade = 1.f; - float step = max / steps; - Vector shades; - for (u32 i = 0; i < steps; i++) { - shade -= step; - shades.append(this->darkened(shade)); - } - return shades; - } - - Vector tints(u32 steps, float max = 1.f) const - { - float shade = 1.f; - float step = max / steps; - Vector tints; - for (u32 i = 0; i < steps; i++) { - shade += step; - tints.append(this->lightened(shade)); - } - return tints; - } + Vector shades(u32 steps, float max = 1.f) const; + Vector tints(u32 steps, float max = 1.f) const; constexpr Color inverted() const { diff --git a/Userland/Libraries/LibGfx/Filters/FastBoxBlurFilter.cpp b/Userland/Libraries/LibGfx/Filters/FastBoxBlurFilter.cpp index 23c18b32249..6a543918dde 100644 --- a/Userland/Libraries/LibGfx/Filters/FastBoxBlurFilter.cpp +++ b/Userland/Libraries/LibGfx/Filters/FastBoxBlurFilter.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include namespace Gfx { diff --git a/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h b/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h index c50d200f165..81f8710cdfc 100644 --- a/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h +++ b/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include namespace JS { diff --git a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp index 4c1ed3f9226..5f74d07d463 100644 --- a/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp +++ b/Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp @@ -5,6 +5,7 @@ */ #include "ParsedCookie.h" +#include #include #include #include @@ -280,12 +281,12 @@ Optional parse_date_time(StringView date_string) return to_uint(token, year); }; - auto is_delimeter = [](char ch) { + Function is_delimiter = [](char ch) { return ch == 0x09 || (ch >= 0x20 && ch <= 0x2f) || (ch >= 0x3b && ch <= 0x40) || (ch >= 0x5b && ch <= 0x60) || (ch >= 0x7b && ch <= 0x7e); }; // 1. Using the grammar below, divide the cookie-date into date-tokens. - Vector date_tokens = date_string.split_view_if(is_delimeter); + Vector date_tokens = date_string.split_view_if(is_delimiter); // 2. Process each date-token sequentially in the order the date-tokens appear in the cookie-date. bool found_time = false; diff --git a/Userland/Services/LookupServer/DNSName.cpp b/Userland/Services/LookupServer/DNSName.cpp index 2d887b51ce5..fde5575bcae 100644 --- a/Userland/Services/LookupServer/DNSName.cpp +++ b/Userland/Services/LookupServer/DNSName.cpp @@ -7,6 +7,7 @@ #include "DNSName.h" #include +#include #include namespace LookupServer { diff --git a/Userland/Shell/Formatter.h b/Userland/Shell/Formatter.h index a8316b42edf..6a89a589127 100644 --- a/Userland/Shell/Formatter.h +++ b/Userland/Shell/Formatter.h @@ -12,6 +12,7 @@ #include #include #include +#include #include namespace Shell {