aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Common/Config/AbstractConfigurationComparison.h
blob: 75e0b77b1cac58293fb48a4036f9225c563e2167 (plain) (blame)
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
#pragma once

#include <base/types.h>

namespace Poco::Util
{
    class AbstractConfiguration;
}

namespace DB
{
    /// Returns true if two configurations contains the same keys and values.
    bool isSameConfiguration(const Poco::Util::AbstractConfiguration & left,
                             const Poco::Util::AbstractConfiguration & right);

    /// Config may have multiple keys with one name. For example:
    /// <root>
    ///     <some_key>...</some_key>
    ///     <some_key>...</some_key>
    /// </root>
    /// Returns true if the specified subview of the two configurations contains
    /// the same keys and values for each key with the given name.
    bool isSameConfigurationWithMultipleKeys(const Poco::Util::AbstractConfiguration & left,
                                             const Poco::Util::AbstractConfiguration & right,
                                             const String & root, const String & name);

    /// Returns true if the specified subview of the two configurations contains the same keys and values.
    bool isSameConfiguration(const Poco::Util::AbstractConfiguration & left,
                             const Poco::Util::AbstractConfiguration & right,
                             const String & key);

    /// Returns true if specified subviews of the two configurations contains the same keys and values.
    bool isSameConfiguration(const Poco::Util::AbstractConfiguration & left, const String & left_key,
                             const Poco::Util::AbstractConfiguration & right, const String & right_key);

    inline bool operator==(const Poco::Util::AbstractConfiguration & left, const Poco::Util::AbstractConfiguration & right)
    {
        return isSameConfiguration(left, right);
    }

    inline bool operator!=(const Poco::Util::AbstractConfiguration & left, const Poco::Util::AbstractConfiguration & right)
    {
        return !isSameConfiguration(left, right);
    }
}