[odb-users] Can I define views wherever I want ?

Boris Kolpackov boris at codesynthesis.com
Sun Aug 19 10:08:57 EDT 2012


Hi,

yb947835908 at gmail.com writes:

> Must I define all the views in the .hxx file(the input file of the ODB
> compiler) ? What if I don't know what views I may use at first? Can I
> define views wherever I want to, for example, in my main function?

No, this is not supported.

While I agree, it would neat to be able to define function-local views
(e.g., in main(), as you suggested), this would pose a chicken-and-egg
problem. Consider that in order to use the view, you will need to include
the header file that contains the database support code for this view
(i.e., the -odb.hxx header). So if you define the view in a file, say
main.cxx, where you also use it then this file will need to include
the main-odb.hxx file that is produced by the ODB compiler. But when
you invoke the ODB compiler on main.cxx, no main-odb.hxx is yet
available. So you will get a compile error.

There are also other problems, such as the need for main-odb.hxx to
include the definition of the view (including main.cxx is probably
a bad idea).

Boris



More information about the odb-users mailing list