/src/CMake/Source/cmSpdxSerializer.h
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | #pragma once |
4 | | |
5 | | #include <memory> |
6 | | #include <ostream> |
7 | | #include <string> |
8 | | |
9 | | #include <cm3p/json/value.h> |
10 | | #include <cm3p/json/writer.h> |
11 | | |
12 | | #include "cmSbomSerializer.h" |
13 | | |
14 | | struct cmSpdxSerializer final : cmSbomSerializer |
15 | | { |
16 | | cmSpdxSerializer(); |
17 | | |
18 | 0 | ~cmSpdxSerializer() override = default; |
19 | | |
20 | | void BeginObject() override; |
21 | | |
22 | | void BeginArray() override; |
23 | | |
24 | | void EndObject() override; |
25 | | |
26 | | void EndArray() override; |
27 | | |
28 | | void AddReference(std::string const& id) override; |
29 | | |
30 | | void AddString(std::string const& key, std::string const& value) override; |
31 | | |
32 | | void AddVisitable(std::string const& key, |
33 | | cmSbomObject const& visitable) override; |
34 | | |
35 | | void AddVectorIfPresent(std::string const& key, |
36 | | std::vector<cmSbomObject> const& vec) override; |
37 | | |
38 | | void AddVectorIfPresent(std::string const& key, |
39 | | std::vector<std::string> const& vec) override; |
40 | | |
41 | | bool WriteSbom(std::ostream& os, cmSbomObject const& document) override; |
42 | | |
43 | 0 | Json::Value GetJson() { return CurrentValue; } |
44 | | |
45 | | private: |
46 | | Json::Value CurrentValue; |
47 | | std::string CurrentKey; |
48 | | std::unique_ptr<Json::StreamWriter> Writer; |
49 | | }; |