Skip to content

Commit

Permalink
libcore|Record: Utility for removing members
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Dec 21, 2019
1 parent 977df19 commit b543937
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doomsday/sdk/libcore/include/de/data/record.h
Expand Up @@ -246,6 +246,12 @@ class DENG2_PUBLIC Record

Variable *tryRemove(String const &variableName);

/**
* Removes all members whose name begins with @a prefix.
* @param prefix Prefix string.
*/
void removeMembersWithPrefix(const String &prefix);

/**
* Adds a new variable to the record with a NoneValue. If there is an existing
* variable with the given name, the old variable is deleted first.
Expand Down
11 changes: 11 additions & 0 deletions doomsday/sdk/libcore/src/data/record.cpp
Expand Up @@ -566,6 +566,17 @@ Variable *Record::tryRemove(String const &variableName)
return nullptr;
}

void Record::removeMembersWithPrefix(const String &prefix)
{
for (const String &name : members().keys())
{
if (name.beginsWith(prefix))
{
remove(name);
}
}
}

Variable &Record::add(String const &name, Variable::Flags variableFlags)
{
return d->parentRecordByPath(name)
Expand Down

0 comments on commit b543937

Please sign in to comment.