[odb-users] Error: "--include-regex: error: unable to open in read
mode"
Sum, Eric B
eric.b.sum at lmco.com
Fri Aug 12 08:58:27 EDT 2011
HI,
I am trying to follow these instructions for making a timeval struct a composite value member of a persistent class:
Storing timeval as a composite value is a bit trickier because it is defined in a system header and, as you mentioned, we don't want to modify it by adding a pragma that tells the ODB compiler it is a composite value type. What we can do is add this pragma into the ODB compilation process using the --odb-epilogue option. We will also need to use the --include-regex option (added in ODB 1.5.0) to fix up some of the includes. Here are step-by-step instructions for a test header I created (test.hxx):
#include <sys/time.h>
#pragma db object
class person
{
public:
#pragma db id
unsigned long id_;
timeval time_;
};
1. First, I created the "mapping file" for sys/time.h, I called it
time-mapping.h, it contains just this line:
#pragma db value(timeval)
2. Now if I try to compile /usr/include/sys/time.h, I get empty
generated files. As it turns out, timeval is defined in the
bits/time.h header which is included by sys/time.h. So the
ODB compiler command line I used is this:
odb -d sqlite --odb-epilogue-file time-mapping.h \ --include-regex '%time.h%<sys/time.h>%' -D __need_timeval \ /usr/include/bits/time.h
The __need_timeval define is needed in order to make bits/time.h
to define struct timeval.
This step will product a set of C++ source file (time-odb.?xx) that
contain the persistence code for struct timeval.
3. To compile test.hxx, I used this command line:
odb -d sqlite --odb-epilogue-file time-mapping.h \ --include-regex '%bits/time-odb.hxx%"time-odb.hxx"%' test.hxx
To tidy this up, you may want to place some of the options into an options file, e.g., time.options:
--odb-epilogue-file time-mapping.h
--include-regex '%bits/time-odb.hxx%"time-odb.hxx"%'
Then the command lines become:
odb -d sqlite --include-regex '%time.h%<sys/time.h>%' -D __need_timeval \ --options-file time.options /usr/include/bits/time.h
odb -d sqlite --options-file time.options test.hxx
I set these exact files up (test.hxx and time-mapping.h), but when I try the odb compiler command in step 2, I get "-include-regex: error: unable to open in read mode".
I am not sure how to go about fixing this. What does this error mean? I am using version 1.5.0 of the odb compiler.
Thanks,
Eric
More information about the odb-users
mailing list