[sword-devel] Multiple Feature entries from getConfigEntry().
David "Judah's Shadow" Blue
yudahsshadow at gmx.com
Mon May 20 14:37:07 EDT 2024
On Wednesday, May 15, 2024 9:01:14 AM EDT Troy A. Griffitts wrote:
> Hi David,
>
> Yeah, so a module's config is simply a multimap<SWBuf, SWBuf>. We
> extend multimap with our own class multimapwithdefault to make it nice
> to work with when there is only one entry so you can still simply say:
>
> SWBuf x = configEntries["mykey"];
>
> Just like a map works, but if there is more than one entry, for your key
> (which is allowed by multimap) the behavior is undefined. You'll get
> one of the entries, but not sure which one.
>
> So, for cases when you want to read multiple entries for a key, you'll
> have to use the standard multimap iterators, something like the following:
>
> ConfigEntMap::iterator begin =
> module->getConfig().lower_bound("Feature");
> ConfigEntMap::iterator end =
> module->getConfig().upper_bound("Feature");
> while (begin != end) {
> SWBuf featureValue = begin->second;
> ++begin;
> }
>
> Hope this helps,
It does, however, when I try this I get errors about no viable overloaded '='.
I've tried both declaring my ConfigEntMap::iterators before hand and assigning
them in the declaration, the errors differ slightly, but it all boils down to
the compiler not being able to decide if it should be an implicit copy or an
implicit move. I assume it should be a copy, but I'm not sure how to go about
specifying that in the code.
More information about the sword-devel
mailing list