List:MySQL++« Previous MessageNext Message »
From:Robert Simmons Date:February 25 2009 6:29pm
Subject:Re: Newbie Row question
View as plain text  
I'll admit I have had similar issues, attempting to assign a retrieved  
value back into a std::string (previously discussed on the list). I  
too am using the string(result.data(), result,length()) method to cast  
the value as string. Having an operator for it within MySQL++ would  
make my code much much tidier.


On 25 Feb 2009, at 18:14, Warren Young wrote:

> Sebastián Salazar Molina. wrote:
>> but when I change out to int, it compile fine, when I use string, i  
>> can't compile:
>
> That's because Row::operator[] returns mysqlpp::String, which knows  
> how to convert itself to an int, but not to std::string.  Without a  
> direct conversion, your compiler is having to choose among the const  
> char* and char conversions, and doesn't understand that the first is  
> clearly the right one.
>
> One way to fix it:
>
> 	String field = actual[f];
> 	return string(field.data());
>
> Another way would be to add a std::string conversion operator to lib/ 
> mystring.h, try it, and report back.  If it works and doesn't cause  
> problems, I'll add it to the next version of MySQL++.
>
> -- 
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe:    http://lists.mysql.com/plusplus?unsub=1
>

Thread
Newbie Row questionSebasti├ín Salazar Molina.25 Feb
  • Re: Newbie Row questionWarren Young25 Feb
    • Re: Newbie Row questionSebasti├ín Salazar Molina.25 Feb
    • Re: Newbie Row questionRobert Simmons25 Feb
      • Re: Newbie Row questionWarren Young25 Feb