winget-cli

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

ConfigurationSetParser_0_3.h (3557B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #pragma once
      4 #include "ConfigurationSetParser.h"
      5 #include "ConfigurationParameter.h"
      6 #include <winrt/Microsoft.Management.Configuration.h>
      7 
      8 #include <winget/Yaml.h>
      9 #include <optional>
     10 #include <utility>
     11 
     12 namespace winrt::Microsoft::Management::Configuration::implementation
     13 {
     14     // Parser for schema version 0.3
     15     struct ConfigurationSetParser_0_3 : public ConfigurationSetParser
     16     {
     17         ConfigurationSetParser_0_3() = default;
     18 
     19         virtual ~ConfigurationSetParser_0_3() noexcept = default;
     20 
     21         ConfigurationSetParser_0_3(const ConfigurationSetParser_0_3&) = delete;
     22         ConfigurationSetParser_0_3& operator=(const ConfigurationSetParser_0_3&) = delete;
     23         ConfigurationSetParser_0_3(ConfigurationSetParser_0_3&&) = default;
     24         ConfigurationSetParser_0_3& operator=(ConfigurationSetParser_0_3&&) = default;
     25 
     26         // Retrieve the configuration units from the parser.
     27         void Parse() override;
     28 
     29         // Retrieves the schema version of the parser.
     30         hstring GetSchemaVersion() override;
     31 
     32         // Extracts the environment configuration from the given metadata.
     33         // This only examines the winget subnode.
     34         void ExtractEnvironmentFromMetadata(Windows::Foundation::Collections::ValueSet valueSet, implementation::ConfigurationEnvironment& environment) override;
     35 
     36     protected:
     37         // Sets (or resets) the document to parse.
     38         void SetDocument(AppInstaller::YAML::Node&& document) override;
     39 
     40         void ParseParameters(ConfigurationSetParser::ConfigurationSetPtr& set);
     41         void ParseParameter(ConfigurationParameter* parameter, const AppInstaller::YAML::Node& node);
     42         void ParseParameterType(ConfigurationParameter* parameter, const AppInstaller::YAML::Node& node);
     43         void GetStringValueForParameter(
     44             const AppInstaller::YAML::Node& node,
     45             ConfigurationField field,
     46             ConfigurationParameter* parameter,
     47             void(ConfigurationParameter::* propertyFunction)(const hstring& value));
     48         void GetUInt32ValueForParameter(
     49             const AppInstaller::YAML::Node& node,
     50             ConfigurationField field,
     51             ConfigurationParameter* parameter,
     52             void(ConfigurationParameter::* propertyFunction)(uint32_t value));
     53         void ParseObjectValueForParameter(
     54             const AppInstaller::YAML::Node& node,
     55             ConfigurationField field,
     56             Windows::Foundation::PropertyType type,
     57             ConfigurationParameter* parameter,
     58             void(ConfigurationParameter::* propertyFunction)(const Windows::Foundation::IInspectable& value));
     59 
     60         void ParseConfigurationUnitsFromField(const AppInstaller::YAML::Node& document, ConfigurationField field, std::vector<Configuration::ConfigurationUnit>& result);
     61         virtual void ParseConfigurationUnit(ConfigurationUnit* unit, const AppInstaller::YAML::Node& unitNode);
     62         // Determines if the given unit should be converted to a group.
     63         bool ShouldConvertToGroup(ConfigurationUnit* unit);
     64 
     65         // Extracts the environment for a unit.
     66         void ExtractEnvironmentForUnit(ConfigurationUnit* unit);
     67 
     68         AppInstaller::YAML::Node m_document;
     69     };
     70 
     71     std::optional<std::pair<Windows::Foundation::PropertyType, bool>> ParseWindowsFoundationPropertyType(std::string_view value);
     72     std::string_view ToString(Windows::Foundation::PropertyType value, bool isSecure);
     73 }