11#ifndef CLP_DICTIONARYREADER_HPP
22#define CLP_DICTIONARYREADER_HPP
33
4+ #include < iterator>
45#include < string>
6+ #include < string_view>
7+ #include < utility>
58#include < vector>
69
710#include < boost/algorithm/string.hpp>
@@ -34,6 +37,9 @@ class DictionaryReader {
3437 char const * what () const noexcept override { return " DictionaryReader operation failed" ; }
3538 };
3639
40+ using dictionary_id_t = DictionaryIdType;
41+ using entry_t = EntryType;
42+
3743 // Constructors
3844 DictionaryReader () : m_is_open(false ), m_num_segments_read_from_index(0 ) {
3945 static_assert (
@@ -85,15 +91,15 @@ class DictionaryReader {
8591 * @return a vector of matching entries, or an empty vector if no entry matches.
8692 */
8793 std::vector<EntryType const *>
88- get_entry_matching_value (std::string const & search_string, bool ignore_case) const ;
94+ get_entry_matching_value (std::string_view search_string, bool ignore_case) const ;
8995 /* *
9096 * Gets the entries that match a given wildcard string
9197 * @param wildcard_string
9298 * @param ignore_case
9399 * @param entries Set in which to store found entries
94100 */
95101 void get_entries_matching_wildcard_string (
96- std::string const & wildcard_string,
102+ std::string_view wildcard_string,
97103 bool ignore_case,
98104 std::unordered_set<EntryType const *>& entries
99105 ) const ;
@@ -235,7 +241,7 @@ DictionaryReader<DictionaryIdType, EntryType>::get_value(DictionaryIdType id) co
235241template <typename DictionaryIdType, typename EntryType>
236242std::vector<EntryType const *>
237243DictionaryReader<DictionaryIdType, EntryType>::get_entry_matching_value(
238- std::string const & search_string,
244+ std::string_view search_string,
239245 bool ignore_case
240246) const {
241247 if (false == ignore_case) {
@@ -252,7 +258,11 @@ DictionaryReader<DictionaryIdType, EntryType>::get_entry_matching_value(
252258 }
253259
254260 std::vector<EntryType const *> entries;
255- auto const search_string_uppercase = boost::algorithm::to_upper_copy (search_string);
261+ std::string search_string_uppercase;
262+ std::ignore = boost::algorithm::to_upper_copy (
263+ std::back_inserter (search_string_uppercase),
264+ search_string
265+ );
256266 for (auto const & entry : m_entries) {
257267 if (boost::algorithm::to_upper_copy (entry.get_value ()) == search_string_uppercase) {
258268 entries.push_back (&entry);
@@ -263,7 +273,7 @@ DictionaryReader<DictionaryIdType, EntryType>::get_entry_matching_value(
263273
264274template <typename DictionaryIdType, typename EntryType>
265275void DictionaryReader<DictionaryIdType, EntryType>::get_entries_matching_wildcard_string(
266- std::string const & wildcard_string,
276+ std::string_view wildcard_string,
267277 bool ignore_case,
268278 std::unordered_set<EntryType const *>& entries
269279) const {
0 commit comments