ManifestJSONParser.h (2065B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <AppInstallerVersions.h> 5 #include <winget/JsonUtil.h> 6 #include <winget/Manifest.h> 7 8 #include <memory> 9 #include <vector> 10 11 namespace AppInstaller::Repository::JSON 12 { 13 // Exposes functions for parsing JSON REST responses to manifest requests. 14 struct ManifestJSONParser 15 { 16 ManifestJSONParser(const Utility::Version& responseSchemaVersion); 17 18 ManifestJSONParser(const ManifestJSONParser&) = delete; 19 ManifestJSONParser& operator=(const ManifestJSONParser&) = delete; 20 21 ManifestJSONParser(ManifestJSONParser&&) noexcept; 22 ManifestJSONParser& operator=(ManifestJSONParser&&) noexcept; 23 24 ~ManifestJSONParser(); 25 26 // Deserializes the manifests from the REST response object root. 27 // May potentially contain multiple versions of the same package. 28 std::vector<Manifest::Manifest> Deserialize(const web::json::value& response) const; 29 30 // Deserializes the manifests from the Data field of the REST response object. 31 // May potentially contain multiple versions of the same package. 32 std::vector<Manifest::Manifest> DeserializeData(const web::json::value& data) const; 33 34 // Deserializes the AppsAndFeaturesEntries node, returning the set of values below it. 35 std::vector<Manifest::AppsAndFeaturesEntry> DeserializeAppsAndFeaturesEntries(const web::json::array& data) const; 36 37 // Deserializes the locale node; returning an object if a proper locale was found. 38 std::optional<Manifest::ManifestLocalization> DeserializeLocale(const web::json::value& locale) const; 39 40 // Deserializes the InstallationMetadata node; returning an object if a proper InstallationMetadata was found. 41 std::optional<Manifest::InstallationMetadataInfo> DeserializeInstallationMetadata(const web::json::value& installationMetadata) const; 42 43 private: 44 struct impl; 45 std::unique_ptr<impl> m_pImpl; 46 }; 47 }