Delete a helper function that's now exposed directly by sync
This commit is contained in:
parent
e93ff333ed
commit
d89c7ea24f
|
@ -1002,36 +1002,6 @@ void RealmClass<T>::compact(ContextType ctx, ObjectType this_object, Arguments a
|
|||
return_value.set(realm->compact());
|
||||
}
|
||||
|
||||
#if REALM_ENABLE_SYNC
|
||||
namespace {
|
||||
|
||||
// FIXME: Sync should provide this: https://github.com/realm/realm-sync/issues/1796
|
||||
inline sync::ObjectID object_id_from_string(std::string const& string)
|
||||
{
|
||||
if (string.front() != '{' || string.back() != '}')
|
||||
throw std::invalid_argument("Invalid object ID.");
|
||||
|
||||
size_t dash_index = string.find('-');
|
||||
if (dash_index == std::string::npos)
|
||||
throw std::invalid_argument("Invalid object ID.");
|
||||
|
||||
std::string high_string = string.substr(1, dash_index - 1);
|
||||
std::string low_string = string.substr(dash_index + 1, string.size() - dash_index - 2);
|
||||
|
||||
if (high_string.size() == 0 || high_string.size() > 16 || low_string.size() == 0 || low_string.size() > 16)
|
||||
throw std::invalid_argument("Invalid object ID.");
|
||||
|
||||
auto isxdigit = static_cast<int(*)(int)>(std::isxdigit);
|
||||
if (!std::all_of(high_string.begin(), high_string.end(), isxdigit) ||
|
||||
!std::all_of(low_string.begin(), low_string.end(), isxdigit)) {
|
||||
throw std::invalid_argument("Invalid object ID.");
|
||||
}
|
||||
return sync::ObjectID(strtoull(high_string.c_str(), nullptr, 16), strtoull(low_string.c_str(), nullptr, 16));
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
#endif // REALM_ENABLE_SYNC
|
||||
|
||||
template<typename T>
|
||||
void RealmClass<T>::object_for_object_id(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue& return_value) {
|
||||
args.validate_count(2);
|
||||
|
@ -1045,7 +1015,7 @@ void RealmClass<T>::object_for_object_id(ContextType ctx, ObjectType this_object
|
|||
validated_object_schema_for_value(ctx, realm, args[0], object_type);
|
||||
|
||||
std::string object_id_string = Value::validated_to_string(ctx, args[1]);
|
||||
auto object_id = object_id_from_string(object_id_string);
|
||||
auto object_id = sync::ObjectID::from_string(object_id_string);
|
||||
|
||||
const Group& group = realm->read_group();
|
||||
size_t ndx = sync::row_for_object_id(group, *ObjectStore::table_for_object_type(group, object_type), object_id);
|
||||
|
|
Loading…
Reference in New Issue