[odb-users] Containers of containers not detected
Andrew Cunningham
andrew at a-cunningham.com
Fri Apr 29 17:20:51 EDT 2016
Hi Boris,
It would be great if the ODB compiler could detect "containers of
containers" and throw an error.
I am using a std::map<key, value> and the "value" object is holding a
std::vector<unsigned char>.
The ODB compiler accepts that quite happily, but this violates "container
of containers" AFAIK.
But surprisingly, if the std::vector<unsigned char> is declared #pragma db
type("BLOB") then the code actually functions correctly and loads the
nested data container.
If the BLOB #pragma is removed , then the std::vector data is not loaded
So it seems I have unintentionally backed myself into a corner.
- Is the "container of containers" a hard limitation that will remain in
future versions of ODB?
- Is the fact that using a BLOB makes the code work just blind good luck?
e.g.
#pragma db value
class ValueObject
{
....
#pragma db type("BLOB")
std::vector< unsigned char > vec_;
};
#pragma db object
class Other
{
....
std::map<int,ValueObject> aMap_;
}
I'll send you a project that illustrates this.
More information about the odb-users
mailing list