summaryrefslogtreecommitdiff
path: root/Kernel/KParams.cpp
blob: 26f4df771a535461799341e0c6c08b9f03765e5f (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);
}

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