Skip to content

Commit

Permalink
add method to fetch the number of keys that exist for a given namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Mar 29, 2012
1 parent 49d5d5d commit 3a1f122
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/pdal/Metadata.hpp
Expand Up @@ -508,7 +508,11 @@ class PDAL_DLL Metadata
metadata::Entry const& getMetadata(std::size_t index) const;

/// @return the number of metadata::Entry entries in the map
inline metadata::EntryMap::size_type getMetadataCount() const { return m_metadata.get<metadata::index>().size(); }
inline metadata::EntryMap::size_type size() const { return m_metadata.get<metadata::index>().size(); }

/// @return the number of metadata::Entry entries in the map
/// for a given namespace
metadata::EntryMap::size_type size(std::string const& ns) const;

std::vector<metadata::Entry> getEntriesForNamespace(std::string const& ns) const;

Expand Down
19 changes: 19 additions & 0 deletions src/Metadata.cpp
Expand Up @@ -436,6 +436,25 @@ std::vector<metadata::Entry> Metadata::getEntriesForNamespace(std::string const&
return output;
}

metadata::EntryMap::size_type Metadata::size(std::string const& ns) const
{

std::vector<metadata::Entry> output;

metadata::index_by_namespace const& idx = m_metadata.get<metadata::ns>();
metadata::index_by_namespace::iterator it = idx.find(ns);
metadata::index_by_namespace::size_type i(0);

while (it != idx.end())
{
++i;
++it;
}

return i;
}


boost::property_tree::ptree Metadata::toPTree() const
{
boost::property_tree::ptree tree;
Expand Down

0 comments on commit 3a1f122

Please sign in to comment.