summaryrefslogtreecommitdiff
path: root/Kernel/KParams.cpp
blob: 67a66aa07974c114d38d49f5a3e24c03c9f3e1a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#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(' ')) {
        if (str == "") {
            continue;
        }

        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).value_or({});
}

bool KParams::has(const String& key) const
{
    return m_params.contains(key);
}