[odb-users] Variant type mapping?
Luis Valdés
luisvaldes88 at gmail.com
Sat Apr 7 19:07:04 EDT 2012
Hi,
Can't you save your data just as a BLOB type and map it as a QByteArray in
your c++ class??
So, you will read the BLOB column as a QByteArray object, and you can
decide what to do with it later.
class Whatever
{
public:
long m_id;
QByteArray m_variantData;
};
namespace qx
{
template <> void register_class(QxClass< Whatever> & t)
{
t.id(& Whatever :: m_id , "id");
t.data(& Whatever :: m_variantData , "variantData");
}
}
2012/4/7 Alexander A. Prokhorov <prokher at gmail.com>
> Dear colleagues,
>
> I was thinking about using ODB in my project, I've tried several trivial
> cases and it showed itself well. Then I've faced tricky case. I need to
> store Variant type (QVariant or boost::variant, whatever) in DB. Do you
> have any recommendations how to perform this? I understand that I can
> create table "Variants" with columns "id", "type_id", "type_specific_id",
> where "type_specific_id" points to the record in the table implicitly
> pointed by "type_id". I feel this approach 'smells' a little. Anyway I
> don't have an idea how to implement this with ODB. Can you give me an
> advice? Any ideas?
>
> Thank you in advance.
>
>
--
Atentamente.
Luis Valdes
luisvaldes88 at gmail.com
(0994) 205 781
More information about the odb-users
mailing list