mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +00:00
Kernel: Add KParams class for accessing kernel cmdline parameters (#188)
This commit is contained in:
parent
042895317d
commit
738f9de9a9
5 changed files with 59 additions and 3 deletions
34
Kernel/KParams.cpp
Normal file
34
Kernel/KParams.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include <Kernel/KParams.h>
|
||||
|
||||
static KParams* s_the;
|
||||
|
||||
KParams& KParams::the()
|
||||
{
|
||||
return *s_the;
|
||||
}
|
||||
|
||||
KParams::KParams(const String& cmdline)
|
||||
: m_cmdline(cmdline)
|
||||
{
|
||||
s_the = this;
|
||||
|
||||
for (auto str : m_cmdline.split(' ')) {
|
||||
auto pair = str.split_limit('=', 2);
|
||||
|
||||
if (pair.size() == 1) {
|
||||
m_params.set(pair[0], "");
|
||||
} else {
|
||||
m_params.set(pair[0], pair[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String KParams::get(const String& key) const
|
||||
{
|
||||
return m_params.get(key);
|
||||
}
|
||||
|
||||
bool KParams::has(const String& key) const
|
||||
{
|
||||
return m_params.contains(key);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue