• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

realm / realm-core / jorgen.edelbo_138

13 Mar 2024 08:41AM UTC coverage: 91.77% (-0.3%) from 92.078%
jorgen.edelbo_138

Pull #7356

Evergreen

jedelbo
Add ability to get path to modified collections in object notifications
Pull Request #7356: Add ability to get path to modified collections in object notifications

94532 of 174642 branches covered (54.13%)

118 of 163 new or added lines in 16 files covered. (72.39%)

765 existing lines in 41 files now uncovered.

242808 of 264584 relevant lines covered (91.77%)

5878961.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.81
/src/realm/table_ref.hpp
1
/*************************************************************************
2
 *
3
 * Copyright 2016 Realm Inc.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 **************************************************************************/
18

19
#ifndef REALM_TABLE_REF_HPP
20
#define REALM_TABLE_REF_HPP
21

22
#include <cstdint>
23
#include <cstddef>
24
#include <ostream>
25
namespace realm {
26

27

28
class Table;
29
class TableRef;
30

31
class ConstTableRef {
32
public:
33
    constexpr ConstTableRef() noexcept = default;
25,887,852✔
34
    constexpr ConstTableRef(std::nullptr_t) noexcept {}
12,915,984✔
35
    ConstTableRef(const TableRef& other) noexcept;
36

37
    const Table* operator->() const;
38
    const Table& operator*() const;
39
    operator bool() const noexcept;
40
    const Table* unchecked_ptr() const
41
    {
15,715,575✔
42
        return m_table;
15,715,575✔
43
    }
15,715,575✔
44

45
    bool operator==(const ConstTableRef& other) const
46
    {
16,156,167✔
47
        return m_table == other.m_table && m_instance_version == other.m_instance_version;
16,156,167✔
48
    }
16,156,167✔
49

50
    bool operator!=(const ConstTableRef& other) const
51
    {
11,989,926✔
52
        return !(*this == other);
11,989,926✔
53
    }
11,989,926✔
54

55
    bool operator<(const ConstTableRef& other) const
56
    {
×
57
        if (m_table == other.m_table)
×
58
            return m_instance_version < other.m_instance_version;
×
59
        else
×
60
            return m_table < other.m_table;
×
61
    }
×
62

63
    bool operator>(const ConstTableRef& other) const
64
    {
×
65
        if (m_table == other.m_table)
×
66
            return m_instance_version > other.m_instance_version;
×
67
        else
×
68
            return m_table > other.m_table;
×
69
    }
×
70

71
    std::ostream& print(std::ostream& o) const
72
    {
×
73
        return o << "TableRef(" << m_table << ", " << m_instance_version << ")";
×
74
    }
×
75
    TableRef cast_away_const() const;
76
    static ConstTableRef unsafe_create(const Table* t_ptr);
77
    void check() const;
78

79
protected:
80
    explicit ConstTableRef(const Table* t_ptr, uint64_t instance_version)
81
        : m_table(const_cast<Table*>(t_ptr))
82
        , m_instance_version(instance_version)
83
    {
113,337,840✔
84
    }
113,337,840✔
85
    friend class Group;
86
    friend class Table;
87
    friend class ClusterTree;
88

89
    Table* m_table = nullptr;
90
    uint64_t m_instance_version = 0;
91
};
92

93
class TableRef : public ConstTableRef {
94
public:
95
    constexpr TableRef() noexcept = default;
22,484,823✔
UNCOV
96
    constexpr TableRef(std::nullptr_t) noexcept {}
×
97

98
    Table* operator->() const;
99
    Table& operator*() const;
100
    Table* unchecked_ptr() const
101
    {
443,071,053✔
102
        return m_table;
443,071,053✔
103
    }
443,071,053✔
104
    static TableRef unsafe_create(Table* t_ptr);
105

106
private:
107
    explicit TableRef(Table* t_ptr, uint64_t instance_version)
108
        : ConstTableRef(t_ptr, instance_version)
109
    {
109,228,416✔
110
    }
109,228,416✔
111
    friend class Group;
112
    friend class Table;
113
    friend class ClusterTree;
114
    friend class ConstTableRef;
115
};
116

117

118
inline ConstTableRef::ConstTableRef(const TableRef& other) noexcept
119
    : m_table(other.m_table)
120
    , m_instance_version(other.m_instance_version)
121
{
10,453,443✔
122
}
10,453,443✔
123

124
inline TableRef ConstTableRef::cast_away_const() const
125
{
76,740,741✔
126
    return TableRef(m_table, m_instance_version);
76,740,741✔
127
}
76,740,741✔
128

129
inline std::ostream& operator<<(std::ostream& o, const ConstTableRef& tr)
130
{
×
131
    return tr.print(o);
×
132
}
×
133

134
} // namespace realm
135

136
#endif // REALM_TABLE_REF_HPP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc