-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set interface nested collections #6648
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -459,6 +459,15 @@ DictionaryPtr Lst<Mixed>::get_dictionary(const PathElement& path_elem) const | |
return ret; | ||
} | ||
|
||
SetMixedPtr Lst<Mixed>::get_set(const PathElement& path_elem) const | ||
{ | ||
auto weak = const_cast<Lst<Mixed>*>(this)->weak_from_this(); | ||
auto shared = weak.expired() ? std::make_shared<Lst<Mixed>>(*this) : weak.lock(); | ||
auto ret = std::make_shared<Set<Mixed>>(m_obj_mem, m_col_key); | ||
ret->set_owner(shared, m_tree->get_key(path_elem.get_ndx())); | ||
return ret; | ||
} | ||
|
||
std::shared_ptr<Lst<Mixed>> Lst<Mixed>::get_list(const PathElement& path_elem) const | ||
{ | ||
auto weak = const_cast<Lst<Mixed>*>(this)->weak_from_this(); | ||
|
@@ -619,6 +628,12 @@ void Lst<Mixed>::to_json(std::ostream& out, size_t link_depth, JSONOutputMode ou | |
Lst<Mixed> list(parent, i); | ||
list.to_json(out, link_depth, output_mode, fn); | ||
} | ||
else if (val.is_type(type_Set)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above |
||
auto parent = std::make_shared<DummyParent>(this->get_table(), val.get_ref()); | ||
Set<Mixed> set(m_obj_mem, m_col_key); | ||
set.set_owner(parent, i); | ||
set.to_json(out, link_depth, output_mode, fn); | ||
} | ||
else { | ||
val.to_json(out, output_mode); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1100,6 +1100,12 @@ void Obj::to_json(std::ostream& out, size_t link_depth, const std::map<std::stri | |
Dictionary dict(parent, 0); | ||
dict.to_json(out, link_depth, output_mode, print_link); | ||
} | ||
else if (val.is_type(type_Set)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again |
||
auto parent = std::make_shared<DummyParent>(this->get_table(), val.get_ref()); | ||
Set<Mixed> set(*this, ck); | ||
set.set_owner(parent, 0); | ||
set.to_json(out, link_depth, output_mode, print_link); | ||
} | ||
else if (val.is_type(type_List)) { | ||
DummyParent parent(m_table, val.get_ref()); | ||
Lst<Mixed> list(parent, 0); | ||
|
@@ -2050,6 +2056,9 @@ CollectionBasePtr Obj::get_collection_ptr(ColKey col_key) const | |
if (val.is_type(type_List)) { | ||
return std::make_shared<Lst<Mixed>>(*this, col_key); | ||
} | ||
else if (val.is_type(type_Set)) { | ||
return std::make_shared<Set<Mixed>>(*this, col_key); | ||
} | ||
REALM_ASSERT(val.is_type(type_Dictionary)); | ||
return std::make_shared<Dictionary>(*this, col_key); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use same constructs as above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not want to turn
Sets
into parent collections, that's why... but I guess if I don't expose the interface Sets can inherent fromParentCollection
and it should be fineThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it turns out that all I need is
CollectionParent::Index
.. I fixed the code.