[odb-users] Combining ODB with CXX Tree

Jeroen N. Witmond jnw at xs4all.nl
Sun Dec 10 03:06:26 EST 2017


Greetings!

I was thinking about combining ODB with CXX Tree, so I found this post 
https://codesynthesis.com/pipermail/xsd-users/2015-November/004714.html 
dated Thu Nov 5 03:40:20 EST 2015. I understand that in general, 
implementing this combination is not trivial, but I felt that should be 
able to get a trivial case to work, just for the fun of it.

However, I've run into a problem that I do not understand.

I started with:

[bicycles.xsd]
<?xml version="1.0"?>

<schema targetNamespace="test" xmlns:t="test"
         xmlns="http://www.w3.org/2001/XMLSchema">

   <complexType name="bicycle">
     <sequence>
       <element name="id"   type="unsignedInt"/>
       <element name="name" type="NCName"     />
     </sequence>
   </complexType>

   <complexType name="bicycles">
     <sequence>
       <element name="bicycle" type="t:bicycle" maxOccurs="unbounded"/>
     </sequence>
   </complexType>

   <element name="bicycles" type="t:bicycles"/>

</schema>
[/bicycles.xsd]

and I created:

[bicycle.odb]
namespace test
{
#pragma db object(bicycle)
#pragma db member(bicycle::id_) id get(id()) set(id(?))
#pragma db member(bicycle::name_) get(name()) set(name(?))
}
[/bicycle.odb]

This results in the following output:

-*- mode: compilation; default-directory: 
"~/development/bahcowork/odb+xsd/" -*-
Compilation started at Sun Dec 10 08:47:53

make -Wbicycles.xsd bicycles-odb.cxx
xsdcxx cxx-tree --std c++11 --generate-wildcard --generate-ostream \
	bicycles.xsd
odb --database mysql --std c++11 --generate-query --generate-schema \
	--odb-epilogue  '#include "bicycle.odb"' bicycles.hxx
bicycle.odb:4:46: error: modifier expression requires member type to be 
default-constructible
Makefile:814: recipe for target 'bicycles-odb.cxx' failed
make: *** [bicycles-odb.cxx] Error 1

Compilation exited abnormally with code 2 at Sun Dec 10 08:47:54

$ xsdcxx --version
CodeSynthesis XSD XML Schema to C++ compiler 4.0.0
Copyright (c) 2005-2014 Code Synthesis Tools CC
This is free software; see the source for copying conditions. There is 
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
PURPOSE.

$ odb --version
ODB object-relational mapping (ORM) compiler for C++ 2.4.0
Copyright (c) 2009-2015 Code Synthesis Tools CC
This is free software; see the source for copying conditions. There is 
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
PURPOSE.

I do not understand the "error: modifier expression requires member type 
to be default-constructible" because the following code compiles 
cleanly:

[testing.cpp]
#include <xsd/cxx/pre.hxx>

#include "bicycles.hxx"

int main()
{
   typedef ::xml_schema::unsigned_int id_type;
   ::xsd::cxx::tree::one< id_type > id_();

   typedef ::xml_schema::ncname name_type;
   ::xsd::cxx::tree::one< name_type > name_();
}

#include <xsd/cxx/post.hxx>
[/testing.cpp]

The post I referred to above is in the xsd-users mailing list. I've 
posted this in the odb-users mailing list because I guessed that this is 
a better place for this problem, but I may be wrong ...

Can anybody help to get this trivial case to work?

Thanks,

Jeroen.



More information about the odb-users mailing list