Debian Codegraph @

src/core/info/common/swinfokernel.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include "swinfokernel.h"
5
6 #include "../infoproviderregistry.h"
7 #include "common/stringutils.h"
8 #include "swinfokerneldatasource.h"
9 #include <string_view>
10 #include <utility>
11
12 SWInfoKernel::SWInfoKernel(
13 std::unique_ptr<IDataSource<std::string>> &&dataSource) noexcept
14 : dataSource_(std::move(dataSource))
15 {
16 }
17
18 std::vector<std::pair<std::string, std::string>> SWInfoKernel::provideInfo() const
19 {
20 std::vector<std::pair<std::string, std::string>> info;
21
22 std::string data;
23 dataSource_->read(data);
24 data = Utils::String::parseKernelProcVersion(data).value_or("0.0.0");
25
26 info.emplace_back(ISWInfo::Keys::kernelVersion, data);
27
28 return info;
29 }
30
31 bool const SWInfoKernel::registered_ = InfoProviderRegistry::add(
32 std::make_unique<SWInfoKernel>(std::make_unique<SWInfoKernelDataSource>()));