PackageVersionDataManifest.h (2459B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <AppInstallerVersions.h> 5 #include <winget/Compression.h> 6 #include <filesystem> 7 8 9 namespace AppInstaller::Manifest 10 { 11 // Contains the manifest that stores package version data for index v2 12 struct PackageVersionDataManifest 13 { 14 // The file name to use for the package version data manifest. 15 static std::string_view VersionManifestFileName(); 16 17 // The file name to use for the compressed package version data manifest. 18 static std::string_view VersionManifestCompressedFileName(); 19 20 // Gets the relative path to the package version manifest from the inputs. 21 static std::filesystem::path GetRelativeDirectoryPath(std::string_view packageIdentifier, std::string_view manifestHash); 22 23 // Creates the compressor used by the PackageVersionDataManifest. 24 static Compression::Compressor CreateCompressor(); 25 26 // Creates the decompressor used by the PackageVersionDataManifest. 27 static Compression::Decompressor CreateDecompressor(); 28 29 // Data on an individual version. 30 struct VersionData 31 { 32 VersionData() = default; 33 34 VersionData( 35 const Utility::VersionAndChannel& versionAndChannel, 36 std::optional<std::string> arpMinVersion, 37 std::optional<std::string> arpMaxVersion, 38 std::optional<std::string> relativePath, 39 std::optional<std::string> manifestHash); 40 41 Utility::Version Version; 42 std::optional<std::string> ArpMinVersion; 43 std::optional<std::string> ArpMaxVersion; 44 std::string ManifestRelativePath; 45 std::string ManifestHash; 46 }; 47 48 // Adds the given version data to the manifest. 49 void AddVersion(VersionData&& versionData); 50 51 // Gets the version data in this object. 52 const std::vector<VersionData>& Versions() const; 53 54 // Returns a serialized version of the current manifest data. 55 std::string Serialize(); 56 57 // Parses the input into this objects data. 58 void Deserialize(std::string_view input); 59 60 // Parses the input into this objects data. 61 void Deserialize(const std::vector<uint8_t>& input); 62 63 private: 64 std::vector<VersionData> m_versions; 65 }; 66 }