Skip to content

Commit

Permalink
Add convinience data retrieval method to QXmppBitsOfBinaryDataList
Browse files Browse the repository at this point in the history
  • Loading branch information
jbruechert committed Sep 27, 2022
1 parent f762f73 commit b55d006
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/base/QXmppBitsOfBinaryData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,24 @@ QXmppBitsOfBinaryDataList::QXmppBitsOfBinaryDataList() = default;
QXmppBitsOfBinaryDataList::~QXmppBitsOfBinaryDataList() = default;

/// \cond

///
/// \brief finds the data for a uri
/// \param uri cid uri
/// \return data belonging to the uri
///
/// \since QXmpp 1.5
///
const QXmppBitsOfBinaryData &QXmppBitsOfBinaryDataList::forCidUri(const QString &uri) const
{
auto cid = QXmppBitsOfBinaryContentId::fromCidUrl(uri);
const auto thumbnailData = std::find_if(begin(), end(), [&](const auto &bobBlob) {
return bobBlob.cid() == cid;
});

return *thumbnailData;
}

void QXmppBitsOfBinaryDataList::parse(const QDomElement &element)
{
// clear previous data elements
Expand Down
3 changes: 3 additions & 0 deletions src/base/QXmppBitsOfBinaryDataList.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@

class QDomElement;
class QXmlStreamWriter;
class QUrl;

class QXMPP_EXPORT QXmppBitsOfBinaryDataList : public QVector<QXmppBitsOfBinaryData>
{
public:
QXmppBitsOfBinaryDataList();
~QXmppBitsOfBinaryDataList();

const QXmppBitsOfBinaryData &forCidUri(const QString &uri) const;

/// \cond
void parse(const QDomElement &element);
void toXml(QXmlStreamWriter *writer) const;
Expand Down

0 comments on commit b55d006

Please sign in to comment.