[sword-devel] Multiple Feature entries from getConfigEntry().

David "Judah's Shadow" Blue yudahsshadow at gmx.com
Tue Jun 11 15:34:52 EDT 2024


On Monday, May 20, 2024 2:37:07 PM EDT David "Judah's Shadow" Blue wrote:
> 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.

I've still not managed to get any headway on getting this to compile. Here's 
my code:

If(this->mod->getConfigEntry("Feature") != NULL) {
    sword::ConfigEntMap::iterator begin;
    sword::ConfigEntMap::iterator end;

    begin = this->mod->getConfig().lower_bound("Feature");
    end = this->mod->getConfig().upper_bound("Feature");

    while(begin != end) {
        featureSet += "Feature: ";
        featureSet += begin->second;
        featureSet += "\n";
        ++begin;
    }
}

Where featureSet is a std::string.

And this is the output of the compiler.
[  6%] Building CXX object CMakeFiles/bibish.dir/src/front/info.cpp.o
~/Projects/bibish/src/front/info.cpp: In member function ‘std::string 
Info::getInfo()’:
~/Projects/bibish/src/front/info.cpp:63:61: error: no match for ‘operator=’ 
(operand types are ‘std::multimap<sword::SWBuf, sword::SWBuf, 
std::less<sword::SWBuf>, std::allocator<std::pair<const sword::SWBuf, 
sword::SWBuf> > >::iterator’ {aka ‘std::_Rb_tree<sword::SWBuf, std::pair<const 
sword::SWBuf, sword::SWBuf>, std::_Select1st<std::pair<const sword::SWBuf, 
sword::SWBuf> >, std::less<sword::SWBuf>, std::allocator<std::pair<const 
sword::SWBuf, sword::SWBuf> > >::iterator’} and ‘std::multimap<sword::SWBuf, 
sword::SWBuf, std::less<sword::SWBuf>, std::allocator<std::pair<const 
sword::SWBuf, sword::SWBuf> > >::const_iterator’ {aka 
‘std::_Rb_tree<sword::SWBuf, std::pair<const sword::SWBuf, sword::SWBuf>, 
std::_Select1st<std::pair<const sword::SWBuf, sword::SWBuf> >, 
std::less<sword::SWBuf>, std::allocator<std::pair<const sword::SWBuf, 
sword::SWBuf> > >::const_iterator’})
   63 |         begin = this->mod->getConfig().lower_bound("Feature");
      |                                                             ^
In file included from /usr/include/c++/13/map:62,
                 from /usr/include/sword/swmgr.h:60,
                 from ~/Projects/bibish/src/front/info.cpp:25:
/usr/include/c++/13/bits/stl_tree.h:256:12: note: candidate: 
‘std::_Rb_tree_iterator<std::pair<const sword::SWBuf, sword::SWBuf> >& 
std::_Rb_tree_iterator<std::pair<const sword::SWBuf, sword::SWBuf> 
>::operator=(const std::_Rb_tree_iterator<std::pair<const sword::SWBuf, 
sword::SWBuf> >&)’
  256 |     struct _Rb_tree_iterator
      |            ^~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_tree.h:256:12: note:   no known conversion for 
argument 1 from ‘std::multimap<sword::SWBuf, sword::SWBuf, 
std::less<sword::SWBuf>, std::allocator<std::pair<const sword::SWBuf, 
sword::SWBuf> > >::const_iterator’ {aka ‘std::_Rb_tree<sword::SWBuf, 
std::pair<const sword::SWBuf, sword::SWBuf>, std::_Select1st<std::pair<const 
sword::SWBuf, sword::SWBuf> >, std::less<sword::SWBuf>, 
std::allocator<std::pair<const sword::SWBuf, sword::SWBuf> > 
>::const_iterator’} to ‘const std::_Rb_tree_iterator<std::pair<const 
sword::SWBuf, sword::SWBuf> >&’
/usr/include/c++/13/bits/stl_tree.h:256:12: note: candidate: 
‘std::_Rb_tree_iterator<std::pair<const sword::SWBuf, sword::SWBuf> >& 
std::_Rb_tree_iterator<std::pair<const sword::SWBuf, sword::SWBuf> 
>::operator=(std::_Rb_tree_iterator<std::pair<const sword::SWBuf, 
sword::SWBuf> >&&)’
/usr/include/c++/13/bits/stl_tree.h:256:12: note:   no known conversion for 
argument 1 from ‘std::multimap<sword::SWBuf, sword::SWBuf, 
std::less<sword::SWBuf>, std::allocator<std::pair<const sword::SWBuf, 
sword::SWBuf> > >::const_iterator’ {aka ‘std::_Rb_tree<sword::SWBuf, 
std::pair<const sword::SWBuf, sword::SWBuf>, std::_Select1st<std::pair<const 
sword::SWBuf, sword::SWBuf> >, std::less<sword::SWBuf>, 
std::allocator<std::pair<const sword::SWBuf, sword::SWBuf> > 
>::const_iterator’} to ‘std::_Rb_tree_iterator<std::pair<const sword::SWBuf, 
sword::SWBuf> >&&’
~/Projects/bibish/src/front/info.cpp:64:59: error: no match for ‘operator=’ 
(operand types are ‘std::multimap<sword::SWBuf, sword::SWBuf, 
std::less<sword::SWBuf>, std::allocator<std::pair<const sword::SWBuf, 
sword::SWBuf> > >::iterator’ {aka ‘std::_Rb_tree<sword::SWBuf, std::pair<const 
sword::SWBuf, sword::SWBuf>, std::_Select1st<std::pair<const sword::SWBuf, 
sword::SWBuf> >, std::less<sword::SWBuf>, std::allocator<std::pair<const 
sword::SWBuf, sword::SWBuf> > >::iterator’} and ‘std::multimap<sword::SWBuf, 
sword::SWBuf, std::less<sword::SWBuf>, std::allocator<std::pair<const 
sword::SWBuf, sword::SWBuf> > >::const_iterator’ {aka 
‘std::_Rb_tree<sword::SWBuf, std::pair<const sword::SWBuf, sword::SWBuf>, 
std::_Select1st<std::pair<const sword::SWBuf, sword::SWBuf> >, 
std::less<sword::SWBuf>, std::allocator<std::pair<const sword::SWBuf, 
sword::SWBuf> > >::const_iterator’})
   64 |         end = this->mod->getConfig().upper_bound("Feature");
      |                                                           ^
/usr/include/c++/13/bits/stl_tree.h:256:12: note: candidate: 
‘std::_Rb_tree_iterator<std::pair<const sword::SWBuf, sword::SWBuf> >& 
std::_Rb_tree_iterator<std::pair<const sword::SWBuf, sword::SWBuf> 
>::operator=(const std::_Rb_tree_iterator<std::pair<const sword::SWBuf, 
sword::SWBuf> >&)’
  256 |     struct _Rb_tree_iterator
      |            ^~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_tree.h:256:12: note:   no known conversion for 
argument 1 from ‘std::multimap<sword::SWBuf, sword::SWBuf, 
std::less<sword::SWBuf>, std::allocator<std::pair<const sword::SWBuf, 
sword::SWBuf> > >::const_iterator’ {aka ‘std::_Rb_tree<sword::SWBuf, 
std::pair<const sword::SWBuf, sword::SWBuf>, std::_Select1st<std::pair<const 
sword::SWBuf, sword::SWBuf> >, std::less<sword::SWBuf>, 
std::allocator<std::pair<const sword::SWBuf, sword::SWBuf> > 
>::const_iterator’} to ‘const std::_Rb_tree_iterator<std::pair<const 
sword::SWBuf, sword::SWBuf> >&’
/usr/include/c++/13/bits/stl_tree.h:256:12: note: candidate: 
‘std::_Rb_tree_iterator<std::pair<const sword::SWBuf, sword::SWBuf> >& 
std::_Rb_tree_iterator<std::pair<const sword::SWBuf, sword::SWBuf> 
>::operator=(std::_Rb_tree_iterator<std::pair<const sword::SWBuf, 
sword::SWBuf> >&&)’
/usr/include/c++/13/bits/stl_tree.h:256:12: note:   no known conversion for 
argument 1 from ‘std::multimap<sword::SWBuf, sword::SWBuf, 
std::less<sword::SWBuf>, std::allocator<std::pair<const sword::SWBuf, 
sword::SWBuf> > >::const_iterator’ {aka ‘std::_Rb_tree<sword::SWBuf, 
std::pair<const sword::SWBuf, sword::SWBuf>, std::_Select1st<std::pair<const 
sword::SWBuf, sword::SWBuf> >, std::less<sword::SWBuf>, 
std::allocator<std::pair<const sword::SWBuf, sword::SWBuf> > 
>::const_iterator’} to ‘std::_Rb_tree_iterator<std::pair<const sword::SWBuf, 
sword::SWBuf> >&&’
make[2]: *** [CMakeFiles/bibish.dir/build.make:258: CMakeFiles/bibish.dir/src/
front/info.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/bibish.dir/all] Error 2
make: *** [Makefile:136: all] Error 2






More information about the sword-devel mailing list