summaryrefslogtreecommitdiff
path: root/src/desktop/rule/layerRule/LayerRule.hpp
blob: 8934d1c6217ade44bfa41b73e07bd8509606e68b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once

#include "../RuleWithEffects.hpp"
#include "../../DesktopTypes.hpp"
#include "LayerRuleEffectContainer.hpp"

#include <expected>
#include <variant>

namespace Desktop::Rule {
    using LayerRuleEffectValue = std::variant<std::monostate, bool, int64_t, float, std::string>;

    struct SLayerRuleEffect {
        using storageType = CLayerRuleEffectContainer::storageType;
        using valueType   = LayerRuleEffectValue;

        CLayerRuleEffectContainer::storageType key = LAYER_RULE_EFFECT_NONE;
        std::string                            raw;
        LayerRuleEffectValue                   value;
    };

    class CLayerRule : public CRuleWithEffects<SLayerRuleEffect, RULE_TYPE_LAYER> {
      public:
        using Base        = CRuleWithEffects<SLayerRuleEffect, RULE_TYPE_LAYER>;
        using storageType = Base::storageType;

        CLayerRule(const std::string& name = "");
        virtual ~CLayerRule() = default;

        bool matches(PHLLS w);

      private:
        std::expected<LayerRuleEffectValue, std::string> parseEffect(storageType e, const std::string& result) override;
    };
};