Is it safe to convert a mysqlpp::sql_blob to a std::string?
Posted
by Runcible
on Stack Overflow
See other posts from Stack Overflow
or by Runcible
Published on 2009-10-09T00:44:37Z
Indexed on
2010/04/20
18:13 UTC
Read the original article
Hit count: 333
I'm grabbing some binary data out of my MySQL database. It comes out as a mysqlpp::sql_blob type.
It just so happens that this BLOB is a serialized Google Protobuf. I need to de-serialize it so that I can access it normally.
This gives a compile error, since ParseFromString() is not intended for mysqlpp:sql_blob types:
protobuf.ParseFromString( record.data );
However, if I force the cast, it compiles OK:
protobuf.ParseFromString( (std::string) record.data );
Is this safe? I'm particularly worried because of this snippet from the mysqlpp documentation:
Thanks for your assistance!
© Stack Overflow or respective owner