Пример #1
0
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;
	}
}
Пример #2
0
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;
}
Пример #3
0
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;
}
Пример #4
0
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;
}
Пример #5
0
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;
}
Пример #6
0
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;
	}
}
Пример #7
0
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;
}
Пример #8
0
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;
}
Пример #9
0
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;
	}
}
Пример #10
0
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;
}
Пример #11
0
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;
}
Пример #12
0
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";
	}
}