Sign in to follow this  
FGFS

arguments

Recommended Posts

FGFS    345

Hi

what arguments does it want?

 

    - invalid use of ‘std::vector<Procedure*>::value_type’
    - Invalid arguments ' Candidates are: unsigned long int count(const std::basic_string<char,std::char_traits<char>,std::allocator<char>>

 

What are char_traits, allocator etc.

Thanks

 

 

Share this post


Link to post
Share on other sites
FGFS    345

it's huge...

and what is the "?"

IFSDatabase::getAppr(&it);

 

nvalid arguments ' Candidates are: std::vector<Procedure *,std::allocator<Procedure *>> getAppr(const ? &) '

 

the declaration is:

 

    virtual ProcedureList getAppr(const QString &id);

 

and the class:

 

class Procedure : public Route
{
public:

    Procedure();

    Procedure(const QString& id,
              const QStringList& runway_list);

    virtual ~Procedure() {};

    virtual const Procedure* asProcedure() const { return this; }
    virtual Procedure* asProcedure() { return this; }

    virtual QString toString() const;

    /////////////////////////////////////////////////////////////////////////////

    const QStringList& runwayList() const {  return m_runway_list; }
    void setRunwayList(const QStringList& runway_list) { m_runway_list = runway_list; }

protected:

    QStringList m_runway_list;
};

/////////////////////////////////////////////////////////////////////////////

typedef vector<Procedure*> ProcedureList;
typedef PtrList<Procedure> ProcedurePtrList;
typedef QListIterator<Procedure*> ProcedurePtrListIterator;

 

 

and

 

class IFSDatabase
{
public:

    IFSDatabase();
    virtual ~IFSDatabase() {};
    virtual void load();
...
    virtual ProcedureList getAppr(const QString &id);

...

Edited by FGFS

Share this post


Link to post
Share on other sites
FGFS    345

   for (std::multimap<string, ProcedureList>::iterator it=m_procedure_map.begin(); it!=m_procedure_map.end(); ++it)
   {
       const char* msga = IFSDatabase::getAppr(&it);

Share this post


Link to post
Share on other sites
Wooh    1088
You have got all the types wrong. You have declared getAppr to take a QString as argument but you try to pass it a pointer to an iterator, and then you try to store the return value as a char pointer when the function actually returns a vector.

I don't see how you expected this to work. Did you maybe call the wrong function?

Share this post


Link to post
Share on other sites
FGFS    345

Yes, so how to pass a QString and store the return value? Basically I want first to see the value, hence I tried char*.

Thanks

Share this post


Link to post
Share on other sites
Wooh    1088
So I guess you want to pass the map key to the function. I have never used Qt but from the documentation it seems that std::string will not be converted to a QString implicitly so you probably have to use the fromStdString function.

The value type of the map is the same as the return type of the function so I guess you want to assign the returned value to that vector in the map.

.. so I guess it would look something like this:
it->second = IFSDatabase::getAppr(QString::fromStdString(it->first));

Share this post


Link to post
Share on other sites
FGFS    345

Thanks

  with:

const char* msga = IFSDatabase::getAppr(QString::fromStdString(it->first));

I get:

    - cannot convert ‘ProcedureList {aka std::vector<Procedure*>}’ to ‘const char*’ in initialization

 

sure but how to view the values. Also with std::cout << I get errors.

 

but with second:

 

       IFSDatabase::getAppr(QString::fromStdString(it->second));

 

i get:

Multiple markers at this line
    - Function 'fromStdString' could not be resolved
    - Invalid arguments ' Candidates are: std::vector<Procedure *,std::allocator<Procedure *>> getAppr(const ?
     &) '
    - no matching function for call to ‘QString::fromStdString(std::vector<Procedure*>&)’
    - candidate is:

Edited by FGFS

Share this post


Link to post
Share on other sites
FGFS    345

seems so. With:

std::cout << it->second = IFSDatabase::getAppr(QString::fromStdString(it->first));

 

I get:

 

..IFSDatabase.cpp:577:22: error: no match for ‘operator<<’ in ‘std::cout << it.std::_Rb_tree_iterator<_Tp>::operator-><std::pair<const std::basic_string<char>, std::vector<Procedure*> > >()->std::pair<const std::basic_string<char>, std::vector<Procedure*> >::second’

Share this post


Link to post
Share on other sites
Wooh    1088
it->second is a std::vector<Procedure*> (aka ProcedureList). If you have not overloaded operator<< for that type you will have to loop the vector and print each Procedure object manually.

Something like this:
for (ProcedureList::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
{
	std::cout << (*it2)->toString() << std::endl;
}
If the pointers can be null you'll have to check that too.

Share this post


Link to post
Share on other sites
FGFS    345

Thanks but with that I get:

 

SDatabase.cpp:580:36: error: no match for ‘operator<<’ in ‘std::cout << Procedure::toString()’

Share this post


Link to post
Share on other sites
Wooh    1088
std::cout << (*it2)->toString().toStdString() << std::endl;

Not sure if it's the best way to do it but I think it will should work.

Share this post


Link to post
Share on other sites
FGFS    345

That works but I forgot that I cannot use cout but need a char*

char* ss = (*it2)->toString().toStdString();

 

tabase.cpp:580:48: error: cannot convert ‘std::string {aka std::basic_string<char>}’ to ‘char*’ in initialization

Thanks again

Share this post


Link to post
Share on other sites
SiCrane    11839

You can use the .c_str() member function to get a const char * for a std::string. Be careful about storing it as the return value is only valid as long as the std::string exists, so you may need to copy the std::string first and keep it around before using .c_str().

Share this post


Link to post
Share on other sites
Wooh    1088

You can use c_str() to get a const char* from a std::string but that pointer will only stay valid for as long as the string is not destroyed/modified.

const char* ss = (*it2)->toString().toStdString().c_str();
doSomethingWith(ss); // ERROR: The data pointed to by ss is no longer valid.

If you just want to pass it to a function on the same line it is OK because the string has not yet been destroyed.

doSomethingWith((*it2)->toString().toStdString().c_str()); // OK

If you want to use it on more than one line you could store the string in a variable to extend the lifetime of the pointer.

std::string str = (*it2)->toString().toStdString();
const char* ss = str.c_str();
doSomethingWith(ss); // OK
doSomethingElseWith(ss); // OK

If you want a non-const char* you can use &str[0] instead of str.c_str().

Edited by Wooh

Share this post


Link to post
Share on other sites
FGFS    345

Now with:

 

    virtual void getIls(const std::string &id, StdWaypointList *list);

 

declared as:

typedef vector<Waypoint*> StdWaypointList;

I cannot find the StdWaypointList. I only see single waypoints...

Thanks again

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this