From paul.s.mcgrath at gmail.com Thu Mar 23 14:28:20 2023 From: paul.s.mcgrath at gmail.com (Paul McGrath) Date: Fri Mar 24 04:32:38 2023 Subject: [xsd-users] Moving over to c++11 Message-ID: Hello, I'm having problems with the move to c++11. When I generate the *.hxx and *.cxx files using xsd cxx-tree --std c++11 --generate-element-type --generate-element-map --generate-ostream --generate-serialization matml31.xsd it looks as though the equivalent c++11 function of the old function (below) does not exist. // Parse a URI or a local file. // ::std::auto_ptr< ::MatML_Doc > MatML_Doc_ (const ::std::string& uri, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); Thanks ahead for any assistance you can provide. Paul From boris at codesynthesis.com Fri Mar 24 04:45:48 2023 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Mar 24 04:38:05 2023 Subject: [xsd-users] Moving over to c++11 In-Reply-To: References: Message-ID: Paul McGrath writes: > it looks as though the equivalent c++11 function of the old function > (below) does not exist. > > ::std::auto_ptr< ::MatML_Doc > > MatML_Doc_ (const ::std::string& uri, > ::xml_schema::flags f = 0, > const ::xml_schema::properties& p = ::xml_schema::properties ()); In C++11 and later the parsing functions are changed to return std::unique_ptr instead of (deprecated) std::auto_ptr: ::std::unique_ptr< ::MatML_Doc > MatML_Doc_ (const ::std::string& uri, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); From paul.s.mcgrath at gmail.com Fri Mar 24 09:02:49 2023 From: paul.s.mcgrath at gmail.com (Paul McGrath) Date: Mon Mar 27 09:06:49 2023 Subject: [xsd-users] Moving over to c++11 In-Reply-To: References: Message-ID: Thanks. I was able to get below generated if I DON'T use the "--generate-element-type" flag. Is this normal behavior? I would like to use that flag. // Parse a URI or a local file. // ::std::unique_ptr< ::MatML_Doc > MatML_Doc_ (const ::std::string& uri, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); On Fri, Mar 24, 2023 at 4:45?AM Boris Kolpackov wrote: > Paul McGrath writes: > > > it looks as though the equivalent c++11 function of the old function > > (below) does not exist. > > > > ::std::auto_ptr< ::MatML_Doc > > > MatML_Doc_ (const ::std::string& uri, > > ::xml_schema::flags f = 0, > > const ::xml_schema::properties& p = ::xml_schema::properties > ()); > > In C++11 and later the parsing functions are changed to return > std::unique_ptr instead of (deprecated) std::auto_ptr: > > ::std::unique_ptr< ::MatML_Doc > > MatML_Doc_ (const ::std::string& uri, > ::xml_schema::flags f = 0, > const ::xml_schema::properties& p = ::xml_schema::properties > ()); > > From boris at codesynthesis.com Mon Mar 27 09:25:39 2023 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 27 09:17:54 2023 Subject: [xsd-users] Moving over to c++11 In-Reply-To: References: Message-ID: Paul McGrath writes: > I was able to get below generated if I DON'T use the > "--generate-element-type" flag. Is this normal behavior? I would like to > use that flag. Yes, this is the expected behavior, per Section 2.9.1, "Element Types"[1]: "Unlike parsing and serialization functions, element types are only capable of parsing and serializing from/to a DOMElement object. This means that the application will need to perform its own XML-to-DOM parsing and DOM-to-XML serialization. The following section describes a mechanism provided by the mapping to uniformly parse and serialize multiple root elements." The mechanism this section refers to is Element Map[2] (enabled with --generate-element-map, which you also seem to pass). You can find sample code for parsing/serializing XML-to/from-DOM in the `messaging` example[3]. [1] https://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.9 [2] https://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.9.2 [3] https://git.codesynthesis.com/cgit/xsd/xsd/tree/xsd-examples/cxx/tree/messaging From paul.s.mcgrath at gmail.com Wed Mar 29 09:34:51 2023 From: paul.s.mcgrath at gmail.com (Paul McGrath) Date: Thu Mar 30 06:46:02 2023 Subject: [xsd-users] c++11 refers to a deleted function. Message-ID: Hello, I'm having an error with the following line in the generated code. AssociationDetails_lib:: AssociationDetails_lib (::std::unique_ptr< value_type > p) : value_ (p, 0) gives an error of: Severity Code Description Project File Line Suppression State Error (active) E1776 function "std::unique_ptr<_Ty, _Dx>::unique_ptr(const std::unique_ptr<_Ty, _Dx> &) [with _Ty=bellshire::lib::ComponentDetails::AssociationDetails_type, _Dx=std::default_delete]" (declared at line 3317 of "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32502\include\memory") cannot be referenced -- it is a deleted function BT-MatML-Editor C:\Users\paulm\source\repos\BT-MatML-Editor\src\MatML_Lib\matml31_lib.cxx 12737 it seems to be referring to a deleted function in header: unique_ptr(const unique_ptr&) = delete; unique_ptr& operator=(const unique_ptr&) = delete; Admittedly, I don't know where the const comes from in the deleted function. This code was generated by xsd cxx-tree --std c++11 --namespace-map =bellshire::lib --generate-element-map --generate-element-type matml31_lib.xsd Let me know if you need any more information. Thanks for your help Paul From boris at codesynthesis.com Fri Mar 31 06:52:16 2023 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Mar 31 06:44:29 2023 Subject: [xsd-users] c++11 refers to a deleted function. In-Reply-To: References: Message-ID: Paul McGrath writes: > I'm having an error with the following line in the generated code. > > AssociationDetails_lib:: > AssociationDetails_lib (::std::unique_ptr< value_type > p) > : value_ (p, 0) > > This code was generated by > > xsd cxx-tree --std c++11 --namespace-map =bellshire::lib > --generate-element-map --generate-element-type matml31_lib.xsd I tried to reproduce this with matml31.xsd using the development version of XSD but I didn't even get this construct (or AssociationDetails_lib type, for that matter). Can you share matml31_lib.xsd? From paul.s.mcgrath at gmail.com Fri Mar 31 10:02:42 2023 From: paul.s.mcgrath at gmail.com (Paul McGrath) Date: Mon Apr 3 09:28:46 2023 Subject: [xsd-users] c++11 refers to a deleted function. In-Reply-To: References: Message-ID: Hello, I have attached the matml31_lib.xsd. The main difference is I tried to add (line 3046) the following to the xsd to allow for multiple roots. The rest is the same as matml31.xsd which works well. It then creates AssociationDetails_lib:: AssociationDetails_lib (std::unique_ptr< value_type > p) : value_ (p, 0) { } Which is the code it is having problems with. Then goes here ::xsd::cxx::tree::one< value_type > value_; Then... public: ~one (); one (container*); one (const T&, container*); one (XSD_AUTO_PTR, container*); one (const one&, flags, container*); ...and this is where I lose it. I don't know where it goes from here. I suspect it is calling one (const T&, container*); instead of one (XSD_AUTO_PTR, container*); Any help would be appreciated. Paul On Fri, Mar 31, 2023 at 6:52?AM Boris Kolpackov wrote: > Paul McGrath writes: > > > I'm having an error with the following line in the generated code. > > > > AssociationDetails_lib:: > > AssociationDetails_lib (::std::unique_ptr< value_type > p) > > : value_ (p, 0) > > > > This code was generated by > > > > xsd cxx-tree --std c++11 --namespace-map =bellshire::lib > > --generate-element-map --generate-element-type matml31_lib.xsd > > I tried to reproduce this with matml31.xsd using the development version > of XSD but I didn't even get this construct (or AssociationDetails_lib > type, for that matter). Can you share matml31_lib.xsd? > -------------- next part -------------- A non-text attachment was scrubbed... Name: matml31_lib.xsd Type: application/xml Size: 123914 bytes Desc: not available Url : https://codesynthesis.com/pipermail/xsd-users/attachments/20230331/759adde7/matml31_lib-0001.xml