List:MySQL++« Previous MessageNext Message »
From:Alex Date:August 25 2008 5:53pm
Subject:Re: A way to copy mysqlpp::StoreQueryResult into a std::map?
View as plain text  
Well to get back on topic (hopefully) I now have this code:

        if(command_tokens[0] == "help"){
                mysqlpp::Query qry_help_cmd = mysql_conn.query();
                qry_help_cmd << "SELECT `name`,`syntax`,`help` FROM
`command` WHERE name = "
                                << quote << command_tokens[1];
                mysqlpp::StoreQueryResult res_help_cmd = qry_help_cmd.store();
                if(res_help_cmd){
                        slog.clog("Name: ",false,true);
                        slog.clog(res_help_cmd[0]["name"].c_str(),true,false);
                        slog.clog("Syntax: ",true,true);
                        slog.clog(res_help_cmd[0]["syntax"].c_str(),true,false);
                        slog.clog("Description: ",true,true);
                        slog.clog(res_help_cmd[0]["help"].c_str(),true,false);
                        goto awi_start;
                }else{
                        slog.clog("No help available for " +
command_tokens[1] + ".");
                };
        };

I don't think I have to go about what those true/false means, as
they're not the point.. Point is that even if there's no help data for
the command the user requests help for, res_help_cmd returns true and
it tries to output help about that command, but obviously fails:

Command: help info
-- Mon Aug 25 03:50:17 2008
Name: info
Syntax: info
Description: Shows information about AWI.
Command: help test
-- Mon Aug 25 03:50:21 2008
Name: -- Mon Aug 25 03:50:21 2008
AWI crashed. Attempting to exit normally...

I'm not entirely sure what error it crashes with, but I'm certain it's
caused by the fact that the result vector isn't filled and it tries to
output it anyway - which it shouldn't. It should just jump to the "No
help available" message.

Any ideas? Thanks.

2008/8/22 Warren Young <mysqlpp@stripped>:
> Alex wrote:
>>
>>                        slog.clog("Name: " + res_help_cmd[0]["name"]);
>
> I passed over this earlier because I assumed you knew what you were doing.
>  I now believe you're under the impression that you're writing Javascript,
> or maybe VB.  C++ can be made to concatenate strings with operator +, but
> its operator overloading rules don't make it automatic or trivial.
>
> I'm pretty sure the compiler believes you want pointer arithmetic here.
>
> Fixing this is way, way off topic for this list.
>
> --
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe:    http://lists.mysql.com/plusplus?unsub=1
>
>



-- 
GamerzWoW - http://www.gamerzwow.net
Thread
A way to copy mysqlpp::StoreQueryResult into a std::map?Alex13 Aug
  • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Warren Young13 Aug
    • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex13 Aug
      • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Warren Young13 Aug
        • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex14 Aug
          • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex17 Aug
            • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Warren Young17 Aug
              • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex19 Aug
                • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Warren Young19 Aug
                  • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex20 Aug
                    • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Warren Young21 Aug
                      • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex21 Aug
                        • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Warren Young21 Aug
                          • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex21 Aug
                            • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex22 Aug
                              • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Warren Young22 Aug
                                • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex22 Aug
                                  • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Warren Young22 Aug
                                    • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex22 Aug
                                      • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex22 Aug
                                      • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Warren Young22 Aug
                                        • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex22 Aug
                                          • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Warren Young22 Aug
                                            • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex25 Aug
                                              • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Joel Fielder26 Aug
                                                • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex26 Aug
                                                  • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Joel Fielder26 Aug
                                                    • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex26 Aug
                                                  • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Warren Young26 Aug
                                                    • Re: A way to copy mysqlpp::StoreQueryResult into a std::map?Alex27 Aug