bool RegexKeyTagFilter::p_matches(const IPrimitive& primitive) { if (m_dirty || !m_PBI) { for(int i(0), s(primitive.tagsSize()); i < s; ++i) { if (std::regex_match(primitive.key(i), m_regex, m_matchFlags)) { return true; } } return false; } else { for(int i(0), s(primitive.tagsSize()); i < s; ++i) { if (m_IdSet.count(primitive.keyId(i))) { return true; } } return false; } }
bool KeyValueTagFilter::p_matches(const IPrimitive & primitive) { if (m_Key.empty()) return false; if (m_PBI) { if (m_PBI->isNull()) return false; checkKeyIdCache(); checkValueIdCache(); m_LatestMatch = findTag<IPrimitive>(primitive, m_KeyId, m_ValueId); return m_LatestMatch > -1; } m_LatestMatch = -1; for (int i = 0; i < primitive.tagsSize(); ++i) { if ((primitive.key(i) == m_Key) && primitive.value(i) == m_Value) { m_LatestMatch = i; return true; } } return false; }
bool RegexKeyTagFilter::p_cached_match(const IPrimitive& primitive) { for(int i(0), s(primitive.tagsSize()); i < s; ++i) { if (std::regex_match(primitive.key(i), m_regex, m_matchFlags)) { return true; } } return false; }
bool MultiKeyMultiValueTagFilter::p_matches(const IPrimitive& primitive) { for(int i(0), s(primitive.tagsSize()); i < s; ++i) { ValueMap::const_iterator it( m_ValueMap.find(primitive.key(i)) ); if ( it != m_ValueMap.end() && it->second.count(primitive.value(i)) ) { return true; } } return false; }
bool MultiKeyTagFilter::p_uncached_match(const IPrimitive& primitive) { if (m_KeySet.empty()) { return false; } for(int i(0), s(primitive.tagsSize()); i < s; ++i) { if (m_KeySet.count( primitive.key(i) )) { return true; } } return false; }
bool MultiKeyTagFilter::p_matches(const IPrimitive& primitive) { if (m_KeySet.empty()) { return false; } if (m_PBI) { if (m_PBI->isNull()) { return false; } if (m_KeyIdIsDirty) { rebuildCache(); } if (!m_IdSet.size()) { return false; } for(int i(0), s(primitive.tagsSize()); i < s; ++i) { if (m_IdSet.count( primitive.keyId(i) )) { return true; } } return false; } else { for(int i(0), s(primitive.tagsSize()); i < s; ++i) { if (m_KeySet.count( primitive.key(i) )) { return true; } } return false; } }
bool KeyMultiValueTagFilter::p_uncached_match(const IPrimitive & primitive) { if (m_Key.empty()) return false; m_LatestMatch = -1; for (int i = 0; i < primitive.tagsSize(); i++) { if (primitive.key(i) == m_Key && m_ValueSet.count(primitive.value(i))) { m_LatestMatch = -1; return true; } } return false; }
bool KeyValueTagFilter::p_uncached_match(const IPrimitive & primitive) { if (m_Key.empty()) return false; m_LatestMatch = -1; for (int i = 0; i < primitive.tagsSize(); ++i) { if ((primitive.key(i) == m_Key) && primitive.value(i) == m_Value) { m_LatestMatch = i; return true; } } return false; }
bool KeyMultiValueTagFilter::p_matches(const IPrimitive & primitive) { if (m_Key.empty()) return false; m_LatestMatch = -1; if (m_PBI) { if (m_PBI->isNull()) return false; checkKeyIdCache(); if (!m_KeyId || m_IdSet.empty()) return false; for (int i = 0; i < primitive.tagsSize(); i++) { if (primitive.keyId(i) == m_KeyId && m_IdSet.count(primitive.valueId(i))) { m_LatestMatch = -1; return true; } } return false; } else { for (int i = 0; i < primitive.tagsSize(); i++) { if (primitive.key(i) == m_Key && m_ValueSet.count(primitive.value(i))) { m_LatestMatch = -1; return true; } } return false; } }
bool IntTagFilter::p_uncached_match(const IPrimitive & primitive) { if (m_Key.empty()) return false; m_LatestMatch = -1; for (int i = 0; i < primitive.tagsSize(); ++i) { if (primitive.key(i) == m_Key) { char * endptr; auto intTagValue = strtol(primitive.value(i).c_str(), &endptr, 10); if ((*endptr == '\0') && (intTagValue == m_Value)) { m_LatestMatch = i; return true; } } } return false; }
bool IntTagFilter::p_matches(const IPrimitive & primitive) { if (m_Key.empty()) return false; if (m_PBI) { if (m_PBI->isNull()) return false; checkKeyIdCache(); checkValueIdCache(); m_LatestMatch = findTag<IPrimitive>(primitive, m_KeyId, m_ValueId); return m_LatestMatch > -1; } m_LatestMatch = -1; for (int i = 0; i < primitive.tagsSize(); ++i) { if (primitive.key(i) == m_Key) { char * endptr; int intTagValue = strtol(primitive.value(i).c_str(), &endptr, 10); if ((*endptr == '\0') && (intTagValue == m_Value)) { m_LatestMatch = i; return true; } } } return false; }
void printTags(std::ostream & out, const IPrimitive & prim, const std::string & prefix) { for(uint32_t i = 0, s = prim.tagsSize(); i < s; ++i) { out << prefix << "<tag k=" << prim.key(i) << " v=" << prim.value(i) << ">\n"; } }