winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

Interface.h (4555B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #pragma once
      4 #include "Microsoft/Schema/ISQLiteIndex.h"
      5 #include "Microsoft/Schema/1_0/SearchResultsTable.h"
      6 #include "Microsoft/Schema/1_0/OneToManyTable.h"
      7 
      8 #include <memory>
      9 #include <vector>
     10 
     11 
     12 namespace AppInstaller::Repository::Microsoft::Schema::V1_0
     13 {
     14     // Interface to this schema version exposed through ISQLiteIndex.
     15     struct Interface : public ISQLiteIndex
     16     {
     17         // Version 1.0
     18         SQLite::Version GetVersion() const override;
     19         void CreateTables(SQLite::Connection& connection, CreateOptions options) override;
     20         SQLite::rowid_t AddManifest(SQLite::Connection& connection, const Manifest::Manifest& manifest, const std::optional<std::filesystem::path>& relativePath) override;
     21         std::pair<bool, SQLite::rowid_t> UpdateManifest(SQLite::Connection& connection, const Manifest::Manifest& manifest, const std::optional<std::filesystem::path>& relativePath) override;
     22         SQLite::rowid_t RemoveManifest(SQLite::Connection& connection, const Manifest::Manifest& manifest) override;
     23         void RemoveManifestById(SQLite::Connection& connection, SQLite::rowid_t manifestId) override;
     24         void PrepareForPackaging(SQLite::Connection& connection) override;
     25         bool CheckConsistency(const SQLite::Connection& connection, bool log) const override;
     26         SearchResult Search(const SQLite::Connection& connection, const SearchRequest& request) const override;
     27         std::optional<std::string> GetPropertyByPrimaryId(const SQLite::Connection& connection, SQLite::rowid_t primaryId, PackageVersionProperty property) const override;
     28         std::vector<std::string> GetMultiPropertyByPrimaryId(const SQLite::Connection& connection, SQLite::rowid_t primaryId, PackageVersionMultiProperty property) const override;
     29         std::optional<SQLite::rowid_t> GetManifestIdByKey(const SQLite::Connection& connection, SQLite::rowid_t id, std::string_view version, std::string_view channel) const override;
     30         std::optional<SQLite::rowid_t> GetManifestIdByManifest(const SQLite::Connection& connection, const Manifest::Manifest& manifest) const override;
     31         std::vector<VersionKey> GetVersionKeysById(const SQLite::Connection& connection, SQLite::rowid_t id) const override;
     32 
     33         // Version 1.1
     34         MetadataResult GetMetadataByManifestId(const SQLite::Connection& connection, SQLite::rowid_t manifestId) const override;
     35         void SetMetadataByManifestId(SQLite::Connection& connection, SQLite::rowid_t manifestId, PackageVersionMetadata metadata, std::string_view value) override;
     36 
     37         // Version 1.2
     38         Utility::NormalizedName NormalizeName(std::string_view name, std::string_view publisher) const override;
     39 
     40         // Version 1.4 Get all the dependencies for a specific manifest.
     41         std::set<std::pair<SQLite::rowid_t, Utility::NormalizedString>> GetDependenciesByManifestRowId(const SQLite::Connection& connection, SQLite::rowid_t manifestRowId) const override;
     42         std::vector<std::pair<SQLite::rowid_t, Utility::NormalizedString>> GetDependentsById(const SQLite::Connection& connection, AppInstaller::Manifest::string_t packageId) const override;
     43 
     44         // Version 1.7
     45         void DropTables(SQLite::Connection& connection) override;
     46 
     47         // Version 2.0
     48         bool MigrateFrom(SQLite::Connection& connection, const ISQLiteIndex* current) override;
     49 
     50     protected:
     51         virtual bool NotNeeded(const SQLite::Connection& connection, std::string_view tableName, std::string_view valueName, SQLite::rowid_t id) const;
     52 
     53         // Creates the search results table.
     54         virtual std::unique_ptr<SearchResultsTable> CreateSearchResultsTable(const SQLite::Connection& connection) const;
     55 
     56         // Executes all relevant searches for the query.
     57         virtual void PerformQuerySearch(SearchResultsTable& resultsTable, const RequestMatch& query) const;
     58 
     59         // Gets a property already knowing that the manifest id is valid.
     60         virtual std::optional<std::string> GetPropertyByManifestIdInternal(const SQLite::Connection& connection, SQLite::rowid_t manifestId, PackageVersionProperty property) const;
     61 
     62         // Gets the one to many table schema to use.
     63         virtual OneToManyTableSchema GetOneToManyTableSchema() const;
     64 
     65         // Force the database to shrink the file size.
     66         // This *must* be done outside of an active transaction.
     67         void Vacuum(const SQLite::Connection& connection);
     68     };
     69 }