mirror of
https://github.com/status-im/realm-js.git
synced 2025-02-05 11:13:48 +00:00
make list members private
This commit is contained in:
parent
c9ef337552
commit
ed193d8f5c
12
list.cpp
12
list.cpp
@ -22,29 +22,29 @@
|
||||
using namespace realm;
|
||||
|
||||
size_t List::size() {
|
||||
return link_view->size();
|
||||
return m_link_view->size();
|
||||
}
|
||||
|
||||
Row List::get(std::size_t row_ndx) {
|
||||
verify_valid_row(row_ndx);
|
||||
return link_view->get(row_ndx);
|
||||
return m_link_view->get(row_ndx);
|
||||
}
|
||||
|
||||
void List::set(std::size_t row_ndx, std::size_t target_row_ndx) {
|
||||
verify_valid_row(row_ndx);
|
||||
link_view->set(row_ndx, target_row_ndx);
|
||||
m_link_view->set(row_ndx, target_row_ndx);
|
||||
}
|
||||
|
||||
void List::verify_valid_row(std::size_t row_ndx) {
|
||||
size_t size = link_view->size();
|
||||
size_t size = m_link_view->size();
|
||||
if (row_ndx >= size) {
|
||||
throw std::out_of_range(std::string("Index ") + std::to_string(row_ndx) + " is outside of range 0..." + std::to_string(size) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
void List::verify_attached() {
|
||||
if (!link_view->is_attached()) {
|
||||
if (!m_link_view->is_attached()) {
|
||||
throw std::runtime_error("Tableview is not attached");
|
||||
}
|
||||
link_view->sync_if_needed();
|
||||
m_link_view->sync_if_needed();
|
||||
}
|
||||
|
18
list.hpp
18
list.hpp
@ -23,18 +23,24 @@
|
||||
#import <realm/link_view.hpp>
|
||||
|
||||
namespace realm {
|
||||
struct List {
|
||||
List(SharedRealm &r, ObjectSchema &s, LinkViewRef l) : realm(r), object_schema(s), link_view(l) {}
|
||||
// FIXME - all should be const
|
||||
SharedRealm realm;
|
||||
ObjectSchema &object_schema;
|
||||
LinkViewRef link_view;
|
||||
class List {
|
||||
public:
|
||||
List(SharedRealm &r, const ObjectSchema &s, LinkViewRef l) : m_realm(r), object_schema(s), m_link_view(l) {}
|
||||
|
||||
const ObjectSchema &object_schema;
|
||||
SharedRealm realm() { return m_realm; }
|
||||
LinkViewRef link_view() { return m_link_view; }
|
||||
|
||||
size_t size();
|
||||
Row get(std::size_t row_ndx);
|
||||
void set(std::size_t row_ndx, std::size_t target_row_ndx);
|
||||
|
||||
void verify_valid_row(std::size_t row_ndx);
|
||||
void verify_attached();
|
||||
|
||||
private:
|
||||
SharedRealm m_realm;
|
||||
LinkViewRef m_link_view;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace realm {
|
||||
|
||||
class Object {
|
||||
public:
|
||||
Object(SharedRealm &r, ObjectSchema &s, Row o) : m_realm(r), object_schema(s), m_row(o) {}
|
||||
Object(SharedRealm r, const ObjectSchema &s, Row o) : m_realm(r), object_schema(s), m_row(o) {}
|
||||
|
||||
// property getter/setter
|
||||
template<typename ValueType, typename ContextType>
|
||||
@ -85,7 +85,7 @@ namespace realm {
|
||||
// convert value to persisted object
|
||||
// for existing objects return the existing row index
|
||||
// for new/updated objects return the row index
|
||||
static size_t to_object_index(ContextType ctx, SharedRealm &realm, ValueType &val, const std::string &type, bool try_update);
|
||||
static size_t to_object_index(ContextType ctx, SharedRealm realm, ValueType &val, const std::string &type, bool try_update);
|
||||
static ValueType from_object(ContextType ctx, Object);
|
||||
|
||||
// list value acessors
|
||||
|
Loading…
x
Reference in New Issue
Block a user