SlHelpers
Loading...
Searching...
No Matches
CveBscMap.h
1// SPDX-License-Identifier: GPL-2.0-only
2
3#pragma once
4
5#include <filesystem>
6#include <unordered_map>
7#include <string>
8
9#include "../helpers/String.h"
10
11namespace SlCVEs {
12
16class CveBscMap {
17public:
19 using Map = std::unordered_map<std::string, std::string, SlHelpers::String::Hash,
21
22 CveBscMap() = delete;
23
24 CveBscMap(const CveBscMap &) = delete;
25 CveBscMap &operator=(const CveBscMap &) = delete;
26
28 CveBscMap(CveBscMap &&) = default;
30 CveBscMap &operator=(CveBscMap &&) = default;
31
36 CveBscMap(const std::filesystem::path &cve2Bugzilla);
37
43 std::string_view getBsc(std::string_view cve) const {
44 const auto it = m_cveBscMap.find(cve);
45 if (it != m_cveBscMap.cend())
46 return it->second;
47
48 return {};
49 }
50
51
57 std::string_view getCve(std::string_view bsc) const
58 {
59 const auto it = m_bscCveMap.find(bsc);
60 if (it != m_bscCveMap.cend())
61 return it->second;
62
63 return {};
64 }
65
66private:
67 Map m_cveBscMap;
68 Map m_bscCveMap;
69};
70
71}
std::unordered_map< std::string, std::string, SlHelpers::String::Hash, SlHelpers::String::Eq > Map
CVE -> Bugzilla mapping.
Definition CveBscMap.h:19
CveBscMap & operator=(CveBscMap &&)=default
Move assignment operator.
CveBscMap(CveBscMap &&)=default
Move constructor.
std::string_view getBsc(std::string_view cve) const
Get bugzilla number for a CVE cve.
Definition CveBscMap.h:43
CveBscMap(const std::filesystem::path &cve2Bugzilla)
Create a new CveBscMap map from cve2Bugzilla.
std::string_view getCve(std::string_view bsc) const
Get CVE number for a bugzilla bsc.
Definition CveBscMap.h:57
Equality test for string and string_view to be used in containers.
Definition String.h:281
Hash for string and string_view to be used in hashing containers.
Definition String.h:254