[generator] Skip empty address data for search additional information.

This commit is contained in:
vng 2015-12-11 17:07:34 +03:00 committed by Sergey Yershov
parent 4b893fbe6a
commit aca026daca
2 changed files with 21 additions and 16 deletions

View file

@ -200,7 +200,6 @@ bool FeatureParams::AddHouseName(string const & s)
return false;
}
bool FeatureParams::AddHouseNumber(string const & ss)
{
if (!feature::IsHouseNumber(ss))

View file

@ -14,6 +14,24 @@ namespace feature
{
class MetadataBase
{
protected:
void Set(uint8_t type, string const & value)
{
auto found = m_metadata.find(type);
if (found == m_metadata.end())
{
if (!value.empty())
m_metadata[type] = value;
}
else
{
if (value.empty())
m_metadata.erase(found);
else
found->second = value;
}
}
public:
string Get(uint8_t type) const
{
@ -97,22 +115,10 @@ namespace feature
void Set(EType type, string const & value)
{
auto found = m_metadata.find(type);
if (found == m_metadata.end())
{
if (!value.empty())
m_metadata[type] = value;
}
else
{
if (value.empty())
m_metadata.erase(found);
else
found->second = value;
}
MetadataBase::Set(type, value);
}
void Drop(EType type) { Set(type, ""); }
void Drop(EType type) { Set(type, string()); }
string GetWikiURL() const;
@ -153,7 +159,7 @@ namespace feature
void Add(Type type, string const & s)
{
/// @todo Probably, we need to add separator here and store multiple values.
m_metadata[type] = s;
MetadataBase::Set(type, s);
}
};
}