[sword-devel] Behavior of SWModule::getConfigEntry in case of multiple entries with same key

Troy A. Griffitts scribe at crosswire.org
Sun May 5 06:41:54 MST 2019


While Peter is correct about how to find all the options that any loaded module might allow for toggling by an end user... and if this is your purpose, you should certainly use the methods Peter suggested... your question as to more generally how to read config entries which have the same key values is answered by how to iterate a multimap in C++. SWModule::getConfig returns the full multimap of config entries. Something like this should work:

ConfigEntMap::const_iterator begin = module->getConfig().lower_bound("Key");
ConfigEntMap::const_iterator end = module->getConfig().upper_bound("Key");

for(; begin !=end; ++begin)  {
  cout << begin->first.c_str() << " = " << begin->second.c_str() << endl;
}

But I've never needed to do this as a client of the library. Maybe if you tell us your use case, we can recommend a facility in the system which might make things easier for you.

Troy

On May 5, 2019 2:04:11 AM MST, Peter von Kaehne <refdoc at gmx.net> wrote:
>On Sun, 2019-05-05 at 08:49 +0200, Tobias Klein wrote:
>> Hi,
>> how is SWModule::getConfigEntry(const char *key) supposed to behave
>> when there are multiple entries with the same key?
>
>There is a set of separate methods for those.
>
>Check out ./examples/cmdline/listoptions.cpp
>
>> {
>>         SWMgr library;
>>
>>         StringList options = library.getGlobalOptions();
>>         for (StringList::const_iterator it = options.begin(); it !=
>> options.end(); ++it) {
>>                 cout << *it << " (" <<
>> library.getGlobalOptionTip(*it) << ")\n";
>>                 StringList optionValues =
>> library.getGlobalOptionValues(*it);
>>                 for (StringList::const_iterator it2 =
>> optionValues.begin(); it2 != optionValues.end(); ++it2) {
>>                         cout << "\t" << *it2 << "\n";
>>                 }
>>         }
>>
>
>
>_______________________________________________
>sword-devel mailing list: sword-devel at crosswire.org
>http://www.crosswire.org/mailman/listinfo/sword-devel
>Instructions to unsubscribe/change your settings at above page

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/sword-devel/attachments/20190505/aa65d5e3/attachment.html>


More information about the sword-devel mailing list