~aleteoryx/muditaos

ref: 7ffccabd0f86dde3b2c5a46497ac2103d7678733 muditaos/module-services/service-db/EntryPath.cpp -rw-r--r-- 1.4 KiB
7ffccabd — Radoslaw Wicik [EGD-6670] Cancel jenkins build on PR update 4 years ago
                                                                                
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "service-db/SettingsMessages.hpp"

namespace settings
{
    namespace
    {
        bool isLessAppLocal(const EntryPath &lhs, const EntryPath &rhs) noexcept
        {
            if (lhs.mode < rhs.mode) {
                return true;
            }
            if (lhs.mode > rhs.mode) {
                return false;
            }
            if (lhs.service < rhs.service) {
                return true;
            }
            if (lhs.service > rhs.service) {
                return false;
            }
            if (lhs.profile < rhs.profile) {
                return true;
            }
            if (lhs.profile > rhs.profile) {
                return false;
            }
            if (lhs.variable < rhs.variable) {
                return true;
            }
            if (lhs.variable > rhs.variable) {
                return false;
            }
            return false;
        }
    } // namespace

    bool operator<(const EntryPath &lhs, const EntryPath &rhs) noexcept
    {
        if (lhs.scope != rhs.scope) {
            return lhs.scope < rhs.scope;
        }

        // Scopes are equal - compare other internals.
        if (lhs.scope == SettingsScope::AppLocal) {
            return isLessAppLocal(lhs, rhs);
        }
        return lhs.variable < rhs.variable;
    }
} // namespace settings