[sword-devel] Behavior of SWModule::getConfigEntry in case of multiple entries with same key
Tobias Klein
contact at tklein.info
Sun May 5 07:56:06 MST 2019
Hi Troy, Peter,
Thank you! My usecase is to list the options available for one
particular (bible translation) module.
@Troy: The solution you suggested is probably what I need. Or are there
better solutions based on my usecase mentioned above?
Best regards,
Tobias
On 05.05.19 15:41, Troy A. Griffitts wrote:
> 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:Hi
>
> 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.
>
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/sword-devel/attachments/20190505/6f7a7c3a/attachment-0001.html>
More information about the sword-devel
mailing list