uint32_t add(const char* s) { auto f = m_index.find(s); if (f != m_index.end()) { return uint32_t(f->second); } const char* cs = m_strings.add(s); m_index[cs] = ++m_size; if (m_size > max_entries) { throw osmium::pbf_error("string table has too many entries"); } return m_size; }
void update(const char* value, const Osmium::OSM::Object& object, StringStore& string_store) { key.count[object.type()]++; value_hash_map_t::iterator values_iterator(values_hash.find(value)); if (values_iterator == values_hash.end()) { Counter counter; counter.count[object.type()] = 1; values_hash.insert(std::pair<const char*, Counter>(string_store.add(value), counter)); values.count[object.type()]++; } else { values_iterator->second.count[object.type()]++; if (values_iterator->second.count[object.type()] == 1) { values.count[object.type()]++; } } user_hash[object.uid()]++; }
void clear() { m_strings.clear(); m_index.clear(); m_size = 0; m_strings.add(""); }
explicit StringTable(size_t size = default_stringtable_chunk_size) : m_strings(size), m_index(), m_size(0) { m_strings.add(""); }