FeatureType::SetMetadata() and SetNames().

This commit is contained in:
Alex Zolotarev 2015-12-09 12:18:20 +03:00 committed by Sergey Yershov
parent 8d84276ee2
commit 9dfa0e5e28
2 changed files with 28 additions and 0 deletions

View file

@ -151,6 +151,28 @@ void FeatureType::ParseMetadata() const
m_bMetadataParsed = true;
}
void FeatureType::SetNames(StringUtf8Multilang const & newNames)
{
m_params.name.Clear();
// Validate passed string to clean up empty names (if any).
newNames.ForEachRef([this](int8_t langCode, string const & name) -> bool
{
if (!name.empty())
m_params.name.AddString(langCode, name);
return true;
});
if (m_params.name.IsEmpty())
SetHeader(~feature::HEADER_HAS_NAME & Header());
else
SetHeader(feature::HEADER_HAS_NAME | Header());
}
void FeatureType::SetMetadata(feature::Metadata const & newMetadata)
{
m_bMetadataParsed = true;
m_metadata = newMetadata;
}
namespace
{

View file

@ -156,6 +156,12 @@ public:
inline void SetID(FeatureID const & id) { m_id = id; }
inline FeatureID GetID() const { return m_id; }
/// @name Editor functions.
//@{
void SetNames(StringUtf8Multilang const & newNames);
void SetMetadata(feature::Metadata const & newMetadata);
//@}
/// @name Parse functions. Do simple dispatching to m_pLoader.
//@{
void ParseHeader2() const;