Alex wrote:
>
> So you can understand that I wouldn't be able to directly refer to the
> specific command the user wants help for as the vector is split up in
> numbers.
I understand no such thing. The answer is simple either way:
Query q = conn.query("SELECT * FROM command WHERE NAME =");
q << quote << myCommandName;
StoreQueryResult res = q.store();
if (res) {
// have help for this command
}
else {
// don't have help for this command
}
Or:
class command {
public:
command(const char* name, const char* help = 0,
const char* syntax = 0) :
name_(name),
help_(help ? help : ""),
syntax_(syntax ? syntax : "")
{
}
....
bool operator==(const command& rhs)
{
return name_ == rhs.name_;
}
private:
string name_, help_, syntax_;
};
vector<commands> vc;
// populate vector of command objects somehow
vector<commands>::iterator it = find(vc.begin(), vc.end(),
command(myCommandName));
if (it != vc.end()) {
// have help for this command
}
else {
// don't have help for this command
}
So, is this a homework problem, or what?