Jump to content
  • Advertisement
Sign in to follow this  
FGFS

multimap

This topic is 2099 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi

how to change the function below to have it return ss. I want the user to be able to select later one value of ss. Something with push_back

but I'm confused.

Many thanks

 

void SDatabase::displayProcedure(const string &name)
{
          for (multimap<string, ProcedureList>::iterator it = m_procedure_map.begin() ; it != m_procedure_map.end(); ++it)
           {
               const char* msg = name.c_str();
               it->second = SDatabase::getProcedure(msg);
               for (ProcedureList::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
               {
               string str2 = (*it2)->toString().toStdString();
               const char* ss = str2.c_str();
               RenderText(font, 1, 1, 1, PanelLeft1 + 550, PanelTop1 - (360 + increm), ss);

...

Edited by FGFS

Share this post


Link to post
Share on other sites
Advertisement

I'm not entirely clear on what your question is. You appear to be asking how to modify the function to return a variable. That is pretty elementary, but yet you are using std::multipmap and already appear to have a custom function (SDatabase::getProcedure) which has a return value.

 

Can you clarify?

Share this post


Link to post
Share on other sites

Hello

 

typedef vector<Procedure*> ProcedureList;

 

----------

 

 

ProcedureList SDatabase::getProcedure(const std::string &id)
{
    ProcedureMapIterator i = m_procedure_map.find(id);
    if (i != m_procedure_map.end())
        return (*i).second;
    else {
        ProcedureList list;
        return list;
    }
};

 

 

yes getProcedure, does it return only the name? In the first post I only render the names (like ILS14, ILS34, Vor dme 12 etc.) which is ok. Now I want to store all the Procedure so that the user can later select one of those. ( for ex ILS14 ) and I use that complete procedure for forther utilization.

Many thanks

Edited by FGFS

Share this post


Link to post
Share on other sites

As I've said I want the return of getProcedure for further processing. ie the user can select one of those later.

 

extern vector<ProcedureList*>foundProcedures; ( or maybe rather: extern vector<Procedure*>foundProcedures; ?)

 

------

 

...
               it->second = SDatabase::getProcedure(msg);
               foundProcedures.push_back (it->second);

...

 

 

I get:

Multiple markers at this line
    - no matching function for call to
     ‘std::vector<std::vector<Procedure*>*>::push_back(std::vector<Procedure*>&)’
    - candidates are:
    - Invalid arguments ' Candidates are: void push_back(std::vector<Procedure *,std::allocator<Procedure *>> *
     const &) '

Thanks

Share this post


Link to post
Share on other sites

You need to add #include <vector> to fix the error message you're getting. "No matching function call" means the compiler cannot find the function body.

 

Your code could be improved to the following:

ProcedureList SDatabase::getProcedure(const std::string &id)
{
    ProcedureMapIterator i = m_procedure_map.find(id);
    if (i != m_procedure_map.end())
        return i->second;

   return ProcedureList();
};

If you have a variable pointing to your object, use the -> operator instead of (*i).

Share this post


Link to post
Share on other sites

Yes I've included vector. Now trying alike:

 

               for (ProcedureList::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
               {
               foundProcedures.push_back ((*it2));

...

 

I get:

 

 

Multiple markers at this line
    - Invalid arguments ' Candidates are: void push_back(std::vector<Procedure *,std::allocator<Procedure
     *>> * const &) '
    - no matching function for call to ‘std::vector<std::vector<Procedure*>*>::push_back(Procedure*&)’
    - candidates are:

Edited by FGFS

Share this post


Link to post
Share on other sites
Just as the error says, you are trying to push_back an 'std::vector<Procedure*>*' into a vector which is itself of type 'std::vector<Procedure*>'. Obviously a pointer to a vector of Procedure pointers cannot be converted into a Procedure pointer.

You might want to check out std::vector::insert but I'm still not sure what exactly you are trying to do and all of the types involved and whether they make sense. My gut feeling says you make something much more complex than it needs to be though.

Share this post


Link to post
Share on other sites

Can you please post some more code (everything that's relevant)? It's extremely hard and annoying to have to fix every single line you post here without an overview.

Share this post


Link to post
Share on other sites

I struggle with understanding this. I feel bad writing this because I may be guessing wrong, but as it gets into a habit I feel like I have to now. My gut is feeling like the OP got hired somewhere to maintain some closed source business app, does not understand much of the code, should ask his coworkers to explain the system, does not or they do not answer, so when he changes something and gets a compiler error he cannot fix immediately he just copys a few lines from the code and wants people on the net to do guesswork and his job.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!