Skip to content

Commit f35bcc4

Browse files
authored
Added C4Replicator::Parameters::removeCollection() (#2279)
1 parent a4efc9d commit f35bcc4

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

C/Cpp_include/c4Replicator.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ struct C4Replicator
9191
C4ReplicationCollection& addCollection(C4CollectionSpec const&, C4ReplicatorMode pushMode,
9292
C4ReplicatorMode pullMode);
9393

94+
bool removeCollection(C4CollectionSpec const&);
95+
9496
fleece::MutableDict copyOptions() const; ///< Returns copy of options (never null)
9597
void setOptions(fleece::Dict); ///< Updates options Dict
9698
void updateOptions(std::function<void(fleece::MutableDict)> const& callback);

Replicator/c4Replicator.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ C4ReplicationCollection& C4Replicator::Parameters::addCollection(C4ReplicationCo
202202
return copiedSpec;
203203
}
204204

205+
bool C4Replicator::Parameters::removeCollection(C4CollectionSpec const& spec) {
206+
for ( auto i = _collections.begin(); i != _collections.end(); ++i ) {
207+
if ( i->collection == spec ) {
208+
_collections.erase(i);
209+
this->C4ReplicatorParameters::collections = _collections.data();
210+
collectionCount = _collections.size();
211+
return true;
212+
}
213+
}
214+
return false;
215+
}
216+
205217
MutableDict C4Replicator::Parameters::copyOptions() const {
206218
if ( _options ) return Doc{_options}.asDict().mutableCopy();
207219
else

0 commit comments

Comments
 (0)