[odb-users] How to persist a custom collection adapted from
std::vector ?
ALAIN MARI
alain.mari at se.com
Tue Feb 4 05:52:10 EST 2020
Hi,
I am replacing an existing object database layer with odb.
I would like to make a custom persistent class which is an array of elements named os_Array.
I could easily replace this os_Array with a std::vector which is already natively persisted by odb.
But, in order to ease development migration, I just created a wrapper class like this :
template <typename T>
class os_Array : private std::vector<T>
{
...
}
In order to keep the same API.
But when I want to use my new class to persist a field like this for instance :
typedef odb::os_Array<std::shared_ptr<int>> TIntArray;
TIntArray m_collParam;
I just get the following error message when I try to compile with odb.exe :
1> Generating ODB schema for CrossRef.odb
1> PXRefAddressObjRE.h:178:20: error: unable to map C++ type '::CPXRefAddressObjRE::TIntArray' used in data member 'm_collParam' to a SQLite database type
1> PXRefAddressObjRE.h:178:20: info: use '#pragma db type' to specify the database type
What could be the best way to make my field persistent with my own wrapper class ?
Regards.
Alain.
More information about the odb-users
mailing list