Skip to content

Commit

Permalink
Sanitize pdal::Metadata key names to remove some special characters #475
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Sep 19, 2014
1 parent c6d987c commit 49ee61c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
5 changes: 2 additions & 3 deletions include/pdal/Metadata.hpp
Expand Up @@ -68,9 +68,8 @@ class MetadataNodeImpl
friend class MetadataNode;

private:
MetadataNodeImpl(const std::string& name) :
m_name(name), m_kind(MetadataType::Instance)
{}
MetadataNodeImpl(const std::string& name);


MetadataNodeImpl() : m_kind(MetadataType::Instance)
{}
Expand Down
20 changes: 20 additions & 0 deletions src/Metadata.cpp
Expand Up @@ -40,10 +40,30 @@
#include <map>

#include <boost/property_tree/xml_parser.hpp>
#include <boost/algorithm/string.hpp>

std::string sanitize(const std::string& name)
{
std::vector<std::string> to_replace = {";", ":", " ", "'", "\""};

std::string v(name);
for (auto c: to_replace)
{
v = boost::algorithm::replace_all_copy(v, c, "_");
}
return v;

}

namespace pdal
{

MetadataNodeImpl::MetadataNodeImpl(const std::string& name)
{
m_kind = MetadataType::Instance;
m_name = sanitize(name);
}

std::string MetadataNodeImpl::toJSON() const
{
std::ostringstream o;
Expand Down

0 comments on commit 49ee61c

Please sign in to comment.