added bool completeMatch to MessageMap::findAll
This commit is contained in:
@@ -421,7 +421,7 @@ Message* MessageMap::find(const string& clazz, const string& name, const bool is
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
deque<Message*> MessageMap::findAll(const string& clazz, const string& name, const short pb)
|
deque<Message*> MessageMap::findAll(const string& clazz, const string& name, const short pb, const bool completeMatch)
|
||||||
{
|
{
|
||||||
deque<Message*> ret;
|
deque<Message*> ret;
|
||||||
|
|
||||||
@@ -432,10 +432,16 @@ deque<Message*> MessageMap::findAll(const string& clazz, const string& name, con
|
|||||||
if (it->first[0] == '-') // avoid duplicates: instances stored multiple times have a key starting with "-"
|
if (it->first[0] == '-') // avoid duplicates: instances stored multiple times have a key starting with "-"
|
||||||
continue;
|
continue;
|
||||||
Message* message = it->second;
|
Message* message = it->second;
|
||||||
if (checkClass == true && message->getClass() != clazz)
|
if (checkClass == true) {
|
||||||
continue;
|
string check = message->getClass();
|
||||||
if (checkName == true && message->getName() != name)
|
if (completeMatch ? (check != clazz) : (check.find(clazz) == check.npos))
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
if (checkName == true) {
|
||||||
|
string check = message->getName();
|
||||||
|
if (completeMatch ? (check != name) : (check.find(name) == check.npos))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (checkPb == true && message->getId()[0] != pb)
|
if (checkPb == true && message->getId()[0] != pb)
|
||||||
continue;
|
continue;
|
||||||
ret.push_back(message);
|
ret.push_back(message);
|
||||||
|
|||||||
@@ -326,10 +326,11 @@ public:
|
|||||||
* @param clazz the device class, or empty for any.
|
* @param clazz the device class, or empty for any.
|
||||||
* @param name the message name, or empty for any.
|
* @param name the message name, or empty for any.
|
||||||
* @param pb the primary ID byte, or -1 for any.
|
* @param pb the primary ID byte, or -1 for any.
|
||||||
|
* @param completeMatch false to also include messages where the class and name matches only a part of the given class and name.
|
||||||
* @return the found @a Message instances.
|
* @return the found @a Message instances.
|
||||||
* Note: the caller may not free the returned instances.
|
* Note: the caller may not free the returned instances.
|
||||||
*/
|
*/
|
||||||
deque<Message*> findAll(const string& clazz, const string& name, const short pb);
|
deque<Message*> findAll(const string& clazz, const string& name, const short pb, const bool completeMatch=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Find the @a Message instance for the specified master data.
|
* @brief Find the @a Message instance for the specified master data.
|
||||||
|
|||||||
Reference in New Issue
Block a user