mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 11:42:38 +03:00
Kernel: Convert CommandLine to KString
This commit is contained in:
parent
a4560313eb
commit
194d1c884b
Notes:
sideshowbarker
2024-07-17 21:04:08 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/194d1c884b2 Pull-request: https://github.com/SerenityOS/serenity/pull/11817 Reviewed-by: https://github.com/bgianfo ✅
@ -48,7 +48,7 @@ UNMAP_AFTER_INIT void CommandLine::initialize()
|
||||
}
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void CommandLine::build_commandline(const String& cmdline_from_bootloader)
|
||||
UNMAP_AFTER_INIT NonnullOwnPtr<KString> CommandLine::build_commandline(StringView cmdline_from_bootloader)
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(cmdline_from_bootloader);
|
||||
@ -56,7 +56,7 @@ UNMAP_AFTER_INIT void CommandLine::build_commandline(const String& cmdline_from_
|
||||
builder.append(" ");
|
||||
builder.append(s_embedded_cmd_line);
|
||||
}
|
||||
m_string = builder.to_string();
|
||||
return KString::must_create(builder.string_view());
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void CommandLine::add_arguments(const Vector<StringView>& args)
|
||||
@ -77,11 +77,11 @@ UNMAP_AFTER_INIT void CommandLine::add_arguments(const Vector<StringView>& args)
|
||||
}
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT CommandLine::CommandLine(const String& cmdline_from_bootloader)
|
||||
UNMAP_AFTER_INIT CommandLine::CommandLine(StringView cmdline_from_bootloader)
|
||||
: m_string(build_commandline(cmdline_from_bootloader))
|
||||
{
|
||||
s_the = this;
|
||||
build_commandline(cmdline_from_bootloader);
|
||||
const auto& args = m_string.split_view(' ');
|
||||
const auto& args = m_string->view().split_view(' ');
|
||||
m_params.ensure_capacity(args.size());
|
||||
add_arguments(args);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
BootloaderOnly
|
||||
};
|
||||
|
||||
[[nodiscard]] const String& string() const { return m_string; }
|
||||
[[nodiscard]] StringView string() const { return m_string->view(); }
|
||||
Optional<StringView> lookup(StringView key) const;
|
||||
[[nodiscard]] bool contains(StringView key) const;
|
||||
|
||||
@ -89,12 +89,12 @@ public:
|
||||
[[nodiscard]] size_t switch_to_tty() const;
|
||||
|
||||
private:
|
||||
CommandLine(const String&);
|
||||
CommandLine(StringView);
|
||||
|
||||
void add_arguments(const Vector<StringView>& args);
|
||||
void build_commandline(const String& cmdline_from_bootloader);
|
||||
static NonnullOwnPtr<KString> build_commandline(StringView cmdline_from_bootloader);
|
||||
|
||||
String m_string;
|
||||
NonnullOwnPtr<KString> m_string;
|
||||
HashMap<StringView, StringView> m_params;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user