mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +00:00
Kernel: Convert CommandLine to KString
This commit is contained in:
parent
a4560313eb
commit
194d1c884b
2 changed files with 9 additions and 9 deletions
|
@ -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;
|
StringBuilder builder;
|
||||||
builder.append(cmdline_from_bootloader);
|
builder.append(cmdline_from_bootloader);
|
||||||
|
@ -56,7 +56,7 @@ UNMAP_AFTER_INIT void CommandLine::build_commandline(const String& cmdline_from_
|
||||||
builder.append(" ");
|
builder.append(" ");
|
||||||
builder.append(s_embedded_cmd_line);
|
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)
|
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;
|
s_the = this;
|
||||||
build_commandline(cmdline_from_bootloader);
|
const auto& args = m_string->view().split_view(' ');
|
||||||
const auto& args = m_string.split_view(' ');
|
|
||||||
m_params.ensure_capacity(args.size());
|
m_params.ensure_capacity(args.size());
|
||||||
add_arguments(args);
|
add_arguments(args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
BootloaderOnly
|
BootloaderOnly
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] const String& string() const { return m_string; }
|
[[nodiscard]] StringView string() const { return m_string->view(); }
|
||||||
Optional<StringView> lookup(StringView key) const;
|
Optional<StringView> lookup(StringView key) const;
|
||||||
[[nodiscard]] bool contains(StringView key) const;
|
[[nodiscard]] bool contains(StringView key) const;
|
||||||
|
|
||||||
|
@ -89,12 +89,12 @@ public:
|
||||||
[[nodiscard]] size_t switch_to_tty() const;
|
[[nodiscard]] size_t switch_to_tty() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CommandLine(const String&);
|
CommandLine(StringView);
|
||||||
|
|
||||||
void add_arguments(const Vector<StringView>& args);
|
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;
|
HashMap<StringView, StringView> m_params;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue