[editor] Trim name

This commit is contained in:
Ilya Zverev 2016-06-27 17:45:27 +03:00
parent 3238e11b7a
commit b2b1c5132a
4 changed files with 9 additions and 7 deletions

View file

@ -105,7 +105,7 @@ bool XMLFeature::operator==(XMLFeature const & other) const
vector<XMLFeature> XMLFeature::FromOSM(string const & osmXml)
{
pugi::xml_document doc;
if (doc.load_string(osmXml.c_str()).status != pugi::status_ok)
if (doc.load_string(osmXml.data()).status != pugi::status_ok)
MYTHROW(editor::InvalidXML, ("Not valid XML:", osmXml));
vector<XMLFeature> features;
@ -349,14 +349,15 @@ string XMLFeature::GetTagValue(string const & key) const
return tag.attribute("v").value();
}
void XMLFeature::SetTagValue(string const & key, string const & value)
void XMLFeature::SetTagValue(string const & key, string value)
{
strings::Trim(value);
auto tag = FindTag(m_document, key);
if (!tag)
{
tag = GetRootNode().append_child("tag");
tag.append_attribute("k").set_value(key.c_str());
tag.append_attribute("v").set_value(value.c_str());
tag.append_attribute("k").set_value(key.data());
tag.append_attribute("v").set_value(value.data());
}
else
{

View file

@ -155,7 +155,7 @@ public:
}
string GetTagValue(string const & key) const;
void SetTagValue(string const & key, string const & value);
void SetTagValue(string const & key, string value);
string GetAttribute(string const & key) const;
void SetAttribute(string const & key, string const & value);

View file

@ -61,8 +61,9 @@ void EditableMapObject::SetEditableProperties(osm::EditableProperties const & pr
void EditableMapObject::SetName(StringUtf8Multilang const & name) { m_name = name; }
void EditableMapObject::SetName(string const & name, int8_t langCode)
void EditableMapObject::SetName(string name, int8_t langCode)
{
strings::Trim(name);
if (!name.empty())
m_name.AddString(langCode, name);
}

View file

@ -74,7 +74,7 @@ public:
void SetEditableProperties(osm::EditableProperties const & props);
// void SetFeatureID(FeatureID const & fid);
void SetName(StringUtf8Multilang const & name);
void SetName(string const & name, int8_t langCode = StringUtf8Multilang::kDefaultCode);
void SetName(string name, int8_t langCode = StringUtf8Multilang::kDefaultCode);
void SetMercator(m2::PointD const & center);
void SetType(uint32_t featureType);
void SetID(FeatureID const & fid);