Skip to content

Commit

Permalink
Add Resource::removeItem() method
Browse files Browse the repository at this point in the history
  • Loading branch information
manup committed Mar 10, 2018
1 parent cbf571d commit 1ca248a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,24 @@ ResourceItem *Resource::addItem(ApiDataType type, const char *suffix)
return it;
}

void Resource::removeItem(const char *suffix)
{
std::vector<ResourceItem>::iterator i = m_rItems.begin();
std::vector<ResourceItem>::iterator end = m_rItems.end();

for (; i != end; ++i)
{
if (i->descriptor().suffix != suffix)
{
continue;
}

*i = m_rItems.back();
m_rItems.pop_back();
return;
}
}

ResourceItem *Resource::item(const char *suffix)
{
for (size_t i = 0; i < m_rItems.size(); i++)
Expand Down
1 change: 1 addition & 0 deletions resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class Resource
Resource(const char *prefix);
const char *prefix() const;
ResourceItem *addItem(ApiDataType type, const char *suffix);
void removeItem(const char *suffix);
ResourceItem *item(const char *suffix);
const ResourceItem *item(const char *suffix) const;
bool toBool(const char *suffix) const;
Expand Down

0 comments on commit 1ca248a

Please sign in to comment.