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

realm / realm-core / github_pull_request_281750

30 Oct 2023 03:37PM UTC coverage: 90.528% (-1.0%) from 91.571%
github_pull_request_281750

Pull #6073

Evergreen

jedelbo
Log free space and history sizes when opening file
Pull Request #6073: Merge next-major

95488 of 175952 branches covered (0.0%)

8973 of 12277 new or added lines in 149 files covered. (73.09%)

622 existing lines in 51 files now uncovered.

233503 of 257934 relevant lines covered (90.53%)

6533720.56 hits per line

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

58.14
/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;
27,645,927✔
34
    constexpr ConstTableRef(std::nullptr_t) noexcept {}
12,794,931✔
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
    {
16,190,349✔
42
        return m_table;
16,190,349✔
43
    }
16,190,349✔
44

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

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

55
    bool operator<(const ConstTableRef& other) const
UNCOV
56
    {
×
UNCOV
57
        if (m_table == other.m_table)
×
UNCOV
58
            return m_instance_version < other.m_instance_version;
×
UNCOV
59
        else
×
UNCOV
60
            return m_table < other.m_table;
×
UNCOV
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
    {
118,620,792✔
84
    }
118,620,792✔
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;
9,341,541✔
96
    constexpr TableRef(std::nullptr_t) noexcept {}
14,551,473✔
97

98
    Table* operator->() const;
99
    Table& operator*() const;
100
    Table* unchecked_ptr() const
101
    {
369,915,543✔
102
        return m_table;
369,915,543✔
103
    }
369,915,543✔
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
    {
114,036,999✔
110
    }
114,036,999✔
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,519,518✔
122
}
10,519,518✔
123

124
inline TableRef ConstTableRef::cast_away_const() const
125
{
74,400,891✔
126
    return TableRef(m_table, m_instance_version);
74,400,891✔
127
}
74,400,891✔
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

© 2026 Coveralls, Inc