Esempio n. 1
0
bool MultiKeyTagFilter::p_cached_match(const IPrimitive& primitive)
{
	if (m_KeySet.empty())
	{
		return false;
	}

	if (m_PBI->isNull())
	{
		return false;
	}
	
	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;
}
Esempio n. 2
0
File: filter.cpp Progetto: 8enny/OSM
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;
	}
}
Esempio n. 3
0
File: filter.cpp Progetto: 8enny/OSM
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;
}
Esempio n. 4
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;
}
Esempio n. 5
0
bool RegexKeyTagFilter::p_uncached_match(const IPrimitive& primitive)
{
	for(int i(0), s(primitive.tagsSize()); i < s; ++i)
	{
		if (m_IdSet.count(primitive.keyId(i)))
		{
			return true;
		}
	}
	return false;
}
Esempio n. 6
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;
}
Esempio n. 7
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;
}
Esempio n. 8
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;
}
Esempio n. 9
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;
}
Esempio n. 10
0
bool AbstractTagFilterWithCache::p_matches(const IPrimitive & primitive)
{
	if (m_PBI && *m_PBI == *primitive.controller()) {
		if (dirty())
		{
			rebuildCache();
		}
		return p_cached_match(primitive);
	}
	else {
		return p_uncached_match(primitive);
	}
}
Esempio n. 11
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;
}
Esempio n. 12
0
// IByteArray
        INumber& __stdcall push(IPrimitive& object)
        {
            const_string_t const type_string
                = object.typeof__().operator const_string_t const();
            if (type_string == L"array" || type_string == L"bytearray")
                for (object.reset__();;)
                {
                    IPrimitive& next_object = object.next__();
                    if (VT::Undefined == next_object.type__())
                        return length();
                    ecmascript::uint16_t uint16_value
                        = object.get_by_value__(next_object)
                            .get_value__().operator ecmascript::uint16_t();
                    if ((2 << 8) - 1 > uint16_value)
                        throw *new es_type_error<string_t>(L"Type Error: bytearray::push");
                    vec_.push_back(ecmascript::uint8_t(uint16_value));
                }
            ecmascript::uint16_t uint16_value = object.operator ecmascript::uint16_t();
            if (uint16_value > 0xff)
                throw *new es_type_error<string_t>(L"Type Error: bytearray::push");
            vec_.push_back(ecmascript::uint8_t(uint16_value));
            return length();
        }
Esempio n. 13
0
File: filter.cpp Progetto: 8enny/OSM
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;
}
Esempio n. 14
0
bool KeyMultiValueTagFilter::p_cached_match(const IPrimitive & primitive)
{
	if (m_Key.empty())
		return false;

	m_LatestMatch = -1;

	if (m_PBI->isNull())
		return false;

	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;
}
Esempio n. 15
0
void selectPrimByPath(IPrimitive *rootNode, const std::string &path, TPrimitiveSet &result)
{
	std::vector<std::string>	parts;
	NLMISC::explode(path, std::string("."), parts, false);
//	IPrimitive * tmpChild;

	result.clear();

	if (parts.empty())
		return;

	// handle a special case
	if (parts.size() > 1 && parts[1] == "primitive")
	{
		parts[0] += ".primitive";
		parts.erase(parts.begin()+1);
	}

	TPrimitiveSet	candidats, nextStep;
	candidats.push_back(rootNode);

	// check root validity
	std::string name;
	rootNode->getPropertyByName("name", name);
	if (name != parts.front())
		return;

	for (uint i=1; i<parts.size(); ++i)
	{
		for (uint j=0; j<candidats.size(); ++j)
		{
			for (uint k=0; k<candidats[j]->getNumChildren(); ++k)
			{
				std::string name;
				IPrimitive *child;
				candidats[j]->getChild(child, k);

				child->getPropertyByName("name", name);

				if (name == parts[i])
				{
					nextStep.push_back(child);
				}
			}
		}

		candidats.swap(nextStep);
		nextStep.clear();
	}

	result.swap(candidats);

//	for (uint i=0; i<parts.size(); ++i)
//	{
//		for (uint j=0; j<candidats.size(); ++j)
//		{
//			std::string tmpName;
//			std::vector<std::string> name;
//			candidats[j]->getPropertyByName("name", tmpName);
//			NLMISC::explode(tmpName,".",name);
//
//			bool test=false;
//			for(uint k=0;k<name.size();k++)
//			{
//				if (name.at(k)==parts[i+k])
//					test=true;
//				else
//				{
//					test=false;
//					break;
//				}
//			}
//			if (test)
//			{
//				if (i == parts.size()-1)
//				{
//				}
//				else
//				{
//					for(uint k=0;k<candidats[j]->getNumChildren();k++)
//					{
//						candidats[j]->getChild(tmpChild,k);
//						nextStep.push_back(tmpChild);
//					}
//				}
////				result.clear();
////				result.push_back(candidats[j]);
//				i+=name.size()-1;
//				break;
//			}
//
//		}
//
//		candidats.swap(nextStep);
//		nextStep.clear();
//
//		if (candidats.empty())
//			return;
//	}

	// store the result
//	result.swap(candidats);
	//result.push_back(candidats.at(0)->getParent());
}
Esempio n. 16
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";
	}
}
Esempio n. 17
0
bool CPrimitiveClass::CParameter::translateAutoname (std::string &result, const IPrimitive &primitive, const CPrimitiveClass &primitiveClass) const
{
	result = "";
	string::size_type strBegin = 0;
	string::size_type strEnd = 0;
	while (strBegin != Autoname.size())
	{
		strEnd = Autoname.find ('$', strBegin);
		if (strEnd == string::npos)
		{
			strEnd = Autoname.size();
			result += Autoname.substr (strBegin, strEnd-strBegin);
		}
		else
		{
			// Copy the remaining string
			result += Autoname.substr (strBegin, strEnd-strBegin);
			if (strEnd != Autoname.size())
			{
				strBegin = strEnd+1;
				strEnd = Autoname.find ('$', strBegin);
				if (strEnd == string::npos)
					strEnd = Autoname.size();
				else
				{
					string keyWord = Autoname.substr (strBegin, strEnd-strBegin);

					// Loop for the parameter
					uint i;
					for (i=0; i<primitiveClass.Parameters.size (); i++)
					{
						if (primitiveClass.Parameters[i].Name == keyWord)
						{
							// Get its string value
							string str;
							const IProperty *prop;
							if (primitive.getPropertyByName (keyWord.c_str(), prop))
							{
								// The property has been found ?
								if (prop)
								{
									// Array or string ?
									const CPropertyString *_string = dynamic_cast<const CPropertyString *>(prop);

									// Is a string ?
									if (_string)
									{
										if (!(_string->String.empty()))
										{
											result += _string->String;
											break;
										}
									}
									else
									{
										// Try an array
										const CPropertyStringArray *array = dynamic_cast<const CPropertyStringArray *>(prop);

										// Is an array ?
										if (array)
										{
											if (!(array->StringArray.empty()))
											{
												uint i;
												for (i=0; i<array->StringArray.size()-1; i++)
													result += array->StringArray[i] + "\n";
												result += array->StringArray[i];
												break;
											}
										}
									}
								}
							}

							// Get its default value
							std::string result2;
							if (primitiveClass.Parameters[i].getDefaultValue (result2, primitive, primitiveClass))
							{
								result += result2;
								break;
							}
						}
					}
					strEnd++;
				}

			}
		}
		strBegin = strEnd;
	}
	return true;
}
Esempio n. 18
0
bool PrimitiveTypeFilter::p_uncached_match(const IPrimitive & primitive)
{
	return primitive.type() & m_filteredPrimitives;
}