diff --git a/AK/BufferStream.h b/AK/BufferStream.h index 2e2e6bac175..a106ac95b4c 100644 --- a/AK/BufferStream.h +++ b/AK/BufferStream.h @@ -28,6 +28,7 @@ #include #include +#include namespace AK { diff --git a/AK/Demangle.h b/AK/Demangle.h index 722c32b4773..dbba1b6c7ed 100644 --- a/AK/Demangle.h +++ b/AK/Demangle.h @@ -27,9 +27,10 @@ #pragma once #include +#include #ifndef BUILDING_SERENITY_TOOLCHAIN -#include +# include #endif namespace AK { diff --git a/AK/FileSystemPath.cpp b/AK/FileSystemPath.cpp index 69456cb5ed5..a53283510b6 100644 --- a/AK/FileSystemPath.cpp +++ b/AK/FileSystemPath.cpp @@ -24,9 +24,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "FileSystemPath.h" -#include "StringBuilder.h" -#include "Vector.h" +#include +#include +#include +#include namespace AK { diff --git a/AK/FlyString.cpp b/AK/FlyString.cpp index 07fc58e5183..86acdd85708 100644 --- a/AK/FlyString.cpp +++ b/AK/FlyString.cpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace AK { @@ -98,4 +99,9 @@ FlyString FlyString::to_lowercase() const return String(*m_impl).to_lowercase(); } +StringView FlyString::view() const +{ + return { characters(), length() }; +} + } diff --git a/AK/FlyString.h b/AK/FlyString.h index cef44986032..b494bd801c1 100644 --- a/AK/FlyString.h +++ b/AK/FlyString.h @@ -44,7 +44,7 @@ public: const char* characters() const { return m_impl ? m_impl->characters() : nullptr; } size_t length() const { return m_impl ? m_impl->length() : 0; } - StringView view() const { return { characters(), length() }; } + StringView view() const; FlyString to_lowercase() const; diff --git a/AK/IPv4Address.h b/AK/IPv4Address.h index 6d5dc6f5353..aee493035fd 100644 --- a/AK/IPv4Address.h +++ b/AK/IPv4Address.h @@ -30,6 +30,7 @@ #include #include #include +#include #include typedef u32 in_addr_t; diff --git a/AK/String.cpp b/AK/String.cpp index 7e751d752ca..96d426a025a 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #ifndef KERNEL @@ -41,6 +42,14 @@ extern "C" char* strstr(const char* haystack, const char* needle); namespace AK { +String::String(const StringView& view) +{ + if (view.m_impl) + m_impl = *view.m_impl; + else + m_impl = StringImpl::create(view.characters_without_null_termination(), view.length()); +} + bool String::operator==(const String& other) const { if (!m_impl) @@ -341,4 +350,50 @@ String String::to_uppercase() const return m_impl->to_uppercase(); } +bool operator<(const char* characters, const String& string) +{ + if (!characters) + return !string.is_null(); + + if (string.is_null()) + return false; + + return __builtin_strcmp(characters, string.characters()) < 0; +} + +bool operator>=(const char* characters, const String& string) +{ + return !(characters < string); +} + +bool operator>(const char* characters, const String& string) +{ + if (!characters) + return !string.is_null(); + + if (string.is_null()) + return false; + + return __builtin_strcmp(characters, string.characters()) > 0; +} + +bool operator<=(const char* characters, const String& string) +{ + return !(characters > string); +} + +bool String::operator==(const char* cstring) const +{ + if (is_null()) + return !cstring; + if (!cstring) + return false; + return !__builtin_strcmp(characters(), cstring); +} + +StringView String::view() const +{ + return { characters(), length() }; +} + } diff --git a/AK/String.h b/AK/String.h index 246bd02831d..ce7ad196e2e 100644 --- a/AK/String.h +++ b/AK/String.h @@ -30,7 +30,6 @@ #include #include #include -#include #include namespace AK { @@ -62,14 +61,7 @@ public: ~String() {} String() {} - - String(const StringView& view) - { - if (view.m_impl) - m_impl = *view.m_impl; - else - m_impl = StringImpl::create(view.characters_without_null_termination(), view.length()); - } + String(const StringView&); String(const String& other) : m_impl(const_cast(other).m_impl) @@ -166,19 +158,8 @@ public: bool operator<=(const String& other) const { return !(*this > other); } bool operator<=(const char* other) const { return !(*this > other); } - bool operator==(const char* cstring) const - { - if (is_null()) - return !cstring; - if (!cstring) - return false; - return !__builtin_strcmp(characters(), cstring); - } - - bool operator!=(const char* cstring) const - { - return !(*this == cstring); - } + bool operator==(const char* cstring) const; + bool operator!=(const char* cstring) const { return !(*this == cstring); } String isolated_copy() const; @@ -228,28 +209,12 @@ public: static String number(long); static String number(long long); - StringView view() const - { - return { characters(), length() }; - } + StringView view() const; private: RefPtr m_impl; }; -inline bool StringView::operator==(const String& string) const -{ - if (string.is_null()) - return !m_characters; - if (!m_characters) - return false; - if (m_length != string.length()) - return false; - if (m_characters == string.characters()) - return true; - return !__builtin_memcmp(m_characters, string.characters(), m_length); -} - template<> struct Traits : public GenericTraits { static unsigned hash(const String& s) { return s.impl() ? s.impl()->hash() : 0; } @@ -260,37 +225,10 @@ struct CaseInsensitiveStringTraits : public AK::Traits { static bool equals(const String& a, const String& b) { return a.to_lowercase() == b.to_lowercase(); } }; -inline bool operator<(const char* characters, const String& string) -{ - if (!characters) - return !string.is_null(); - - if (string.is_null()) - return false; - - return __builtin_strcmp(characters, string.characters()) < 0; -} - -inline bool operator>=(const char* characters, const String& string) -{ - return !(characters < string); -} - -inline bool operator>(const char* characters, const String& string) -{ - if (!characters) - return !string.is_null(); - - if (string.is_null()) - return false; - - return __builtin_strcmp(characters, string.characters()) > 0; -} - -inline bool operator<=(const char* characters, const String& string) -{ - return !(characters > string); -} +bool operator<(const char*, const String&); +bool operator>=(const char*, const String&); +bool operator>(const char*, const String&); +bool operator<=(const char*, const String&); String escape_html_entities(const StringView& html); diff --git a/AK/StringBuilder.cpp b/AK/StringBuilder.cpp index 3e83f52bcaf..17be5972a92 100644 --- a/AK/StringBuilder.cpp +++ b/AK/StringBuilder.cpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace AK { diff --git a/AK/StringView.cpp b/AK/StringView.cpp index e979e20fdaa..f927f32211c 100644 --- a/AK/StringView.cpp +++ b/AK/StringView.cpp @@ -200,4 +200,17 @@ unsigned StringView::hash() const return string_hash(characters_without_null_termination(), length()); } +bool StringView::operator==(const String& string) const +{ + if (string.is_null()) + return !m_characters; + if (!m_characters) + return false; + if (m_length != string.length()) + return false; + if (m_characters == string.characters()) + return true; + return !__builtin_memcmp(m_characters, string.characters(), m_length); +} + } diff --git a/Kernel/ACPI/ACPIParser.cpp b/Kernel/ACPI/ACPIParser.cpp index 03e68b36033..c17a6366b75 100644 --- a/Kernel/ACPI/ACPIParser.cpp +++ b/Kernel/ACPI/ACPIParser.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include namespace Kernel { diff --git a/Kernel/ACPI/ACPIStaticParser.cpp b/Kernel/ACPI/ACPIStaticParser.cpp index 488442582c8..f8d1f3a9074 100644 --- a/Kernel/ACPI/ACPIStaticParser.cpp +++ b/Kernel/ACPI/ACPIStaticParser.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include diff --git a/Kernel/ACPI/DMIDecoder.cpp b/Kernel/ACPI/DMIDecoder.cpp index 6f6f40cdb6d..755e46a87b9 100644 --- a/Kernel/ACPI/DMIDecoder.cpp +++ b/Kernel/ACPI/DMIDecoder.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include diff --git a/Kernel/ACPI/MultiProcessorParser.cpp b/Kernel/ACPI/MultiProcessorParser.cpp index 0b405b95b1b..05157a77df3 100644 --- a/Kernel/ACPI/MultiProcessorParser.cpp +++ b/Kernel/ACPI/MultiProcessorParser.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include diff --git a/Kernel/Devices/KeyboardDevice.cpp b/Kernel/Devices/KeyboardDevice.cpp index 2a5f2513052..3ee979bc28c 100644 --- a/Kernel/Devices/KeyboardDevice.cpp +++ b/Kernel/Devices/KeyboardDevice.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/Kernel/Devices/PATAChannel.cpp b/Kernel/Devices/PATAChannel.cpp index 7f77d048faa..7d649ddf2b9 100644 --- a/Kernel/Devices/PATAChannel.cpp +++ b/Kernel/Devices/PATAChannel.cpp @@ -24,9 +24,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "PATADiskDevice.h" #include +#include #include +#include #include #include #include diff --git a/Kernel/Devices/PATADiskDevice.cpp b/Kernel/Devices/PATADiskDevice.cpp index a3aeb13a75f..7dcad3678b5 100644 --- a/Kernel/Devices/PATADiskDevice.cpp +++ b/Kernel/Devices/PATADiskDevice.cpp @@ -27,6 +27,7 @@ //#define PATA_DEVICE_DEBUG #include +#include #include #include #include diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp index 0c27e24bae9..938f37ac2a0 100644 --- a/Kernel/Devices/SB16.cpp +++ b/Kernel/Devices/SB16.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include #include diff --git a/Kernel/DoubleBuffer.cpp b/Kernel/DoubleBuffer.cpp index 0ebac2ae532..f817edb1672 100644 --- a/Kernel/DoubleBuffer.cpp +++ b/Kernel/DoubleBuffer.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include namespace Kernel { diff --git a/Kernel/FileSystem/Custody.cpp b/Kernel/FileSystem/Custody.cpp index 71b5d383935..7699c3ea8db 100644 --- a/Kernel/FileSystem/Custody.cpp +++ b/Kernel/FileSystem/Custody.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include #include diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp index f2ca0a23517..5bb0266b6b0 100644 --- a/Kernel/FileSystem/DevPtsFS.cpp +++ b/Kernel/FileSystem/DevPtsFS.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include #include diff --git a/Kernel/FileSystem/DiskBackedFileSystem.cpp b/Kernel/FileSystem/DiskBackedFileSystem.cpp index 98233da3adc..d281f935ebe 100644 --- a/Kernel/FileSystem/DiskBackedFileSystem.cpp +++ b/Kernel/FileSystem/DiskBackedFileSystem.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index cc247457d64..1e4004068d3 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp index 586d9e4eb35..9110968e3d6 100644 --- a/Kernel/FileSystem/FIFO.cpp +++ b/Kernel/FileSystem/FIFO.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/Kernel/FileSystem/File.cpp b/Kernel/FileSystem/File.cpp index 89032208095..85d0de5a71d 100644 --- a/Kernel/FileSystem/File.cpp +++ b/Kernel/FileSystem/File.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include diff --git a/Kernel/FileSystem/FileSystem.cpp b/Kernel/FileSystem/FileSystem.cpp index eaa0a3ea498..021da73153b 100644 --- a/Kernel/FileSystem/FileSystem.cpp +++ b/Kernel/FileSystem/FileSystem.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp index a31d4abd22e..aa67d33cf43 100644 --- a/Kernel/FileSystem/Inode.cpp +++ b/Kernel/FileSystem/Inode.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp index 399ae4a11ae..9b12c18c764 100644 --- a/Kernel/FileSystem/InodeFile.cpp +++ b/Kernel/FileSystem/InodeFile.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include diff --git a/Kernel/Interrupts/APIC.cpp b/Kernel/Interrupts/APIC.cpp index 6bf3a1aacb5..67c25db8783 100644 --- a/Kernel/Interrupts/APIC.cpp +++ b/Kernel/Interrupts/APIC.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include #include diff --git a/Kernel/Interrupts/IOAPIC.cpp b/Kernel/Interrupts/IOAPIC.cpp index c1cb1d495bc..0bf77069e76 100644 --- a/Kernel/Interrupts/IOAPIC.cpp +++ b/Kernel/Interrupts/IOAPIC.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include diff --git a/Kernel/Interrupts/InterruptManagement.cpp b/Kernel/Interrupts/InterruptManagement.cpp index 7ae979e0343..154a1a9ce45 100644 --- a/Kernel/Interrupts/InterruptManagement.cpp +++ b/Kernel/Interrupts/InterruptManagement.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include #include diff --git a/Kernel/KBuffer.h b/Kernel/KBuffer.h index f5cd6aedf26..6e035186074 100644 --- a/Kernel/KBuffer.h +++ b/Kernel/KBuffer.h @@ -40,6 +40,7 @@ #include #include #include +#include #include #include diff --git a/Kernel/PCI/MMIOAccess.cpp b/Kernel/PCI/MMIOAccess.cpp index 7606c9b6f01..ae3b3ca751d 100644 --- a/Kernel/PCI/MMIOAccess.cpp +++ b/Kernel/PCI/MMIOAccess.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include diff --git a/Kernel/Thread.h b/Kernel/Thread.h index 1d0e9e0e50e..aeebdc462ff 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -100,7 +100,7 @@ public: Vector raw_backtrace(FlatPtr ebp) const; const String& name() const { return m_name; } - void set_name(StringView s) { m_name = s; } + void set_name(const StringView& s) { m_name = s; } void finalize(); diff --git a/Kernel/Time/HPET.cpp b/Kernel/Time/HPET.cpp index ffac2834117..e7d082780c2 100644 --- a/Kernel/Time/HPET.cpp +++ b/Kernel/Time/HPET.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index b03f1fe1bcb..4ee2a19e587 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -28,6 +28,7 @@ #include "Process.h" #include #include +#include #include #include #include diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp index 6caf5a24da3..2320ef6ea0c 100644 --- a/Kernel/VM/Region.cpp +++ b/Kernel/VM/Region.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include #include diff --git a/Libraries/LibELF/ELFImage.cpp b/Libraries/LibELF/ELFImage.cpp index 6344639c877..815b272561f 100644 --- a/Libraries/LibELF/ELFImage.cpp +++ b/Libraries/LibELF/ELFImage.cpp @@ -26,6 +26,7 @@ #include #include +#include #include ELFImage::ELFImage(const u8* buffer, size_t size) diff --git a/Libraries/LibELF/ELFLoader.h b/Libraries/LibELF/ELFLoader.h index 1331dd27111..f0e51bc8ea6 100644 --- a/Libraries/LibELF/ELFLoader.h +++ b/Libraries/LibELF/ELFLoader.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include