List Info

Thread: BAD_CAST question




BAD_CAST question
user name
2006-12-08 19:45:48
Hi, I have a function that returns a std::string that I need to convert to an xmlChar*.  What is the best way to do this? ; I get a compiler error when I use the BAD_CAST macro.  I'm fairly new to to C and libxml.  Thanks for your help.

Clint
BAD_CAST question
user name
2006-12-08 19:50:44
Clint Barlow wrote:
> Hi, I have a function that returns a std::string that I
need to convert
> to an xmlChar*.  What is the best way to do this?  I
get a compiler
> error when I use the BAD_CAST macro.  I'm fairly new to
to C and
> libxml.  Thanks for your help.

To extract a 'char const *' from a std::string you have to
call its c_str()
method. That you can cast using BAD_CAST. (But make sure it
gets appropriately
copied, depending on where you us it !)

HTH,
		Stefan

-- 

      ...ich hab' noch einen Koffer in Berlin...
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )