aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-03-08 17:23:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-03-08 17:23:30 +0200
commit0bce70a0e483294b83b8bf9d5468838a63405612 (patch)
treed11afb4998d6980435c15c4df6e40b1979531672
parent6c63b913179127e09ed7d9da8920493ccceec6ce (diff)
Add support for binary representations
xsde/cxx/hybrid/insertion-*: insertion operators generator xsde/cxx/hybrid/extraction-*: extraction operators generator libxsde/xsde/cxx/hybrid/cdr/: CDR support code libxsde/xsde/cxx/hybrid/xdr/: XDR support code tests/cxx/hybrid/binary/: new tests examples/cxx/hybrid/binary/: new examples documentation/cxx/hybrid/guide/: new chapter
-rw-r--r--NEWS15
-rw-r--r--build/configuration.make4
-rwxr-xr-xbuild/configure17
-rw-r--r--build/import/libace/LICENSE340
-rw-r--r--build/import/libace/configuration-rules.make15
-rwxr-xr-xbuild/import/libace/configure58
-rw-r--r--build/import/libace/rules.make29
-rw-r--r--build/import/libace/stub.make32
-rw-r--r--build/import/libace/version1
-rw-r--r--dist/build/config.make2
-rw-r--r--dist/config/config.make16
-rw-r--r--dist/config/config.nmake16
-rw-r--r--dist/etc/evc-4.0/config.nmake16
-rw-r--r--dist/etc/iphone/config-device.make16
-rw-r--r--dist/etc/iphone/config-simulator.make16
-rw-r--r--dist/etc/lynxos/config-4.2.make16
-rw-r--r--dist/etc/qnx/config-6.3-gcc-2.95.make16
-rw-r--r--dist/etc/qnx/config-6.3-gcc-3.3.make16
-rw-r--r--dist/etc/qnx/config-6.4.make16
-rw-r--r--dist/etc/vc-8.0/config-max.nmake16
-rw-r--r--dist/etc/vc-8.0/config-min.nmake16
-rw-r--r--dist/etc/vc-9.0/config-max.nmake16
-rw-r--r--dist/etc/vc-9.0/config-min.nmake16
-rw-r--r--dist/etc/vxworks/config-5.5.1.make16
-rw-r--r--dist/etc/vxworks/config-6.4-max.make (renamed from dist/etc/vxworks/config-max-6.4.make)16
-rw-r--r--dist/etc/vxworks/config-6.4-min.make (renamed from dist/etc/vxworks/config-min-6.4.make)16
-rw-r--r--dist/examples/cxx/hybrid/binary/cdr/makefile58
-rw-r--r--dist/examples/cxx/hybrid/binary/cdr/nmakefile55
-rw-r--r--dist/examples/cxx/hybrid/binary/custom/makefile70
-rw-r--r--dist/examples/cxx/hybrid/binary/custom/nmakefile68
-rw-r--r--dist/examples/cxx/hybrid/binary/custom/options8
-rw-r--r--dist/examples/cxx/hybrid/binary/makefile33
-rw-r--r--dist/examples/cxx/hybrid/binary/nmakefile29
-rw-r--r--dist/examples/cxx/hybrid/binary/xdr/makefile58
-rw-r--r--dist/examples/cxx/hybrid/binary/xdr/nmakefile53
-rw-r--r--dist/examples/cxx/hybrid/makefile2
-rw-r--r--dist/libxsde/xsde/makefile19
-rw-r--r--dist/libxsde/xsde/nmakefile19
-rw-r--r--documentation/cxx/hybrid/guide/index.xhtml289
-rw-r--r--documentation/xsde.128
-rw-r--r--documentation/xsde.xhtml22
-rw-r--r--examples/cxx/hybrid/README4
-rw-r--r--examples/cxx/hybrid/binary/README16
-rw-r--r--examples/cxx/hybrid/binary/cdr/README51
-rw-r--r--examples/cxx/hybrid/binary/cdr/driver.cxx128
-rw-r--r--examples/cxx/hybrid/binary/cdr/library.xml53
-rw-r--r--examples/cxx/hybrid/binary/cdr/library.xsd69
-rw-r--r--examples/cxx/hybrid/binary/cdr/makefile112
-rw-r--r--examples/cxx/hybrid/binary/custom/README77
-rw-r--r--examples/cxx/hybrid/binary/custom/driver.cxx107
-rw-r--r--examples/cxx/hybrid/binary/custom/exceptions.cxx11
-rw-r--r--examples/cxx/hybrid/binary/custom/exceptions.hxx16
-rw-r--r--examples/cxx/hybrid/binary/custom/irawstream.cxx296
-rw-r--r--examples/cxx/hybrid/binary/custom/irawstream.hxx92
-rw-r--r--examples/cxx/hybrid/binary/custom/irawstream.ixx110
-rw-r--r--examples/cxx/hybrid/binary/custom/irawstream.txx72
-rw-r--r--examples/cxx/hybrid/binary/custom/library.xml53
-rw-r--r--examples/cxx/hybrid/binary/custom/library.xsd69
-rw-r--r--examples/cxx/hybrid/binary/custom/makefile138
-rw-r--r--examples/cxx/hybrid/binary/custom/orawstream.cxx224
-rw-r--r--examples/cxx/hybrid/binary/custom/orawstream.hxx91
-rw-r--r--examples/cxx/hybrid/binary/custom/orawstream.ixx110
-rw-r--r--examples/cxx/hybrid/binary/custom/orawstream.txx47
-rw-r--r--examples/cxx/hybrid/binary/makefile53
-rw-r--r--examples/cxx/hybrid/binary/xdr/README50
-rw-r--r--examples/cxx/hybrid/binary/xdr/driver.cxx196
-rw-r--r--examples/cxx/hybrid/binary/xdr/library.xml53
-rw-r--r--examples/cxx/hybrid/binary/xdr/library.xsd69
-rw-r--r--examples/cxx/hybrid/binary/xdr/makefile112
-rw-r--r--examples/cxx/hybrid/makefile6
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/date-time.cxx764
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/exceptions.cxx21
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/exceptions.hxx26
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/istream.cxx101
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/istream.hxx182
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/istream.ixx385
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/istream.txx184
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/ostream.cxx88
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/ostream.hxx182
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/ostream.ixx245
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/ostream.txx110
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/qname.cxx74
-rw-r--r--libxsde/xsde/cxx/hybrid/cdr/string-sequence.cxx107
-rw-r--r--libxsde/xsde/cxx/hybrid/sequence.hxx2
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/date-time.cxx764
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/exceptions.cxx21
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/exceptions.hxx26
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/istream.cxx135
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/istream.hxx181
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/istream.ixx365
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/istream.txx184
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/ostream.cxx92
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/ostream.hxx181
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/ostream.ixx281
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/ostream.txx110
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/qname.cxx74
-rw-r--r--libxsde/xsde/cxx/hybrid/xdr/string-sequence.cxx107
-rw-r--r--libxsde/xsde/cxx/sequence-base.hxx2
-rw-r--r--libxsde/xsde/makefile34
-rw-r--r--tests/cxx/hybrid/binary/cdr/driver.cxx102
-rw-r--r--tests/cxx/hybrid/binary/cdr/makefile97
-rw-r--r--tests/cxx/hybrid/binary/cdr/output.xml2
-rw-r--r--tests/cxx/hybrid/binary/cdr/test.xml93
-rw-r--r--tests/cxx/hybrid/binary/cdr/test.xsd131
-rw-r--r--tests/cxx/hybrid/binary/custom/driver.cxx102
-rw-r--r--tests/cxx/hybrid/binary/custom/makefile128
-rw-r--r--tests/cxx/hybrid/binary/custom/output.xml2
-rw-r--r--tests/cxx/hybrid/binary/custom/test.xml93
-rw-r--r--tests/cxx/hybrid/binary/custom/test.xsd131
-rw-r--r--tests/cxx/hybrid/binary/xdr/driver.cxx147
-rw-r--r--tests/cxx/hybrid/binary/xdr/makefile98
-rw-r--r--tests/cxx/hybrid/binary/xdr/output.xml2
-rw-r--r--tests/cxx/hybrid/binary/xdr/test.xml93
-rw-r--r--tests/cxx/hybrid/binary/xdr/test.xsd131
-rw-r--r--tests/cxx/hybrid/makefile8
-rw-r--r--xsde/cxx/hybrid/cli.hxx4
-rw-r--r--xsde/cxx/hybrid/elements.cxx42
-rw-r--r--xsde/cxx/hybrid/elements.hxx37
-rw-r--r--xsde/cxx/hybrid/extraction-header.cxx255
-rw-r--r--xsde/cxx/hybrid/extraction-header.hxx22
-rw-r--r--xsde/cxx/hybrid/extraction-source.cxx1063
-rw-r--r--xsde/cxx/hybrid/extraction-source.hxx22
-rw-r--r--xsde/cxx/hybrid/generator.cxx30
-rw-r--r--xsde/cxx/hybrid/insertion-header.cxx255
-rw-r--r--xsde/cxx/hybrid/insertion-header.hxx22
-rw-r--r--xsde/cxx/hybrid/insertion-source.cxx694
-rw-r--r--xsde/cxx/hybrid/insertion-source.hxx22
-rw-r--r--xsde/cxx/hybrid/tree-forward.cxx87
-rw-r--r--xsde/cxx/hybrid/tree-header.cxx3
-rw-r--r--xsde/makefile4
130 files changed, 13001 insertions, 14 deletions
diff --git a/NEWS b/NEWS
index cb3d35b..73398df 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,18 @@
+Version 3.1.0
+
+ C++/Hybrid
+
+ * Support for saving the object model to and loading it from binary
+ representations. The new --generate--insertion and --generate-extraction
+ options trigger generation of data representation stream insertion and
+ extraction operators, respectively. The XSD/e runtime provides support
+ for the ACE CDR streams and XDR API that is part of Sun RPC. Custom
+ representations can supported by implementing insertion and extraction
+ operators for the built-in XML Schema types and sequence templates. For
+ more information, see Chapter 7, "Binary Representation" in the Getting
+ Started Guide as well as examples in the examples/cxx/hybrid/binary/
+ directory.
+
Version 3.0.0
* The new Embedded C++/Hybrid mapping provides a light-weight, tree-
diff --git a/build/configuration.make b/build/configuration.make
index 6efbbfd..bb7b932 100644
--- a/build/configuration.make
+++ b/build/configuration.make
@@ -18,6 +18,8 @@ xsde_snprintf :=
xsde_parser_validation :=
xsde_serializer_validation :=
xsde_reuse_style :=
+xsde_xdr :=
+xsde_cdr :=
xsde_polymorphic :=
xsde_parser_smap_buckets :=
xsde_parser_imap_buckets :=
@@ -40,6 +42,8 @@ $(out_root)/%: xsde_snprintf := $(xsde_snprintf)
$(out_root)/%: xsde_parser_validation := $(xsde_parser_validation)
$(out_root)/%: xsde_serializer_validation := $(xsde_serializer_validation)
$(out_root)/%: xsde_reuse_style := $(xsde_reuse_style)
+$(out_root)/%: xsde_xdr := $(xsde_xdr)
+$(out_root)/%: xsde_cdr := $(xsde_cdr)
$(out_root)/%: xsde_polymorphic := $(xsde_polymorphic)
$(out_root)/%: xsde_parser_smap_buckets := $(xsde_parser_smap_buckets)
$(out_root)/%: xsde_parser_imap_buckets := $(xsde_parser_imap_buckets)
diff --git a/build/configure b/build/configure
index d99f1c2..16bccff 100755
--- a/build/configure
+++ b/build/configure
@@ -92,6 +92,21 @@ $echo
reuse_style=`read_option "mixin tiein none" "tiein"`
$echo
+$echo "Would you like to build support for serialization in XDR format?"
+$echo "This requires the XDR API that is part of Sun RPC (rpc/xdr.h)."
+$echo
+
+xdr=`read_y_n n`
+
+$echo
+$echo "Would you like to build support for serialization in CDR format?"
+$echo "This requires the ACE library."
+$echo
+
+cdr=`read_y_n n`
+
+
+$echo
$echo "Would you like the runtime library to support XML Schema polymorphism"
$echo "(xsi:type and substitution groups)?"
$echo
@@ -152,6 +167,8 @@ echo "xsde_snprintf := $snprintf" >>
echo "xsde_parser_validation := $parser_validation" >>$1
echo "xsde_serializer_validation := $serializer_validation" >>$1
echo "xsde_reuse_style := $reuse_style" >>$1
+echo "xsde_xdr := $xdr" >>$1
+echo "xsde_cdr := $cdr" >>$1
echo "xsde_polymorphic := $polymorphic" >>$1
echo "xsde_parser_smap_buckets := $parser_smap_buckets" >>$1
echo "xsde_parser_imap_buckets := $parser_imap_buckets" >>$1
diff --git a/build/import/libace/LICENSE b/build/import/libace/LICENSE
new file mode 100644
index 0000000..3912109
--- /dev/null
+++ b/build/import/libace/LICENSE
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/build/import/libace/configuration-rules.make b/build/import/libace/configuration-rules.make
new file mode 100644
index 0000000..0c262e6
--- /dev/null
+++ b/build/import/libace/configuration-rules.make
@@ -0,0 +1,15 @@
+# file : build/import/libace/configuration-rules.make
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2005-2008 Boris Kolpackov
+# license : GNU GPL v2; see accompanying LICENSE file
+
+$(dcf_root)/import/libace/configuration-dynamic.make: | $(dcf_root)/import/libace/.
+ $(call message,,$(scf_root)/import/libace/configure $@)
+
+ifndef %foreign%
+
+disfigure::
+ $(call message,rm $(dcf_root)/import/libace/configuration-dynamic.make,\
+rm -f $(dcf_root)/import/libace/configuration-dynamic.make)
+
+endif
diff --git a/build/import/libace/configure b/build/import/libace/configure
new file mode 100755
index 0000000..2f9f276
--- /dev/null
+++ b/build/import/libace/configure
@@ -0,0 +1,58 @@
+#! /usr/bin/env bash
+
+# file : build/import/libace/configure
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2005-2008 Boris Kolpackov
+# license : GNU GPL v2; see accompanying LICENSE file
+
+
+# $1 - out config file
+#
+# bld_root - build root
+# project_name - project name
+#
+
+source $bld_root/dialog.bash
+
+
+$echo
+$echo "Configuring external dependency on 'ACE' for '$project_name'."
+$echo
+
+$echo
+$echo "Would you like to configure dependency on the installed version"
+$echo "of 'ACE' as opposed to the development build?"
+$echo
+
+installed=`read_y_n y`
+
+path=
+type=
+
+if [ "$installed" = "n" ]; then
+
+ $echo
+ $echo "Please enter the 'ACE' root directory (ACE_ROOT)."
+ $echo
+
+ root=`read_path --directory --exist`
+
+ $echo
+ $echo "Please select the library type you would like to use:"
+ $echo
+ $echo "(1) archive"
+ $echo "(2) shared object"
+ $echo
+
+ type=`read_option "archive shared" "shared"`
+
+fi
+
+echo libace_installed := $installed >$1
+
+if [ "$installed" = "n" ]; then
+
+ echo libace_root := $root >>$1
+ echo libace_type := $type >>$1
+
+fi
diff --git a/build/import/libace/rules.make b/build/import/libace/rules.make
new file mode 100644
index 0000000..1a4cfaa
--- /dev/null
+++ b/build/import/libace/rules.make
@@ -0,0 +1,29 @@
+# file : build/import/libace/rules.make
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2005-2008 Boris Kolpackov
+# license : GNU GPL v2; see accompanying LICENSE file
+
+$(dcf_root)/import/libace/%: root := $(libace_root)
+
+ifeq ($(libace_type),archive)
+
+$(dcf_root)/import/libace/ace.l: $(libace_root)/lib/libACE.a
+ @echo $< >$@
+else
+
+$(dcf_root)/import/libace/ace.l: $(libace_root)/lib/libACE.so
+ @echo $< >$@
+ @echo rpath:$(root)/lib >>$@
+endif
+
+$(dcf_root)/import/libace/ace.l.cpp-options:
+ @echo include: -I$(root) >$@
+
+ifndef %foreign%
+
+disfigure::
+ $(call message,rm $(dcf_root)/import/libace/ace.l,\
+rm -f $(dcf_root)/import/libace/ace.l)
+ $(call message,,rm -f $(dcf_root)/import/libace/ace.l.cpp-options)
+
+endif
diff --git a/build/import/libace/stub.make b/build/import/libace/stub.make
new file mode 100644
index 0000000..a1274b0
--- /dev/null
+++ b/build/import/libace/stub.make
@@ -0,0 +1,32 @@
+# file : build/import/libace/stub.make
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2005-2008 Boris Kolpackov
+# license : GNU GPL v2; see accompanying LICENSE file
+
+$(call include-once,$(scf_root)/import/libace/configuration-rules.make,$(dcf_root))
+
+libace_installed :=
+
+$(call -include,$(dcf_root)/import/libace/configuration-dynamic.make)
+
+ifdef libace_installed
+
+ifeq ($(libace_installed),y)
+
+$(call export,l: -lACE,cpp-options: )
+
+else
+
+$(call include-once,$(scf_root)/import/libace/rules.make,$(dcf_root))
+
+$(call export,\
+ l: $(dcf_root)/import/libace/ace.l,\
+ cpp-options: $(dcf_root)/import/libace/ace.l.cpp-options)
+
+endif
+
+else
+
+.NOTPARALLEL:
+
+endif
diff --git a/build/import/libace/version b/build/import/libace/version
new file mode 100644
index 0000000..0d91a54
--- /dev/null
+++ b/build/import/libace/version
@@ -0,0 +1 @@
+0.3.0
diff --git a/dist/build/config.make b/dist/build/config.make
index 44f3c36..532bdf0 100644
--- a/dist/build/config.make
+++ b/dist/build/config.make
@@ -22,6 +22,8 @@ XSDE_SNPRINTF := $(strip $(XSDE_SNPRINTF))
XSDE_PARSER_VALIDATION := $(strip $(XSDE_PARSER_VALIDATION))
XSDE_SERIALIZER_VALIDATION := $(strip $(XSDE_SERIALIZER_VALIDATION))
XSDE_REUSE_STYLE := $(strip $(XSDE_REUSE_STYLE))
+XSDE_CDR := $(strip $(XSDE_CDR))
+XSDE_XDR := $(strip $(XSDE_XDR))
XSDE_POLYMORPHIC := $(strip $(XSDE_POLYMORPHIC))
XSDE_PARSER_SMAP_BUCKETS := $(strip $(XSDE_PARSER_SMAP_BUCKETS))
XSDE_PARSER_IMAP_BUCKETS := $(strip $(XSDE_PARSER_IMAP_BUCKETS))
diff --git a/dist/config/config.make b/dist/config/config.make
index b6c4212..0602490 100644
--- a/dist/config/config.make
+++ b/dist/config/config.make
@@ -95,6 +95,22 @@ XSDE_SERIALIZER_VALIDATION := y
XSDE_REUSE_STYLE := tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR := n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR := n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/config/config.nmake b/dist/config/config.nmake
index 6279c60..79e68d8 100644
--- a/dist/config/config.nmake
+++ b/dist/config/config.nmake
@@ -94,6 +94,22 @@ XSDE_SERIALIZER_VALIDATION = y
XSDE_REUSE_STYLE = tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR = n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR = n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/evc-4.0/config.nmake b/dist/etc/evc-4.0/config.nmake
index 78d5840..b42a80b 100644
--- a/dist/etc/evc-4.0/config.nmake
+++ b/dist/etc/evc-4.0/config.nmake
@@ -97,6 +97,22 @@ XSDE_SERIALIZER_VALIDATION = y
XSDE_REUSE_STYLE = tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR = n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR = n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/iphone/config-device.make b/dist/etc/iphone/config-device.make
index 84fd828..8fde555 100644
--- a/dist/etc/iphone/config-device.make
+++ b/dist/etc/iphone/config-device.make
@@ -102,6 +102,22 @@ XSDE_SERIALIZER_VALIDATION := y
XSDE_REUSE_STYLE := tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR := n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR := n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/iphone/config-simulator.make b/dist/etc/iphone/config-simulator.make
index fc9ab84..0f2853d 100644
--- a/dist/etc/iphone/config-simulator.make
+++ b/dist/etc/iphone/config-simulator.make
@@ -102,6 +102,22 @@ XSDE_SERIALIZER_VALIDATION := y
XSDE_REUSE_STYLE := tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR := n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR := n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/lynxos/config-4.2.make b/dist/etc/lynxos/config-4.2.make
index 56ff0e1..183566d 100644
--- a/dist/etc/lynxos/config-4.2.make
+++ b/dist/etc/lynxos/config-4.2.make
@@ -101,6 +101,22 @@ XSDE_SERIALIZER_VALIDATION := y
XSDE_REUSE_STYLE := tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR := n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR := n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/qnx/config-6.3-gcc-2.95.make b/dist/etc/qnx/config-6.3-gcc-2.95.make
index 0b4b28d..fe97e86 100644
--- a/dist/etc/qnx/config-6.3-gcc-2.95.make
+++ b/dist/etc/qnx/config-6.3-gcc-2.95.make
@@ -100,6 +100,22 @@ XSDE_SERIALIZER_VALIDATION := y
XSDE_REUSE_STYLE := tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR := n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR := n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/qnx/config-6.3-gcc-3.3.make b/dist/etc/qnx/config-6.3-gcc-3.3.make
index 80343c4..37345f6 100644
--- a/dist/etc/qnx/config-6.3-gcc-3.3.make
+++ b/dist/etc/qnx/config-6.3-gcc-3.3.make
@@ -100,6 +100,22 @@ XSDE_SERIALIZER_VALIDATION := y
XSDE_REUSE_STYLE := tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR := n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR := n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/qnx/config-6.4.make b/dist/etc/qnx/config-6.4.make
index d14e458..3d4f3b6 100644
--- a/dist/etc/qnx/config-6.4.make
+++ b/dist/etc/qnx/config-6.4.make
@@ -100,6 +100,22 @@ XSDE_SERIALIZER_VALIDATION := y
XSDE_REUSE_STYLE := tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR := n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR := n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/vc-8.0/config-max.nmake b/dist/etc/vc-8.0/config-max.nmake
index cd1e4a1..1fb78e5 100644
--- a/dist/etc/vc-8.0/config-max.nmake
+++ b/dist/etc/vc-8.0/config-max.nmake
@@ -98,6 +98,22 @@ XSDE_SERIALIZER_VALIDATION = y
XSDE_REUSE_STYLE = tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR = n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR = n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/vc-8.0/config-min.nmake b/dist/etc/vc-8.0/config-min.nmake
index b2f3c6d..2d4f742 100644
--- a/dist/etc/vc-8.0/config-min.nmake
+++ b/dist/etc/vc-8.0/config-min.nmake
@@ -98,6 +98,22 @@ XSDE_SERIALIZER_VALIDATION = y
XSDE_REUSE_STYLE = tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR = n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR = n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/vc-9.0/config-max.nmake b/dist/etc/vc-9.0/config-max.nmake
index 24bf39b..585ff0e 100644
--- a/dist/etc/vc-9.0/config-max.nmake
+++ b/dist/etc/vc-9.0/config-max.nmake
@@ -98,6 +98,22 @@ XSDE_SERIALIZER_VALIDATION = y
XSDE_REUSE_STYLE = tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR = n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR = n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/vc-9.0/config-min.nmake b/dist/etc/vc-9.0/config-min.nmake
index c085f97..1b141df 100644
--- a/dist/etc/vc-9.0/config-min.nmake
+++ b/dist/etc/vc-9.0/config-min.nmake
@@ -98,6 +98,22 @@ XSDE_SERIALIZER_VALIDATION = y
XSDE_REUSE_STYLE = tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR = n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR = n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/vxworks/config-5.5.1.make b/dist/etc/vxworks/config-5.5.1.make
index 2de4676..65d96ad 100644
--- a/dist/etc/vxworks/config-5.5.1.make
+++ b/dist/etc/vxworks/config-5.5.1.make
@@ -101,6 +101,22 @@ XSDE_SERIALIZER_VALIDATION := y
XSDE_REUSE_STYLE := tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR := n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR := n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/vxworks/config-max-6.4.make b/dist/etc/vxworks/config-6.4-max.make
index 5aa80e8..ac063e4 100644
--- a/dist/etc/vxworks/config-max-6.4.make
+++ b/dist/etc/vxworks/config-6.4-max.make
@@ -112,6 +112,22 @@ XSDE_SERIALIZER_VALIDATION := y
XSDE_REUSE_STYLE := tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR := n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR := n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/etc/vxworks/config-min-6.4.make b/dist/etc/vxworks/config-6.4-min.make
index 522771f..a9f9ba5 100644
--- a/dist/etc/vxworks/config-min-6.4.make
+++ b/dist/etc/vxworks/config-6.4-min.make
@@ -100,6 +100,22 @@ XSDE_SERIALIZER_VALIDATION := y
XSDE_REUSE_STYLE := tiein
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the CDR (Common Data Representation) binary format.
+# This functionality requires the ACE library.
+#
+XSDE_CDR := n
+
+
+# Set to 'y' if you want support for serialization of the C++/Hybrid
+# object model to the XDR (eXternal Data Representation) binary format.
+# This functionality requires the XDR API which is available out of the
+# box on most POSIX systems as part of Sun RPC. On other platforms you
+# may need to install a third-party library which provides the XDR API.
+#
+XSDE_XDR := n
+
+
# Set to 'y' if you need to handle XML vocabularies that use XML Schema
# polymorphism (xsi:type or substitution groups). Also don't forget to
# use either --generate-polymorphic (generates polymorphism-aware code)
diff --git a/dist/examples/cxx/hybrid/binary/cdr/makefile b/dist/examples/cxx/hybrid/binary/cdr/makefile
new file mode 100644
index 0000000..96c6274
--- /dev/null
+++ b/dist/examples/cxx/hybrid/binary/cdr/makefile
@@ -0,0 +1,58 @@
+root := ../../../../..
+
+include $(root)/build/cxx/rules.make
+
+override LIBS += -lACE
+
+# Build.
+#
+EXTRA_CPPFLAGS := -I$(root)/libxsde
+
+ifeq ($(XSDE_STL),n)
+EXTRA_XSDFLAGS += --no-stl
+endif
+
+ifeq ($(XSDE_LONGLONG),n)
+EXTRA_XSDFLAGS += --no-long-long
+endif
+
+ifeq ($(XSDE_PARSER_VALIDATION),n)
+EXTRA_XSDFLAGS += --suppress-validation
+endif
+
+ifeq ($(XSDE_REUSE_STYLE),mixin)
+EXTRA_XSDFLAGS += --reuse-style-mixin
+endif
+
+driver: driver.o library.o library-pskel.o library-pimpl.o \
+library-sskel.o library-simpl.o $(root)/libxsde/xsde/libxsde.a
+
+driver.o: driver.cxx library.hxx library-pimpl.hxx library-simpl.hxx
+library.o: library.cxx library.hxx
+library-pskel.o: library-pskel.cxx
+library-pimpl.o: library-pimpl.cxx
+library-simpl.o: library-simpl.cxx
+library-simpl.o: library-simpl.cxx
+
+.PRECIOUS: %.hxx %.cxx %-pskel.hxx %-pskel.cxx %-pimpl.hxx %-pimpl.cxx \
+%-sskel.hxx %-sskel.cxx %-simpl.hxx %-simpl.cxx
+
+%.hxx %.cxx %-pskel.hxx %-pskel.cxx %-pimpl.hxx %-pimpl.cxx \
+%-sskel.hxx %-sskel.cxx %-simpl.hxx %-simpl.cxx: %.xsd
+ $(root)/bin/xsde cxx-hybrid $(XSDFLAGS) $(EXTRA_XSDFLAGS) \
+--generate-parser --generate-serializer --generate-aggregate \
+--generate-insertion CDR --generate-extraction CDR $<
+
+# Test.
+#
+.PHONY: test
+test: driver library.xml
+ ./driver library.xml
+
+# Clean.
+#
+.PHONY: clean
+clean:
+ rm -f library-pimpl.?xx library-pskel.?xx library-simpl.?xx \
+library-sskel.?xx library.?xx library-pimpl.o library-pskel.o \
+library-simpl.o library-sskel.o library.o driver.o driver
diff --git a/dist/examples/cxx/hybrid/binary/cdr/nmakefile b/dist/examples/cxx/hybrid/binary/cdr/nmakefile
new file mode 100644
index 0000000..a87ded2
--- /dev/null
+++ b/dist/examples/cxx/hybrid/binary/cdr/nmakefile
@@ -0,0 +1,55 @@
+root = ..\..\..\..\..
+
+!include $(root)\build\cxx\rules.nmake
+
+LIBS = $(LIBS) ACE.lib
+
+# Build.
+#
+EXTRA_CPPFLAGS = /I$(root)\libxsde
+
+!if "$(XSDE_STL)" == "n"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
+!endif
+
+!if "$(XSDE_LONGLONG)" == "n"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
+!endif
+
+!if "$(XSDE_PARSER_VALIDATION)" == "n"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --suppress-validation
+!endif
+
+!if "$(XSDE_REUSE_STYLE)" == "mixin"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --reuse-style-mixin
+!endif
+
+driver.exe: driver.obj library.obj library-pskel.obj library-pimpl.obj \
+library-sskel.obj library-simpl.obj $(root)\libxsde\xsde\xsde.lib
+
+driver.obj: driver.cxx library.hxx library-pimpl.hxx library-simpl.hxx
+library.obj: library.cxx
+library-pskel.obj: library-pskel.cxx
+library-pimpl.obj: library-pimpl.cxx
+library-sskel.obj: library-sskel.cxx
+library-simpl.obj: library-simpl.cxx
+
+library.cxx library.hxx \
+library-pskel.cxx library-pskel.hxx library-pimpl.cxx library-pimpl.hxx \
+library-sskel.cxx library-sskel.hxx library-simpl.cxx library-simpl.hxx \
+: library.xsd
+ $(root)\bin\xsde.exe cxx-hybrid $(XSDFLAGS) $(EXTRA_XSDFLAGS) \
+--generate-parser --generate-serializer --generate-aggregate \
+--generate-insertion CDR --generate-extraction CDR library.xsd
+
+# Test.
+#
+test: driver.exe library.xml
+ .\driver.exe library.xml
+
+# Clean.
+#
+clean:
+ -del library-pimpl.?xx library-pskel.?xx library-simpl.?xx \
+library-sskel.?xx library.?xx library-pimpl.obj library-pskel.obj \
+library-simpl.obj library-sskel.obj library.obj driver.obj driver.exe
diff --git a/dist/examples/cxx/hybrid/binary/custom/makefile b/dist/examples/cxx/hybrid/binary/custom/makefile
new file mode 100644
index 0000000..c0e57ad
--- /dev/null
+++ b/dist/examples/cxx/hybrid/binary/custom/makefile
@@ -0,0 +1,70 @@
+root := ../../../../..
+
+include $(root)/build/cxx/rules.make
+
+# Build.
+#
+EXTRA_CPPFLAGS := -I$(root)/libxsde
+
+ifeq ($(XSDE_STL),n)
+EXTRA_XSDFLAGS += --no-stl
+endif
+
+ifeq ($(XSDE_LONGLONG),n)
+EXTRA_XSDFLAGS += --no-long-long
+endif
+
+ifeq ($(XSDE_PARSER_VALIDATION),n)
+EXTRA_XSDFLAGS += --suppress-validation
+endif
+
+ifeq ($(XSDE_REUSE_STYLE),mixin)
+EXTRA_XSDFLAGS += --reuse-style-mixin
+endif
+
+driver: driver.o library.o library-pskel.o library-pimpl.o \
+library-sskel.o library-simpl.o exceptions.o orawstream.o \
+irawstream.o $(root)/libxsde/xsde/libxsde.a
+
+driver.o: driver.cxx library.hxx library-pimpl.hxx library-simpl.hxx
+exceptions.o: exceptions.cxx
+orawstream.o: orawstream.cxx xml-schema.hxx
+irawstream.o: irawstream.cxx xml-schema.hxx
+library.o: library.cxx library.hxx
+library-pskel.o: library-pskel.cxx library-pskel.hxx
+library-pimpl.o: library-pimpl.cxx library-pskel.hxx
+library-simpl.o: library-simpl.cxx library-simpl.hxx
+library-simpl.o: library-simpl.cxx library-simpl.hxx
+
+library.hxx: xml-schema.hxx
+library-pskel.hxx: xml-schema-pskel.hxx
+library-pimpl.hxx: xml-schema-pskel.hxx
+library-sskel.hxx: xml-schema-sskel.hxx
+library-simpl.hxx: xml-schema-sskel.hxx
+
+.PRECIOUS: %.hxx %.cxx %-pskel.hxx %-pskel.cxx %-pimpl.hxx %-pimpl.cxx \
+%-sskel.hxx %-sskel.cxx %-simpl.hxx %-simpl.cxx
+
+xml-schema%hxx xml-schema-pskel%hxx xml-schema-sskel%hxx:
+ $(root)/bin/xsde cxx-hybrid $(XSDFLAGS) $(EXTRA_XSDFLAGS) \
+--generate-parser --generate-serializer --generate-xml-schema xml-schema.xsd
+
+%.hxx %.cxx %-pskel.hxx %-pskel.cxx %-pimpl.hxx %-pimpl.cxx \
+%-sskel.hxx %-sskel.cxx %-simpl.hxx %-simpl.cxx: %.xsd
+ $(root)/bin/xsde cxx-hybrid $(XSDFLAGS) $(EXTRA_XSDFLAGS) \
+--options-file options $<
+
+# Test.
+#
+.PHONY: test
+test: driver library.xml
+ ./driver library.xml
+
+# Clean.
+#
+.PHONY: clean
+clean:
+ rm -f xml-schema.hxx xml-schema-pskel.hxx xml-schema-sskel.hxx \
+library-pimpl.?xx library-pskel.?xx library-simpl.?xx library-sskel.?xx \
+library.?xx library-pimpl.o library-pskel.o library-simpl.o library-sskel.o \
+library.o irawstream.o orawstream.o exceptions.o driver.o driver
diff --git a/dist/examples/cxx/hybrid/binary/custom/nmakefile b/dist/examples/cxx/hybrid/binary/custom/nmakefile
new file mode 100644
index 0000000..b53db8e
--- /dev/null
+++ b/dist/examples/cxx/hybrid/binary/custom/nmakefile
@@ -0,0 +1,68 @@
+root = ..\..\..\..\..
+
+!include $(root)\build\cxx\rules.nmake
+
+# Build.
+#
+EXTRA_CPPFLAGS = /I$(root)\libxsde
+
+!if "$(XSDE_STL)" == "n"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
+!endif
+
+!if "$(XSDE_LONGLONG)" == "n"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
+!endif
+
+!if "$(XSDE_PARSER_VALIDATION)" == "n"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --suppress-validation
+!endif
+
+!if "$(XSDE_REUSE_STYLE)" == "mixin"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --reuse-style-mixin
+!endif
+
+driver.exe: driver.obj library.obj library-pskel.obj library-pimpl.obj \
+library-sskel.obj library-simpl.obj exceptions.obj orawstream.obj \
+irawstream.obj $(root)\libxsde\xsde\xsde.lib
+
+driver.obj: driver.cxx library.hxx library-pimpl.hxx library-simpl.hxx
+exceptions.obj: exceptions.cxx
+orawstream.obj: orawstream.cxx xml-schema.hxx
+irawstream.obj: irawstream.cxx xml-schema.hxx
+library.obj: library.cxx library.hxx
+library-pskel.obj: library-pskel.cxx library-pskel.hxx
+library-pimpl.obj: library-pimpl.cxx library-pskel.hxx
+library-simpl.obj: library-simpl.cxx library-simpl.hxx
+library-simpl.obj: library-simpl.cxx library-simpl.hxx
+
+library.hxx: xml-schema.hxx
+library-pskel.hxx: xml-schema-pskel.hxx
+library-sskel.hxx: xml-schema-sskel.hxx
+library-sskel.hxx: xml-schema-sskel.hxx
+library-simpl.hxx: xml-schema-sskel.hxx
+
+xml-schema.hxx xml-schema-pskel.hxx xml-schema-sskel.hxx:
+ $(root)\bin\xsde.exe cxx-hybrid $(XSDFLAGS) $(EXTRA_XSDFLAGS) \
+--generate-parser --generate-serializer --generate-xml-schema xml-schema.xsd
+
+library.cxx library.hxx \
+library-pskel.cxx library-pskel.hxx library-pimpl.cxx library-pimpl.hxx \
+library-sskel.cxx library-sskel.hxx library-simpl.cxx library-simpl.hxx \
+: library.xsd
+ $(root)\bin\xsde.exe cxx-hybrid $(XSDFLAGS) $(EXTRA_XSDFLAGS) \
+--options-file options library.xsd
+
+# Test.
+#
+test: driver.exe library.xml
+ .\driver.exe library.xml
+
+# Clean.
+#
+clean:
+ -del xml-schema.hxx xml-schema-pskel.hxx xml-schema-sskel.hxx \
+library-pimpl.?xx library-pskel.?xx library-simpl.?xx library-sskel.?xx \
+library.?xx library-pimpl.obj library-pskel.obj library-simpl.obj \
+library-sskel.obj library.obj irawstream.obj orawstream.obj exceptions.obj \
+driver.obj driver.exe
diff --git a/dist/examples/cxx/hybrid/binary/custom/options b/dist/examples/cxx/hybrid/binary/custom/options
new file mode 100644
index 0000000..f37d345
--- /dev/null
+++ b/dist/examples/cxx/hybrid/binary/custom/options
@@ -0,0 +1,8 @@
+--generate-parser
+--generate-serializer
+--generate-aggregate
+--generate-insertion orawstream
+--hxx-prologue #include "orawstream.hxx"
+--generate-extraction irawstream
+--hxx-prologue #include "irawstream.hxx"
+--extern-xml-schema xml-schema.xsd
diff --git a/dist/examples/cxx/hybrid/binary/makefile b/dist/examples/cxx/hybrid/binary/makefile
new file mode 100644
index 0000000..a683d0e
--- /dev/null
+++ b/dist/examples/cxx/hybrid/binary/makefile
@@ -0,0 +1,33 @@
+root := ../../../..
+
+include $(root)/build/config.make
+
+dirs :=
+
+ifeq ($(XSDE_IOSTREAM),y)
+ifeq ($(XSDE_EXCEPTIONS),y)
+
+dirs += custom
+
+ifeq ($(XSDE_CDR),y)
+dirs += cdr
+endif
+
+ifeq ($(XSDE_XDR),y)
+dirs += xdr
+endif
+
+endif
+endif
+
+.PHONY: all $(dirs)
+
+all: $(dirs)
+
+$(dirs):
+ @$(MAKE) -C $@ $(MAKECMDGOALS)
+
+makefile: ;
+%.make:: ;
+
+%:: $(dirs) ;
diff --git a/dist/examples/cxx/hybrid/binary/nmakefile b/dist/examples/cxx/hybrid/binary/nmakefile
new file mode 100644
index 0000000..384694a
--- /dev/null
+++ b/dist/examples/cxx/hybrid/binary/nmakefile
@@ -0,0 +1,29 @@
+root = ..\..\..\..
+
+!include $(root)\build\config.nmake
+
+dirs =
+
+!if "$(XSDE_IOSTREAM)" == "y"
+!if "$(XSDE_EXCEPTIONS)" == "y"
+
+dirs = $(dirs) custom
+
+!if "$(XSDE_CDR)" == "y"
+dirs = $(dirs) cdr
+!endif
+
+!if "$(XSDE_XDR)" == "y"
+dirs = $(dirs) xdr
+!endif
+
+!endif
+!endif
+
+all:
+ @for %i in ( $(dirs) ) do \
+@cmd /c "cd %i & $(MAKE) /nologo /f nmakefile"
+
+test clean:
+ @for %i in ( $(dirs) ) do \
+@cmd /c "cd %i & $(MAKE) /nologo /f nmakefile $@"
diff --git a/dist/examples/cxx/hybrid/binary/xdr/makefile b/dist/examples/cxx/hybrid/binary/xdr/makefile
new file mode 100644
index 0000000..95ceade
--- /dev/null
+++ b/dist/examples/cxx/hybrid/binary/xdr/makefile
@@ -0,0 +1,58 @@
+root := ../../../../..
+
+include $(root)/build/cxx/rules.make
+
+override LIBS += -lnsl
+
+# Build.
+#
+EXTRA_CPPFLAGS := -I$(root)/libxsde
+
+ifeq ($(XSDE_STL),n)
+EXTRA_XSDFLAGS += --no-stl
+endif
+
+ifeq ($(XSDE_LONGLONG),n)
+EXTRA_XSDFLAGS += --no-long-long
+endif
+
+ifeq ($(XSDE_PARSER_VALIDATION),n)
+EXTRA_XSDFLAGS += --suppress-validation
+endif
+
+ifeq ($(XSDE_REUSE_STYLE),mixin)
+EXTRA_XSDFLAGS += --reuse-style-mixin
+endif
+
+driver: driver.o library.o library-pskel.o library-pimpl.o \
+library-sskel.o library-simpl.o $(root)/libxsde/xsde/libxsde.a
+
+driver.o: driver.cxx library.hxx library-pimpl.hxx library-simpl.hxx
+library.o: library.cxx library.hxx
+library-pskel.o: library-pskel.cxx
+library-pimpl.o: library-pimpl.cxx
+library-simpl.o: library-simpl.cxx
+library-simpl.o: library-simpl.cxx
+
+.PRECIOUS: %.hxx %.cxx %-pskel.hxx %-pskel.cxx %-pimpl.hxx %-pimpl.cxx \
+%-sskel.hxx %-sskel.cxx %-simpl.hxx %-simpl.cxx
+
+%.hxx %.cxx %-pskel.hxx %-pskel.cxx %-pimpl.hxx %-pimpl.cxx \
+%-sskel.hxx %-sskel.cxx %-simpl.hxx %-simpl.cxx: %.xsd
+ $(root)/bin/xsde cxx-hybrid $(XSDFLAGS) $(EXTRA_XSDFLAGS) \
+--generate-parser --generate-serializer --generate-aggregate \
+--generate-insertion XDR --generate-extraction XDR $<
+
+# Test.
+#
+.PHONY: test
+test: driver library.xml
+ ./driver library.xml
+
+# Clean.
+#
+.PHONY: clean
+clean:
+ rm -f library-pimpl.?xx library-pskel.?xx library-simpl.?xx \
+library-sskel.?xx library.?xx library-pimpl.o library-pskel.o \
+library-simpl.o library-sskel.o library.o driver.o driver
diff --git a/dist/examples/cxx/hybrid/binary/xdr/nmakefile b/dist/examples/cxx/hybrid/binary/xdr/nmakefile
new file mode 100644
index 0000000..f71e178
--- /dev/null
+++ b/dist/examples/cxx/hybrid/binary/xdr/nmakefile
@@ -0,0 +1,53 @@
+root = ..\..\..\..\..
+
+!include $(root)\build\cxx\rules.nmake
+
+# Build.
+#
+EXTRA_CPPFLAGS = /I$(root)\libxsde
+
+!if "$(XSDE_STL)" == "n"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-stl
+!endif
+
+!if "$(XSDE_LONGLONG)" == "n"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --no-long-long
+!endif
+
+!if "$(XSDE_PARSER_VALIDATION)" == "n"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --suppress-validation
+!endif
+
+!if "$(XSDE_REUSE_STYLE)" == "mixin"
+EXTRA_XSDFLAGS = $(EXTRA_XSDFLAGS) --reuse-style-mixin
+!endif
+
+driver.exe: driver.obj library.obj library-pskel.obj library-pimpl.obj \
+library-sskel.obj library-simpl.obj $(root)\libxsde\xsde\xsde.lib
+
+driver.obj: driver.cxx library.hxx library-pimpl.hxx library-simpl.hxx
+library.obj: library.cxx
+library-pskel.obj: library-pskel.cxx
+library-pimpl.obj: library-pimpl.cxx
+library-sskel.obj: library-sskel.cxx
+library-simpl.obj: library-simpl.cxx
+
+library.cxx library.hxx \
+library-pskel.cxx library-pskel.hxx library-pimpl.cxx library-pimpl.hxx \
+library-sskel.cxx library-sskel.hxx library-simpl.cxx library-simpl.hxx \
+: library.xsd
+ $(root)\bin\xsde.exe cxx-hybrid $(XSDFLAGS) $(EXTRA_XSDFLAGS) \
+--generate-parser --generate-serializer --generate-aggregate \
+--generate-insertion XDR --generate-extraction XDR library.xsd
+
+# Test.
+#
+test: driver.exe library.xml
+ .\driver.exe library.xml
+
+# Clean.
+#
+clean:
+ -del library-pimpl.?xx library-pskel.?xx library-simpl.?xx \
+library-sskel.?xx library.?xx library-pimpl.obj library-pskel.obj \
+library-simpl.obj library-sskel.obj library.obj driver.obj driver.exe
diff --git a/dist/examples/cxx/hybrid/makefile b/dist/examples/cxx/hybrid/makefile
index fdcec1d..38ccd04 100644
--- a/dist/examples/cxx/hybrid/makefile
+++ b/dist/examples/cxx/hybrid/makefile
@@ -2,7 +2,7 @@ root := ../../..
include $(root)/build/config.make
-dirs := compositors
+dirs := binary compositors
ifeq ($(XSDE_IOSTREAM),y)
ifeq ($(XSDE_EXCEPTIONS),y)
diff --git a/dist/libxsde/xsde/makefile b/dist/libxsde/xsde/makefile
index 7ce4bdc..9120561 100644
--- a/dist/libxsde/xsde/makefile
+++ b/dist/libxsde/xsde/makefile
@@ -49,6 +49,25 @@ endif
##
src += cxx/hybrid/sequence.cxx
+ifeq ($(XSDE_CDR),y)
+src += \
+cxx/hybrid/cdr/exceptions.cxx \
+cxx/hybrid/cdr/istream.cxx \
+cxx/hybrid/cdr/ostream.cxx \
+cxx/hybrid/cdr/qname.cxx \
+cxx/hybrid/cdr/date-time.cxx \
+cxx/hybrid/cdr/string-sequence.cxx
+endif
+
+ifeq ($(XSDE_XDR),y)
+src += \
+cxx/hybrid/xdr/exceptions.cxx \
+cxx/hybrid/xdr/istream.cxx \
+cxx/hybrid/xdr/ostream.cxx \
+cxx/hybrid/xdr/qname.cxx \
+cxx/hybrid/xdr/date-time.cxx \
+cxx/hybrid/xdr/string-sequence.cxx
+endif
## C++/Parser
##
diff --git a/dist/libxsde/xsde/nmakefile b/dist/libxsde/xsde/nmakefile
index 5588d57..2e7e11a 100644
--- a/dist/libxsde/xsde/nmakefile
+++ b/dist/libxsde/xsde/nmakefile
@@ -51,6 +51,25 @@ src = $(src) cxx\xml\char-table.cxx cxx\xml\ncname.cxx
##
src = $(src) cxx\hybrid\sequence.cxx
+!if "$(XSDE_CDR)" == "y"
+src = $(src) \
+cxx\hybrid\cdr\exceptions.cxx \
+cxx\hybrid\cdr\istream.cxx \
+cxx\hybrid\cdr\ostream.cxx \
+cxx\hybrid\cdr\qname.cxx \
+cxx\hybrid\cdr\date-time.cxx \
+cxx\hybrid\cdr\string-sequence.cxx
+!endif
+
+!if "$(XSDE_XDR)" == "y"
+src = $(src) \
+cxx\hybrid\xdr\exceptions.cxx \
+cxx\hybrid\xdr\istream.cxx \
+cxx\hybrid\xdr\ostream.cxx \
+cxx\hybrid\xdr\qname.cxx \
+cxx\hybrid\xdr\date-time.cxx \
+cxx\hybrid\xdr\string-sequence.cxx
+!endif
## C++/Parser
##
diff --git a/documentation/cxx/hybrid/guide/index.xhtml b/documentation/cxx/hybrid/guide/index.xhtml
index b555009..9a95473 100644
--- a/documentation/cxx/hybrid/guide/index.xhtml
+++ b/documentation/cxx/hybrid/guide/index.xhtml
@@ -303,6 +303,16 @@
</td>
</tr>
+ <tr>
+ <th>7</th><td><a href="#7">Binary Representation</a>
+ <table class="toc">
+ <tr><th>7.1</th><td><a href="#7.1">CDR (Common Data Representation)</a></td></tr>
+ <tr><th>7.2</th><td><a href="#7.2">XDR (eXternal Data Representation)</a></td></tr>
+ <tr><th>7.3</th><td><a href="#7.3">Custom Representations</a></td></tr>
+ </table>
+ </td>
+ </tr>
+
</table>
</div>
@@ -398,6 +408,17 @@
that would otherwise not fit into memory.
</p>
+ <p>Besides reading from and writing to XML, the C++/Hybrid mapping
+ also supports saving the object model to and loading it from a
+ number of predefined as well as custom binary formats. Binary
+ representations contain only the data without any meta information
+ or markup. Consequently, saving to and loading from a binary
+ format can be an order of magnitude faster as well as result
+ in a much smaller footprint compared to parsing and serializing
+ the same data in XML. Furthermore, the resulting representation
+ is normally several times smaller than the equivalent XML
+ representation.</p>
+
<p>The Embedded C++/Hybrid mapping was specifically designed and
optimized for mobile and embedded systems where hardware
constraints require high efficiency and economical use of
@@ -5090,6 +5111,274 @@ age: 25
</pre>
+ <!-- Binary Representations -->
+
+ <h1><a name="7">7 Binary Representation</a></h1>
+
+ <p>Besides reading from and writing to XML, the C++/Hybrid mapping
+ also allows you to save the object model to and load it from a
+ number of predefined as well as custom data representation
+ formats. The predefined binary formats are CDR (Common Data
+ Representation) and XDR (eXternal Data Representation). A
+ custom format can easily be supported by providing
+ insertion and extraction operators for basic types.</p>
+
+ <p>Binary representations contain only the data without any meta
+ information or markup. Consequently, saving to and loading
+ from a binary representation can be an order of magnitude
+ faster as well as result in a much smaller footprint compared
+ to parsing and serializing the same data in XML. Furthermore,
+ the resulting representation is normally several times smaller
+ than the equivalent XML representation. These properties make a
+ binary representation ideal for internal data exchange and storage.
+ A typical application that uses this facility stores the data and
+ communicates within the system using a binary format and reads/writes
+ the data in XML when communicating with the outside world.</p>
+
+ <p>In order to request the generation of insertion and extraction
+ operators for a specific predefined or custom data representation
+ stream, you will need to use the <code>--generate-insertion</code>
+ and <code>--generate-extraction</code> compiler options. See the
+ <a href="http://www.codesynthesis.com/projects/xsde/documentation/xsde.xhtml">XSD/e
+ Compiler Command Line Manual</a> for more information.</p>
+
+ <p>The XSD/e runtime provides implementations of the base insertion
+ and extraction operators for the ACE (Adaptive Communication
+ Environment) CDR streams and the XDR API. The XDR API is available
+ out of the box on most POSIX systems as part of Sun RPC. On other
+ platforms you may need to install a third-party library which
+ provides the XDR API.
+
+ The XSD/e compiler recognizes two special argument values to the
+ <code>--generate-insertion</code> and <code>--generate-extraction</code>
+ options: <code>CDR</code> and <code>XDR</code>. When one of these
+ arguments is specified, the corresponding implementation from the
+ XSD/e runtime is automatically used. The following two sections
+ describe each of these two formats in more detail. It is also
+ possible to add support for saving the object model to and loading
+ it from custom data representation formats as discussed in the
+ last section of this chapter.</p>
+
+ <p>The saving of the object model types to a representation stream
+ is implemented with stream insertion operators
+ (<code>operator&lt;&lt;</code>). Similarly, loading of the object
+ model from a representation stream is implemented with stream
+ extraction operators (<code>operator>></code>). The insertion
+ and extraction operators for the built-in XML Schema types as
+ well as the sequence templates are provided by the stream
+ implementation (that is, by the XSD/e runtime in case of CDR and
+ XDR and by you for custom formats). The XSD/e compiler automatically
+ generates insertion and extraction operators for the generated object
+ model types.</p>
+
+ <p>When C++ exceptions are enabled (<a href="#3.3">Section 3.3, "C++
+ Exceptions"</a>), the signatures of the insertion and extraction
+ operators are as follows:</p>
+
+ <pre class="c++">
+void
+operator&lt;&lt; (ostream&amp;, const type&amp;);
+
+void
+operator>> (istream&amp;, type&amp;);
+ </pre>
+
+ <p>The insertion and extraction errors are indicated by throwing
+ stream-specific exceptions. When C++ exceptions are disabled,
+ the signatures of the insertion and extraction operators are
+ as follows:</p>
+
+ <pre class="c++">
+bool
+operator&lt;&lt; (ostream&amp;, const type&amp;);
+
+bool
+operator>> (istream&amp;, type&amp;);
+ </pre>
+
+ <p>In this case the insertion and extraction operators return
+ <code>true</code> if the operation was successful and
+ <code>false</code> otherwise. The stream object may
+ provide additional error information.</p>
+
+
+ <h2><a name="7.1">7.1 CDR (Common Data Representation)</a></h2>
+
+ <p>When you request the generation of CDR stream insertion and extraction
+ operators, the <code>ocdrstream</code> and <code>icdrstream</code>
+ types are defined in the <code>xml_schema</code> namespace. Additionally,
+ if C++ exceptions are enabled, the <code>cdr_exception</code> exception
+ is also defined in <code>xml_schema</code>. The <code>icdrstream</code>
+ and <code>ocdrstream</code> types are simple wrappers for the
+ ACE_InputCDR and ACE_OutputCDR streams. The following code fragment
+ shows how we can use these types when C++ exceptions are enabled:</p>
+
+ <pre class="c++">
+try
+{
+ const type&amp; x = ... // Object model.
+
+ // Save to a CDR stream.
+ //
+ ACE_OutputCDR ace_ocdr;
+ xml_schema::ocdrstream ocdr (ace_ocdr);
+
+ ocdr &lt;&lt; x;
+
+ // Load from a CDR stream.
+ //
+ ACE_InputCDR ace_icdr (buf, size);
+ xml_schema::icdrstream icdr (ace_icdr);
+
+ type copy;
+ icdr >> copy;
+}
+catch (const xml_schema::cdr_exception&amp;)
+{
+ cerr &lt;&lt; "CDR operation failed" &lt;&lt; endl;
+}
+ </pre>
+
+ <p>The same code fragment but when C++ exceptions are disabled:</p>
+
+ <pre class="c++">
+const type&amp; x = ... // Object model.
+
+// Save to a CDR stream.
+//
+ACE_OutputCDR ace_ocdr;
+xml_schema::ocdrstream ocdr (ace_ocdr);
+
+if (!(ocdr &lt;&lt; x))
+{
+ cerr &lt;&lt; "CDR operation failed" &lt;&lt; endl;
+}
+
+// Load from a CDR stream.
+//
+ACE_InputCDR ace_icdr (buf, size);
+xml_schema::icdrstream icdr (ace_icdr);
+
+type copy;
+
+if (!(icdr >> copy))
+{
+ cerr &lt;&lt; "CDR operation failed" &lt;&lt; endl;
+}
+ </pre>
+
+ <p>The <code>cdr</code> example which can be found in the
+ <code>examples/cxx/hybrid/binary/</code> directory of the XSD/e
+ distribution includes complete source code that shows how to
+ save the object model to and load it from the CDR format.</p>
+
+ <h2><a name="7.2">7.2 XDR (eXternal Data Representation)</a></h2>
+
+ <p>When you request the generation of XDR stream insertion and extraction
+ operators, the <code>oxdrstream</code> and <code>xcdrstream</code>
+ types are defined in the <code>xml_schema</code> namespace. Additionally,
+ if C++ exceptions are enabled, the <code>xdr_exception</code> exception
+ is also defined in <code>xml_schema</code>. The <code>ixdrstream</code>
+ and <code>oxdrstream</code> types are simple wrappers for the XDR
+ API. The following code fragment shows how we can use these types
+ when C++ exceptions are enabled:</p>
+
+ <pre class="c++">
+try
+{
+ const type&amp; x = ... // Object model.
+
+ // Save to a XDR stream.
+ //
+ XDR xdr;
+ xdrrec_create (&amp;xdr, ...);
+ xml_schema::oxdrstream oxdr (xdr);
+
+ oxdr &lt;&lt; x;
+
+ // Load from a XDR stream.
+ //
+ xdrrec_create (&amp;xdr, ...);
+ xml_schema::ixdrstream ixdr (xdr);
+
+ type copy;
+ ixdr >> copy;
+}
+catch (const xml_schema::xdr_exception&amp;)
+{
+ cerr &lt;&lt; "XDR operation failed" &lt;&lt; endl;
+}
+ </pre>
+
+ <p>The same code fragment but when C++ exceptions are disabled:</p>
+
+ <pre class="c++">
+const type&amp; x = ... // Object model.
+
+// Save to a XDR stream.
+//
+XDR xdr;
+xdrrec_create (&amp;xdr, ...);
+xml_schema::oxdrstream oxdr (xdr);
+
+if (!(oxdr &lt;&lt; x))
+{
+ cerr &lt;&lt; "XDR operation failed" &lt;&lt; endl;
+}
+
+// Load from a XDR stream.
+//
+xdrrec_create (&amp;xdr, ...);
+xml_schema::ixdrstream ixdr (xdr);
+
+type copy;
+
+if (!(ixdr >> copy))
+{
+ cerr &lt;&lt; "XDR operation failed" &lt;&lt; endl;
+}
+ </pre>
+
+ <p>The <code>xdr</code> example which can be found in the
+ <code>examples/cxx/hybrid/binary/</code> directory of the XSD/e
+ distribution includes complete source code that shows how to
+ save the object model to and load it from the XDR format.</p>
+
+
+ <h2><a name="7.3">7.3 Custom Representations</a></h2>
+
+ <p>To add support for saving the object model to and loading it
+ from a custom format, you will need to perform the following
+ general steps:</p>
+
+ <ol class="list">
+ <li>Generate a header file corresponding to the XML Schema
+ namespace using the <code>--generate-xml-schema</code>
+ compiler option.</li>
+
+ <li>Implement custom stream insertion and extraction operators
+ for the built-in XML Schema types and sequence templates.
+ Include the header file obtained in the previous step to
+ get definitions for these types.</li>
+
+ <li>Compile your schemas with the <code>--generate-insertion</code>
+ and <code>--generate-extraction</code> options. The arguments
+ to these options will be your custom output and input stream
+ types, respectively. Use the <code>--hxx-prologue</code>
+ option to include the definitions for these stream types
+ into the generated code. Also use the
+ <code>--extern-xml-schema</code> option to include the
+ header file obtained in the first step instead of generating
+ the same code directly.</li>
+ </ol>
+
+ <p>The <code>custom</code> example which can be found in the
+ <code>examples/cxx/hybrid/binary/</code> directory of the XSD/e
+ distribution includes complete source code that shows how to
+ save the object model to and load it from a custom format using
+ the raw binary representation as an example. You can use the
+ source code from this example as a base to implement support
+ for your own format.</p>
</div>
</div>
diff --git a/documentation/xsde.1 b/documentation/xsde.1
index 1f72eef..79a9179 100644
--- a/documentation/xsde.1
+++ b/documentation/xsde.1
@@ -944,6 +944,34 @@ Suppress the generation of validation code in parser.
.IP "\fB\--suppress-serializer-val\fR"
Suppress the generation of validation code in serializer.
+.IP "\fB\--generate-insertion \fIos\fR"
+Generate data representation stream insertion operators for the
+.I os
+output stream type. Repeat this option to specify more than one stream
+type. The special
+.B CDR
+and
+.B XDR
+arguments are recognized as ACE CDR and Sun RPC XDR stream types and the
+corresponding stream wrappers provided by the XSD/e runtime are automatically
+used. For custom stream types use the
+.B --hxx-prologue*
+options to include the necessary declarations.
+
+.IP "\fB\--generate-extraction \fIis\fR"
+Generate data representation stream extraction operators for the
+.I is
+input stream type. Repeat this option to specify more than one stream
+type. The special
+.B CDR
+and
+.B XDR
+arguments are recognized as ACE CDR and Sun RPC XDR stream types and the
+corresponding stream wrappers provided by the XSD/e runtime are automatically
+used. For custom stream types use the
+.B --hxx-prologue*
+options to include the necessary declarations.
+
.IP "\fB\--generate-forward\fR"
Generate forward declaration file.
diff --git a/documentation/xsde.xhtml b/documentation/xsde.xhtml
index ac01b91..d07197b 100644
--- a/documentation/xsde.xhtml
+++ b/documentation/xsde.xhtml
@@ -816,6 +816,28 @@
<dt><code><b>--suppress-serializer-val</b></code></dt>
<dd>Suppress the generation of validation code in serializer.</dd>
+ <dt><code><b>--generate-insertion</b> <i>os</i></code></dt>
+ <dd>Generate data representation stream insertion operators for
+ the <code><i>os</i></code> output stream type. Repeat this
+ option to specify more than one stream type. The special
+ <code><b>CDR</b></code> and <code><b>XDR</b></code> arguments
+ are recognized as ACE CDR and Sun RPC XDR stream types and
+ the corresponding stream wrappers provided by the XSD/e runtime
+ are automatically used. For custom stream types use the
+ <code><b>--hxx-prologue*</b></code> options to include the
+ necessary declarations.</dd>
+
+ <dt><code><b>--generate-extraction</b> <i>is</i></code></dt>
+ <dd>Generate data representation stream extraction operators for
+ the <code><i>is</i></code> input stream type. Repeat this
+ option to specify more than one stream type. The special
+ <code><b>CDR</b></code> and <code><b>XDR</b></code> arguments
+ are recognized as ACE CDR and Sun RPC XDR stream types and
+ the corresponding stream wrappers provided by the XSD/e runtime
+ are automatically used. For custom stream types use the
+ <code><b>--hxx-prologue*</b></code> options to include the
+ necessary declarations.</dd>
+
<dt><code><b>--generate-forward</b></code></dt>
<dd>Generate forward declaration file.</dd>
diff --git a/examples/cxx/hybrid/README b/examples/cxx/hybrid/README
index ee55a90..2008450 100644
--- a/examples/cxx/hybrid/README
+++ b/examples/cxx/hybrid/README
@@ -35,3 +35,7 @@ streaming
compositors
Shows how to create, access, and modify object models with complex
nested choice and sequence compositors.
+
+binary/
+ A collection of examples that show how to serialize the object model
+ into a number of predefined and custom binary formats.
diff --git a/examples/cxx/hybrid/binary/README b/examples/cxx/hybrid/binary/README
new file mode 100644
index 0000000..73e3491
--- /dev/null
+++ b/examples/cxx/hybrid/binary/README
@@ -0,0 +1,16 @@
+This directory contains a number of examples that show how to serialize
+the object model into a number of predefined and custom binary formats.
+The following list gives an overview of each example:
+
+cdr
+ Shows how to save/load the object model to/from CDR (Common Data
+ Representation) binary format using ACE CDR streams.
+
+xdr
+ Shows how to save/load the object model to/from XDR (eXternal Data
+ Representation) binary format using the XDR API provided as part of
+ Sun RPC.
+
+custom
+ Shows how to save/load the C++/Hybrid object model to/from a custom
+ format using the raw binary representation as an example.
diff --git a/examples/cxx/hybrid/binary/cdr/README b/examples/cxx/hybrid/binary/cdr/README
new file mode 100644
index 0000000..52045f0
--- /dev/null
+++ b/examples/cxx/hybrid/binary/cdr/README
@@ -0,0 +1,51 @@
+This example shows how to save/load the C++/Hybrid object model to/from
+CDR (Common Data Representation) binary format using ACE CDR streams.
+You will need the ACE library installed in order to build and run this
+example:
+
+http://www.cs.wustl.edu/~schmidt/ACE.html
+
+The example consists of the following files:
+
+library.xsd
+ XML Schema which describes a library of books.
+
+library.xml
+ Sample XML instance document.
+
+library.hxx
+library.cxx
+
+library-pskel.hxx
+library-pskel.cxx
+library-pimpl.hxx
+library-pimpl.cxx
+
+library-pskel.hxx
+library-pskel.cxx
+library-pimpl.hxx
+library-pimpl.cxx
+ Object model (the first pair of files), parser skeletons (the
+ second pair), parser implementations (the third pair), serializer
+ skeletons (the fourth pair), and serializer implementations (the
+ fifth pair). These files are generated by the XSD/e compiler from
+ library.xsd. The --generate-parser, --generate-serializer, and
+ --generate-aggregate options were used to request the generation
+ of the parsing and serialization code. The --generate-insertion and
+ --generate-extraction options were used to generate the insertion
+ and extraction operations for the CDR streams.
+
+driver.cxx
+ Driver for the example. It first calls the parser that constructs
+ the object model from the input XML file. It then saves the object
+ model to the CDR representation and loads it back. Finally, the
+ driver calls the serializer to serialize the loaded object model
+ back to XML.
+
+To run the example on the sample XML instance document simply execute:
+
+$ ./driver library.xml
+
+The example reads from STDIN if input file is not specified:
+
+$ ./driver <library.xml
diff --git a/examples/cxx/hybrid/binary/cdr/driver.cxx b/examples/cxx/hybrid/binary/cdr/driver.cxx
new file mode 100644
index 0000000..18848eb
--- /dev/null
+++ b/examples/cxx/hybrid/binary/cdr/driver.cxx
@@ -0,0 +1,128 @@
+// file : examples/cxx/hybrid/binary/cdr/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#include <string.h> // memcpy
+
+#include <memory> // std::auto_ptr
+#include <iostream>
+
+#include <ace/Log_Msg.h> // ACE_HEX_DUMP
+#include <ace/CDR_Stream.h>
+
+#include "library.hxx"
+#include "library-pimpl.hxx"
+#include "library-simpl.hxx"
+
+using std::cerr;
+using std::endl;
+
+int
+main (int argc, char* argv[])
+{
+ const char* input;
+
+ if (argc < 2)
+ {
+ input = "STDIN";
+ cerr << "XML file not specified, reading from STDIN" << endl;
+ }
+ else
+ input = argv[1];
+
+ try
+ {
+ using namespace library;
+
+ // Parse.
+ //
+ catalog_paggr catalog_p;
+
+ xml_schema::document_pimpl doc_p (
+ catalog_p.root_parser (),
+ catalog_p.root_namespace (),
+ catalog_p.root_name ());
+
+ catalog_p.pre ();
+
+ if (argc < 2)
+ doc_p.parse (std::cin);
+ else
+ doc_p.parse (argv[1]);
+
+ std::auto_ptr<catalog> c (catalog_p.post ());
+
+ // Save the object model to a CDR stream.
+ //
+ ACE_OutputCDR ace_ocdr;
+ xml_schema::ocdrstream ocdr (ace_ocdr);
+ ocdr << *c;
+
+ // Print the binary representation and at the same time save
+ // it into a continuous buffer.
+ //
+ cerr << "binary representation size: " << ace_ocdr.total_length () << endl
+ << endl;
+
+ xml_schema::buffer buf (ace_ocdr.total_length ());
+ char* data = buf.data ();
+
+ for (const ACE_Message_Block* mb = ace_ocdr.begin ();
+ mb != 0;
+ mb = mb->cont ())
+ {
+ memcpy (data, mb->rd_ptr (), mb->length ());
+ data += mb->length ();
+
+ ACE_HEX_DUMP ((LM_DEBUG, mb->rd_ptr (), mb->length ()));
+ }
+
+ // Load the object model from a CDR stream. Note that ACE_InputCDR
+ // expects the buffer to be properly aligned. Since our buffer is
+ // dynamically allocated, its alignment should be good enough.
+ //
+ ACE_InputCDR ace_icdr (buf.data (), buf.size ());
+ xml_schema::icdrstream icdr (ace_icdr);
+ std::auto_ptr<catalog> copy (new catalog);
+ icdr >> *copy;
+
+ // Serialize the copy back to XML.
+ //
+ catalog_saggr catalog_s;
+
+ xml_schema::document_simpl doc_s (
+ catalog_s.root_serializer (),
+ catalog_s.root_namespace (),
+ catalog_s.root_name ());
+
+ doc_s.add_prefix ("lib", "http://www.codesynthesis.com/library");
+ doc_s.add_schema ("http://www.codesynthesis.com/library", "library.xsd");
+
+ catalog_s.pre (*c);
+ doc_s.serialize (std::cout);
+ catalog_s.post ();
+ }
+ catch (const xml_schema::cdr_exception&)
+ {
+ cerr << "CDR operation failed" << endl;
+ return 1;
+ }
+ catch (const xml_schema::parser_exception& e)
+ {
+ cerr << input << ":" << e.line () << ":" << e.column () << ": "
+ << e.text () << endl;
+ return 1;
+ }
+ catch (const xml_schema::serializer_exception& e)
+ {
+ cerr << "error: " << e.text () << endl;
+ return 1;
+ }
+ catch (const std::ios_base::failure&)
+ {
+ cerr << input << ": unable to open or read/write failure" << endl;
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/examples/cxx/hybrid/binary/cdr/library.xml b/examples/cxx/hybrid/binary/cdr/library.xml
new file mode 100644
index 0000000..6bfb4d8
--- /dev/null
+++ b/examples/cxx/hybrid/binary/cdr/library.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+
+<!--
+
+file : examples/cxx/hybrid/binary/cdr/library.xml
+author : Boris Kolpackov <boris@codesynthesis.com>
+copyright : not copyrighted - public domain
+
+-->
+
+<lib:catalog xmlns:lib="http://www.codesynthesis.com/library"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.codesynthesis.com/library library.xsd">
+
+ <book available="false">
+ <isbn>0679760806</isbn>
+ <title>The Master and Margarita</title>
+ <genre>fiction</genre>
+
+ <author>
+ <name>Mikhail Bulgakov</name>
+ <born>1891-05-15</born>
+ <died>1940-03-10</died>
+ </author>
+ </book>
+
+
+ <book available="true" >
+ <isbn>0679600841</isbn>
+ <title>War and Peace</title>
+ <genre>history</genre>
+
+ <author>
+ <name>Leo Tolstoy</name>
+ <born>1828-09-09</born>
+ <died>1910-11-20</died>
+ </author>
+ </book>
+
+
+ <book available="false">
+ <isbn>0679420290</isbn>
+ <title>Crime and Punishment</title>
+ <genre>philosophy</genre>
+
+ <author>
+ <name>Fyodor Dostoevsky</name>
+ <born>1821-11-11</born>
+ <died>1881-02-09</died>
+ </author>
+ </book>
+
+</lib:catalog>
diff --git a/examples/cxx/hybrid/binary/cdr/library.xsd b/examples/cxx/hybrid/binary/cdr/library.xsd
new file mode 100644
index 0000000..0b0d9d1
--- /dev/null
+++ b/examples/cxx/hybrid/binary/cdr/library.xsd
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+
+<!--
+
+file : examples/cxx/hybrid/binary/cdr/library.xsd
+author : Boris Kolpackov <boris@codesynthesis.com>
+copyright : not copyrighted - public domain
+
+-->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:lib="http://www.codesynthesis.com/library"
+ targetNamespace="http://www.codesynthesis.com/library">
+
+ <xsd:simpleType name="isbn">
+ <xsd:restriction base="xsd:unsignedInt"/>
+ </xsd:simpleType>
+
+
+ <xsd:complexType name="title">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="lang" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+
+ <xsd:simpleType name="genre">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="romance"/>
+ <xsd:enumeration value="fiction"/>
+ <xsd:enumeration value="horror"/>
+ <xsd:enumeration value="history"/>
+ <xsd:enumeration value="philosophy"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <xsd:complexType name="author">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="born" type="xsd:date"/>
+ <xsd:element name="died" type="xsd:date" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="book">
+ <xsd:sequence>
+ <xsd:element name="isbn" type="lib:isbn"/>
+ <xsd:element name="title" type="lib:title"/>
+ <xsd:element name="genre" type="lib:genre"/>
+ <xsd:element name="author" type="lib:author" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="available" type="xsd:boolean" use="required"/>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="catalog">
+ <xsd:sequence>
+ <xsd:element name="book" type="lib:book" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:element name="catalog" type="lib:catalog"/>
+
+</xsd:schema>
diff --git a/examples/cxx/hybrid/binary/cdr/makefile b/examples/cxx/hybrid/binary/cdr/makefile
new file mode 100644
index 0000000..eba1c77
--- /dev/null
+++ b/examples/cxx/hybrid/binary/cdr/makefile
@@ -0,0 +1,112 @@
+# file : examples/cxx/hybrid/binary/cdr/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make
+
+xsd := library.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+dist := $(out_base)/.dist
+dist-win := $(out_base)/.dist-win
+clean := $(out_base)/.clean
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.cxx) \
+ $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.cxx) \
+ $(xsd:.xsd=-pimpl.hxx) $(xsd:.xsd=-pimpl.cxx) \
+ $(xsd:.xsd=-sskel.hxx) $(xsd:.xsd=-sskel.cxx) \
+ $(xsd:.xsd=-simpl.hxx) $(xsd:.xsd=-simpl.cxx)
+
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen): xsde_options += --generate-parser --generate-serializer \
+--generate-aggregate --generate-insertion CDR --generate-extraction CDR
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Dist.
+#
+dist-common := $(out_base)/.dist-common
+
+.PHONY: $(dist) $(dist-win) $(dist-common)
+
+$(dist) $(dist-win) $(dist-common): path := $(subst $(src_root)/,,$(src_base))
+
+$(dist-common):
+ $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx)
+ $(call install-data,$(src_base)/library.xsd,$(dist_prefix)/$(path)/library.xsd)
+ $(call install-data,$(src_base)/library.xml,$(dist_prefix)/$(path)/library.xml)
+
+$(dist): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README)
+
+$(dist-win): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt)
+ $(call message,,unix2dos $(dist_prefix)/$(path)/README.txt)
+
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(bld_root)/install.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/examples/cxx/hybrid/binary/custom/README b/examples/cxx/hybrid/binary/custom/README
new file mode 100644
index 0000000..b7475d8
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/README
@@ -0,0 +1,77 @@
+This example shows how to save/load the C++/Hybrid object model to/from
+a custom format using the raw binary representation as an example. Note
+that if you would like to use this format in your applications, make sure
+that all the targets use exactly the same base type sizes (e.g., int, long,
+float, double, size_t, etc.) and byte order.
+
+The example consists of the following files:
+
+library.xsd
+ XML Schema which describes a library of books.
+
+library.xml
+ Sample XML instance document.
+
+xml-schema.hxx
+xml-schema-pskel.hxx
+xml-schema-sskel.hxx
+ Base object model types (the first file), parser skeletons (the second
+ file), and serializer skeletons (the third file) for the XML Schema
+ built-in types. These header files are generated by the XSD/e compiler
+ using the --generate-xml-schema option. The --generate-parser and
+ --generate-serializer options were also specified.
+
+irawstream.hxx
+irawstream.ixx
+irawstream.txx
+irawstream.cxx
+
+orawstream.hxx
+orawstream.ixx
+orawstream.txx
+orawstream.cxx
+ Implementation of the raw binary representation streams. The header
+ files include xml-schema.hxx to gain access to the base object model
+ types. You can use this implementation as a base for your custom
+ format.
+
+library.hxx
+library.cxx
+
+library-pskel.hxx
+library-pskel.cxx
+library-pimpl.hxx
+library-pimpl.cxx
+
+library-pskel.hxx
+library-pskel.cxx
+library-pimpl.hxx
+library-pimpl.cxx
+ Object model (the first pair of files), parser skeletons (the second
+ pair), parser implementations (the third pair), serializer skeletons
+ (the fourth pair), and serializer implementations (the fifth pair).
+ These files are generated by the XSD/e compiler from library.xsd. The
+ --generate-parser, --generate-serializer, and --generate-aggregate
+ options were used to request the generation of the parsing and
+ serialization code. The --generate-insertion and --generate-extraction
+ options were used to generate the insertion and extraction operations
+ for the orawstream and irawstream, respectively. The --hxx-prologue
+ option was used to include the orawstream.hxx and irawstream.hxx
+ header files at the beginning of library.hxx. Finally, the
+ --extern-xml-schema option was used to include xml-schema* files
+ instead of generating the same code directly.
+
+driver.cxx
+ Driver for the example. It first calls the parser that constructs
+ the object model from the input XML file. It then saves the object
+ model to the raw binary representation and loads it back. Finally,
+ the driver calls the serializer to serialize the loaded object model
+ back to XML.
+
+To run the example on the sample XML instance document simply execute:
+
+$ ./driver library.xml
+
+The example reads from STDIN if input file is not specified:
+
+$ ./driver <library.xml
diff --git a/examples/cxx/hybrid/binary/custom/driver.cxx b/examples/cxx/hybrid/binary/custom/driver.cxx
new file mode 100644
index 0000000..e453a37
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/driver.cxx
@@ -0,0 +1,107 @@
+// file : examples/cxx/hybrid/binary/custom/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#include <memory> // std::auto_ptr
+#include <iostream>
+
+#include "orawstream.hxx"
+#include "irawstream.hxx"
+
+#include "library.hxx"
+#include "library-pimpl.hxx"
+#include "library-simpl.hxx"
+
+using std::cerr;
+using std::endl;
+
+int
+main (int argc, char* argv[])
+{
+ const char* input;
+
+ if (argc < 2)
+ {
+ input = "STDIN";
+ cerr << "XML file not specified, reading from STDIN" << endl;
+ }
+ else
+ input = argv[1];
+
+ try
+ {
+ using namespace library;
+
+ // Parse.
+ //
+ catalog_paggr catalog_p;
+
+ xml_schema::document_pimpl doc_p (
+ catalog_p.root_parser (),
+ catalog_p.root_namespace (),
+ catalog_p.root_name ());
+
+ catalog_p.pre ();
+
+ if (argc < 2)
+ doc_p.parse (std::cin);
+ else
+ doc_p.parse (argv[1]);
+
+ std::auto_ptr<catalog> c (catalog_p.post ());
+
+ // Save the object model to a RAW stream.
+ //
+ xml_schema::buffer buf;
+ orawstream oraw (buf);
+ oraw << *c;
+
+ cerr << "binary representation size: " << buf.size () << endl
+ << endl;
+
+ // Load the object model from a RAW stream.
+ //
+ irawstream iraw (buf);
+ std::auto_ptr<catalog> copy (new catalog);
+ iraw >> *copy;
+
+ // Serialize the copy back to XML.
+ //
+ catalog_saggr catalog_s;
+
+ xml_schema::document_simpl doc_s (
+ catalog_s.root_serializer (),
+ catalog_s.root_namespace (),
+ catalog_s.root_name ());
+
+ doc_s.add_prefix ("lib", "http://www.codesynthesis.com/library");
+ doc_s.add_schema ("http://www.codesynthesis.com/library", "library.xsd");
+
+ catalog_s.pre (*c);
+ doc_s.serialize (std::cout);
+ catalog_s.post ();
+ }
+ catch (const raw_exception&)
+ {
+ cerr << "RAW stream operation failed" << endl;
+ return 1;
+ }
+ catch (const xml_schema::parser_exception& e)
+ {
+ cerr << input << ":" << e.line () << ":" << e.column () << ": "
+ << e.text () << endl;
+ return 1;
+ }
+ catch (const xml_schema::serializer_exception& e)
+ {
+ cerr << "error: " << e.text () << endl;
+ return 1;
+ }
+ catch (const std::ios_base::failure&)
+ {
+ cerr << input << ": unable to open or read/write failure" << endl;
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/examples/cxx/hybrid/binary/custom/exceptions.cxx b/examples/cxx/hybrid/binary/custom/exceptions.cxx
new file mode 100644
index 0000000..0ad8c4b
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/exceptions.cxx
@@ -0,0 +1,11 @@
+// file : examples/cxx/hybrid/binary/custom/exceptions.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#include "exceptions.hxx"
+
+const char* raw_exception::
+what () const throw ()
+{
+ return "RAW stream operation failed";
+}
diff --git a/examples/cxx/hybrid/binary/custom/exceptions.hxx b/examples/cxx/hybrid/binary/custom/exceptions.hxx
new file mode 100644
index 0000000..0111799
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/exceptions.hxx
@@ -0,0 +1,16 @@
+// file : examples/cxx/hybrid/binary/custom/exceptions.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#ifndef EXCEPTIONS_HXX
+#define EXCEPTIONS_HXX
+
+#include <exception> // std::exception
+
+struct raw_exception: std::exception
+{
+ virtual const char*
+ what () const throw ();
+};
+
+#endif // EXCEPTIONS_HXX
diff --git a/examples/cxx/hybrid/binary/custom/irawstream.cxx b/examples/cxx/hybrid/binary/custom/irawstream.cxx
new file mode 100644
index 0000000..d3d6aae
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/irawstream.cxx
@@ -0,0 +1,296 @@
+// file : examples/cxx/hybrid/binary/custom/irawstream.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#include <string.h> // memcpy
+
+#include "irawstream.hxx"
+
+using namespace xml_schema;
+
+const char* irawstream::
+align (size_t a, size_t n)
+{
+ size_t r = pos_ % a;
+
+ if (r)
+ n += a - r;
+
+ if (buf_.size () - pos_ < n)
+ throw raw_exception ();
+
+ const char* p = buf_.data () + pos_;
+
+ if (r)
+ p += a - r;
+
+ pos_ += n;
+ return p;
+}
+
+void irawstream::
+operator>> (std::string& x)
+{
+ size_t n = *reinterpret_cast<const size_t*> (
+ align (sizeof (size_t), sizeof (size_t)));
+
+ x.clear ();
+
+ if (n != 0)
+ {
+ x.resize (n);
+ memcpy (const_cast<char*> (x.c_str ()), align (1, n), n);
+ }
+}
+
+void irawstream::
+operator>> (buffer& x)
+{
+ size_t n = *reinterpret_cast<const size_t*> (
+ align (sizeof (size_t), sizeof (size_t)));
+
+ x.size (n);
+
+ if (n != 0)
+ memcpy (x.data (), align (1, n), n);
+}
+
+void
+operator>> (irawstream& s, str_seq& x)
+{
+ size_t n;
+ irawstream::as_size as_size (n);
+ s >> as_size;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ x.reserve (n);
+ std::string i;
+
+ while (n--)
+ {
+ s >> i;
+ x.push_back (i);
+ }
+ }
+}
+
+void
+operator>> (irawstream& s, qname& x)
+{
+ std::string p, n;
+
+ s >> p;
+ s >> n;
+
+ x.prefix (p);
+ x.name (n);
+}
+
+void
+operator>> (irawstream& s, time_zone& x)
+{
+ short h, m;
+ s >> h;
+ s >> m;
+
+ x.zone_hours (h);
+ x.zone_minutes (m);
+}
+
+void
+operator>> (irawstream& s, date& x)
+{
+ int y;
+ unsigned short m, d;
+ bool zp;
+
+ s >> y;
+ s >> m;
+ s >> d;
+ s >> zp;
+
+ x.year (y);
+ x.month (m);
+ x.day (d);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+}
+
+void
+operator>> (irawstream& s, date_time& x)
+{
+ int y;
+ unsigned short m, d, h, mi;
+ double se;
+ bool zp;
+
+ s >> y;
+ s >> m;
+ s >> d;
+ s >> h;
+ s >> mi;
+ s >> se;
+ s >> zp;
+
+ x.year (y);
+ x.month (m);
+ x.day (d);
+ x.hours (h);
+ x.minutes (mi);
+ x.seconds (se);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+}
+
+void
+operator>> (irawstream& s, duration& x)
+{
+ bool n;
+ unsigned int y, m, d, h, mi;
+ double se;
+
+ s >> n;
+ s >> y;
+ s >> m;
+ s >> d;
+ s >> h;
+ s >> mi;
+ s >> se;
+
+ x.negative (n);
+ x.years (y);
+ x.months (m);
+ x.days (d);
+ x.hours (h);
+ x.minutes (mi);
+ x.seconds (se);
+}
+
+void
+operator>> (irawstream& s, gday& x)
+{
+ unsigned short d;
+ bool zp;
+
+ s >> d;
+ s >> zp;
+
+ x.day (d);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+}
+
+void
+operator>> (irawstream& s, gmonth& x)
+{
+ unsigned short m;
+ bool zp;
+
+ s >> m;
+ s >> zp;
+
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+}
+
+void
+operator>> (irawstream& s, gmonth_day& x)
+{
+ unsigned short d, m;
+ bool zp;
+
+ s >> d;
+ s >> m;
+ s >> zp;
+
+ x.day (d);
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+}
+
+void
+operator>> (irawstream& s, gyear& x)
+{
+ int y;
+ bool zp;
+
+ s >> y;
+ s >> zp;
+
+ x.year (y);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+}
+
+void
+operator>> (irawstream& s, gyear_month& x)
+{
+ int y;
+ unsigned short m;
+ bool zp;
+
+ s >> y;
+ s >> m;
+ s >> zp;
+
+ x.year (y);
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+}
+
+void
+operator>> (irawstream& s, xml_schema::time& x)
+{
+ unsigned short h, m;
+ double se;
+ bool zp;
+
+ s >> h;
+ s >> m;
+ s >> se;
+ s >> zp;
+
+ x.hours (h);
+ x.minutes (m);
+ x.seconds (se);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+}
diff --git a/examples/cxx/hybrid/binary/custom/irawstream.hxx b/examples/cxx/hybrid/binary/custom/irawstream.hxx
new file mode 100644
index 0000000..94d2382
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/irawstream.hxx
@@ -0,0 +1,92 @@
+// file : examples/cxx/hybrid/binary/custom/irawstream.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#ifndef IRAWSTREAM_HXX
+#define IRAWSTREAM_HXX
+
+#include <stddef.h> // size_t
+
+#include <string>
+
+#include "exceptions.hxx"
+#include "xml-schema.hxx"
+
+class irawstream
+{
+public:
+ explicit
+ irawstream (const xml_schema::buffer&, size_t start = 0);
+
+public:
+ struct as_size
+ {
+ explicit as_size (size_t& s) : s_ (s) {}
+ size_t& s_;
+ };
+
+public:
+ void operator>> (bool&);
+ void operator>> (signed char&);
+ void operator>> (unsigned char&);
+ void operator>> (short&);
+ void operator>> (unsigned short&);
+ void operator>> (int&);
+ void operator>> (unsigned int&);
+ void operator>> (long&);
+ void operator>> (unsigned long&);
+
+#ifdef XSDE_LONGLONG
+ void operator>> (long long&);
+ void operator>> (unsigned long long&);
+#endif
+
+ void operator>> (as_size&);
+ void operator>> (float&);
+ void operator>> (double&);
+
+ void operator>> (std::string&);
+ void operator>> (xml_schema::buffer&);
+
+private:
+ irawstream (const irawstream&);
+ irawstream& operator= (const irawstream&);
+
+public:
+ const char*
+ align (size_t alignment, size_t size);
+
+private:
+ const xml_schema::buffer& buf_;
+ size_t pos_;
+};
+
+void operator>> (irawstream&, xml_schema::any_type&);
+void operator>> (irawstream&, xml_schema::any_simple_type&);
+void operator>> (irawstream&, xml_schema::qname&);
+void operator>> (irawstream&, xml_schema::time_zone&);
+void operator>> (irawstream&, xml_schema::date&);
+void operator>> (irawstream&, xml_schema::date_time&);
+void operator>> (irawstream&, xml_schema::duration&);
+void operator>> (irawstream&, xml_schema::gday&);
+void operator>> (irawstream&, xml_schema::gmonth&);
+void operator>> (irawstream&, xml_schema::gmonth_day&);
+void operator>> (irawstream&, xml_schema::gyear&);
+void operator>> (irawstream&, xml_schema::gyear_month&);
+void operator>> (irawstream&, xml_schema::time&);
+
+void operator>> (irawstream&, xml_schema::str_seq&);
+
+template <typename T>
+void operator>> (irawstream&, xml_schema::pod_seq<T>&);
+
+template <typename T>
+void operator>> (irawstream&, xml_schema::fix_seq<T>&);
+
+template <typename T>
+void operator>> (irawstream&, xml_schema::var_seq<T>&);
+
+#include "irawstream.ixx"
+#include "irawstream.txx"
+
+#endif // IRAWSTREAM_HXX
diff --git a/examples/cxx/hybrid/binary/custom/irawstream.ixx b/examples/cxx/hybrid/binary/custom/irawstream.ixx
new file mode 100644
index 0000000..bc9ff9a
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/irawstream.ixx
@@ -0,0 +1,110 @@
+// file : examples/cxx/hybrid/binary/custom/irawstream.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+inline irawstream::
+irawstream (const xml_schema::buffer& buf, size_t start)
+ : buf_ (buf), pos_ (start)
+{
+}
+
+inline void irawstream::
+operator>> (bool& x)
+{
+ x = *align (1, 1);
+}
+
+inline void irawstream::
+operator>> (signed char& x)
+{
+ x = *reinterpret_cast<const signed char*> (align (1, 1));
+}
+
+inline void irawstream::
+operator>> (unsigned char& x)
+{
+ x = *reinterpret_cast<const unsigned char*> (align (1, 1));
+}
+
+inline void irawstream::
+operator>> (short& x)
+{
+ x = *reinterpret_cast<const short*> (align (2, 2));
+}
+
+inline void irawstream::
+operator>> (unsigned short& x)
+{
+ x = *reinterpret_cast<const unsigned short*> (align (2, 2));
+}
+
+inline void irawstream::
+operator>> (int& x)
+{
+ x = *reinterpret_cast<const int*> (align (4, 4));
+}
+
+inline void irawstream::
+operator>> (unsigned int& x)
+{
+ x = *reinterpret_cast<const unsigned int*> (align (4, 4));
+}
+
+inline void irawstream::
+operator>> (long& x)
+{
+ x = *reinterpret_cast<const long*> (
+ align (sizeof (long), sizeof (long)));
+}
+
+inline void irawstream::
+operator>> (unsigned long& x)
+{
+ x = *reinterpret_cast<const unsigned long*> (
+ align (sizeof (unsigned long), sizeof (unsigned long)));
+}
+
+#ifdef XSDE_LONGLONG
+inline void irawstream::
+operator>> (long long& x)
+{
+ x = *reinterpret_cast<const long long*> (align (8, 8));
+}
+
+inline void irawstream::
+operator>> (unsigned long long& x)
+{
+ x = *reinterpret_cast<const unsigned long long*> (align (8, 8));
+}
+#endif
+
+inline void irawstream::
+operator>> (as_size& x)
+{
+ x.s_ = *reinterpret_cast<const size_t*> (
+ align (sizeof (size_t), sizeof (size_t)));
+}
+
+inline void irawstream::
+operator>> (float& x)
+{
+ x = *reinterpret_cast<const float*> (
+ align (sizeof (float), sizeof (float)));
+}
+
+inline void irawstream::
+operator>> (double& x)
+{
+ x = *reinterpret_cast<const double*> (
+ align (sizeof (double), sizeof (double)));
+}
+
+inline void
+operator>> (irawstream&, xml_schema::any_type&)
+{
+}
+
+inline void
+operator>> (irawstream&, xml_schema::any_simple_type&)
+{
+}
diff --git a/examples/cxx/hybrid/binary/custom/irawstream.txx b/examples/cxx/hybrid/binary/custom/irawstream.txx
new file mode 100644
index 0000000..2d4965e
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/irawstream.txx
@@ -0,0 +1,72 @@
+// file : examples/cxx/hybrid/binary/custom/irawostream.txx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#include <string.h> // memcpy
+
+template <typename T>
+void
+operator>> (irawstream& s, xml_schema::pod_seq<T>& x)
+{
+ size_t n;
+ irawstream::as_size as_size (n);
+ s >> as_size;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ x.reserve (n);
+ size_t mn = sizeof (T) * n;
+ memcpy (x.data_, s.align (sizeof (T), mn), mn);
+ x.size_ = n;
+ }
+}
+
+template <typename T>
+void
+operator>> (irawstream& s, xml_schema::fix_seq<T>& x)
+{
+ size_t n;
+ irawstream::as_size as_size (n);
+ s >> as_size;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ x.reserve (n);
+
+ while (n--)
+ {
+ T i;
+ s >> i;
+ x.push_back (i);
+ }
+ }
+}
+
+template <typename T>
+void
+operator>> (irawstream& s, xml_schema::var_seq<T>& x)
+{
+ size_t n;
+ irawstream::as_size as_size (n);
+ s >> as_size;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ x.reserve (n);
+
+ while (n--)
+ {
+ T* p = new T;
+ typename xml_schema::var_seq<T>::guard g (p);
+ s >> *p;
+ g.release ();
+ x.push_back (p);
+ }
+ }
+}
diff --git a/examples/cxx/hybrid/binary/custom/library.xml b/examples/cxx/hybrid/binary/custom/library.xml
new file mode 100644
index 0000000..e93bab4
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/library.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+
+<!--
+
+file : examples/cxx/hybrid/binary/custom/library.xml
+author : Boris Kolpackov <boris@codesynthesis.com>
+copyright : not copyrighted - public domain
+
+-->
+
+<lib:catalog xmlns:lib="http://www.codesynthesis.com/library"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.codesynthesis.com/library library.xsd">
+
+ <book available="false">
+ <isbn>0679760806</isbn>
+ <title>The Master and Margarita</title>
+ <genre>fiction</genre>
+
+ <author>
+ <name>Mikhail Bulgakov</name>
+ <born>1891-05-15</born>
+ <died>1940-03-10</died>
+ </author>
+ </book>
+
+
+ <book available="true" >
+ <isbn>0679600841</isbn>
+ <title>War and Peace</title>
+ <genre>history</genre>
+
+ <author>
+ <name>Leo Tolstoy</name>
+ <born>1828-09-09</born>
+ <died>1910-11-20</died>
+ </author>
+ </book>
+
+
+ <book available="false">
+ <isbn>0679420290</isbn>
+ <title>Crime and Punishment</title>
+ <genre>philosophy</genre>
+
+ <author>
+ <name>Fyodor Dostoevsky</name>
+ <born>1821-11-11</born>
+ <died>1881-02-09</died>
+ </author>
+ </book>
+
+</lib:catalog>
diff --git a/examples/cxx/hybrid/binary/custom/library.xsd b/examples/cxx/hybrid/binary/custom/library.xsd
new file mode 100644
index 0000000..7b75c2d
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/library.xsd
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+
+<!--
+
+file : examples/cxx/hybrid/binary/custom/library.xsd
+author : Boris Kolpackov <boris@codesynthesis.com>
+copyright : not copyrighted - public domain
+
+-->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:lib="http://www.codesynthesis.com/library"
+ targetNamespace="http://www.codesynthesis.com/library">
+
+ <xsd:simpleType name="isbn">
+ <xsd:restriction base="xsd:unsignedInt"/>
+ </xsd:simpleType>
+
+
+ <xsd:complexType name="title">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="lang" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+
+ <xsd:simpleType name="genre">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="romance"/>
+ <xsd:enumeration value="fiction"/>
+ <xsd:enumeration value="horror"/>
+ <xsd:enumeration value="history"/>
+ <xsd:enumeration value="philosophy"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <xsd:complexType name="author">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="born" type="xsd:date"/>
+ <xsd:element name="died" type="xsd:date" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="book">
+ <xsd:sequence>
+ <xsd:element name="isbn" type="lib:isbn"/>
+ <xsd:element name="title" type="lib:title"/>
+ <xsd:element name="genre" type="lib:genre"/>
+ <xsd:element name="author" type="lib:author" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="available" type="xsd:boolean" use="required"/>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="catalog">
+ <xsd:sequence>
+ <xsd:element name="book" type="lib:book" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:element name="catalog" type="lib:catalog"/>
+
+</xsd:schema>
diff --git a/examples/cxx/hybrid/binary/custom/makefile b/examples/cxx/hybrid/binary/custom/makefile
new file mode 100644
index 0000000..7ab91d0
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/makefile
@@ -0,0 +1,138 @@
+# file : examples/cxx/hybrid/binary/custom/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make
+
+xsd := library.xsd
+cxx := driver.cxx exceptions.cxx orawstream.cxx irawstream.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+dist := $(out_base)/.dist
+dist-win := $(out_base)/.dist-win
+clean := $(out_base)/.clean
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.cxx) \
+ $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.cxx) \
+ $(xsd:.xsd=-pimpl.hxx) $(xsd:.xsd=-pimpl.cxx) \
+ $(xsd:.xsd=-sskel.hxx) $(xsd:.xsd=-sskel.cxx) \
+ $(xsd:.xsd=-simpl.hxx) $(xsd:.xsd=-simpl.cxx)
+
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen): xsde_options += --generate-parser --generate-serializer \
+--generate-aggregate --extern-xml-schema xml-schema.xsd \
+--generate-insertion orawstream --hxx-prologue '\\\#include "orawstream.hxx"' \
+--generate-extraction irawstream --hxx-prologue '\\\#include "irawstream.hxx"'
+
+# Header files for XML Schema namespace.
+#
+$(out_base)/xml-schema%hxx \
+$(out_base)/xml-schema-pskel%hxx \
+$(out_base)/xml-schema-sskel%hxx: $(out_root)/xsde/xsde
+ $(call message,xsde $(src_base)/xml-schema.xsd,\
+$(out_root)/xsde/xsde cxx-hybrid --output-dir $(out_base) \
+--generate-xml-schema --generate-parser --generate-serializer xml-schema.xsd)
+
+genf += xml-schema.hxx xml-schema-pskel.hxx xml-schema-sskel.hxx
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Dist.
+#
+dist-common := $(out_base)/.dist-common
+
+.PHONY: $(dist) $(dist-win) $(dist-common)
+
+$(dist) $(dist-win) $(dist-common): path := $(subst $(src_root)/,,$(src_base))
+
+$(dist-common):
+ $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx)
+ $(call install-data,$(src_base)/exceptions.cxx,$(dist_prefix)/$(path)/exceptions.cxx)
+ $(call install-data,$(src_base)/exceptions.hxx,$(dist_prefix)/$(path)/exceptions.hxx)
+ $(call install-data,$(src_base)/orawstream.hxx,$(dist_prefix)/$(path)/orawstream.hxx)
+ $(call install-data,$(src_base)/orawstream.ixx,$(dist_prefix)/$(path)/orawstream.ixx)
+ $(call install-data,$(src_base)/orawstream.txx,$(dist_prefix)/$(path)/orawstream.txx)
+ $(call install-data,$(src_base)/orawstream.cxx,$(dist_prefix)/$(path)/orawstream.cxx)
+ $(call install-data,$(src_base)/irawstream.hxx,$(dist_prefix)/$(path)/irawstream.hxx)
+ $(call install-data,$(src_base)/irawstream.ixx,$(dist_prefix)/$(path)/irawstream.ixx)
+ $(call install-data,$(src_base)/irawstream.txx,$(dist_prefix)/$(path)/irawstream.txx)
+ $(call install-data,$(src_base)/irawstream.cxx,$(dist_prefix)/$(path)/irawstream.cxx)
+ $(call install-data,$(src_base)/library.xsd,$(dist_prefix)/$(path)/library.xsd)
+ $(call install-data,$(src_base)/library.xml,$(dist_prefix)/$(path)/library.xml)
+
+$(dist): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README)
+
+$(dist-win): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt)
+ $(call message,,unix2dos $(dist_prefix)/$(path)/README.txt)
+
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+ $(call message,rm $$1,rm -f $$1,$(out_base)/xml-schema.hxx)
+ $(call message,rm $$1,rm -f $$1,$(out_base)/xml-schema-pskel.hxx)
+ $(call message,rm $$1,rm -f $$1,$(out_base)/xml-schema-sskel.hxx)
+
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(bld_root)/install.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/examples/cxx/hybrid/binary/custom/orawstream.cxx b/examples/cxx/hybrid/binary/custom/orawstream.cxx
new file mode 100644
index 0000000..dc4b477
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/orawstream.cxx
@@ -0,0 +1,224 @@
+// file : examples/cxx/hybrid/binary/custom/orawstream.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#include <string.h> // memcpy
+
+#include "orawstream.hxx"
+
+using namespace xml_schema;
+
+char* orawstream::
+align (size_t a, size_t n)
+{
+ size_t s = buf_.size ();
+ size_t c = buf_.capacity ();
+ size_t r = s % a;
+
+ if (r)
+ n += a - r;
+
+ if (c - s < n)
+ {
+ // Do exponential growth.
+ //
+ size_t nc = s + n;
+ c *= 2;
+
+ if (nc < c)
+ nc = c;
+
+ buf_.capacity (nc);
+ }
+
+ char* p = buf_.data () + s;
+
+ if (r)
+ p += a - r;
+
+ buf_.size (s + n);
+ return p;
+}
+
+void orawstream::
+operator<< (const std::string& x)
+{
+ size_t n = x.length ();
+ char* p = align (sizeof (size_t), sizeof (size_t) + n);
+
+ *reinterpret_cast<size_t*> (p) = n;
+ p += sizeof (size_t);
+ memcpy (p, x.c_str (), n);
+}
+
+void orawstream::
+operator<< (const buffer& x)
+{
+ size_t n = x.size ();
+ char* p = align (sizeof (size_t), sizeof (size_t) + n);
+
+ *reinterpret_cast<size_t*> (p) = n;
+ p += sizeof (size_t);
+ memcpy (p, x.data (), n);
+}
+
+void
+operator<< (orawstream& s, const str_seq& x)
+{
+ s << orawstream::as_size (x.size ());
+
+ for (str_seq::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+}
+
+void
+operator<< (orawstream& s, const qname& x)
+{
+ s << x.prefix ();
+ s << x.name ();
+}
+
+void
+operator<< (orawstream& s, const time_zone& x)
+{
+ s << x.zone_hours ();
+ s << x.zone_minutes ();
+}
+
+void
+operator<< (orawstream& s, const date& x)
+{
+ s << x.year ();
+ s << x.month ();
+ s << x.day ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+}
+
+void
+operator<< (orawstream& s, const date_time& x)
+{
+ s << x.year ();
+ s << x.month ();
+ s << x.day ();
+ s << x.hours ();
+ s << x.minutes ();
+ s << x.seconds ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+}
+
+void
+operator<< (orawstream& s, const duration& x)
+{
+ s << x.negative ();
+ s << x.years ();
+ s << x.months ();
+ s << x.days ();
+ s << x.hours ();
+ s << x.minutes ();
+ s << x.seconds ();
+}
+
+void
+operator<< (orawstream& s, const gday& x)
+{
+ s << x.day ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+}
+
+void
+operator<< (orawstream& s, const gmonth& x)
+{
+ s << x.month ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+}
+
+void
+operator<< (orawstream& s, const gmonth_day& x)
+{
+ s << x.month ();
+ s << x.day ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+}
+
+void
+operator<< (orawstream& s, const gyear& x)
+{
+ s << x.year ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+}
+
+void
+operator<< (orawstream& s, const gyear_month& x)
+{
+ s << x.year ();
+ s << x.month ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+}
+
+void
+operator<< (orawstream& s, const xml_schema::time& x)
+{
+ s << x.hours ();
+ s << x.minutes ();
+ s << x.seconds ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+}
diff --git a/examples/cxx/hybrid/binary/custom/orawstream.hxx b/examples/cxx/hybrid/binary/custom/orawstream.hxx
new file mode 100644
index 0000000..9689e61
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/orawstream.hxx
@@ -0,0 +1,91 @@
+// file : examples/cxx/hybrid/binary/custom/orawstream.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#ifndef ORAWSTREAM_HXX
+#define ORAWSTREAM_HXX
+
+#include <stddef.h> // size_t
+
+#include <string>
+
+#include "exceptions.hxx"
+#include "xml-schema.hxx"
+
+class orawstream
+{
+public:
+ explicit
+ orawstream (xml_schema::buffer&);
+
+public:
+ struct as_size
+ {
+ explicit as_size (size_t s) : s_ (s) {}
+ size_t s_;
+ };
+
+public:
+ void operator<< (bool);
+ void operator<< (signed char);
+ void operator<< (unsigned char);
+ void operator<< (short);
+ void operator<< (unsigned short);
+ void operator<< (int);
+ void operator<< (unsigned int);
+ void operator<< (long);
+ void operator<< (unsigned long);
+
+#ifdef XSDE_LONGLONG
+ void operator<< (long long);
+ void operator<< (unsigned long long);
+#endif
+
+ void operator<< (as_size);
+ void operator<< (float);
+ void operator<< (double);
+
+ void operator<< (const std::string&);
+ void operator<< (const xml_schema::buffer&);
+
+private:
+ orawstream (const orawstream&);
+ orawstream& operator= (const orawstream&);
+
+public:
+ char*
+ align (size_t alignment, size_t size);
+
+private:
+ xml_schema::buffer& buf_;
+};
+
+void operator<< (orawstream&, const xml_schema::any_type&);
+void operator<< (orawstream&, const xml_schema::any_simple_type&);
+void operator<< (orawstream&, const xml_schema::qname&);
+void operator<< (orawstream&, const xml_schema::time_zone&);
+void operator<< (orawstream&, const xml_schema::date&);
+void operator<< (orawstream&, const xml_schema::date_time&);
+void operator<< (orawstream&, const xml_schema::duration&);
+void operator<< (orawstream&, const xml_schema::gday&);
+void operator<< (orawstream&, const xml_schema::gmonth&);
+void operator<< (orawstream&, const xml_schema::gmonth_day&);
+void operator<< (orawstream&, const xml_schema::gyear&);
+void operator<< (orawstream&, const xml_schema::gyear_month&);
+void operator<< (orawstream&, const xml_schema::time&);
+
+void operator<< (orawstream&, const xml_schema::str_seq&);
+
+template <typename T>
+void operator<< (orawstream&, const xml_schema::pod_seq<T>&);
+
+template <typename T>
+void operator<< (orawstream&, const xml_schema::fix_seq<T>&);
+
+template <typename T>
+void operator<< (orawstream&, const xml_schema::var_seq<T>&);
+
+#include "orawstream.ixx"
+#include "orawstream.txx"
+
+#endif // ORAWSTREAM_HXX
diff --git a/examples/cxx/hybrid/binary/custom/orawstream.ixx b/examples/cxx/hybrid/binary/custom/orawstream.ixx
new file mode 100644
index 0000000..577eb1b
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/orawstream.ixx
@@ -0,0 +1,110 @@
+// file : examples/cxx/hybrid/binary/custom/orawstream.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+inline orawstream::
+orawstream (xml_schema::buffer& buf)
+ : buf_ (buf)
+{
+}
+
+inline void orawstream::
+operator<< (bool x)
+{
+ *align (1, 1) = x;
+}
+
+inline void orawstream::
+operator<< (signed char x)
+{
+ *reinterpret_cast<signed char*> (align (1, 1)) = x;
+}
+
+inline void orawstream::
+operator<< (unsigned char x)
+{
+ *reinterpret_cast<unsigned char*> (align (1, 1)) = x;
+}
+
+inline void orawstream::
+operator<< (short x)
+{
+ *reinterpret_cast<short*> (align (2, 2)) = x;
+}
+
+inline void orawstream::
+operator<< (unsigned short x)
+{
+ *reinterpret_cast<unsigned short*> (align (2, 2)) = x;
+}
+
+inline void orawstream::
+operator<< (int x)
+{
+ *reinterpret_cast<int*> (align (4, 4)) = x;
+}
+
+inline void orawstream::
+operator<< (unsigned int x)
+{
+ *reinterpret_cast<unsigned int*> (align (4, 4)) = x;
+}
+
+inline void orawstream::
+operator<< (long x)
+{
+ *reinterpret_cast<long*> (
+ align (sizeof (long), sizeof (long))) = x;
+}
+
+inline void orawstream::
+operator<< (unsigned long x)
+{
+ *reinterpret_cast<unsigned long*> (
+ align (sizeof (unsigned long), sizeof (unsigned long))) = x;
+}
+
+#ifdef XSDE_LONGLONG
+inline void orawstream::
+operator<< (long long x)
+{
+ *reinterpret_cast<long long*> (align (8, 8)) = x;
+}
+
+inline void orawstream::
+operator<< (unsigned long long x)
+{
+ *reinterpret_cast<unsigned long long*> (align (8, 8)) = x;
+}
+#endif
+
+inline void orawstream::
+operator<< (as_size x)
+{
+ *reinterpret_cast<size_t*> (
+ align (sizeof (size_t), sizeof (size_t))) = x.s_;
+}
+
+inline void orawstream::
+operator<< (float x)
+{
+ *reinterpret_cast<float*> (
+ align (sizeof (float), sizeof (float))) = x;
+}
+
+inline void orawstream::
+operator<< (double x)
+{
+ *reinterpret_cast<double*> (
+ align (sizeof (double), sizeof (double))) = x;
+}
+
+inline void
+operator<< (orawstream&, const xml_schema::any_type&)
+{
+}
+
+inline void
+operator<< (orawstream&, const xml_schema::any_simple_type&)
+{
+}
diff --git a/examples/cxx/hybrid/binary/custom/orawstream.txx b/examples/cxx/hybrid/binary/custom/orawstream.txx
new file mode 100644
index 0000000..46c5b71
--- /dev/null
+++ b/examples/cxx/hybrid/binary/custom/orawstream.txx
@@ -0,0 +1,47 @@
+// file : examples/cxx/hybrid/binary/custom/orawostream.txx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#include <string.h> // memcpy
+
+template <typename T>
+void
+operator<< (orawstream& s, const xml_schema::pod_seq<T>& x)
+{
+ size_t n = x.size ();
+
+ s << orawstream::as_size (x.size ());
+
+ if (n != 0)
+ {
+ size_t mn = sizeof (T) * n;
+ char* p = s.align (sizeof (T), mn);
+ memcpy (p, x.begin (), mn);
+ }
+}
+
+template <typename T>
+void
+operator<< (orawstream& s, const xml_schema::fix_seq<T>& x)
+{
+ s << orawstream::as_size (x.size ());
+
+ for (typename xml_schema::fix_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+}
+
+template <typename T>
+void
+operator<< (orawstream& s, const xml_schema::var_seq<T>& x)
+{
+ s << orawstream::as_size (x.size ());
+
+ for (typename xml_schema::var_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+}
diff --git a/examples/cxx/hybrid/binary/makefile b/examples/cxx/hybrid/binary/makefile
new file mode 100644
index 0000000..89fb738
--- /dev/null
+++ b/examples/cxx/hybrid/binary/makefile
@@ -0,0 +1,53 @@
+# file : examples/cxx/hybrid/binary/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
+
+all_examples := cdr xdr custom
+build_examples :=
+
+ifeq ($(xsde_iostream),y)
+ifeq ($(xsde_exceptions),y)
+
+build_examples += custom
+
+ifeq ($(xsde_cdr),y)
+build_examples += cdr
+endif
+
+ifeq ($(xsde_cdr),y)
+build_examples += xdr
+endif
+
+endif
+endif
+
+default := $(out_base)/
+dist := $(out_base)/.dist
+dist-win := $(out_base)/.dist-win
+clean := $(out_base)/.clean
+
+.PHONY: $(default) $(dist) $(dist-win) $(clean)
+
+$(default): $(addprefix $(out_base)/,$(addsuffix /,$(build_examples)))
+$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(build_examples)))
+
+# Dist.
+#
+$(dist) $(dist-win): path := $(subst $(src_root)/,,$(src_base))
+
+$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(all_examples)))
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README)
+
+$(dist-win): $(addprefix $(out_base)/,$(addsuffix /.dist-win,$(all_examples)))
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt)
+ $(call message,,unix2dos $(dist_prefix)/$(path)/README.txt)
+
+
+ifneq ($(filter $(MAKECMDGOALS),dist dist-win),)
+$(foreach e,$(all_examples),$(call import,$(src_base)/$e/makefile))
+else
+$(foreach e,$(build_examples),$(call import,$(src_base)/$e/makefile))
+endif
diff --git a/examples/cxx/hybrid/binary/xdr/README b/examples/cxx/hybrid/binary/xdr/README
new file mode 100644
index 0000000..e81a149
--- /dev/null
+++ b/examples/cxx/hybrid/binary/xdr/README
@@ -0,0 +1,50 @@
+This example shows how to save/load the C++/Hybrid object model to/from
+XDR (eXternal Data Representation) binary format using XDR streams. The
+XDR API is available out of the box on most POSIX systems as part of Sun
+RPC. On other platforms you may need to install a third-party library
+which provides the XDR API.
+
+The example consists of the following files:
+
+library.xsd
+ XML Schema which describes a library of books.
+
+library.xml
+ Sample XML instance document.
+
+library.hxx
+library.cxx
+
+library-pskel.hxx
+library-pskel.cxx
+library-pimpl.hxx
+library-pimpl.cxx
+
+library-pskel.hxx
+library-pskel.cxx
+library-pimpl.hxx
+library-pimpl.cxx
+ Object model (the first pair of files), parser skeletons (the
+ second pair), parser implementations (the third pair), serializer
+ skeletons (the fourth pair), and serializer implementations (the
+ fifth pair). These files are generated by the XSD/e compiler from
+ library.xsd. The --generate-parser, --generate-serializer, and
+ --generate-aggregate options were used to request the generation
+ of the parsing and serialization code. The --generate-insertion and
+ --generate-extraction options were used to generate the insertion
+ and extraction operations for the XDR streams.
+
+driver.cxx
+ Driver for the example. It first calls the parser that constructs
+ the object model from the input XML file. It then saves the object
+ model to the XDR representation and loads it back. Finally, the
+ driver calls the serializer to serialize the loaded object model
+ back to XML.
+
+To run the example on the sample XML instance document simply execute:
+
+$ ./driver library.xml
+
+The example reads from STDIN if input file is not specified:
+
+$ ./driver <library.xml
diff --git a/examples/cxx/hybrid/binary/xdr/driver.cxx b/examples/cxx/hybrid/binary/xdr/driver.cxx
new file mode 100644
index 0000000..e629849
--- /dev/null
+++ b/examples/cxx/hybrid/binary/xdr/driver.cxx
@@ -0,0 +1,196 @@
+// file : examples/cxx/hybrid/binary/xdr/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : not copyrighted - public domain
+
+#include <stddef.h> // size_t
+#include <string.h> // memcpy
+#include <rpc/xdr.h>
+
+#include <memory> // std::auto_ptr
+#include <iostream>
+
+#include "library.hxx"
+
+#include "library-pimpl.hxx"
+#include "library-simpl.hxx"
+
+using std::cerr;
+using std::endl;
+
+// XDR output functions. Their implementations are provided after main().
+//
+struct underflow_info
+{
+ xml_schema::buffer* buf;
+ size_t pos;
+};
+
+extern "C" int
+overflow (void* user_data, char* buf, int n);
+
+extern "C" int
+underflow (void* user_data, char* buf, int n);
+
+// The xdrrec_create function (used below) has slightly different
+// prototypes on different platforms. To make this example portable
+// we will need to cast the actual function to the following common
+// prototype.
+//
+extern "C"
+typedef void (*xdrrec_create_p) (
+ XDR*,
+ unsigned int write_size,
+ unsigned int read_size,
+ void* user_data,
+ int (*read) (void* user_data, char* buf, int n),
+ int (*write) (void* user_data, char* buf, int n));
+
+int
+main (int argc, char* argv[])
+{
+ const char* input;
+
+ if (argc < 2)
+ {
+ input = "STDIN";
+ cerr << "XML file not specified, reading from STDIN" << endl;
+ }
+ else
+ input = argv[1];
+
+ try
+ {
+ using namespace library;
+
+ // Parse.
+ //
+ catalog_paggr catalog_p;
+
+ xml_schema::document_pimpl doc_p (
+ catalog_p.root_parser (),
+ catalog_p.root_namespace (),
+ catalog_p.root_name ());
+
+ catalog_p.pre ();
+
+ if (argc < 2)
+ doc_p.parse (std::cin);
+ else
+ doc_p.parse (argv[1]);
+
+ std::auto_ptr<catalog> c (catalog_p.post ());
+
+ // Save the object model to an XDR stream.
+ //
+ xdrrec_create_p xdrrec_create_ =
+ reinterpret_cast<xdrrec_create_p> (::xdrrec_create);
+
+ XDR xdr;
+ xml_schema::buffer buf;
+
+ xdrrec_create_ (&xdr, 0, 0, reinterpret_cast<char*> (&buf), 0, &overflow);
+ xdr.x_op = XDR_ENCODE;
+ xml_schema::oxdrstream oxdr (xdr);
+
+ oxdr << *c;
+
+ xdrrec_endofrecord (&xdr, true); // Flush the data.
+ xdr_destroy (&xdr);
+
+ // The binary representation is now in the memory buffer 'buf'.
+ // To get to the raw data use buf.data() and buf.size().
+ //
+ cerr << "binary representation size: " << buf.size () << endl
+ << endl;
+
+ // Load the object model from an XDR stream.
+ //
+ underflow_info ui;
+ ui.buf = &buf;
+ ui.pos = 0;
+
+ xdrrec_create_ (&xdr, 0, 0, reinterpret_cast<char*> (&ui), &underflow, 0);
+ xdr.x_op = XDR_DECODE;
+ xdrrec_skiprecord (&xdr);
+ xml_schema::ixdrstream ixdr (xdr);
+
+ std::auto_ptr<catalog> copy (new catalog);
+ ixdr >> *copy;
+
+ xdr_destroy (&xdr);
+
+ // Serialize the copy back to XML.
+ //
+ catalog_saggr catalog_s;
+
+ xml_schema::document_simpl doc_s (
+ catalog_s.root_serializer (),
+ catalog_s.root_namespace (),
+ catalog_s.root_name ());
+
+ doc_s.add_prefix ("lib", "http://www.codesynthesis.com/library");
+ doc_s.add_schema ("http://www.codesynthesis.com/library", "library.xsd");
+
+ catalog_s.pre (*c);
+ doc_s.serialize (std::cout);
+ catalog_s.post ();
+ }
+ catch (const xml_schema::xdr_exception&)
+ {
+ cerr << "XDR operation failed" << endl;
+ return 1;
+ }
+ catch (const xml_schema::parser_exception& e)
+ {
+ cerr << input << ":" << e.line () << ":" << e.column () << ": "
+ << e.text () << endl;
+ return 1;
+ }
+ catch (const xml_schema::serializer_exception& e)
+ {
+ cerr << "error: " << e.text () << endl;
+ return 1;
+ }
+ catch (const std::ios_base::failure&)
+ {
+ cerr << input << ": unable to open or read/write failure" << endl;
+ return 1;
+ }
+
+ return 0;
+}
+
+extern "C" int
+overflow (void* p, char* buf, int n_)
+{
+ xml_schema::buffer* dst (reinterpret_cast<xml_schema::buffer*> (p));
+ size_t n (static_cast<size_t> (n_));
+
+ size_t size (dst->size ());
+ size_t capacity (dst->capacity ());
+
+ // Implement exponential growth.
+ //
+ if (size + n > capacity && size + n < capacity * 2)
+ dst->capacity (capacity * 2);
+
+ dst->size (size + n);
+ memcpy (dst->data () + size, buf, n);
+
+ return n;
+}
+
+extern "C" int
+underflow (void* p, char* buf, int n_)
+{
+ underflow_info* ui (reinterpret_cast<underflow_info*> (p));
+ size_t n (static_cast<size_t> (n_));
+
+ size_t size (ui->buf->size () - ui->pos);
+ n = size > n ? n : size;
+
+ memcpy (buf, ui->buf->data () + ui->pos, n);
+ ui->pos += n;
+
+ return n;
+}
diff --git a/examples/cxx/hybrid/binary/xdr/library.xml b/examples/cxx/hybrid/binary/xdr/library.xml
new file mode 100644
index 0000000..ee5f771
--- /dev/null
+++ b/examples/cxx/hybrid/binary/xdr/library.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+
+<!--
+
+file : examples/cxx/hybrid/binary/xdr/library.xml
+author : Boris Kolpackov <boris@codesynthesis.com>
+copyright : not copyrighted - public domain
+
+-->
+
+<lib:catalog xmlns:lib="http://www.codesynthesis.com/library"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.codesynthesis.com/library library.xsd">
+
+ <book available="false">
+ <isbn>0679760806</isbn>
+ <title>The Master and Margarita</title>
+ <genre>fiction</genre>
+
+ <author>
+ <name>Mikhail Bulgakov</name>
+ <born>1891-05-15</born>
+ <died>1940-03-10</died>
+ </author>
+ </book>
+
+
+ <book available="true" >
+ <isbn>0679600841</isbn>
+ <title>War and Peace</title>
+ <genre>history</genre>
+
+ <author>
+ <name>Leo Tolstoy</name>
+ <born>1828-09-09</born>
+ <died>1910-11-20</died>
+ </author>
+ </book>
+
+
+ <book available="false">
+ <isbn>0679420290</isbn>
+ <title>Crime and Punishment</title>
+ <genre>philosophy</genre>
+
+ <author>
+ <name>Fyodor Dostoevsky</name>
+ <born>1821-11-11</born>
+ <died>1881-02-09</died>
+ </author>
+ </book>
+
+</lib:catalog>
diff --git a/examples/cxx/hybrid/binary/xdr/library.xsd b/examples/cxx/hybrid/binary/xdr/library.xsd
new file mode 100644
index 0000000..5e411d9
--- /dev/null
+++ b/examples/cxx/hybrid/binary/xdr/library.xsd
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+
+<!--
+
+file : examples/cxx/hybrid/binary/xdr/library.xsd
+author : Boris Kolpackov <boris@codesynthesis.com>
+copyright : not copyrighted - public domain
+
+-->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:lib="http://www.codesynthesis.com/library"
+ targetNamespace="http://www.codesynthesis.com/library">
+
+ <xsd:simpleType name="isbn">
+ <xsd:restriction base="xsd:unsignedInt"/>
+ </xsd:simpleType>
+
+
+ <xsd:complexType name="title">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="lang" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+
+ <xsd:simpleType name="genre">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="romance"/>
+ <xsd:enumeration value="fiction"/>
+ <xsd:enumeration value="horror"/>
+ <xsd:enumeration value="history"/>
+ <xsd:enumeration value="philosophy"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <xsd:complexType name="author">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="born" type="xsd:date"/>
+ <xsd:element name="died" type="xsd:date" minOccurs="0"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="book">
+ <xsd:sequence>
+ <xsd:element name="isbn" type="lib:isbn"/>
+ <xsd:element name="title" type="lib:title"/>
+ <xsd:element name="genre" type="lib:genre"/>
+ <xsd:element name="author" type="lib:author" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="available" type="xsd:boolean" use="required"/>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="catalog">
+ <xsd:sequence>
+ <xsd:element name="book" type="lib:book" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:element name="catalog" type="lib:catalog"/>
+
+</xsd:schema>
diff --git a/examples/cxx/hybrid/binary/xdr/makefile b/examples/cxx/hybrid/binary/xdr/makefile
new file mode 100644
index 0000000..0cff972
--- /dev/null
+++ b/examples/cxx/hybrid/binary/xdr/makefile
@@ -0,0 +1,112 @@
+# file : examples/cxx/hybrid/binary/xdr/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make
+
+xsd := library.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+dist := $(out_base)/.dist
+dist-win := $(out_base)/.dist-win
+clean := $(out_base)/.clean
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.cxx) \
+ $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.cxx) \
+ $(xsd:.xsd=-pimpl.hxx) $(xsd:.xsd=-pimpl.cxx) \
+ $(xsd:.xsd=-sskel.hxx) $(xsd:.xsd=-sskel.cxx) \
+ $(xsd:.xsd=-simpl.hxx) $(xsd:.xsd=-simpl.cxx)
+
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen): xsde_options += --generate-parser --generate-serializer \
+--generate-aggregate --generate-insertion XDR --generate-extraction XDR
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Dist.
+#
+dist-common := $(out_base)/.dist-common
+
+.PHONY: $(dist) $(dist-win) $(dist-common)
+
+$(dist) $(dist-win) $(dist-common): path := $(subst $(src_root)/,,$(src_base))
+
+$(dist-common):
+ $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx)
+ $(call install-data,$(src_base)/library.xsd,$(dist_prefix)/$(path)/library.xsd)
+ $(call install-data,$(src_base)/library.xml,$(dist_prefix)/$(path)/library.xml)
+
+$(dist): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README)
+
+$(dist-win): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt)
+ $(call message,,unix2dos $(dist_prefix)/$(path)/README.txt)
+
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(bld_root)/install.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/examples/cxx/hybrid/makefile b/examples/cxx/hybrid/makefile
index 765c196..06a0ffa 100644
--- a/examples/cxx/hybrid/makefile
+++ b/examples/cxx/hybrid/makefile
@@ -5,10 +5,10 @@
include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make
-all_examples := compositors hello multiroot streaming library wildcard \
-filter minimal
+all_examples := binary compositors hello multiroot streaming library \
+wildcard filter minimal
-build_examples := compositors
+build_examples := binary compositors
ifeq ($(xsde_iostream),y)
ifeq ($(xsde_exceptions),y)
diff --git a/libxsde/xsde/cxx/hybrid/cdr/date-time.cxx b/libxsde/xsde/cxx/hybrid/cdr/date-time.cxx
new file mode 100644
index 0000000..4feaa44
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/date-time.cxx
@@ -0,0 +1,764 @@
+// file : xsde/cxx/hybrid/cdr/date-time.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/cdr/istream.hxx>
+#include <xsde/cxx/hybrid/cdr/ostream.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+ // operator<<
+ //
+
+ void
+ operator<< (ocdrstream& s, const time_zone& x)
+ {
+ s << x.zone_hours ();
+ s << x.zone_minutes ();
+ }
+
+ void
+ operator<< (ocdrstream& s, const date& x)
+ {
+ s << x.year ();
+ s << x.month ();
+ s << x.day ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (ocdrstream& s, const date_time& x)
+ {
+ s << x.year ();
+ s << x.month ();
+ s << x.day ();
+ s << x.hours ();
+ s << x.minutes ();
+ s << x.seconds ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (ocdrstream& s, const duration& x)
+ {
+ s << x.negative ();
+ s << x.years ();
+ s << x.months ();
+ s << x.days ();
+ s << x.hours ();
+ s << x.minutes ();
+ s << x.seconds ();
+ }
+
+ void
+ operator<< (ocdrstream& s, const gday& x)
+ {
+ s << x.day ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (ocdrstream& s, const gmonth& x)
+ {
+ s << x.month ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (ocdrstream& s, const gmonth_day& x)
+ {
+ s << x.month ();
+ s << x.day ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (ocdrstream& s, const gyear& x)
+ {
+ s << x.year ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (ocdrstream& s, const gyear_month& x)
+ {
+ s << x.year ();
+ s << x.month ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (ocdrstream& s, const time& x)
+ {
+ s << x.hours ();
+ s << x.minutes ();
+ s << x.seconds ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+
+ // operator>>
+ //
+
+ void
+ operator>> (icdrstream& s, time_zone& x)
+ {
+ short h, m;
+ s >> h;
+ s >> m;
+
+ x.zone_hours (h);
+ x.zone_minutes (m);
+ }
+
+ void
+ operator>> (icdrstream& s, date& x)
+ {
+ int y;
+ unsigned short m, d;
+ bool zp;
+
+ s >> y;
+ s >> m;
+ s >> d;
+ s >> zp;
+
+ x.year (y);
+ x.month (m);
+ x.day (d);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (icdrstream& s, date_time& x)
+ {
+ int y;
+ unsigned short m, d, h, mi;
+ double se;
+ bool zp;
+
+ s >> y;
+ s >> m;
+ s >> d;
+ s >> h;
+ s >> mi;
+ s >> se;
+ s >> zp;
+
+ x.year (y);
+ x.month (m);
+ x.day (d);
+ x.hours (h);
+ x.minutes (mi);
+ x.seconds (se);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (icdrstream& s, duration& x)
+ {
+ bool n;
+ unsigned int y, m, d, h, mi;
+ double se;
+
+ s >> n;
+ s >> y;
+ s >> m;
+ s >> d;
+ s >> h;
+ s >> mi;
+ s >> se;
+
+ x.negative (n);
+ x.years (y);
+ x.months (m);
+ x.days (d);
+ x.hours (h);
+ x.minutes (mi);
+ x.seconds (se);
+ }
+
+ void
+ operator>> (icdrstream& s, gday& x)
+ {
+ unsigned short d;
+ bool zp;
+
+ s >> d;
+ s >> zp;
+
+ x.day (d);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (icdrstream& s, gmonth& x)
+ {
+ unsigned short m;
+ bool zp;
+
+ s >> m;
+ s >> zp;
+
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (icdrstream& s, gmonth_day& x)
+ {
+ unsigned short d, m;
+ bool zp;
+
+ s >> d;
+ s >> m;
+ s >> zp;
+
+ x.day (d);
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (icdrstream& s, gyear& x)
+ {
+ int y;
+ bool zp;
+
+ s >> y;
+ s >> zp;
+
+ x.year (y);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (icdrstream& s, gyear_month& x)
+ {
+ int y;
+ unsigned short m;
+ bool zp;
+
+ s >> y;
+ s >> m;
+ s >> zp;
+
+ x.year (y);
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (icdrstream& s, time& x)
+ {
+ unsigned short h, m;
+ double se;
+ bool zp;
+
+ s >> h;
+ s >> m;
+ s >> se;
+ s >> zp;
+
+ x.hours (h);
+ x.minutes (m);
+ x.seconds (se);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ // operator<<
+ //
+
+ bool
+ operator<< (ocdrstream& s, const time_zone& x)
+ {
+ return s << x.zone_hours () && s << x.zone_minutes ();
+ }
+
+ bool
+ operator<< (ocdrstream& s, const date& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.year ()) ||
+ !(s << x.month ()) ||
+ !(s << x.day ()) ||
+ !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (ocdrstream& s, const date_time& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.year ()) ||
+ !(s << x.month ()) ||
+ !(s << x.day ()) ||
+ !(s << x.hours ()) ||
+ !(s << x.minutes ()) ||
+ !(s << x.seconds ()) ||
+ !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (ocdrstream& s, const duration& x)
+ {
+ return s << x.negative () &&
+ s << x.years () &&
+ s << x.months () &&
+ s << x.days () &&
+ s << x.hours () &&
+ s << x.minutes () &&
+ s << x.seconds ();
+ }
+
+ bool
+ operator<< (ocdrstream& s, const gday& x)
+ {
+ bool zp = x.zone_present ();
+
+
+ if (!(s << x.day ()) || !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (ocdrstream& s, const gmonth& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.month ()) || !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (ocdrstream& s, const gmonth_day& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.month ()) || !(s << x.day ()) || !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (ocdrstream& s, const gyear& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.year ()) || !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (ocdrstream& s, const gyear_month& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.year ()) || !(s << x.month ()) || !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (ocdrstream& s, const time& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.hours ()) ||
+ !(s << x.minutes ()) ||
+ !(s << x.seconds ()) ||
+ !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+
+ // operator>>
+ //
+
+ bool
+ operator>> (icdrstream& s, time_zone& x)
+ {
+ short h, m;
+
+ if (!(s >> h) || !(s >> m))
+ return false;
+
+ x.zone_hours (h);
+ x.zone_minutes (m);
+
+ return true;
+ }
+
+ bool
+ operator>> (icdrstream& s, date& x)
+ {
+ int y;
+ unsigned short m, d;
+ bool zp;
+
+ if (!(s >> y) || !(s >> m) || !(s >> d) || !(s >> zp))
+ return false;
+
+ x.year (y);
+ x.month (m);
+ x.day (d);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (icdrstream& s, date_time& x)
+ {
+ int y;
+ unsigned short m, d, h, mi;
+ double se;
+ bool zp;
+
+ if (!(s >> y) || !(s >> m) || !(s >> d) ||
+ !(s >> h) || !(s >> mi) || !(s >> se) || !(s >> zp))
+ return false;
+
+ x.year (y);
+ x.month (m);
+ x.day (d);
+ x.hours (h);
+ x.minutes (mi);
+ x.seconds (se);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (icdrstream& s, duration& x)
+ {
+ bool n;
+ unsigned int y, m, d, h, mi;
+ double se;
+
+ if (!(s >> n) || !(s >> y) || !(s >> m) || !(s >> d) ||
+ !(s >> h) || !(s >> mi) || !(s >> se))
+ return false;
+
+ x.negative (n);
+ x.years (y);
+ x.months (m);
+ x.days (d);
+ x.hours (h);
+ x.minutes (mi);
+ x.seconds (se);
+
+ return true;
+ }
+
+ bool
+ operator>> (icdrstream& s, gday& x)
+ {
+ unsigned short d;
+ bool zp;
+
+ if (!(s >> d) || !(s >> zp))
+ return false;
+
+ x.day (d);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (icdrstream& s, gmonth& x)
+ {
+ unsigned short m;
+ bool zp;
+
+ if (!(s >> m) || !(s >> zp))
+ return false;
+
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (icdrstream& s, gmonth_day& x)
+ {
+ unsigned short d, m;
+ bool zp;
+
+ if (!(s >> d) || !(s >> m) || !(s >> zp))
+ return false;
+
+ x.day (d);
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (icdrstream& s, gyear& x)
+ {
+ int y;
+ bool zp;
+
+ if (!(s >> y) || !(s >> zp))
+ return false;
+
+ x.year (y);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (icdrstream& s, gyear_month& x)
+ {
+ int y;
+ unsigned short m;
+ bool zp;
+
+ if (!(s >> y) || !(s >> m) || !(s >> zp))
+ return false;
+
+ x.year (y);
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (icdrstream& s, time& x)
+ {
+ unsigned short h, m;
+ double se;
+ bool zp;
+
+ if (!(s >> h) || !(s >> m) || !(s >> se) || !(s >> zp))
+ return false;
+
+ x.hours (h);
+ x.minutes (m);
+ x.seconds (se);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/cdr/exceptions.cxx b/libxsde/xsde/cxx/hybrid/cdr/exceptions.cxx
new file mode 100644
index 0000000..8b79805
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/exceptions.cxx
@@ -0,0 +1,21 @@
+// file : xsde/cxx/hybrid/cdr/exceptions.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/cdr/exceptions.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ const char* cdr_exception::
+ what () const throw ()
+ {
+ return "CDR stream operation failed";
+ }
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/cdr/exceptions.hxx b/libxsde/xsde/cxx/hybrid/cdr/exceptions.hxx
new file mode 100644
index 0000000..bc0b861
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/exceptions.hxx
@@ -0,0 +1,26 @@
+// file : xsde/cxx/hybrid/cdr/exceptions.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_HYBRID_CDR_EXCEPTIONS_HXX
+#define XSDE_CXX_HYBRID_CDR_EXCEPTIONS_HXX
+
+#include <xsde/cxx/exceptions.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ struct cdr_exception: xsde::cxx::exception
+ {
+ virtual const char*
+ what () const throw ();
+ };
+ }
+ }
+}
+
+#endif // XSDE_CXX_HYBRID_CDR_EXCEPTIONS_HXX
diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.cxx b/libxsde/xsde/cxx/hybrid/cdr/istream.cxx
new file mode 100644
index 0000000..111e668
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/istream.cxx
@@ -0,0 +1,101 @@
+// file : xsde/cxx/hybrid/cdr/istream.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/cdr/istream.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+#ifdef XSDE_STL
+ struct str_guard
+ {
+ str_guard (char* s) : s_ (s) {}
+ ~str_guard () {delete[] s_;}
+
+ private:
+ char* s_;
+ };
+
+ void icdrstream::
+ operator>> (std::string& x)
+ {
+ char* v;
+
+ if (!cdr_.read_string (v))
+ throw cdr_exception ();
+
+ str_guard g (v);
+ x = v;
+ }
+#else
+ void icdrstream::
+ operator>> (char*& x)
+ {
+ if (!cdr_.read_string (x))
+ throw cdr_exception ();
+ }
+#endif
+
+ void icdrstream::
+ operator>> (buffer& x)
+ {
+ ACE_CDR::ULong n;
+
+ if (!cdr_.read_ulong (n))
+ throw cdr_exception ();
+
+ x.size (n);
+
+ if (!cdr_.read_octet_array (
+ reinterpret_cast<ACE_CDR::Octet*> (x.data ()), n))
+ throw cdr_exception ();
+ }
+
+#else // XSDE_EXCEPTIONS
+
+#ifdef XSDE_STL
+ bool icdrstream::
+ operator>> (std::string& x)
+ {
+ char* v;
+
+ if (!cdr_.read_string (v))
+ return false;
+
+ x = v;
+ delete[] v;
+ return true;
+ }
+#else
+ bool icdrstream::
+ operator>> (char*& x)
+ {
+ return cdr_.read_string (x);
+ }
+#endif
+
+ bool icdrstream::
+ operator>> (buffer& x)
+ {
+ ACE_CDR::ULong n;
+
+ if (!cdr_.read_ulong (n))
+ return false;
+
+ x.size (n);
+ return cdr_.read_octet_array (
+ reinterpret_cast<ACE_CDR::Octet*> (x.data ()), n);
+ }
+
+#endif // XSDE_EXCEPTIONS
+
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.hxx b/libxsde/xsde/cxx/hybrid/cdr/istream.hxx
new file mode 100644
index 0000000..484010b
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/istream.hxx
@@ -0,0 +1,182 @@
+// file : xsde/cxx/hybrid/cdr/istream.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_HYBRID_CDR_ISTREAM_HXX
+#define XSDE_CXX_HYBRID_CDR_ISTREAM_HXX
+
+#include <xsde/cxx/config.hxx>
+
+#include <stddef.h> // size_t
+
+#ifdef XSDE_STL
+# include <string>
+#endif
+
+#include <ace/CDR_Stream.h>
+
+#include <xsde/cxx/buffer.hxx>
+#include <xsde/cxx/date-time.hxx>
+
+#ifdef XSDE_STL
+# include <xsde/cxx/qname-stl.hxx>
+# include <xsde/cxx/string-sequence-stl.hxx>
+#else
+# include <xsde/cxx/qname.hxx>
+# include <xsde/cxx/string-sequence.hxx>
+#endif
+
+#include <xsde/cxx/hybrid/any-type.hxx>
+#include <xsde/cxx/hybrid/sequence.hxx>
+
+#ifdef XSDE_EXCEPTIONS
+# include <xsde/cxx/hybrid/cdr/exceptions.hxx>
+#endif
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ class icdrstream
+ {
+ public:
+ explicit
+ icdrstream (ACE_InputCDR& cdr);
+
+ ACE_InputCDR&
+ impl ();
+
+ public:
+ struct as_size
+ {
+ explicit as_size (size_t& s) : s_ (s) {}
+ size_t& s_;
+ };
+
+ public:
+#ifdef XSDE_EXCEPTIONS
+
+ void operator>> (bool&);
+ void operator>> (signed char&);
+ void operator>> (unsigned char&);
+ void operator>> (short&);
+ void operator>> (unsigned short&);
+ void operator>> (int&);
+ void operator>> (unsigned int&);
+ void operator>> (long&);
+ void operator>> (unsigned long&);
+
+#ifdef XSDE_LONGLONG
+ void operator>> (long long&);
+ void operator>> (unsigned long long&);
+#endif
+ void operator>> (as_size&);
+ void operator>> (float&);
+ void operator>> (double&);
+
+#ifdef XSDE_STL
+ void operator>> (std::string&);
+#else
+ void operator>> (char*&);
+#endif
+ void operator>> (buffer&);
+
+#else // XSDE_EXCEPTIONS
+
+ bool operator>> (bool&);
+ bool operator>> (signed char&);
+ bool operator>> (unsigned char&);
+ bool operator>> (short&);
+ bool operator>> (unsigned short&);
+ bool operator>> (int&);
+ bool operator>> (unsigned int&);
+ bool operator>> (long&);
+ bool operator>> (unsigned long&);
+
+#ifdef XSDE_LONGLONG
+ bool operator>> (long long&);
+ bool operator>> (unsigned long long&);
+#endif
+ bool operator>> (as_size&);
+ bool operator>> (float&);
+ bool operator>> (double&);
+
+#ifdef XSDE_STL
+ bool operator>> (std::string&);
+#else
+ bool operator>> (char*&);
+#endif
+ bool operator>> (buffer&);
+
+#endif // XSDE_EXCEPTIONS
+
+ private:
+ icdrstream (const icdrstream&);
+ icdrstream& operator= (const icdrstream&);
+
+ private:
+ ACE_InputCDR& cdr_;
+ };
+
+#ifdef XSDE_EXCEPTIONS
+ void operator>> (icdrstream&, any_type&);
+ void operator>> (icdrstream&, any_simple_type&);
+ void operator>> (icdrstream&, qname&);
+ void operator>> (icdrstream&, string_sequence&);
+ void operator>> (icdrstream&, time_zone&);
+ void operator>> (icdrstream&, date&);
+ void operator>> (icdrstream&, date_time&);
+ void operator>> (icdrstream&, duration&);
+ void operator>> (icdrstream&, gday&);
+ void operator>> (icdrstream&, gmonth&);
+ void operator>> (icdrstream&, gmonth_day&);
+ void operator>> (icdrstream&, gyear&);
+ void operator>> (icdrstream&, gyear_month&);
+ void operator>> (icdrstream&, time&);
+#else
+ bool operator>> (icdrstream&, any_type&);
+ bool operator>> (icdrstream&, any_simple_type&);
+ bool operator>> (icdrstream&, qname&);
+ bool operator>> (icdrstream&, string_sequence&);
+ bool operator>> (icdrstream&, time_zone&);
+ bool operator>> (icdrstream&, date&);
+ bool operator>> (icdrstream&, date_time&);
+ bool operator>> (icdrstream&, duration&);
+ bool operator>> (icdrstream&, gday&);
+ bool operator>> (icdrstream&, gmonth&);
+ bool operator>> (icdrstream&, gmonth_day&);
+ bool operator>> (icdrstream&, gyear&);
+ bool operator>> (icdrstream&, gyear_month&);
+ bool operator>> (icdrstream&, time&);
+#endif
+
+#ifdef XSDE_EXCEPTIONS
+ template <typename T>
+ void operator>> (icdrstream&, pod_seq<T>&);
+
+ template <typename T>
+ void operator>> (icdrstream&, fix_seq<T>&);
+
+ template <typename T>
+ void operator>> (icdrstream&, var_seq<T>&);
+#else
+ template <typename T>
+ bool operator>> (icdrstream&, pod_seq<T>&);
+
+ template <typename T>
+ bool operator>> (icdrstream&, fix_seq<T>&);
+
+ template <typename T>
+ bool operator>> (icdrstream&, var_seq<T>&);
+#endif
+ }
+ }
+}
+
+#include <xsde/cxx/hybrid/cdr/istream.ixx>
+#include <xsde/cxx/hybrid/cdr/istream.txx>
+
+#endif // XSDE_CXX_HYBRID_CDR_ISTREAM_HXX
diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.ixx b/libxsde/xsde/cxx/hybrid/cdr/istream.ixx
new file mode 100644
index 0000000..36d67dd
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/istream.ixx
@@ -0,0 +1,385 @@
+// file : xsde/cxx/hybrid/cdr/istream.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ inline icdrstream::
+ icdrstream (ACE_InputCDR& cdr)
+ : cdr_ (cdr)
+ {
+ }
+
+ inline ACE_InputCDR& icdrstream::
+ impl ()
+ {
+ return cdr_;
+ }
+
+#ifdef XSDE_EXCEPTIONS
+
+ inline void icdrstream::
+ operator>> (bool& x)
+ {
+ ACE_CDR::Boolean v;
+
+ if (!cdr_.read_boolean (v))
+ throw cdr_exception ();
+
+ x = static_cast<bool> (v);
+ }
+
+ inline void icdrstream::
+ operator>> (signed char& x)
+ {
+ ACE_CDR::Octet v;
+
+ if (!cdr_.read_octet (v))
+ throw cdr_exception ();
+
+ x = static_cast<signed char> (v);
+ }
+
+
+ inline void icdrstream::
+ operator>> (unsigned char& x)
+ {
+ ACE_CDR::Octet v;
+
+ if (!cdr_.read_octet (v))
+ throw cdr_exception ();
+
+ x = static_cast<unsigned char> (v);
+ }
+
+ inline void icdrstream::
+ operator>> (short& x)
+ {
+ ACE_CDR::Short v;
+
+ if (!cdr_.read_short (v))
+ throw cdr_exception ();
+
+ x = static_cast<short> (v);
+ }
+
+ inline void icdrstream::
+ operator>> (unsigned short& x)
+ {
+ ACE_CDR::UShort v;
+
+ if (!cdr_.read_ushort (v))
+ throw cdr_exception ();
+
+ x = static_cast<unsigned short> (v);
+ }
+
+ inline void icdrstream::
+ operator>> (int& x)
+ {
+ ACE_CDR::Long v;
+
+ if (!cdr_.read_long (v))
+ throw cdr_exception ();
+
+ x = static_cast<int> (v);
+ }
+
+ inline void icdrstream::
+ operator>> (unsigned int& x)
+ {
+ ACE_CDR::ULong v;
+
+ if (!cdr_.read_ulong (v))
+ throw cdr_exception ();
+
+ x = static_cast<unsigned int> (v);
+ }
+
+ inline void icdrstream::
+ operator>> (long& x)
+ {
+ ACE_CDR::Long v;
+
+ if (!cdr_.read_long (v))
+ throw cdr_exception ();
+
+ x = static_cast<long> (v);
+ }
+
+ inline void icdrstream::
+ operator>> (unsigned long& x)
+ {
+ ACE_CDR::ULong v;
+
+ if (!cdr_.read_ulong (v))
+ throw cdr_exception ();
+
+ x = static_cast<unsigned long> (v);
+ }
+
+#ifdef XSDE_LONGLONG
+ inline void icdrstream::
+ operator>> (long long& x)
+ {
+ ACE_CDR::LongLong v;
+
+ if (!cdr_.read_longlong (v))
+ throw cdr_exception ();
+
+ x = static_cast<long long> (v);
+ }
+
+ inline void icdrstream::
+ operator>> (unsigned long long& x)
+ {
+ ACE_CDR::ULongLong v;
+
+ if (!cdr_.read_ulonglong (v))
+ throw cdr_exception ();
+
+ x = static_cast<unsigned long long> (v);
+ }
+#endif
+
+ inline void icdrstream::
+ operator>> (as_size& x)
+ {
+ // Assume size is 32-bit.
+ //
+ ACE_CDR::ULong v;
+
+ if (!cdr_.read_ulong (v))
+ throw cdr_exception ();
+
+ x.s_ = static_cast<size_t> (v);
+ }
+
+ inline void icdrstream::
+ operator>> (float& x)
+ {
+ ACE_CDR::Float v;
+
+ if (!cdr_.read_float (v))
+ throw cdr_exception ();
+
+ x = static_cast<float> (v);
+ }
+
+ inline void icdrstream::
+ operator>> (double& x)
+ {
+ ACE_CDR::Double v;
+
+ if (!cdr_.read_double (v))
+ throw cdr_exception ();
+
+ x = static_cast<double> (v);
+ }
+
+ inline void
+ operator>> (icdrstream&, any_type&)
+ {
+ }
+
+ inline void
+ operator>> (icdrstream&, any_simple_type&)
+ {
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ inline bool icdrstream::
+ operator>> (bool& x)
+ {
+ ACE_CDR::Boolean v;
+
+ if (!cdr_.read_boolean (v))
+ return false;
+
+ x = static_cast<bool> (v);
+ return true;
+ }
+
+ inline bool icdrstream::
+ operator>> (signed char& x)
+ {
+ ACE_CDR::Octet v;
+
+ if (!cdr_.read_octet (v))
+ return false;
+
+ x = static_cast<signed char> (v);
+ return true;
+ }
+
+
+ inline bool icdrstream::
+ operator>> (unsigned char& x)
+ {
+ ACE_CDR::Octet v;
+
+ if (!cdr_.read_octet (v))
+ return false;
+
+ x = static_cast<unsigned char> (v);
+ return true;
+ }
+
+ inline bool icdrstream::
+ operator>> (short& x)
+ {
+ ACE_CDR::Short v;
+
+ if (!cdr_.read_short (v))
+ return false;
+
+ x = static_cast<short> (v);
+ return true;
+ }
+
+ inline bool icdrstream::
+ operator>> (unsigned short& x)
+ {
+ ACE_CDR::UShort v;
+
+ if (!cdr_.read_ushort (v))
+ return false;
+
+ x = static_cast<unsigned short> (v);
+ return true;
+ }
+
+ inline bool icdrstream::
+ operator>> (int& x)
+ {
+ ACE_CDR::Long v;
+
+ if (!cdr_.read_long (v))
+ return false;
+
+ x = static_cast<int> (v);
+ return true;
+ }
+
+ inline bool icdrstream::
+ operator>> (unsigned int& x)
+ {
+ ACE_CDR::ULong v;
+
+ if (!cdr_.read_ulong (v))
+ return false;
+
+ x = static_cast<unsigned int> (v);
+ return true;
+ }
+
+ inline bool icdrstream::
+ operator>> (long& x)
+ {
+ ACE_CDR::Long v;
+
+ if (!cdr_.read_long (v))
+ return false;
+
+ x = static_cast<long> (v);
+ return true;
+ }
+
+ inline bool icdrstream::
+ operator>> (unsigned long& x)
+ {
+ ACE_CDR::ULong v;
+
+ if (!cdr_.read_ulong (v))
+ return false;
+
+ x = static_cast<unsigned long> (v);
+ return true;
+ }
+
+#ifdef XSDE_LONGLONG
+ inline bool icdrstream::
+ operator>> (long long& x)
+ {
+ ACE_CDR::LongLong v;
+
+ if (!cdr_.read_longlong (v))
+ return false;
+
+ x = static_cast<long long> (v);
+ return true;
+ }
+
+ inline bool icdrstream::
+ operator>> (unsigned long long& x)
+ {
+ ACE_CDR::ULongLong v;
+
+ if (!cdr_.read_ulonglong (v))
+ return false;
+
+ x = static_cast<unsigned long long> (v);
+ return true;
+ }
+#endif
+
+ inline bool icdrstream::
+ operator>> (as_size& x)
+ {
+ // Assume size is 32-bit.
+ //
+ ACE_CDR::ULong v;
+
+ if (!cdr_.read_ulong (v))
+ return false;
+
+ x.s_ = static_cast<size_t> (v);
+ return true;
+ }
+
+ inline bool icdrstream::
+ operator>> (float& x)
+ {
+ ACE_CDR::Float v;
+
+ if (!cdr_.read_float (v))
+ return false;
+
+ x = static_cast<float> (v);
+ return true;
+ }
+
+ inline bool icdrstream::
+ operator>> (double& x)
+ {
+ ACE_CDR::Double v;
+
+ if (!cdr_.read_double (v))
+ return false;
+
+ x = static_cast<double> (v);
+ return true;
+ }
+
+ inline bool
+ operator>> (icdrstream&, any_type&)
+ {
+ return true;
+ }
+
+ inline bool
+ operator>> (icdrstream&, any_simple_type&)
+ {
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.txx b/libxsde/xsde/cxx/hybrid/cdr/istream.txx
new file mode 100644
index 0000000..9afc5f5
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/istream.txx
@@ -0,0 +1,184 @@
+// file : xsde/cxx/hybrid/cdr/istream.txx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+ template <typename T>
+ void
+ operator>> (icdrstream& s, pod_seq<T>& x)
+ {
+ size_t n;
+ icdrstream::as_size as_size (n);
+ s >> as_size;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ x.reserve (n);
+
+ T i;
+ while (n--)
+ {
+ s >> i;
+ x.push_back (i);
+ }
+ }
+ }
+
+ template <typename T>
+ void
+ operator>> (icdrstream& s, fix_seq<T>& x)
+ {
+ size_t n;
+ icdrstream::as_size as_size (n);
+ s >> as_size;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ x.reserve (n);
+
+ while (n--)
+ {
+ T i;
+ s >> i;
+ x.push_back (i);
+ }
+ }
+ }
+
+ template <typename T>
+ void
+ operator>> (icdrstream& s, var_seq<T>& x)
+ {
+ size_t n;
+ icdrstream::as_size as_size (n);
+ s >> as_size;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ x.reserve (n);
+
+ while (n--)
+ {
+ T* p = new T;
+ typename var_seq<T>::guard g (p);
+ s >> *p;
+ g.release ();
+ x.push_back (p);
+ }
+ }
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ template <typename T>
+ bool
+ operator>> (icdrstream& s, pod_seq<T>& x)
+ {
+ size_t n;
+ icdrstream::as_size as_size (n);
+
+ if (!(s >> as_size))
+ return false;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ if (x.reserve (n))
+ return false;
+
+ T i;
+ while (n--)
+ {
+ if (!(s >> i) || x.push_back (i))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ template <typename T>
+ bool
+ operator>> (icdrstream& s, fix_seq<T>& x)
+ {
+ size_t n;
+ icdrstream::as_size as_size (n);
+
+ if (!(s >> as_size))
+ return false;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ if (x.reserve (n))
+ return false;
+
+ while (n--)
+ {
+ T i;
+ if (!(s >> i) || x.push_back (i))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ template <typename T>
+ bool
+ operator>> (icdrstream& s, var_seq<T>& x)
+ {
+ size_t n;
+ icdrstream::as_size as_size (n);
+
+ if (!(s >> as_size))
+ return false;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ if (x.reserve (n))
+ return false;
+
+ while (n--)
+ {
+ T* p = new T;
+
+ if (p == 0)
+ return false;
+
+ if (!(s >> *p))
+ {
+ delete p;
+ return false;
+ }
+
+ if (x.push_back (p))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/cdr/ostream.cxx b/libxsde/xsde/cxx/hybrid/cdr/ostream.cxx
new file mode 100644
index 0000000..e72e5fd
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/ostream.cxx
@@ -0,0 +1,88 @@
+// file : xsde/cxx/hybrid/cdr/ostream.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/config.hxx>
+
+#ifndef XSDE_STL
+# include <string.h>
+#endif
+
+#include <xsde/cxx/hybrid/cdr/ostream.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+ // CDR strings always use 32-bit length.
+ //
+#ifdef XSDE_STL
+ void ocdrstream::
+ operator<< (const std::string& x)
+ {
+ if (!cdr_.write_string (
+ static_cast<ACE_CDR::ULong> (x.length ()), x.c_str ()))
+ throw cdr_exception ();
+ }
+#else
+ void ocdrstream::
+ operator<< (const char* x)
+ {
+ if (!cdr_.write_string (static_cast<ACE_CDR::ULong> (strlen (x)), x))
+ throw cdr_exception ();
+ }
+#endif
+
+ void ocdrstream::
+ operator<< (const buffer& x)
+ {
+ // CDR arrays are limited to 32-bit size.
+ //
+ size_t n = x.size ();
+
+ if (!cdr_.write_ulong (static_cast<ACE_CDR::ULong> (n)) ||
+ !cdr_.write_octet_array (
+ reinterpret_cast<const ACE_CDR::Octet*> (x.data ()), n))
+ throw cdr_exception ();
+ }
+
+#else // XSDE_EXCEPTIONS
+
+#ifdef XSDE_STL
+ bool ocdrstream::
+ operator<< (const std::string& x)
+ {
+ return cdr_.write_string (
+ static_cast<ACE_CDR::ULong> (x.length ()), x.c_str ());
+ }
+#else
+ bool ocdrstream::
+ operator<< (const char* x)
+ {
+ return cdr_.write_string (
+ static_cast<ACE_CDR::ULong> (strlen (x)), x);
+ }
+#endif
+
+ bool ocdrstream::
+ operator<< (const buffer& x)
+ {
+ // CDR arrays are limited to 32-bit size.
+ //
+ size_t n = x.size ();
+
+ return cdr_.write_ulong (static_cast<ACE_CDR::ULong> (n)) &&
+ cdr_.write_octet_array (
+ reinterpret_cast<const ACE_CDR::Octet*> (x.data ()), n);
+ }
+
+#endif // XSDE_EXCEPTIONS
+
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/cdr/ostream.hxx b/libxsde/xsde/cxx/hybrid/cdr/ostream.hxx
new file mode 100644
index 0000000..6b33fe0
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/ostream.hxx
@@ -0,0 +1,182 @@
+// file : xsde/cxx/hybrid/cdr/ostream.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_HYBRID_CDR_OSTREAM_HXX
+#define XSDE_CXX_HYBRID_CDR_OSTREAM_HXX
+
+#include <xsde/cxx/config.hxx>
+
+#include <stddef.h> // size_t
+
+#ifdef XSDE_STL
+# include <string>
+#endif
+
+#include <ace/CDR_Stream.h>
+
+#include <xsde/cxx/buffer.hxx>
+#include <xsde/cxx/date-time.hxx>
+
+#ifdef XSDE_STL
+# include <xsde/cxx/qname-stl.hxx>
+# include <xsde/cxx/string-sequence-stl.hxx>
+#else
+# include <xsde/cxx/qname.hxx>
+# include <xsde/cxx/string-sequence.hxx>
+#endif
+
+#include <xsde/cxx/hybrid/any-type.hxx>
+#include <xsde/cxx/hybrid/sequence.hxx>
+
+#ifdef XSDE_EXCEPTIONS
+# include <xsde/cxx/hybrid/cdr/exceptions.hxx>
+#endif
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ class ocdrstream
+ {
+ public:
+ explicit
+ ocdrstream (ACE_OutputCDR& cdr);
+
+ ACE_OutputCDR&
+ impl ();
+
+ public:
+ struct as_size
+ {
+ explicit as_size (size_t s) : s_ (s) {}
+ size_t s_;
+ };
+
+ public:
+#ifdef XSDE_EXCEPTIONS
+
+ void operator<< (bool);
+ void operator<< (signed char);
+ void operator<< (unsigned char);
+ void operator<< (short);
+ void operator<< (unsigned short);
+ void operator<< (int);
+ void operator<< (unsigned int);
+ void operator<< (long);
+ void operator<< (unsigned long);
+
+#ifdef XSDE_LONGLONG
+ void operator<< (long long);
+ void operator<< (unsigned long long);
+#endif
+ void operator<< (as_size);
+ void operator<< (float);
+ void operator<< (double);
+
+#ifdef XSDE_STL
+ void operator<< (const std::string&);
+#else
+ void operator<< (const char*);
+#endif
+ void operator<< (const buffer&);
+
+#else // XSDE_EXCEPTIONS
+
+ bool operator<< (bool);
+ bool operator<< (signed char);
+ bool operator<< (unsigned char);
+ bool operator<< (short);
+ bool operator<< (unsigned short);
+ bool operator<< (int);
+ bool operator<< (unsigned int);
+ bool operator<< (long);
+ bool operator<< (unsigned long);
+
+#ifdef XSDE_LONGLONG
+ bool operator<< (long long);
+ bool operator<< (unsigned long long);
+#endif
+ bool operator<< (as_size);
+ bool operator<< (float);
+ bool operator<< (double);
+
+#ifdef XSDE_STL
+ bool operator<< (const std::string&);
+#else
+ bool operator<< (const char*);
+#endif
+ bool operator<< (const buffer&);
+
+#endif // XSDE_EXCEPTIONS
+
+ private:
+ ocdrstream (const ocdrstream&);
+ ocdrstream& operator= (const ocdrstream&);
+
+ private:
+ ACE_OutputCDR& cdr_;
+ };
+
+#ifdef XSDE_EXCEPTIONS
+ void operator<< (ocdrstream&, const any_type&);
+ void operator<< (ocdrstream&, const any_simple_type&);
+ void operator<< (ocdrstream&, const qname&);
+ void operator<< (ocdrstream&, const string_sequence&);
+ void operator<< (ocdrstream&, const time_zone&);
+ void operator<< (ocdrstream&, const date&);
+ void operator<< (ocdrstream&, const date_time&);
+ void operator<< (ocdrstream&, const duration&);
+ void operator<< (ocdrstream&, const gday&);
+ void operator<< (ocdrstream&, const gmonth&);
+ void operator<< (ocdrstream&, const gmonth_day&);
+ void operator<< (ocdrstream&, const gyear&);
+ void operator<< (ocdrstream&, const gyear_month&);
+ void operator<< (ocdrstream&, const time&);
+#else
+ bool operator<< (ocdrstream&, const any_type&);
+ bool operator<< (ocdrstream&, const any_simple_type&);
+ bool operator<< (ocdrstream&, const qname&);
+ bool operator<< (ocdrstream&, const string_sequence&);
+ bool operator<< (ocdrstream&, const time_zone&);
+ bool operator<< (ocdrstream&, const date&);
+ bool operator<< (ocdrstream&, const date_time&);
+ bool operator<< (ocdrstream&, const duration&);
+ bool operator<< (ocdrstream&, const gday&);
+ bool operator<< (ocdrstream&, const gmonth&);
+ bool operator<< (ocdrstream&, const gmonth_day&);
+ bool operator<< (ocdrstream&, const gyear&);
+ bool operator<< (ocdrstream&, const gyear_month&);
+ bool operator<< (ocdrstream&, const time&);
+#endif
+
+#ifdef XSDE_EXCEPTIONS
+ template <typename T>
+ void operator<< (ocdrstream&, const pod_seq<T>&);
+
+ template <typename T>
+ void operator<< (ocdrstream&, const fix_seq<T>&);
+
+ template <typename T>
+ void operator<< (ocdrstream&, const var_seq<T>&);
+#else
+ template <typename T>
+ bool operator<< (ocdrstream&, const pod_seq<T>&);
+
+ template <typename T>
+ bool operator<< (ocdrstream&, const fix_seq<T>&);
+
+ template <typename T>
+ bool operator<< (ocdrstream&, const var_seq<T>&);
+#endif
+ }
+ }
+}
+
+#include <xsde/cxx/hybrid/cdr/ostream.ixx>
+#include <xsde/cxx/hybrid/cdr/ostream.txx>
+
+#endif // XSDE_CXX_HYBRID_CDR_OSTREAM_HXX
diff --git a/libxsde/xsde/cxx/hybrid/cdr/ostream.ixx b/libxsde/xsde/cxx/hybrid/cdr/ostream.ixx
new file mode 100644
index 0000000..272c5dd
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/ostream.ixx
@@ -0,0 +1,245 @@
+// file : xsde/cxx/hybrid/cdr/ostream.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ inline ocdrstream::
+ ocdrstream (ACE_OutputCDR& cdr)
+ : cdr_ (cdr)
+ {
+ }
+
+ inline ACE_OutputCDR& ocdrstream::
+ impl ()
+ {
+ return cdr_;
+ }
+
+#ifdef XSDE_EXCEPTIONS
+
+ inline void ocdrstream::
+ operator<< (bool x)
+ {
+ if (!cdr_.write_boolean (static_cast<ACE_CDR::Boolean> (x)))
+ throw cdr_exception ();
+ }
+
+ inline void ocdrstream::
+ operator<< (signed char x)
+ {
+ if (!cdr_.write_octet (static_cast<ACE_CDR::Octet> (x)))
+ throw cdr_exception ();
+ }
+
+
+ inline void ocdrstream::
+ operator<< (unsigned char x)
+ {
+ if (!cdr_.write_octet (static_cast<ACE_CDR::Octet> (x)))
+ throw cdr_exception ();
+ }
+
+ inline void ocdrstream::
+ operator<< (short x)
+ {
+ if (!cdr_.write_short (static_cast<ACE_CDR::Short> (x)))
+ throw cdr_exception ();
+ }
+
+ inline void ocdrstream::
+ operator<< (unsigned short x)
+ {
+ if (!cdr_.write_ushort (static_cast<ACE_CDR::UShort> (x)))
+ throw cdr_exception ();
+ }
+
+ inline void ocdrstream::
+ operator<< (int x)
+ {
+ if (!cdr_.write_long (static_cast<ACE_CDR::Long> (x)))
+ throw cdr_exception ();
+ }
+
+ inline void ocdrstream::
+ operator<< (unsigned int x)
+ {
+ if (!cdr_.write_ulong (static_cast<ACE_CDR::ULong> (x)))
+ throw cdr_exception ();
+ }
+
+ inline void ocdrstream::
+ operator<< (long x)
+ {
+ if (!cdr_.write_long (static_cast<ACE_CDR::Long> (x)))
+ throw cdr_exception ();
+ }
+
+ inline void ocdrstream::
+ operator<< (unsigned long x)
+ {
+ if (!cdr_.write_ulong (static_cast<ACE_CDR::ULong> (x)))
+ throw cdr_exception ();
+ }
+
+#ifdef XSDE_LONGLONG
+ inline void ocdrstream::
+ operator<< (long long x)
+ {
+ if (!cdr_.write_longlong (static_cast<ACE_CDR::LongLong> (x)))
+ throw cdr_exception ();
+ }
+
+ inline void ocdrstream::
+ operator<< (unsigned long long x)
+ {
+ if (!cdr_.write_ulonglong (static_cast<ACE_CDR::ULongLong> (x)))
+ throw cdr_exception ();
+ }
+#endif
+
+ inline void ocdrstream::
+ operator<< (as_size x)
+ {
+ // Assume size is 32-bit.
+ //
+ if (!cdr_.write_ulong (static_cast<ACE_CDR::ULong> (x.s_)))
+ throw cdr_exception ();
+ }
+
+ inline void ocdrstream::
+ operator<< (float x)
+ {
+ if (!cdr_.write_float (static_cast<ACE_CDR::Float> (x)))
+ throw cdr_exception ();
+ }
+
+ inline void ocdrstream::
+ operator<< (double x)
+ {
+ if (!cdr_.write_double (static_cast<ACE_CDR::Double> (x)))
+ throw cdr_exception ();
+ }
+
+ inline void
+ operator<< (ocdrstream&, const any_type&)
+ {
+ }
+
+ inline void
+ operator<< (ocdrstream&, const any_simple_type&)
+ {
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ inline bool ocdrstream::
+ operator<< (bool x)
+ {
+ return cdr_.write_boolean (static_cast<ACE_CDR::Boolean> (x));
+ }
+
+ inline bool ocdrstream::
+ operator<< (signed char x)
+ {
+ return cdr_.write_octet (static_cast<ACE_CDR::Octet> (x));
+ }
+
+
+ inline bool ocdrstream::
+ operator<< (unsigned char x)
+ {
+ return cdr_.write_octet (static_cast<ACE_CDR::Octet> (x));
+ }
+
+ inline bool ocdrstream::
+ operator<< (short x)
+ {
+ return cdr_.write_short (static_cast<ACE_CDR::Short> (x));
+ }
+
+ inline bool ocdrstream::
+ operator<< (unsigned short x)
+ {
+ return cdr_.write_ushort (static_cast<ACE_CDR::UShort> (x));
+ }
+
+ inline bool ocdrstream::
+ operator<< (int x)
+ {
+ return cdr_.write_long (static_cast<ACE_CDR::Long> (x));
+ }
+
+ inline bool ocdrstream::
+ operator<< (unsigned int x)
+ {
+ return cdr_.write_ulong (static_cast<ACE_CDR::ULong> (x));
+ }
+
+ inline bool ocdrstream::
+ operator<< (long x)
+ {
+ return cdr_.write_long (static_cast<ACE_CDR::Long> (x));
+ }
+
+ inline bool ocdrstream::
+ operator<< (unsigned long x)
+ {
+ return cdr_.write_ulong (static_cast<ACE_CDR::ULong> (x));
+ }
+
+#ifdef XSDE_LONGLONG
+ inline bool ocdrstream::
+ operator<< (long long x)
+ {
+ return cdr_.write_longlong (static_cast<ACE_CDR::LongLong> (x));
+ }
+
+ inline bool ocdrstream::
+ operator<< (unsigned long long x)
+ {
+ return cdr_.write_ulonglong (static_cast<ACE_CDR::ULongLong> (x));
+ }
+#endif
+
+ inline bool ocdrstream::
+ operator<< (as_size x)
+ {
+ // Assume size is 32-bit.
+ //
+ return cdr_.write_ulong (static_cast<ACE_CDR::ULong> (x.s_));
+ }
+
+ inline bool ocdrstream::
+ operator<< (float x)
+ {
+ return cdr_.write_float (static_cast<ACE_CDR::Float> (x));
+ }
+
+ inline bool ocdrstream::
+ operator<< (double x)
+ {
+ return cdr_.write_double (static_cast<ACE_CDR::Double> (x));
+ }
+
+ inline bool
+ operator<< (ocdrstream&, const any_type&)
+ {
+ return true;
+ }
+
+ inline bool
+ operator<< (ocdrstream&, const any_simple_type&)
+ {
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/cdr/ostream.txx b/libxsde/xsde/cxx/hybrid/cdr/ostream.txx
new file mode 100644
index 0000000..1dd40df
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/ostream.txx
@@ -0,0 +1,110 @@
+// file : xsde/cxx/hybrid/cdr/ostream.txx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+
+#ifdef XSDE_EXCEPTIONS
+
+ template <typename T>
+ void
+ operator<< (ocdrstream& s, const pod_seq<T>& x)
+ {
+ s << ocdrstream::as_size (x.size ());
+
+ for (typename pod_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+ }
+
+ template <typename T>
+ void
+ operator<< (ocdrstream& s, const fix_seq<T>& x)
+ {
+ s << ocdrstream::as_size (x.size ());
+
+ for (typename fix_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+ }
+
+ template <typename T>
+ void
+ operator<< (ocdrstream& s, const var_seq<T>& x)
+ {
+ s << ocdrstream::as_size (x.size ());
+
+ for (typename var_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ template <typename T>
+ bool
+ operator<< (ocdrstream& s, const pod_seq<T>& x)
+ {
+ if (!(s << ocdrstream::as_size (x.size ())))
+ return false;
+
+ for (typename pod_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ if (!(s << *i))
+ return false;
+ }
+
+ return true;
+ }
+
+ template <typename T>
+ bool
+ operator<< (ocdrstream& s, const fix_seq<T>& x)
+ {
+ if (!(s << ocdrstream::as_size (x.size ())))
+ return false;
+
+ for (typename fix_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ if (!(s << *i))
+ return false;
+ }
+
+ return true;
+ }
+
+ template <typename T>
+ bool
+ operator<< (ocdrstream& s, const var_seq<T>& x)
+ {
+ if (!(s << ocdrstream::as_size (x.size ())))
+ return false;
+
+ for (typename var_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ if (!(s << *i))
+ return false;
+ }
+
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/cdr/qname.cxx b/libxsde/xsde/cxx/hybrid/cdr/qname.cxx
new file mode 100644
index 0000000..396d70b
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/qname.cxx
@@ -0,0 +1,74 @@
+// file : xsde/cxx/hybrid/cdr/qname.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/cdr/istream.hxx>
+#include <xsde/cxx/hybrid/cdr/ostream.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+ void
+ operator<< (ocdrstream& s, const qname& x)
+ {
+ s << x.prefix ();
+ s << x.name ();
+ }
+
+ void
+ operator>> (icdrstream& s, qname& x)
+ {
+
+#ifdef XSDE_STL
+ std::string p, n;
+#else
+ char* p;
+ char* n;
+#endif
+ s >> p;
+ x.prefix (p);
+
+ s >> n; // x will free p in case extraction fails
+ x.name (n);
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ bool
+ operator<< (ocdrstream& s, const qname& x)
+ {
+ return s << x.prefix () && s << x.name ();
+ }
+
+ bool
+ operator>> (icdrstream& s, qname& x)
+ {
+
+#ifdef XSDE_STL
+ std::string p, n;
+#else
+ char* p;
+ char* n;
+#endif
+ if (!(s >> p))
+ return false;
+
+ x.prefix (p);
+
+ if (!(s >> n))
+ return false; // x will free p
+
+ x.name (n);
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/cdr/string-sequence.cxx b/libxsde/xsde/cxx/hybrid/cdr/string-sequence.cxx
new file mode 100644
index 0000000..5ba29f2
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/cdr/string-sequence.cxx
@@ -0,0 +1,107 @@
+// file : xsde/cxx/hybrid/cdr/string-sequence.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/cdr/istream.hxx>
+#include <xsde/cxx/hybrid/cdr/ostream.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+ void
+ operator<< (ocdrstream& s, const string_sequence& x)
+ {
+ s << ocdrstream::as_size (x.size ());
+
+ for (string_sequence::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+ }
+
+ void
+ operator>> (icdrstream& s, string_sequence& x)
+ {
+ size_t n;
+ icdrstream::as_size as_size (n);
+ s >> as_size;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ x.reserve (n);
+
+#ifdef XSDE_STL
+ std::string i;
+#else
+ char* i;
+#endif
+ while (n--)
+ {
+ s >> i;
+ x.push_back (i);
+ }
+ }
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ bool
+ operator<< (ocdrstream& s, const string_sequence& x)
+ {
+ if (!(s << ocdrstream::as_size (x.size ())))
+ return false;
+
+ for (string_sequence::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ if (!(s << *i))
+ return false;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (icdrstream& s, string_sequence& x)
+ {
+ size_t n;
+ icdrstream::as_size as_size (n);
+
+ if (!(s >> as_size))
+ return false;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ if (x.reserve (n))
+ return false;
+
+#ifdef XSDE_STL
+ std::string i;
+#else
+ char* i;
+#endif
+ while (n--)
+ {
+ if (!(s >> i) || x.push_back (i))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/sequence.hxx b/libxsde/xsde/cxx/hybrid/sequence.hxx
index d7f6dcb..3e43b6d 100644
--- a/libxsde/xsde/cxx/hybrid/sequence.hxx
+++ b/libxsde/xsde/cxx/hybrid/sequence.hxx
@@ -789,7 +789,7 @@ namespace xsde
swap (var_seq&);
#ifdef XSDE_EXCEPTIONS
- private:
+ public:
struct guard
{
~guard () { delete p_; }
diff --git a/libxsde/xsde/cxx/hybrid/xdr/date-time.cxx b/libxsde/xsde/cxx/hybrid/xdr/date-time.cxx
new file mode 100644
index 0000000..e920850
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/date-time.cxx
@@ -0,0 +1,764 @@
+// file : xsde/cxx/hybrid/xdr/date-time.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/xdr/istream.hxx>
+#include <xsde/cxx/hybrid/xdr/ostream.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+ // operator<<
+ //
+
+ void
+ operator<< (oxdrstream& s, const time_zone& x)
+ {
+ s << x.zone_hours ();
+ s << x.zone_minutes ();
+ }
+
+ void
+ operator<< (oxdrstream& s, const date& x)
+ {
+ s << x.year ();
+ s << x.month ();
+ s << x.day ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (oxdrstream& s, const date_time& x)
+ {
+ s << x.year ();
+ s << x.month ();
+ s << x.day ();
+ s << x.hours ();
+ s << x.minutes ();
+ s << x.seconds ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (oxdrstream& s, const duration& x)
+ {
+ s << x.negative ();
+ s << x.years ();
+ s << x.months ();
+ s << x.days ();
+ s << x.hours ();
+ s << x.minutes ();
+ s << x.seconds ();
+ }
+
+ void
+ operator<< (oxdrstream& s, const gday& x)
+ {
+ s << x.day ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (oxdrstream& s, const gmonth& x)
+ {
+ s << x.month ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (oxdrstream& s, const gmonth_day& x)
+ {
+ s << x.month ();
+ s << x.day ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (oxdrstream& s, const gyear& x)
+ {
+ s << x.year ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (oxdrstream& s, const gyear_month& x)
+ {
+ s << x.year ();
+ s << x.month ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+ void
+ operator<< (oxdrstream& s, const time& x)
+ {
+ s << x.hours ();
+ s << x.minutes ();
+ s << x.seconds ();
+ bool zp = x.zone_present ();
+ s << zp;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ s << z;
+ }
+ }
+
+
+ // operator>>
+ //
+
+ void
+ operator>> (ixdrstream& s, time_zone& x)
+ {
+ short h, m;
+ s >> h;
+ s >> m;
+
+ x.zone_hours (h);
+ x.zone_minutes (m);
+ }
+
+ void
+ operator>> (ixdrstream& s, date& x)
+ {
+ int y;
+ unsigned short m, d;
+ bool zp;
+
+ s >> y;
+ s >> m;
+ s >> d;
+ s >> zp;
+
+ x.year (y);
+ x.month (m);
+ x.day (d);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (ixdrstream& s, date_time& x)
+ {
+ int y;
+ unsigned short m, d, h, mi;
+ double se;
+ bool zp;
+
+ s >> y;
+ s >> m;
+ s >> d;
+ s >> h;
+ s >> mi;
+ s >> se;
+ s >> zp;
+
+ x.year (y);
+ x.month (m);
+ x.day (d);
+ x.hours (h);
+ x.minutes (mi);
+ x.seconds (se);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (ixdrstream& s, duration& x)
+ {
+ bool n;
+ unsigned int y, m, d, h, mi;
+ double se;
+
+ s >> n;
+ s >> y;
+ s >> m;
+ s >> d;
+ s >> h;
+ s >> mi;
+ s >> se;
+
+ x.negative (n);
+ x.years (y);
+ x.months (m);
+ x.days (d);
+ x.hours (h);
+ x.minutes (mi);
+ x.seconds (se);
+ }
+
+ void
+ operator>> (ixdrstream& s, gday& x)
+ {
+ unsigned short d;
+ bool zp;
+
+ s >> d;
+ s >> zp;
+
+ x.day (d);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (ixdrstream& s, gmonth& x)
+ {
+ unsigned short m;
+ bool zp;
+
+ s >> m;
+ s >> zp;
+
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (ixdrstream& s, gmonth_day& x)
+ {
+ unsigned short d, m;
+ bool zp;
+
+ s >> d;
+ s >> m;
+ s >> zp;
+
+ x.day (d);
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (ixdrstream& s, gyear& x)
+ {
+ int y;
+ bool zp;
+
+ s >> y;
+ s >> zp;
+
+ x.year (y);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (ixdrstream& s, gyear_month& x)
+ {
+ int y;
+ unsigned short m;
+ bool zp;
+
+ s >> y;
+ s >> m;
+ s >> zp;
+
+ x.year (y);
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+ void
+ operator>> (ixdrstream& s, time& x)
+ {
+ unsigned short h, m;
+ double se;
+ bool zp;
+
+ s >> h;
+ s >> m;
+ s >> se;
+ s >> zp;
+
+ x.hours (h);
+ x.minutes (m);
+ x.seconds (se);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ s >> z;
+ }
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ // operator<<
+ //
+
+ bool
+ operator<< (oxdrstream& s, const time_zone& x)
+ {
+ return s << x.zone_hours () && s << x.zone_minutes ();
+ }
+
+ bool
+ operator<< (oxdrstream& s, const date& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.year ()) ||
+ !(s << x.month ()) ||
+ !(s << x.day ()) ||
+ !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (oxdrstream& s, const date_time& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.year ()) ||
+ !(s << x.month ()) ||
+ !(s << x.day ()) ||
+ !(s << x.hours ()) ||
+ !(s << x.minutes ()) ||
+ !(s << x.seconds ()) ||
+ !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (oxdrstream& s, const duration& x)
+ {
+ return s << x.negative () &&
+ s << x.years () &&
+ s << x.months () &&
+ s << x.days () &&
+ s << x.hours () &&
+ s << x.minutes () &&
+ s << x.seconds ();
+ }
+
+ bool
+ operator<< (oxdrstream& s, const gday& x)
+ {
+ bool zp = x.zone_present ();
+
+
+ if (!(s << x.day ()) || !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (oxdrstream& s, const gmonth& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.month ()) || !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (oxdrstream& s, const gmonth_day& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.month ()) || !(s << x.day ()) || !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (oxdrstream& s, const gyear& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.year ()) || !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (oxdrstream& s, const gyear_month& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.year ()) || !(s << x.month ()) || !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator<< (oxdrstream& s, const time& x)
+ {
+ bool zp = x.zone_present ();
+
+ if (!(s << x.hours ()) ||
+ !(s << x.minutes ()) ||
+ !(s << x.seconds ()) ||
+ !(s << zp))
+ return false;
+
+ if (zp)
+ {
+ const time_zone& z = x;
+ return s << z;
+ }
+
+ return true;
+ }
+
+
+ // operator>>
+ //
+
+ bool
+ operator>> (ixdrstream& s, time_zone& x)
+ {
+ short h, m;
+
+ if (!(s >> h) || !(s >> m))
+ return false;
+
+ x.zone_hours (h);
+ x.zone_minutes (m);
+
+ return true;
+ }
+
+ bool
+ operator>> (ixdrstream& s, date& x)
+ {
+ int y;
+ unsigned short m, d;
+ bool zp;
+
+ if (!(s >> y) || !(s >> m) || !(s >> d) || !(s >> zp))
+ return false;
+
+ x.year (y);
+ x.month (m);
+ x.day (d);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (ixdrstream& s, date_time& x)
+ {
+ int y;
+ unsigned short m, d, h, mi;
+ double se;
+ bool zp;
+
+ if (!(s >> y) || !(s >> m) || !(s >> d) ||
+ !(s >> h) || !(s >> mi) || !(s >> se) || !(s >> zp))
+ return false;
+
+ x.year (y);
+ x.month (m);
+ x.day (d);
+ x.hours (h);
+ x.minutes (mi);
+ x.seconds (se);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (ixdrstream& s, duration& x)
+ {
+ bool n;
+ unsigned int y, m, d, h, mi;
+ double se;
+
+ if (!(s >> n) || !(s >> y) || !(s >> m) || !(s >> d) ||
+ !(s >> h) || !(s >> mi) || !(s >> se))
+ return false;
+
+ x.negative (n);
+ x.years (y);
+ x.months (m);
+ x.days (d);
+ x.hours (h);
+ x.minutes (mi);
+ x.seconds (se);
+
+ return true;
+ }
+
+ bool
+ operator>> (ixdrstream& s, gday& x)
+ {
+ unsigned short d;
+ bool zp;
+
+ if (!(s >> d) || !(s >> zp))
+ return false;
+
+ x.day (d);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (ixdrstream& s, gmonth& x)
+ {
+ unsigned short m;
+ bool zp;
+
+ if (!(s >> m) || !(s >> zp))
+ return false;
+
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (ixdrstream& s, gmonth_day& x)
+ {
+ unsigned short d, m;
+ bool zp;
+
+ if (!(s >> d) || !(s >> m) || !(s >> zp))
+ return false;
+
+ x.day (d);
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (ixdrstream& s, gyear& x)
+ {
+ int y;
+ bool zp;
+
+ if (!(s >> y) || !(s >> zp))
+ return false;
+
+ x.year (y);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (ixdrstream& s, gyear_month& x)
+ {
+ int y;
+ unsigned short m;
+ bool zp;
+
+ if (!(s >> y) || !(s >> m) || !(s >> zp))
+ return false;
+
+ x.year (y);
+ x.month (m);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (ixdrstream& s, time& x)
+ {
+ unsigned short h, m;
+ double se;
+ bool zp;
+
+ if (!(s >> h) || !(s >> m) || !(s >> se) || !(s >> zp))
+ return false;
+
+ x.hours (h);
+ x.minutes (m);
+ x.seconds (se);
+
+ if (zp)
+ {
+ time_zone& z = x;
+ return s >> z;
+ }
+
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/xdr/exceptions.cxx b/libxsde/xsde/cxx/hybrid/xdr/exceptions.cxx
new file mode 100644
index 0000000..4a66f6c
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/exceptions.cxx
@@ -0,0 +1,21 @@
+// file : xsde/cxx/hybrid/xdr/exceptions.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/xdr/exceptions.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ const char* xdr_exception::
+ what () const throw ()
+ {
+ return "XDR stream operation failed";
+ }
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/xdr/exceptions.hxx b/libxsde/xsde/cxx/hybrid/xdr/exceptions.hxx
new file mode 100644
index 0000000..61d0a3c
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/exceptions.hxx
@@ -0,0 +1,26 @@
+// file : xsde/cxx/hybrid/xdr/exceptions.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_HYBRID_XDR_EXCEPTIONS_HXX
+#define XSDE_CXX_HYBRID_XDR_EXCEPTIONS_HXX
+
+#include <xsde/cxx/exceptions.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ struct xdr_exception: xsde::cxx::exception
+ {
+ virtual const char*
+ what () const throw ();
+ };
+ }
+ }
+}
+
+#endif // XSDE_CXX_HYBRID_XDR_EXCEPTIONS_HXX
diff --git a/libxsde/xsde/cxx/hybrid/xdr/istream.cxx b/libxsde/xsde/cxx/hybrid/xdr/istream.cxx
new file mode 100644
index 0000000..af35769
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/istream.cxx
@@ -0,0 +1,135 @@
+// file : xsde/cxx/hybrid/xdr/istream.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/xdr/istream.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+#ifdef XSDE_STL
+ void ixdrstream::
+ operator>> (std::string& x)
+ {
+ unsigned int n;
+
+ if (!xdr_u_int (&xdr_, &n))
+ throw xdr_exception ();
+
+ x.clear ();
+
+ if (n != 0)
+ {
+ x.resize (n);
+ char* p = const_cast<char*> (x.c_str ());
+
+ if (!xdr_opaque (&xdr_, p, n))
+ throw xdr_exception ();
+ }
+ }
+#else
+ void ixdrstream::
+ operator>> (char*& x)
+ {
+ unsigned int n;
+
+ if (!xdr_u_int (&xdr_, &n))
+ throw xdr_exception ();
+
+ x = new char[n + 1];
+
+ if (!xdr_opaque (&xdr_, x, n))
+ {
+ delete[] x;
+ throw xdr_exception ();
+ }
+
+ x[n] = '\0';
+ }
+#endif
+
+ void ixdrstream::
+ operator>> (buffer& x)
+ {
+ unsigned int n;
+
+ if (!xdr_u_int (&xdr_, &n))
+ throw xdr_exception ();
+
+ x.size (n);
+
+ if (!xdr_opaque (&xdr_, x.data (), n))
+ throw xdr_exception ();
+ }
+
+#else // XSDE_EXCEPTIONS
+
+#ifdef XSDE_STL
+ bool ixdrstream::
+ operator>> (std::string& x)
+ {
+ unsigned int n;
+
+ if (!xdr_u_int (&xdr_, &n))
+ return false;
+
+ x.clear ();
+
+ if (n != 0)
+ {
+ x.resize (n);
+ char* p = const_cast<char*> (x.c_str ());
+ return xdr_opaque (&xdr_, p, n);
+ }
+
+ return true;
+ }
+#else
+ bool ixdrstream::
+ operator>> (char*& x)
+ {
+ unsigned int n;
+
+ if (!xdr_u_int (&xdr_, &n))
+ return false;
+
+ x = new char[n + 1];
+
+ if (x == 0)
+ return false;
+
+ if (!xdr_opaque (&xdr_, x, n))
+ {
+ delete[] x;
+ return false;
+ }
+
+ x[n] = '\0';
+
+ return true;
+ }
+#endif
+
+ bool ixdrstream::
+ operator>> (buffer& x)
+ {
+ unsigned int n;
+
+ if (!xdr_u_int (&xdr_, &n))
+ return false;
+
+ x.size (n);
+ return xdr_opaque (&xdr_, x.data (), n);
+ }
+
+#endif // XSDE_EXCEPTIONS
+
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/xdr/istream.hxx b/libxsde/xsde/cxx/hybrid/xdr/istream.hxx
new file mode 100644
index 0000000..559b136
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/istream.hxx
@@ -0,0 +1,181 @@
+// file : xsde/cxx/hybrid/xdr/istream.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_HYBRID_XDR_ISTREAM_HXX
+#define XSDE_CXX_HYBRID_XDR_ISTREAM_HXX
+
+#include <xsde/cxx/config.hxx>
+
+#include <stddef.h> // size_t
+#include <rpc/xdr.h>
+
+#ifdef XSDE_STL
+# include <string>
+#endif
+
+#include <xsde/cxx/buffer.hxx>
+#include <xsde/cxx/date-time.hxx>
+
+#ifdef XSDE_STL
+# include <xsde/cxx/qname-stl.hxx>
+# include <xsde/cxx/string-sequence-stl.hxx>
+#else
+# include <xsde/cxx/qname.hxx>
+# include <xsde/cxx/string-sequence.hxx>
+#endif
+
+#include <xsde/cxx/hybrid/any-type.hxx>
+#include <xsde/cxx/hybrid/sequence.hxx>
+
+#ifdef XSDE_EXCEPTIONS
+# include <xsde/cxx/hybrid/xdr/exceptions.hxx>
+#endif
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ class ixdrstream
+ {
+ public:
+ explicit
+ ixdrstream (XDR& xdr);
+
+ XDR&
+ impl ();
+
+ public:
+ struct as_size
+ {
+ explicit as_size (size_t& s) : s_ (s) {}
+ size_t& s_;
+ };
+
+ public:
+#ifdef XSDE_EXCEPTIONS
+
+ void operator>> (bool&);
+ void operator>> (signed char&);
+ void operator>> (unsigned char&);
+ void operator>> (short&);
+ void operator>> (unsigned short&);
+ void operator>> (int&);
+ void operator>> (unsigned int&);
+ void operator>> (long&);
+ void operator>> (unsigned long&);
+
+#ifdef XSDE_LONGLONG
+ void operator>> (long long&);
+ void operator>> (unsigned long long&);
+#endif
+ void operator>> (as_size&);
+ void operator>> (float&);
+ void operator>> (double&);
+
+#ifdef XSDE_STL
+ void operator>> (std::string&);
+#else
+ void operator>> (char*&);
+#endif
+ void operator>> (buffer&);
+
+#else // XSDE_EXCEPTIONS
+
+ bool operator>> (bool&);
+ bool operator>> (signed char&);
+ bool operator>> (unsigned char&);
+ bool operator>> (short&);
+ bool operator>> (unsigned short&);
+ bool operator>> (int&);
+ bool operator>> (unsigned int&);
+ bool operator>> (long&);
+ bool operator>> (unsigned long&);
+
+#ifdef XSDE_LONGLONG
+ bool operator>> (long long&);
+ bool operator>> (unsigned long long&);
+#endif
+ bool operator>> (as_size&);
+ bool operator>> (float&);
+ bool operator>> (double&);
+
+#ifdef XSDE_STL
+ bool operator>> (std::string&);
+#else
+ bool operator>> (char*&);
+#endif
+ bool operator>> (buffer&);
+
+#endif // XSDE_EXCEPTIONS
+
+ private:
+ ixdrstream (const ixdrstream&);
+ ixdrstream& operator= (const ixdrstream&);
+
+ private:
+ XDR& xdr_;
+ };
+
+#ifdef XSDE_EXCEPTIONS
+ void operator>> (ixdrstream&, any_type&);
+ void operator>> (ixdrstream&, any_simple_type&);
+ void operator>> (ixdrstream&, qname&);
+ void operator>> (ixdrstream&, string_sequence&);
+ void operator>> (ixdrstream&, time_zone&);
+ void operator>> (ixdrstream&, date&);
+ void operator>> (ixdrstream&, date_time&);
+ void operator>> (ixdrstream&, duration&);
+ void operator>> (ixdrstream&, gday&);
+ void operator>> (ixdrstream&, gmonth&);
+ void operator>> (ixdrstream&, gmonth_day&);
+ void operator>> (ixdrstream&, gyear&);
+ void operator>> (ixdrstream&, gyear_month&);
+ void operator>> (ixdrstream&, time&);
+#else
+ bool operator>> (ixdrstream&, any_type&);
+ bool operator>> (ixdrstream&, any_simple_type&);
+ bool operator>> (ixdrstream&, qname&);
+ bool operator>> (ixdrstream&, string_sequence&);
+ bool operator>> (ixdrstream&, time_zone&);
+ bool operator>> (ixdrstream&, date&);
+ bool operator>> (ixdrstream&, date_time&);
+ bool operator>> (ixdrstream&, duration&);
+ bool operator>> (ixdrstream&, gday&);
+ bool operator>> (ixdrstream&, gmonth&);
+ bool operator>> (ixdrstream&, gmonth_day&);
+ bool operator>> (ixdrstream&, gyear&);
+ bool operator>> (ixdrstream&, gyear_month&);
+ bool operator>> (ixdrstream&, time&);
+#endif
+
+#ifdef XSDE_EXCEPTIONS
+ template <typename T>
+ void operator>> (ixdrstream&, pod_seq<T>&);
+
+ template <typename T>
+ void operator>> (ixdrstream&, fix_seq<T>&);
+
+ template <typename T>
+ void operator>> (ixdrstream&, var_seq<T>&);
+#else
+ template <typename T>
+ bool operator>> (ixdrstream&, pod_seq<T>&);
+
+ template <typename T>
+ bool operator>> (ixdrstream&, fix_seq<T>&);
+
+ template <typename T>
+ bool operator>> (ixdrstream&, var_seq<T>&);
+#endif
+ }
+ }
+}
+
+#include <xsde/cxx/hybrid/xdr/istream.ixx>
+#include <xsde/cxx/hybrid/xdr/istream.txx>
+
+#endif // XSDE_CXX_HYBRID_XDR_ISTREAM_HXX
diff --git a/libxsde/xsde/cxx/hybrid/xdr/istream.ixx b/libxsde/xsde/cxx/hybrid/xdr/istream.ixx
new file mode 100644
index 0000000..86dd0ec
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/istream.ixx
@@ -0,0 +1,365 @@
+// file : xsde/cxx/hybrid/xdr/istream.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ inline ixdrstream::
+ ixdrstream (XDR& xdr)
+ : xdr_ (xdr)
+ {
+ }
+
+ inline XDR& ixdrstream::
+ impl ()
+ {
+ return xdr_;
+ }
+
+#ifdef XSDE_EXCEPTIONS
+
+ inline void ixdrstream::
+ operator>> (bool& x)
+ {
+ bool_t v;
+
+ if (!xdr_bool (&xdr_, &v))
+ throw xdr_exception ();
+
+ x = static_cast<bool> (v);
+ }
+
+ inline void ixdrstream::
+ operator>> (signed char& x)
+ {
+ int8_t v;
+
+ if (!xdr_int8_t (&xdr_, &v))
+ throw xdr_exception ();
+
+ x = static_cast<signed char> (v);
+ }
+
+
+ inline void ixdrstream::
+ operator>> (unsigned char& x)
+ {
+ uint8_t v;
+
+ if (!xdr_uint8_t (&xdr_, &v))
+ throw xdr_exception ();
+
+ x = static_cast<unsigned char> (v);
+ }
+
+ inline void ixdrstream::
+ operator>> (short& x)
+ {
+ int16_t v;
+
+ if (!xdr_int16_t (&xdr_, &v))
+ throw xdr_exception ();
+
+ x = static_cast<short> (v);
+ }
+
+ inline void ixdrstream::
+ operator>> (unsigned short& x)
+ {
+ uint16_t v;
+
+ if (!xdr_uint16_t (&xdr_, &v))
+ throw xdr_exception ();
+
+ x = static_cast<unsigned short> (v);
+ }
+
+ inline void ixdrstream::
+ operator>> (int& x)
+ {
+ int32_t v;
+
+ if (!xdr_int32_t (&xdr_, &v))
+ throw xdr_exception ();
+
+ x = static_cast<int> (v);
+ }
+
+ inline void ixdrstream::
+ operator>> (unsigned int& x)
+ {
+ uint32_t v;
+
+ if (!xdr_uint32_t (&xdr_, &v))
+ throw xdr_exception ();
+
+ x = static_cast<unsigned int> (v);
+ }
+
+ inline void ixdrstream::
+ operator>> (long& x)
+ {
+ int32_t v;
+
+ if (!xdr_int32_t (&xdr_, &v))
+ throw xdr_exception ();
+
+ x = static_cast<long> (v);
+ }
+
+ inline void ixdrstream::
+ operator>> (unsigned long& x)
+ {
+ uint32_t v;
+
+ if (!xdr_uint32_t (&xdr_, &v))
+ throw xdr_exception ();
+
+ x = static_cast<unsigned long> (v);
+ }
+
+#ifdef XSDE_LONGLONG
+ inline void ixdrstream::
+ operator>> (long long& x)
+ {
+ int64_t v;
+
+ if (!xdr_int64_t (&xdr_, &v))
+ throw xdr_exception ();
+
+ x = static_cast<long long> (v);
+ }
+
+ inline void ixdrstream::
+ operator>> (unsigned long long& x)
+ {
+ uint64_t v;
+
+ if (!xdr_uint64_t (&xdr_, &v))
+ throw xdr_exception ();
+
+ x = static_cast<unsigned long long> (v);
+ }
+#endif
+
+ inline void ixdrstream::
+ operator>> (as_size& x)
+ {
+ // Assume size is 32-bit.
+ //
+ uint32_t v;
+
+ if (!xdr_uint32_t (&xdr_, &v))
+ throw xdr_exception ();
+
+ x.s_ = static_cast<size_t> (v);
+ }
+
+ inline void ixdrstream::
+ operator>> (float& x)
+ {
+ if (!xdr_float (&xdr_, &x))
+ throw xdr_exception ();
+ }
+
+ inline void ixdrstream::
+ operator>> (double& x)
+ {
+ if (!xdr_double (&xdr_, &x))
+ throw xdr_exception ();
+ }
+
+ inline void
+ operator>> (ixdrstream&, any_type&)
+ {
+ }
+
+ inline void
+ operator>> (ixdrstream&, any_simple_type&)
+ {
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ inline bool ixdrstream::
+ operator>> (bool& x)
+ {
+ bool_t v;
+
+ if (!xdr_bool (&xdr_, &v))
+ return false;
+
+ x = static_cast<bool> (v);
+ return true;
+ }
+
+ inline bool ixdrstream::
+ operator>> (signed char& x)
+ {
+ int8_t v;
+
+ if (!xdr_int8_t (&xdr_, &v))
+ return false;
+
+ x = static_cast<signed char> (v);
+ return true;
+ }
+
+
+ inline bool ixdrstream::
+ operator>> (unsigned char& x)
+ {
+ uint8_t v;
+
+ if (!xdr_uint8_t (&xdr_, &v))
+ return false;
+
+ x = static_cast<unsigned char> (v);
+ return true;
+ }
+
+ inline bool ixdrstream::
+ operator>> (short& x)
+ {
+ int16_t v;
+
+ if (!xdr_int16_t (&xdr_, &v))
+ return false;
+
+ x = static_cast<short> (v);
+ return true;
+ }
+
+ inline bool ixdrstream::
+ operator>> (unsigned short& x)
+ {
+ uint16_t v;
+
+ if (!xdr_uint16_t (&xdr_, &v))
+ return false;
+
+ x = static_cast<unsigned short> (v);
+ return true;
+ }
+
+ inline bool ixdrstream::
+ operator>> (int& x)
+ {
+ int32_t v;
+
+ if (!xdr_int32_t (&xdr_, &v))
+ return false;
+
+ x = static_cast<int> (v);
+ return true;
+ }
+
+ inline bool ixdrstream::
+ operator>> (unsigned int& x)
+ {
+ uint32_t v;
+
+ if (!xdr_uint32_t (&xdr_, &v))
+ return false;
+
+ x = static_cast<unsigned int> (v);
+ return true;
+ }
+
+ inline bool ixdrstream::
+ operator>> (long& x)
+ {
+ int32_t v;
+
+ if (!xdr_int32_t (&xdr_, &v))
+ return false;
+
+ x = static_cast<long> (v);
+ return true;
+ }
+
+ inline bool ixdrstream::
+ operator>> (unsigned long& x)
+ {
+ uint32_t v;
+
+ if (!xdr_uint32_t (&xdr_, &v))
+ return false;
+
+ x = static_cast<unsigned long> (v);
+ return true;
+ }
+
+#ifdef XSDE_LONGLONG
+ inline bool ixdrstream::
+ operator>> (long long& x)
+ {
+ int64_t v;
+
+ if (!xdr_int64_t (&xdr_, &v))
+ return false;
+
+ x = static_cast<long long> (v);
+ return true;
+ }
+
+ inline bool ixdrstream::
+ operator>> (unsigned long long& x)
+ {
+ uint64_t v;
+
+ if (!xdr_uint64_t (&xdr_, &v))
+ return false;
+
+ x = static_cast<unsigned long long> (v);
+ return true;
+ }
+#endif
+
+ inline bool ixdrstream::
+ operator>> (as_size& x)
+ {
+ // Assume size is 32-bit.
+ //
+ uint32_t v;
+
+ if (!xdr_uint32_t (&xdr_, &v))
+ return false;
+
+ x.s_ = static_cast<size_t> (v);
+ return true;
+ }
+
+ inline bool ixdrstream::
+ operator>> (float& x)
+ {
+ return xdr_float (&xdr_, &x);
+ }
+
+ inline bool ixdrstream::
+ operator>> (double& x)
+ {
+ return xdr_double (&xdr_, &x);
+ }
+
+ inline bool
+ operator>> (ixdrstream&, any_type&)
+ {
+ return true;
+ }
+
+ inline bool
+ operator>> (ixdrstream&, any_simple_type&)
+ {
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/xdr/istream.txx b/libxsde/xsde/cxx/hybrid/xdr/istream.txx
new file mode 100644
index 0000000..c13015d
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/istream.txx
@@ -0,0 +1,184 @@
+// file : xsde/cxx/hybrid/xdr/istream.txx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+ template <typename T>
+ void
+ operator>> (ixdrstream& s, pod_seq<T>& x)
+ {
+ size_t n;
+ ixdrstream::as_size as_size (n);
+ s >> as_size;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ x.reserve (n);
+
+ T i;
+ while (n--)
+ {
+ s >> i;
+ x.push_back (i);
+ }
+ }
+ }
+
+ template <typename T>
+ void
+ operator>> (ixdrstream& s, fix_seq<T>& x)
+ {
+ size_t n;
+ ixdrstream::as_size as_size (n);
+ s >> as_size;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ x.reserve (n);
+
+ while (n--)
+ {
+ T i;
+ s >> i;
+ x.push_back (i);
+ }
+ }
+ }
+
+ template <typename T>
+ void
+ operator>> (ixdrstream& s, var_seq<T>& x)
+ {
+ size_t n;
+ ixdrstream::as_size as_size (n);
+ s >> as_size;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ x.reserve (n);
+
+ while (n--)
+ {
+ T* p = new T;
+ typename var_seq<T>::guard g (p);
+ s >> *p;
+ g.release ();
+ x.push_back (p);
+ }
+ }
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ template <typename T>
+ bool
+ operator>> (ixdrstream& s, pod_seq<T>& x)
+ {
+ size_t n;
+ ixdrstream::as_size as_size (n);
+
+ if (!(s >> as_size))
+ return false;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ if (x.reserve (n))
+ return false;
+
+ T i;
+ while (n--)
+ {
+ if (!(s >> i) || x.push_back (i))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ template <typename T>
+ bool
+ operator>> (ixdrstream& s, fix_seq<T>& x)
+ {
+ size_t n;
+ ixdrstream::as_size as_size (n);
+
+ if (!(s >> as_size))
+ return false;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ if (x.reserve (n))
+ return false;
+
+ while (n--)
+ {
+ T i;
+ if (!(s >> i) || x.push_back (i))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ template <typename T>
+ bool
+ operator>> (ixdrstream& s, var_seq<T>& x)
+ {
+ size_t n;
+ ixdrstream::as_size as_size (n);
+
+ if (!(s >> as_size))
+ return false;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ if (x.reserve (n))
+ return false;
+
+ while (n--)
+ {
+ T* p = new T;
+
+ if (p == 0)
+ return false;
+
+ if (!(s >> *p))
+ {
+ delete p;
+ return false;
+ }
+
+ if (x.push_back (p))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/xdr/ostream.cxx b/libxsde/xsde/cxx/hybrid/xdr/ostream.cxx
new file mode 100644
index 0000000..1abca26
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/ostream.cxx
@@ -0,0 +1,92 @@
+// file : xsde/cxx/hybrid/xdr/ostream.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/config.hxx>
+
+#ifndef XSDE_STL
+# include <string.h>
+#endif
+
+#include <xsde/cxx/hybrid/xdr/ostream.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+ // XDR strings always use 32-bit length.
+ //
+#ifdef XSDE_STL
+ void oxdrstream::
+ operator<< (const std::string& x)
+ {
+ char* p = const_cast<char*> (x.c_str ());
+ unsigned int n = static_cast<unsigned int> (x.length ());
+
+ if (!xdr_u_int (&xdr_, &n) || !xdr_opaque (&xdr_, p, n))
+ throw xdr_exception ();
+ }
+#else
+ void oxdrstream::
+ operator<< (const char* x)
+ {
+ unsigned int n = static_cast<unsigned int> (strlen (x));
+
+ if (!xdr_u_int (&xdr_, &n) ||
+ !xdr_opaque (&xdr_, const_cast<char*> (x), n))
+ throw xdr_exception ();
+ }
+#endif
+
+ void oxdrstream::
+ operator<< (const buffer& x)
+ {
+ // XDR arrays are limited to 32-bit size.
+ //
+ unsigned int n = static_cast<unsigned int> (x.size ());
+
+ if (!xdr_u_int (&xdr_, &n) ||
+ !xdr_opaque (&xdr_, const_cast<char*> (x.data ()), n))
+ throw xdr_exception ();
+ }
+
+#else // XSDE_EXCEPTIONS
+
+#ifdef XSDE_STL
+ bool oxdrstream::
+ operator<< (const std::string& x)
+ {
+ char* p = const_cast<char*> (x.c_str ());
+ unsigned int n = static_cast<unsigned int> (x.length ());
+ return xdr_u_int (&xdr_, &n) && xdr_opaque (&xdr_, p, n);
+ }
+#else
+ bool oxdrstream::
+ operator<< (const char* x)
+ {
+ unsigned int n = static_cast<unsigned int> (strlen (x));
+ return xdr_u_int (&xdr_, &n) &&
+ xdr_opaque (&xdr_, const_cast<char*> (x), n);
+ }
+#endif
+
+ bool oxdrstream::
+ operator<< (const buffer& x)
+ {
+ // XDR arrays are limited to 32-bit size.
+ //
+ unsigned int n = static_cast<unsigned int> (x.size ());
+ return xdr_u_int (&xdr_, &n) &&
+ xdr_opaque (&xdr_, const_cast<char*> (x.data ()), n);
+ }
+
+#endif // XSDE_EXCEPTIONS
+
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/xdr/ostream.hxx b/libxsde/xsde/cxx/hybrid/xdr/ostream.hxx
new file mode 100644
index 0000000..7a6a2b9
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/ostream.hxx
@@ -0,0 +1,181 @@
+// file : xsde/cxx/hybrid/xdr/ostream.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_HYBRID_XDR_OSTREAM_HXX
+#define XSDE_CXX_HYBRID_XDR_OSTREAM_HXX
+
+#include <xsde/cxx/config.hxx>
+
+#include <stddef.h> // size_t
+#include <rpc/xdr.h>
+
+#ifdef XSDE_STL
+# include <string>
+#endif
+
+#include <xsde/cxx/buffer.hxx>
+#include <xsde/cxx/date-time.hxx>
+
+#ifdef XSDE_STL
+# include <xsde/cxx/qname-stl.hxx>
+# include <xsde/cxx/string-sequence-stl.hxx>
+#else
+# include <xsde/cxx/qname.hxx>
+# include <xsde/cxx/string-sequence.hxx>
+#endif
+
+#include <xsde/cxx/hybrid/any-type.hxx>
+#include <xsde/cxx/hybrid/sequence.hxx>
+
+#ifdef XSDE_EXCEPTIONS
+# include <xsde/cxx/hybrid/xdr/exceptions.hxx>
+#endif
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ class oxdrstream
+ {
+ public:
+ explicit
+ oxdrstream (XDR& xdr);
+
+ XDR&
+ impl ();
+
+ public:
+ struct as_size
+ {
+ explicit as_size (size_t s) : s_ (s) {}
+ size_t s_;
+ };
+
+ public:
+#ifdef XSDE_EXCEPTIONS
+
+ void operator<< (bool);
+ void operator<< (signed char);
+ void operator<< (unsigned char);
+ void operator<< (short);
+ void operator<< (unsigned short);
+ void operator<< (int);
+ void operator<< (unsigned int);
+ void operator<< (long);
+ void operator<< (unsigned long);
+
+#ifdef XSDE_LONGLONG
+ void operator<< (long long);
+ void operator<< (unsigned long long);
+#endif
+ void operator<< (as_size);
+ void operator<< (float);
+ void operator<< (double);
+
+#ifdef XSDE_STL
+ void operator<< (const std::string&);
+#else
+ void operator<< (const char*);
+#endif
+ void operator<< (const buffer&);
+
+#else // XSDE_EXCEPTIONS
+
+ bool operator<< (bool);
+ bool operator<< (signed char);
+ bool operator<< (unsigned char);
+ bool operator<< (short);
+ bool operator<< (unsigned short);
+ bool operator<< (int);
+ bool operator<< (unsigned int);
+ bool operator<< (long);
+ bool operator<< (unsigned long);
+
+#ifdef XSDE_LONGLONG
+ bool operator<< (long long);
+ bool operator<< (unsigned long long);
+#endif
+ bool operator<< (as_size);
+ bool operator<< (float);
+ bool operator<< (double);
+
+#ifdef XSDE_STL
+ bool operator<< (const std::string&);
+#else
+ bool operator<< (const char*);
+#endif
+ bool operator<< (const buffer&);
+
+#endif // XSDE_EXCEPTIONS
+
+ private:
+ oxdrstream (const oxdrstream&);
+ oxdrstream& operator= (const oxdrstream&);
+
+ private:
+ XDR& xdr_;
+ };
+
+#ifdef XSDE_EXCEPTIONS
+ void operator<< (oxdrstream&, const any_type&);
+ void operator<< (oxdrstream&, const any_simple_type&);
+ void operator<< (oxdrstream&, const qname&);
+ void operator<< (oxdrstream&, const string_sequence&);
+ void operator<< (oxdrstream&, const time_zone&);
+ void operator<< (oxdrstream&, const date&);
+ void operator<< (oxdrstream&, const date_time&);
+ void operator<< (oxdrstream&, const duration&);
+ void operator<< (oxdrstream&, const gday&);
+ void operator<< (oxdrstream&, const gmonth&);
+ void operator<< (oxdrstream&, const gmonth_day&);
+ void operator<< (oxdrstream&, const gyear&);
+ void operator<< (oxdrstream&, const gyear_month&);
+ void operator<< (oxdrstream&, const time&);
+#else
+ bool operator<< (oxdrstream&, const any_type&);
+ bool operator<< (oxdrstream&, const any_simple_type&);
+ bool operator<< (oxdrstream&, const qname&);
+ bool operator<< (oxdrstream&, const string_sequence&);
+ bool operator<< (oxdrstream&, const time_zone&);
+ bool operator<< (oxdrstream&, const date&);
+ bool operator<< (oxdrstream&, const date_time&);
+ bool operator<< (oxdrstream&, const duration&);
+ bool operator<< (oxdrstream&, const gday&);
+ bool operator<< (oxdrstream&, const gmonth&);
+ bool operator<< (oxdrstream&, const gmonth_day&);
+ bool operator<< (oxdrstream&, const gyear&);
+ bool operator<< (oxdrstream&, const gyear_month&);
+ bool operator<< (oxdrstream&, const time&);
+#endif
+
+#ifdef XSDE_EXCEPTIONS
+ template <typename T>
+ void operator<< (oxdrstream&, const pod_seq<T>&);
+
+ template <typename T>
+ void operator<< (oxdrstream&, const fix_seq<T>&);
+
+ template <typename T>
+ void operator<< (oxdrstream&, const var_seq<T>&);
+#else
+ template <typename T>
+ bool operator<< (oxdrstream&, const pod_seq<T>&);
+
+ template <typename T>
+ bool operator<< (oxdrstream&, const fix_seq<T>&);
+
+ template <typename T>
+ bool operator<< (oxdrstream&, const var_seq<T>&);
+#endif
+ }
+ }
+}
+
+#include <xsde/cxx/hybrid/xdr/ostream.ixx>
+#include <xsde/cxx/hybrid/xdr/ostream.txx>
+
+#endif // XSDE_CXX_HYBRID_XDR_OSTREAM_HXX
diff --git a/libxsde/xsde/cxx/hybrid/xdr/ostream.ixx b/libxsde/xsde/cxx/hybrid/xdr/ostream.ixx
new file mode 100644
index 0000000..64c8a26
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/ostream.ixx
@@ -0,0 +1,281 @@
+// file : xsde/cxx/hybrid/xdr/ostream.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ inline oxdrstream::
+ oxdrstream (XDR& xdr)
+ : xdr_ (xdr)
+ {
+ }
+
+ inline XDR& oxdrstream::
+ impl ()
+ {
+ return xdr_;
+ }
+
+#ifdef XSDE_EXCEPTIONS
+
+ inline void oxdrstream::
+ operator<< (bool x)
+ {
+ bool_t v = static_cast<bool_t> (x);
+
+ if (!xdr_bool (&xdr_, &v))
+ throw xdr_exception ();
+ }
+
+ inline void oxdrstream::
+ operator<< (signed char x)
+ {
+ int8_t v = static_cast<int8_t> (x);
+
+ if (!xdr_int8_t (&xdr_, &v))
+ throw xdr_exception ();
+ }
+
+
+ inline void oxdrstream::
+ operator<< (unsigned char x)
+ {
+ uint8_t v = static_cast<uint8_t> (x);
+
+ if (!xdr_uint8_t (&xdr_, &v))
+ throw xdr_exception ();
+ }
+
+ inline void oxdrstream::
+ operator<< (short x)
+ {
+ int16_t v = static_cast<int16_t> (x);
+
+ if (!xdr_int16_t (&xdr_, &v))
+ throw xdr_exception ();
+ }
+
+ inline void oxdrstream::
+ operator<< (unsigned short x)
+ {
+ uint16_t v = static_cast<uint16_t> (x);
+
+ if (!xdr_uint16_t (&xdr_, &v))
+ throw xdr_exception ();
+ }
+
+ inline void oxdrstream::
+ operator<< (int x)
+ {
+ int32_t v = static_cast<int32_t> (x);
+
+ if (!xdr_int32_t (&xdr_, &v))
+ throw xdr_exception ();
+ }
+
+ inline void oxdrstream::
+ operator<< (unsigned int x)
+ {
+ uint32_t v = static_cast<uint32_t> (x);
+
+ if (!xdr_uint32_t (&xdr_, &v))
+ throw xdr_exception ();
+ }
+
+ inline void oxdrstream::
+ operator<< (long x)
+ {
+ int32_t v = static_cast<int32_t> (x);
+
+ if (!xdr_int32_t (&xdr_, &v))
+ throw xdr_exception ();
+ }
+
+ inline void oxdrstream::
+ operator<< (unsigned long x)
+ {
+ uint32_t v = static_cast<uint32_t> (x);
+
+ if (!xdr_uint32_t (&xdr_, &v))
+ throw xdr_exception ();
+ }
+
+#ifdef XSDE_LONGLONG
+ inline void oxdrstream::
+ operator<< (long long x)
+ {
+ int64_t v = static_cast<int64_t> (x);
+
+ if (!xdr_int64_t (&xdr_, &v))
+ throw xdr_exception ();
+ }
+
+ inline void oxdrstream::
+ operator<< (unsigned long long x)
+ {
+ uint64_t v = static_cast<uint64_t> (x);
+
+ if (!xdr_uint64_t (&xdr_, &v))
+ throw xdr_exception ();
+ }
+#endif
+
+ inline void oxdrstream::
+ operator<< (as_size x)
+ {
+ // Assume size is 32-bit.
+ //
+ uint32_t v = static_cast<uint32_t> (x.s_);
+
+ if (!xdr_uint32_t (&xdr_, &v))
+ throw xdr_exception ();
+ }
+
+ inline void oxdrstream::
+ operator<< (float x)
+ {
+ if (!xdr_float (&xdr_, &x))
+ throw xdr_exception ();
+ }
+
+ inline void oxdrstream::
+ operator<< (double x)
+ {
+ if (!xdr_double (&xdr_, &x))
+ throw xdr_exception ();
+ }
+
+ inline void
+ operator<< (oxdrstream&, const any_type&)
+ {
+ }
+
+ inline void
+ operator<< (oxdrstream&, const any_simple_type&)
+ {
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ inline bool oxdrstream::
+ operator<< (bool x)
+ {
+ bool_t v = static_cast<bool_t> (x);
+ return xdr_bool (&xdr_, &v);
+ }
+
+ inline bool oxdrstream::
+ operator<< (signed char x)
+ {
+ int8_t v = static_cast<int8_t> (x);
+ return xdr_int8_t (&xdr_, &v);
+ }
+
+
+ inline bool oxdrstream::
+ operator<< (unsigned char x)
+ {
+ uint8_t v = static_cast<uint8_t> (x);
+ return xdr_uint8_t (&xdr_, &v);
+ }
+
+ inline bool oxdrstream::
+ operator<< (short x)
+ {
+ int16_t v = static_cast<int16_t> (x);
+ return xdr_int16_t (&xdr_, &v);
+ }
+
+ inline bool oxdrstream::
+ operator<< (unsigned short x)
+ {
+ uint16_t v = static_cast<uint16_t> (x);
+ return xdr_uint16_t (&xdr_, &v);
+ }
+
+ inline bool oxdrstream::
+ operator<< (int x)
+ {
+ int32_t v = static_cast<int32_t> (x);
+ return xdr_int32_t (&xdr_, &v);
+ }
+
+ inline bool oxdrstream::
+ operator<< (unsigned int x)
+ {
+ uint32_t v = static_cast<uint32_t> (x);
+ return xdr_uint32_t (&xdr_, &v);
+ }
+
+ inline bool oxdrstream::
+ operator<< (long x)
+ {
+ int32_t v = static_cast<int32_t> (x);
+ return xdr_int32_t (&xdr_, &v);
+ }
+
+ inline bool oxdrstream::
+ operator<< (unsigned long x)
+ {
+ uint32_t v = static_cast<uint32_t> (x);
+ return xdr_uint32_t (&xdr_, &v);
+ }
+
+#ifdef XSDE_LONGLONG
+ inline bool oxdrstream::
+ operator<< (long long x)
+ {
+ int64_t v = static_cast<int64_t> (x);
+ return xdr_int64_t (&xdr_, &v);
+ }
+
+ inline bool oxdrstream::
+ operator<< (unsigned long long x)
+ {
+ uint64_t v = static_cast<uint64_t> (x);
+ return xdr_uint64_t (&xdr_, &v);
+ }
+#endif
+
+ inline bool oxdrstream::
+ operator<< (as_size x)
+ {
+ // Assume size is 32-bit.
+ //
+ uint32_t v = static_cast<uint32_t> (x.s_);
+ return xdr_uint32_t (&xdr_, &v);
+ }
+
+ inline bool oxdrstream::
+ operator<< (float x)
+ {
+ return xdr_float (&xdr_, &x);
+ }
+
+ inline bool oxdrstream::
+ operator<< (double x)
+ {
+ return xdr_double (&xdr_, &x);
+ }
+
+ inline bool
+ operator<< (oxdrstream&, const any_type&)
+ {
+ return true;
+ }
+
+ inline bool
+ operator<< (oxdrstream&, const any_simple_type&)
+ {
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/xdr/ostream.txx b/libxsde/xsde/cxx/hybrid/xdr/ostream.txx
new file mode 100644
index 0000000..5211b80
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/ostream.txx
@@ -0,0 +1,110 @@
+// file : xsde/cxx/hybrid/xdr/ostream.txx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+
+#ifdef XSDE_EXCEPTIONS
+
+ template <typename T>
+ void
+ operator<< (oxdrstream& s, const pod_seq<T>& x)
+ {
+ s << oxdrstream::as_size (x.size ());
+
+ for (typename pod_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+ }
+
+ template <typename T>
+ void
+ operator<< (oxdrstream& s, const fix_seq<T>& x)
+ {
+ s << oxdrstream::as_size (x.size ());
+
+ for (typename fix_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+ }
+
+ template <typename T>
+ void
+ operator<< (oxdrstream& s, const var_seq<T>& x)
+ {
+ s << oxdrstream::as_size (x.size ());
+
+ for (typename var_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ template <typename T>
+ bool
+ operator<< (oxdrstream& s, const pod_seq<T>& x)
+ {
+ if (!(s << oxdrstream::as_size (x.size ())))
+ return false;
+
+ for (typename pod_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ if (!(s << *i))
+ return false;
+ }
+
+ return true;
+ }
+
+ template <typename T>
+ bool
+ operator<< (oxdrstream& s, const fix_seq<T>& x)
+ {
+ if (!(s << oxdrstream::as_size (x.size ())))
+ return false;
+
+ for (typename fix_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ if (!(s << *i))
+ return false;
+ }
+
+ return true;
+ }
+
+ template <typename T>
+ bool
+ operator<< (oxdrstream& s, const var_seq<T>& x)
+ {
+ if (!(s << oxdrstream::as_size (x.size ())))
+ return false;
+
+ for (typename var_seq<T>::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ if (!(s << *i))
+ return false;
+ }
+
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/xdr/qname.cxx b/libxsde/xsde/cxx/hybrid/xdr/qname.cxx
new file mode 100644
index 0000000..47a6287
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/qname.cxx
@@ -0,0 +1,74 @@
+// file : xsde/cxx/hybrid/xdr/qname.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/xdr/istream.hxx>
+#include <xsde/cxx/hybrid/xdr/ostream.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+ void
+ operator<< (oxdrstream& s, const qname& x)
+ {
+ s << x.prefix ();
+ s << x.name ();
+ }
+
+ void
+ operator>> (ixdrstream& s, qname& x)
+ {
+
+#ifdef XSDE_STL
+ std::string p, n;
+#else
+ char* p;
+ char* n;
+#endif
+ s >> p;
+ x.prefix (p);
+
+ s >> n; // x will free p in case extraction fails
+ x.name (n);
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ bool
+ operator<< (oxdrstream& s, const qname& x)
+ {
+ return s << x.prefix () && s << x.name ();
+ }
+
+ bool
+ operator>> (ixdrstream& s, qname& x)
+ {
+
+#ifdef XSDE_STL
+ std::string p, n;
+#else
+ char* p;
+ char* n;
+#endif
+ if (!(s >> p))
+ return false;
+
+ x.prefix (p);
+
+ if (!(s >> n))
+ return false; // x will free p
+
+ x.name (n);
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/xdr/string-sequence.cxx b/libxsde/xsde/cxx/hybrid/xdr/string-sequence.cxx
new file mode 100644
index 0000000..f8b3a54
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/xdr/string-sequence.cxx
@@ -0,0 +1,107 @@
+// file : xsde/cxx/hybrid/xdr/string-sequence.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/xdr/istream.hxx>
+#include <xsde/cxx/hybrid/xdr/ostream.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+#ifdef XSDE_EXCEPTIONS
+
+ void
+ operator<< (oxdrstream& s, const string_sequence& x)
+ {
+ s << oxdrstream::as_size (x.size ());
+
+ for (string_sequence::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ s << *i;
+ }
+ }
+
+ void
+ operator>> (ixdrstream& s, string_sequence& x)
+ {
+ size_t n;
+ ixdrstream::as_size as_size (n);
+ s >> as_size;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ x.reserve (n);
+
+#ifdef XSDE_STL
+ std::string i;
+#else
+ char* i;
+#endif
+ while (n--)
+ {
+ s >> i;
+ x.push_back (i);
+ }
+ }
+ }
+
+#else // XSDE_EXCEPTIONS
+
+ bool
+ operator<< (oxdrstream& s, const string_sequence& x)
+ {
+ if (!(s << oxdrstream::as_size (x.size ())))
+ return false;
+
+ for (string_sequence::const_iterator i = x.begin ();
+ i != x.end (); ++i)
+ {
+ if (!(s << *i))
+ return false;
+ }
+
+ return true;
+ }
+
+ bool
+ operator>> (ixdrstream& s, string_sequence& x)
+ {
+ size_t n;
+ ixdrstream::as_size as_size (n);
+
+ if (!(s >> as_size))
+ return false;
+
+ x.clear ();
+
+ if (n > 0)
+ {
+ if (x.reserve (n))
+ return false;
+
+#ifdef XSDE_STL
+ std::string i;
+#else
+ char* i;
+#endif
+ while (n--)
+ {
+ if (!(s >> i) || x.push_back (i))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+#endif // XSDE_EXCEPTIONS
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/sequence-base.hxx b/libxsde/xsde/cxx/sequence-base.hxx
index 537ee7c..057ffdf 100644
--- a/libxsde/xsde/cxx/sequence-base.hxx
+++ b/libxsde/xsde/cxx/sequence-base.hxx
@@ -70,7 +70,7 @@ namespace xsde
void
swap_ (sequence_base&);
- protected:
+ public:
void* data_;
size_t size_;
size_t capacity_;
diff --git a/libxsde/xsde/makefile b/libxsde/xsde/makefile
index 1a90807..d42fabf 100644
--- a/libxsde/xsde/makefile
+++ b/libxsde/xsde/makefile
@@ -45,6 +45,26 @@ endif
##
cxx_tun += cxx/hybrid/sequence.cxx
+ifeq ($(xsde_cdr),y)
+cxx_tun += \
+cxx/hybrid/cdr/exceptions.cxx \
+cxx/hybrid/cdr/istream.cxx \
+cxx/hybrid/cdr/ostream.cxx \
+cxx/hybrid/cdr/qname.cxx \
+cxx/hybrid/cdr/date-time.cxx \
+cxx/hybrid/cdr/string-sequence.cxx
+endif
+
+ifeq ($(xsde_xdr),y)
+cxx_tun += \
+cxx/hybrid/xdr/exceptions.cxx \
+cxx/hybrid/xdr/istream.cxx \
+cxx/hybrid/xdr/ostream.cxx \
+cxx/hybrid/xdr/qname.cxx \
+cxx/hybrid/xdr/date-time.cxx \
+cxx/hybrid/xdr/string-sequence.cxx
+endif
+
## C++/Parser
##
@@ -441,13 +461,25 @@ dist := $(out_base)/.dist
dist-win := $(out_base)/.dist-win
clean := $(out_base)/.clean
+# Import.
+#
+
+ifeq ($(xsde_cdr),y)
+$(call import,\
+ $(scf_root)/import/libace/stub.make,\
+ l: ace.l,cpp-options: ace.l.cpp-options)
+endif
# Build.
#
$(xsde.l): $(cxx_o) -lexpat -lgenx
-
$(cxx_o) $(cxx_d): $(xsde.l.cpp-options) $(out_base)/config.h
+ifeq ($(xsde_cdr),y)
+$(xsde.l): $(ace.l)
+$(cxx_o) $(cxx_d): $(ace.l.cpp-options)
+endif
+
$(xsde.l.cpp-options): prefix := xsde/ $(out_root)/libxsde/
$(xsde.l.cpp-options): value := -I$(out_root)/libxsde -I$(src_root)/libxsde
diff --git a/tests/cxx/hybrid/binary/cdr/driver.cxx b/tests/cxx/hybrid/binary/cdr/driver.cxx
new file mode 100644
index 0000000..e7909cf
--- /dev/null
+++ b/tests/cxx/hybrid/binary/cdr/driver.cxx
@@ -0,0 +1,102 @@
+// file : tests/cxx/hybrid/binary/cdr/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test CDR insertion and extraction.
+//
+
+#include <memory>
+#include <iostream>
+
+#include <ace/CDR_Stream.h>
+
+#include "test.hxx"
+#include "test-pimpl.hxx"
+#include "test-simpl.hxx"
+
+using std::cerr;
+using std::endl;
+
+using namespace test;
+
+int
+main (int argc, char* argv[])
+{
+ /*
+ try
+ {
+ */
+
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ // Parse.
+ //
+ root_paggr root_p;
+
+ xml_schema::document_pimpl doc_p (
+ root_p.root_parser (),
+ root_p.root_namespace (),
+ root_p.root_name ());
+
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ std::auto_ptr<type> r (root_p.post ());
+
+ // Save to a CDR stream.
+ //
+ ACE_OutputCDR ace_ocdr;
+ xml_schema::ocdrstream ocdr (ace_ocdr);
+ ocdr << *r;
+
+ // Load from a CDR stream.
+ //
+ ACE_InputCDR ace_icdr (ace_ocdr);
+ xml_schema::icdrstream icdr (ace_icdr);
+ std::auto_ptr<type> c (new type);
+ icdr >> *c;
+
+ // Serialize.
+ //
+ root_saggr root_s;
+
+ xml_schema::document_simpl doc_s (
+ root_s.root_serializer (),
+ root_s.root_namespace (),
+ root_s.root_name ());
+
+ doc_s.add_prefix ("t", "test");
+
+ root_s.pre (*c);
+ doc_s.serialize (std::cout);
+ root_s.post ();
+
+ /*
+ }
+ catch (const xml_schema::xdr_exception&)
+ {
+ cerr << "XDR operation filed" << endl;
+ return 1;
+ }
+ catch (const xml_schema::parser_exception& e)
+ {
+ cerr << argv[0] << ":" << e.line () << ":" << e.column () << ": "
+ << e.text () << endl;
+ return 1;
+ }
+ catch (const xml_schema::serializer_exception& e)
+ {
+ cerr << "error: " << e.text () << endl;
+ return 1;
+ }
+ catch (const std::ios_base::failure&)
+ {
+ cerr << argv[0] << ": unable to open or read/write failure" << endl;
+ return 1;
+ }
+ */
+}
diff --git a/tests/cxx/hybrid/binary/cdr/makefile b/tests/cxx/hybrid/binary/cdr/makefile
new file mode 100644
index 0000000..a557d82
--- /dev/null
+++ b/tests/cxx/hybrid/binary/cdr/makefile
@@ -0,0 +1,97 @@
+# file : tests/cxx/hybrid/binary/cdr/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.cxx) \
+ $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.cxx) \
+ $(xsd:.xsd=-pimpl.hxx) $(xsd:.xsd=-pimpl.cxx) \
+ $(xsd:.xsd=-sskel.hxx) $(xsd:.xsd=-sskel.cxx) \
+ $(xsd:.xsd=-simpl.hxx) $(xsd:.xsd=-simpl.cxx)
+
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen): xsde_options += --generate-parser --generate-serializer \
+--generate-aggregate --generate-extraction CDR --generate-insertion CDR
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/test.xml $(src_base)/output.xml
+ $(call message,test $$1,$$1 $(src_base)/test.xml | diff -ubB $(src_base)/output.xml -,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/hybrid/binary/cdr/output.xml b/tests/cxx/hybrid/binary/cdr/output.xml
new file mode 100644
index 0000000..a484661
--- /dev/null
+++ b/tests/cxx/hybrid/binary/cdr/output.xml
@@ -0,0 +1,2 @@
+<t:root xmlns:t="test"><list>1 2 3</list><union>abc</union><enumeration>left</enumeration><complex x="1"><a>aaa</a></complex><complex x="1" y="2"><a>aaa</a><b>bbb</b><c>c</c><c>cc</c><c>ccc</c></complex><choice></choice><choice><a>123</a></choice><choice><b>ab</b><b>cd</b><b>ef</b></choice><choice><c>12.34</c><d>false</d></choice><byte>65</byte><unsigned_byte>66</unsigned_byte><short>-222</short><unsigned_short>57005</unsigned_short><int>-57005</int><unsigned_int>3735928559</unsigned_int><long>-2147483648</long><unsigned_long>2147483647</unsigned_long><integer>-2147483648</integer><non_positive_integer>-2147483648</non_positive_integer><non_negative_integer>2147483647</non_negative_integer><positive_integer>2147483647</positive_integer><negative_integer>-2147483648</negative_integer><boolean>true</boolean><float>1234.12</float><double>12345678.1234568</double><decimal>1234567812345678</decimal><string>string</string><normalized_string>normalized string</normalized_string><token>one two three</token><name>name</name><name_token>name-token</name_token><name_tokens>name tokens</name_tokens><ncname>ncname</ncname><language>en-us</language><qname>xsi:schemaLocation</qname><id>elements1</id><id>elements2</id><id_ref>elements1</id_ref><id_refs>elements1 elements2</id_refs><any_uri>http://www.codesynthesis.com</any_uri><base64_binary>YmFzZTY0IGJpbmFyeQ==
+</base64_binary><hex_binary>6865782052696E617279</hex_binary><date>2001-10-26+02:00</date><date_time>2001-10-26T21:32:52+02:00</date_time><duration>P1Y2M3DT5H20M30S</duration><day>---01+02:00</day><month>--11+02:00</month><month_day>--02-11+02:00</month_day><year>2001+02:00</year><year_month>2001-11+02:00</year_month><time>21:32:52+02:00</time></t:root> \ No newline at end of file
diff --git a/tests/cxx/hybrid/binary/cdr/test.xml b/tests/cxx/hybrid/binary/cdr/test.xml
new file mode 100644
index 0000000..acd75d2
--- /dev/null
+++ b/tests/cxx/hybrid/binary/cdr/test.xml
@@ -0,0 +1,93 @@
+<t:root xmlns:t="test">
+
+ <list>1 2 3</list>
+
+ <union>abc</union>
+
+ <enumeration>left</enumeration>
+
+ <complex x="1">
+ <a>aaa</a>
+ </complex>
+ <complex x="1" y="2">
+ <a>aaa</a>
+ <b>bbb</b>
+ <c>c</c>
+ <c>cc</c>
+ <c>ccc</c>
+ </complex>
+
+ <choice/>
+ <choice><a>123</a></choice>
+ <choice><b>ab</b><b>cd</b><b>ef</b></choice>
+ <choice><c>12.34</c><d>false</d></choice>
+
+ <!-- integers -->
+ <byte>65</byte>
+ <unsigned_byte>66</unsigned_byte>
+ <short>-222</short>
+ <unsigned_short>57005</unsigned_short>
+ <int>-57005</int>
+ <unsigned_int>3735928559</unsigned_int>
+ <long>-2147483648</long>
+ <unsigned_long>2147483647</unsigned_long>
+ <integer>-2147483648</integer>
+ <non_positive_integer>-2147483648</non_positive_integer>
+ <non_negative_integer>2147483647</non_negative_integer>
+ <positive_integer>2147483647</positive_integer>
+ <negative_integer>-2147483648</negative_integer>
+
+
+ <!-- boolean -->
+ <boolean>true</boolean>
+
+
+ <!-- floats -->
+ <float>1234.1234</float>
+ <double>12345678.12345678</double>
+ <decimal>1234567812345678.1234567812345678</decimal>
+
+
+ <!-- strings -->
+ <string>string</string>
+ <normalized_string>normalized string</normalized_string>
+ <token>one two three</token>
+ <name>name</name>
+ <name_token>name-token</name_token>
+ <name_tokens>name tokens</name_tokens>
+ <ncname>ncname</ncname>
+ <language>en-us</language>
+
+ <!-- qualified name -->
+ <qname>xsi:schemaLocation</qname>
+
+
+ <!-- ID/IDREF -->
+ <id>elements1</id>
+ <id>elements2</id>
+ <id_ref>elements1</id_ref>
+ <id_refs>elements1 elements2</id_refs>
+
+
+ <!-- URI -->
+ <any_uri>http://www.codesynthesis.com</any_uri>
+
+
+ <!-- binary -->
+ <base64_binary>YmFzZTY0IGJpbmFyeQ==</base64_binary>
+ <hex_binary>6865782052696E617279</hex_binary>
+
+
+ <!-- date/time -->
+ <date>2001-10-26+02:00</date>
+ <date_time>2001-10-26T21:32:52+02:00</date_time>
+ <duration>P1Y2M3DT5H20M30S</duration>
+ <day>---01+02:00</day>
+ <month>--11+02:00</month>
+ <month_day>--11-02+02:00</month_day>
+ <year>2001+02:00</year>
+ <year_month>2001-11+02:00</year_month>
+ <time>21:32:52+02:00</time>
+
+
+</t:root>
diff --git a/tests/cxx/hybrid/binary/cdr/test.xsd b/tests/cxx/hybrid/binary/cdr/test.xsd
new file mode 100644
index 0000000..7a92c7e
--- /dev/null
+++ b/tests/cxx/hybrid/binary/cdr/test.xsd
@@ -0,0 +1,131 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="test"
+ targetNamespace="test">
+
+ <simpleType name="list">
+ <list itemType="int"/>
+ </simpleType>
+
+ <simpleType name="union">
+ <union memberTypes="int string"/>
+ </simpleType>
+
+ <simpleType name="enumeration">
+ <restriction base="string">
+ <enumeration value="top"/>
+ <enumeration value="left"/>
+ <enumeration value="bottom"/>
+ <enumeration value="right"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="base">
+ <sequence>
+ <element name="a" type="string"/>
+ </sequence>
+ <attribute name="x" type="int" use="required"/>
+ </complexType>
+
+ <complexType name="complex">
+ <complexContent>
+ <extension base="t:base">
+ <sequence>
+ <element name="b" type="string" minOccurs="0"/>
+ <element name="c" type="string" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="y" type="int"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="choice">
+ <choice>
+ <element name="a" type="int" minOccurs="0"/>
+ <element name="b" type="string" maxOccurs="unbounded"/>
+ <sequence>
+ <element name="c" type="double"/>
+ <element name="d" type="boolean"/>
+ </sequence>
+ </choice>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="list" type="t:list"/>
+ <element name="union" type="t:union"/>
+ <element name="enumeration" type="t:enumeration"/>
+ <element name="complex" type="t:complex" maxOccurs="unbounded"/>
+ <element name="choice" type="t:choice" maxOccurs="unbounded"/>
+
+ <!-- integers -->
+ <element name="byte" type="byte"/>
+ <element name="unsigned_byte" type="unsignedByte"/>
+ <element name="short" type="short"/>
+ <element name="unsigned_short" type="unsignedShort"/>
+ <element name="int" type="int"/>
+ <element name="unsigned_int" type="unsignedInt"/>
+ <element name="long" type="long"/>
+ <element name="unsigned_long" type="unsignedLong"/>
+ <element name="integer" type="integer"/>
+ <element name="non_positive_integer" type="nonPositiveInteger"/>
+ <element name="non_negative_integer" type="nonNegativeInteger"/>
+ <element name="positive_integer" type="positiveInteger"/>
+ <element name="negative_integer" type="negativeInteger"/>
+
+
+ <!-- boolean -->
+ <element name="boolean" type="boolean"/>
+
+
+ <!-- floats -->
+ <element name="float" type="float"/>
+ <element name="double" type="double"/>
+ <element name="decimal" type="decimal"/>
+
+
+ <!-- strings -->
+ <element name="string" type="string"/>
+ <element name="normalized_string" type="normalizedString"/>
+ <element name="token" type="token"/>
+ <element name="name" type="Name"/>
+ <element name="name_token" type="NMTOKEN"/>
+ <element name="name_tokens" type="NMTOKENS"/>
+ <element name="ncname" type="NCName"/>
+ <element name="language" type="language"/>
+
+ <!-- qualified name -->
+ <element name="qname" type="QName"/>
+
+
+ <!-- ID/IDREF -->
+ <element name="id" maxOccurs="2" type="ID"/>
+ <element name="id_ref" type="IDREF"/>
+ <element name="id_refs" type="IDREFS"/>
+
+
+ <!-- URI -->
+ <element name="any_uri" type="anyURI"/>
+
+
+ <!-- binary -->
+ <element name="base64_binary" type="base64Binary"/>
+ <element name="hex_binary" type="hexBinary"/>
+
+
+ <!-- date/time -->
+ <element name="date" type="date"/>
+ <element name="date_time" type="dateTime"/>
+ <element name="duration" type="duration"/>
+ <element name="day" type="gDay"/>
+ <element name="month" type="gMonth"/>
+ <element name="month_day" type="gMonthDay"/>
+ <element name="year" type="gYear"/>
+ <element name="year_month" type="gYearMonth"/>
+ <element name="time" type="time"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/hybrid/binary/custom/driver.cxx b/tests/cxx/hybrid/binary/custom/driver.cxx
new file mode 100644
index 0000000..400551a
--- /dev/null
+++ b/tests/cxx/hybrid/binary/custom/driver.cxx
@@ -0,0 +1,102 @@
+// file : tests/cxx/hybrid/binary/custom/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test RAW insertion and extraction.
+//
+
+#include <memory>
+#include <iostream>
+
+#include "orawstream.hxx"
+#include "irawstream.hxx"
+
+#include "test.hxx"
+#include "test-pimpl.hxx"
+#include "test-simpl.hxx"
+
+using std::cerr;
+using std::endl;
+
+using namespace test;
+
+int
+main (int argc, char* argv[])
+{
+ /*
+ try
+ {
+ */
+
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ // Parse.
+ //
+ root_paggr root_p;
+
+ xml_schema::document_pimpl doc_p (
+ root_p.root_parser (),
+ root_p.root_namespace (),
+ root_p.root_name ());
+
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ std::auto_ptr<type> r (root_p.post ());
+
+ // Save the object model to a RAW stream.
+ //
+ xml_schema::buffer buf;
+ orawstream oraw (buf);
+ oraw << *r;
+
+ // Load the object model from a RAW stream.
+ //
+ irawstream iraw (buf);
+ std::auto_ptr<type> c (new type);
+ iraw >> *c;
+
+ // Serialize.
+ //
+ root_saggr root_s;
+
+ xml_schema::document_simpl doc_s (
+ root_s.root_serializer (),
+ root_s.root_namespace (),
+ root_s.root_name ());
+
+ doc_s.add_prefix ("t", "test");
+
+ root_s.pre (*c);
+ doc_s.serialize (std::cout);
+ root_s.post ();
+
+ /*
+ }
+ catch (const xml_schema::xdr_exception&)
+ {
+ cerr << "XDR operation filed" << endl;
+ return 1;
+ }
+ catch (const xml_schema::parser_exception& e)
+ {
+ cerr << argv[0] << ":" << e.line () << ":" << e.column () << ": "
+ << e.text () << endl;
+ return 1;
+ }
+ catch (const xml_schema::serializer_exception& e)
+ {
+ cerr << "error: " << e.text () << endl;
+ return 1;
+ }
+ catch (const std::ios_base::failure&)
+ {
+ cerr << argv[0] << ": unable to open or read/write failure" << endl;
+ return 1;
+ }
+ */
+}
diff --git a/tests/cxx/hybrid/binary/custom/makefile b/tests/cxx/hybrid/binary/custom/makefile
new file mode 100644
index 0000000..50fe420
--- /dev/null
+++ b/tests/cxx/hybrid/binary/custom/makefile
@@ -0,0 +1,128 @@
+# file : tests/cxx/hybrid/binary/custom/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx exceptions.cxx orawstream.cxx irawstream.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+dist := $(out_base)/.dist
+dist-win := $(out_base)/.dist-win
+clean := $(out_base)/.clean
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.cxx) \
+ $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.cxx) \
+ $(xsd:.xsd=-pimpl.hxx) $(xsd:.xsd=-pimpl.cxx) \
+ $(xsd:.xsd=-sskel.hxx) $(xsd:.xsd=-sskel.cxx) \
+ $(xsd:.xsd=-simpl.hxx) $(xsd:.xsd=-simpl.cxx)
+
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen): xsde_options += --generate-parser --generate-serializer \
+--generate-aggregate --extern-xml-schema xml-schema.xsd \
+--generate-insertion orawstream --hxx-prologue '\\\#include "orawstream.hxx"' \
+--generate-extraction irawstream --hxx-prologue '\\\#include "irawstream.hxx"'
+
+# Header files for XML Schema namespace.
+#
+$(out_base)/xml-schema%hxx \
+$(out_base)/xml-schema-pskel%hxx \
+$(out_base)/xml-schema-sskel%hxx: $(out_root)/xsde/xsde
+ $(call message,xsde $(src_base)/xml-schema.xsd,\
+$(out_root)/xsde/xsde cxx-hybrid --output-dir $(out_base) \
+--generate-xml-schema --generate-parser --generate-serializer xml-schema.xsd)
+
+genf += xml-schema.hxx xml-schema-pskel.hxx xml-schema-sskel.hxx
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Dist.
+#
+dist-common := $(out_base)/.dist-common
+
+.PHONY: $(dist) $(dist-win) $(dist-common)
+
+$(dist) $(dist-win) $(dist-common): path := $(subst $(src_root)/,,$(src_base))
+
+$(dist-common):
+ $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx)
+ $(call install-data,$(src_base)/library.xsd,$(dist_prefix)/$(path)/library.xsd)
+ $(call install-data,$(src_base)/library.xml,$(dist_prefix)/$(path)/library.xml)
+
+$(dist): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README)
+
+$(dist-win): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt)
+ $(call message,,unix2dos $(dist_prefix)/$(path)/README.txt)
+
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+ $(call message,rm $$1,rm -f $$1,$(out_base)/xml-schema.hxx)
+ $(call message,rm $$1,rm -f $$1,$(out_base)/xml-schema-pskel.hxx)
+ $(call message,rm $$1,rm -f $$1,$(out_base)/xml-schema-sskel.hxx)
+
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(bld_root)/install.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/hybrid/binary/custom/output.xml b/tests/cxx/hybrid/binary/custom/output.xml
new file mode 100644
index 0000000..a484661
--- /dev/null
+++ b/tests/cxx/hybrid/binary/custom/output.xml
@@ -0,0 +1,2 @@
+<t:root xmlns:t="test"><list>1 2 3</list><union>abc</union><enumeration>left</enumeration><complex x="1"><a>aaa</a></complex><complex x="1" y="2"><a>aaa</a><b>bbb</b><c>c</c><c>cc</c><c>ccc</c></complex><choice></choice><choice><a>123</a></choice><choice><b>ab</b><b>cd</b><b>ef</b></choice><choice><c>12.34</c><d>false</d></choice><byte>65</byte><unsigned_byte>66</unsigned_byte><short>-222</short><unsigned_short>57005</unsigned_short><int>-57005</int><unsigned_int>3735928559</unsigned_int><long>-2147483648</long><unsigned_long>2147483647</unsigned_long><integer>-2147483648</integer><non_positive_integer>-2147483648</non_positive_integer><non_negative_integer>2147483647</non_negative_integer><positive_integer>2147483647</positive_integer><negative_integer>-2147483648</negative_integer><boolean>true</boolean><float>1234.12</float><double>12345678.1234568</double><decimal>1234567812345678</decimal><string>string</string><normalized_string>normalized string</normalized_string><token>one two three</token><name>name</name><name_token>name-token</name_token><name_tokens>name tokens</name_tokens><ncname>ncname</ncname><language>en-us</language><qname>xsi:schemaLocation</qname><id>elements1</id><id>elements2</id><id_ref>elements1</id_ref><id_refs>elements1 elements2</id_refs><any_uri>http://www.codesynthesis.com</any_uri><base64_binary>YmFzZTY0IGJpbmFyeQ==
+</base64_binary><hex_binary>6865782052696E617279</hex_binary><date>2001-10-26+02:00</date><date_time>2001-10-26T21:32:52+02:00</date_time><duration>P1Y2M3DT5H20M30S</duration><day>---01+02:00</day><month>--11+02:00</month><month_day>--02-11+02:00</month_day><year>2001+02:00</year><year_month>2001-11+02:00</year_month><time>21:32:52+02:00</time></t:root> \ No newline at end of file
diff --git a/tests/cxx/hybrid/binary/custom/test.xml b/tests/cxx/hybrid/binary/custom/test.xml
new file mode 100644
index 0000000..acd75d2
--- /dev/null
+++ b/tests/cxx/hybrid/binary/custom/test.xml
@@ -0,0 +1,93 @@
+<t:root xmlns:t="test">
+
+ <list>1 2 3</list>
+
+ <union>abc</union>
+
+ <enumeration>left</enumeration>
+
+ <complex x="1">
+ <a>aaa</a>
+ </complex>
+ <complex x="1" y="2">
+ <a>aaa</a>
+ <b>bbb</b>
+ <c>c</c>
+ <c>cc</c>
+ <c>ccc</c>
+ </complex>
+
+ <choice/>
+ <choice><a>123</a></choice>
+ <choice><b>ab</b><b>cd</b><b>ef</b></choice>
+ <choice><c>12.34</c><d>false</d></choice>
+
+ <!-- integers -->
+ <byte>65</byte>
+ <unsigned_byte>66</unsigned_byte>
+ <short>-222</short>
+ <unsigned_short>57005</unsigned_short>
+ <int>-57005</int>
+ <unsigned_int>3735928559</unsigned_int>
+ <long>-2147483648</long>
+ <unsigned_long>2147483647</unsigned_long>
+ <integer>-2147483648</integer>
+ <non_positive_integer>-2147483648</non_positive_integer>
+ <non_negative_integer>2147483647</non_negative_integer>
+ <positive_integer>2147483647</positive_integer>
+ <negative_integer>-2147483648</negative_integer>
+
+
+ <!-- boolean -->
+ <boolean>true</boolean>
+
+
+ <!-- floats -->
+ <float>1234.1234</float>
+ <double>12345678.12345678</double>
+ <decimal>1234567812345678.1234567812345678</decimal>
+
+
+ <!-- strings -->
+ <string>string</string>
+ <normalized_string>normalized string</normalized_string>
+ <token>one two three</token>
+ <name>name</name>
+ <name_token>name-token</name_token>
+ <name_tokens>name tokens</name_tokens>
+ <ncname>ncname</ncname>
+ <language>en-us</language>
+
+ <!-- qualified name -->
+ <qname>xsi:schemaLocation</qname>
+
+
+ <!-- ID/IDREF -->
+ <id>elements1</id>
+ <id>elements2</id>
+ <id_ref>elements1</id_ref>
+ <id_refs>elements1 elements2</id_refs>
+
+
+ <!-- URI -->
+ <any_uri>http://www.codesynthesis.com</any_uri>
+
+
+ <!-- binary -->
+ <base64_binary>YmFzZTY0IGJpbmFyeQ==</base64_binary>
+ <hex_binary>6865782052696E617279</hex_binary>
+
+
+ <!-- date/time -->
+ <date>2001-10-26+02:00</date>
+ <date_time>2001-10-26T21:32:52+02:00</date_time>
+ <duration>P1Y2M3DT5H20M30S</duration>
+ <day>---01+02:00</day>
+ <month>--11+02:00</month>
+ <month_day>--11-02+02:00</month_day>
+ <year>2001+02:00</year>
+ <year_month>2001-11+02:00</year_month>
+ <time>21:32:52+02:00</time>
+
+
+</t:root>
diff --git a/tests/cxx/hybrid/binary/custom/test.xsd b/tests/cxx/hybrid/binary/custom/test.xsd
new file mode 100644
index 0000000..7a92c7e
--- /dev/null
+++ b/tests/cxx/hybrid/binary/custom/test.xsd
@@ -0,0 +1,131 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="test"
+ targetNamespace="test">
+
+ <simpleType name="list">
+ <list itemType="int"/>
+ </simpleType>
+
+ <simpleType name="union">
+ <union memberTypes="int string"/>
+ </simpleType>
+
+ <simpleType name="enumeration">
+ <restriction base="string">
+ <enumeration value="top"/>
+ <enumeration value="left"/>
+ <enumeration value="bottom"/>
+ <enumeration value="right"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="base">
+ <sequence>
+ <element name="a" type="string"/>
+ </sequence>
+ <attribute name="x" type="int" use="required"/>
+ </complexType>
+
+ <complexType name="complex">
+ <complexContent>
+ <extension base="t:base">
+ <sequence>
+ <element name="b" type="string" minOccurs="0"/>
+ <element name="c" type="string" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="y" type="int"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="choice">
+ <choice>
+ <element name="a" type="int" minOccurs="0"/>
+ <element name="b" type="string" maxOccurs="unbounded"/>
+ <sequence>
+ <element name="c" type="double"/>
+ <element name="d" type="boolean"/>
+ </sequence>
+ </choice>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="list" type="t:list"/>
+ <element name="union" type="t:union"/>
+ <element name="enumeration" type="t:enumeration"/>
+ <element name="complex" type="t:complex" maxOccurs="unbounded"/>
+ <element name="choice" type="t:choice" maxOccurs="unbounded"/>
+
+ <!-- integers -->
+ <element name="byte" type="byte"/>
+ <element name="unsigned_byte" type="unsignedByte"/>
+ <element name="short" type="short"/>
+ <element name="unsigned_short" type="unsignedShort"/>
+ <element name="int" type="int"/>
+ <element name="unsigned_int" type="unsignedInt"/>
+ <element name="long" type="long"/>
+ <element name="unsigned_long" type="unsignedLong"/>
+ <element name="integer" type="integer"/>
+ <element name="non_positive_integer" type="nonPositiveInteger"/>
+ <element name="non_negative_integer" type="nonNegativeInteger"/>
+ <element name="positive_integer" type="positiveInteger"/>
+ <element name="negative_integer" type="negativeInteger"/>
+
+
+ <!-- boolean -->
+ <element name="boolean" type="boolean"/>
+
+
+ <!-- floats -->
+ <element name="float" type="float"/>
+ <element name="double" type="double"/>
+ <element name="decimal" type="decimal"/>
+
+
+ <!-- strings -->
+ <element name="string" type="string"/>
+ <element name="normalized_string" type="normalizedString"/>
+ <element name="token" type="token"/>
+ <element name="name" type="Name"/>
+ <element name="name_token" type="NMTOKEN"/>
+ <element name="name_tokens" type="NMTOKENS"/>
+ <element name="ncname" type="NCName"/>
+ <element name="language" type="language"/>
+
+ <!-- qualified name -->
+ <element name="qname" type="QName"/>
+
+
+ <!-- ID/IDREF -->
+ <element name="id" maxOccurs="2" type="ID"/>
+ <element name="id_ref" type="IDREF"/>
+ <element name="id_refs" type="IDREFS"/>
+
+
+ <!-- URI -->
+ <element name="any_uri" type="anyURI"/>
+
+
+ <!-- binary -->
+ <element name="base64_binary" type="base64Binary"/>
+ <element name="hex_binary" type="hexBinary"/>
+
+
+ <!-- date/time -->
+ <element name="date" type="date"/>
+ <element name="date_time" type="dateTime"/>
+ <element name="duration" type="duration"/>
+ <element name="day" type="gDay"/>
+ <element name="month" type="gMonth"/>
+ <element name="month_day" type="gMonthDay"/>
+ <element name="year" type="gYear"/>
+ <element name="year_month" type="gYearMonth"/>
+ <element name="time" type="time"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/hybrid/binary/xdr/driver.cxx b/tests/cxx/hybrid/binary/xdr/driver.cxx
new file mode 100644
index 0000000..2f87dd9
--- /dev/null
+++ b/tests/cxx/hybrid/binary/xdr/driver.cxx
@@ -0,0 +1,147 @@
+// file : tests/cxx/hybrid/binary/xdr/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test XDR insertion and extraction.
+//
+
+#include <stddef.h> // size_t
+#include <string.h> // memcpy
+#include <rpc/xdr.h>
+
+#include <memory>
+#include <iostream>
+
+#include "test.hxx"
+#include "test-pimpl.hxx"
+#include "test-simpl.hxx"
+
+using std::cerr;
+using std::endl;
+
+extern "C" int
+overflow (char* p, char* buf, int n)
+{
+ xml_schema::buffer* dst (reinterpret_cast<xml_schema::buffer*> (p));
+
+ size_t size (dst->size ());
+ dst->size (size + n);
+ memcpy (dst->data () + size, buf, n);
+
+ return n;
+}
+
+struct underflow_info
+{
+ xml_schema::buffer* buf;
+ std::size_t pos;
+};
+
+extern "C" int
+underflow (char* p, char* buf, int n)
+{
+ underflow_info* ui (reinterpret_cast<underflow_info*> (p));
+
+ size_t size (ui->buf->size () - ui->pos);
+ n = size > n ? n : size;
+
+ memcpy (buf, ui->buf->data () + ui->pos, n);
+ ui->pos += n;
+
+ return n;
+}
+
+using namespace test;
+
+int
+main (int argc, char* argv[])
+{
+ /*
+ try
+ {
+ */
+
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ // Parse.
+ //
+ root_paggr root_p;
+
+ xml_schema::document_pimpl doc_p (
+ root_p.root_parser (),
+ root_p.root_namespace (),
+ root_p.root_name ());
+
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ std::auto_ptr<type> r (root_p.post ());
+
+ // Save to an XDR stream.
+ //
+ XDR xdr;
+ xml_schema::buffer buf;
+ xdrrec_create (&xdr, 0, 0, reinterpret_cast<char*> (&buf), 0, &overflow);
+ xdr.x_op = XDR_ENCODE;
+ xml_schema::oxdrstream oxdr (xdr);
+ oxdr << *r;
+ xdrrec_endofrecord (&xdr, true); // flush the data
+ xdr_destroy (&xdr);
+
+ // Load from an XDR stream.
+ //
+ underflow_info ui;
+ ui.buf = &buf;
+ ui.pos = 0;
+ xdrrec_create (&xdr, 0, 0, reinterpret_cast<char*> (&ui), &underflow, 0);
+ xdr.x_op = XDR_DECODE;
+ xdrrec_skiprecord (&xdr);
+ xml_schema::ixdrstream ixdr (xdr);
+ std::auto_ptr<type> c (new type);
+ ixdr >> *c;
+ xdr_destroy (&xdr);
+
+ // Serialize.
+ //
+ root_saggr root_s;
+
+ xml_schema::document_simpl doc_s (
+ root_s.root_serializer (),
+ root_s.root_namespace (),
+ root_s.root_name ());
+
+ doc_s.add_prefix ("t", "test");
+
+ root_s.pre (*c);
+ doc_s.serialize (std::cout);
+ root_s.post ();
+
+ /*
+ }
+ catch (const xml_schema::xdr_exception&)
+ {
+ cerr << "XDR operation filed" << endl;
+ return 1;
+ }
+ catch (const xml_schema::parser_exception& e)
+ {
+ cerr << argv[0] << ":" << e.line () << ":" << e.column () << ": "
+ << e.text () << endl;
+ return 1;
+ }
+ catch (const xml_schema::serializer_exception& e)
+ {
+ cerr << "error: " << e.text () << endl;
+ return 1;
+ }
+ catch (const std::ios_base::failure&)
+ {
+ cerr << argv[0] << ": unable to open or read/write failure" << endl;
+ return 1;
+ }
+ */
+}
diff --git a/tests/cxx/hybrid/binary/xdr/makefile b/tests/cxx/hybrid/binary/xdr/makefile
new file mode 100644
index 0000000..d15723f
--- /dev/null
+++ b/tests/cxx/hybrid/binary/xdr/makefile
@@ -0,0 +1,98 @@
+# file : tests/cxx/hybrid/binary/xdr/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.cxx) \
+ $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.cxx) \
+ $(xsd:.xsd=-pimpl.hxx) $(xsd:.xsd=-pimpl.cxx) \
+ $(xsd:.xsd=-sskel.hxx) $(xsd:.xsd=-sskel.cxx) \
+ $(xsd:.xsd=-simpl.hxx) $(xsd:.xsd=-simpl.cxx)
+
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen): xsde_options += --generate-parser --generate-serializer \
+--generate-aggregate --generate-extraction XDR --generate-insertion XDR
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/test.xml $(src_base)/output.xml
+ $(call message,test $$1,$$1 $(src_base)/test.xml | diff -ubB $(src_base)/output.xml -,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/hybrid/binary/xdr/output.xml b/tests/cxx/hybrid/binary/xdr/output.xml
new file mode 100644
index 0000000..a484661
--- /dev/null
+++ b/tests/cxx/hybrid/binary/xdr/output.xml
@@ -0,0 +1,2 @@
+<t:root xmlns:t="test"><list>1 2 3</list><union>abc</union><enumeration>left</enumeration><complex x="1"><a>aaa</a></complex><complex x="1" y="2"><a>aaa</a><b>bbb</b><c>c</c><c>cc</c><c>ccc</c></complex><choice></choice><choice><a>123</a></choice><choice><b>ab</b><b>cd</b><b>ef</b></choice><choice><c>12.34</c><d>false</d></choice><byte>65</byte><unsigned_byte>66</unsigned_byte><short>-222</short><unsigned_short>57005</unsigned_short><int>-57005</int><unsigned_int>3735928559</unsigned_int><long>-2147483648</long><unsigned_long>2147483647</unsigned_long><integer>-2147483648</integer><non_positive_integer>-2147483648</non_positive_integer><non_negative_integer>2147483647</non_negative_integer><positive_integer>2147483647</positive_integer><negative_integer>-2147483648</negative_integer><boolean>true</boolean><float>1234.12</float><double>12345678.1234568</double><decimal>1234567812345678</decimal><string>string</string><normalized_string>normalized string</normalized_string><token>one two three</token><name>name</name><name_token>name-token</name_token><name_tokens>name tokens</name_tokens><ncname>ncname</ncname><language>en-us</language><qname>xsi:schemaLocation</qname><id>elements1</id><id>elements2</id><id_ref>elements1</id_ref><id_refs>elements1 elements2</id_refs><any_uri>http://www.codesynthesis.com</any_uri><base64_binary>YmFzZTY0IGJpbmFyeQ==
+</base64_binary><hex_binary>6865782052696E617279</hex_binary><date>2001-10-26+02:00</date><date_time>2001-10-26T21:32:52+02:00</date_time><duration>P1Y2M3DT5H20M30S</duration><day>---01+02:00</day><month>--11+02:00</month><month_day>--02-11+02:00</month_day><year>2001+02:00</year><year_month>2001-11+02:00</year_month><time>21:32:52+02:00</time></t:root> \ No newline at end of file
diff --git a/tests/cxx/hybrid/binary/xdr/test.xml b/tests/cxx/hybrid/binary/xdr/test.xml
new file mode 100644
index 0000000..acd75d2
--- /dev/null
+++ b/tests/cxx/hybrid/binary/xdr/test.xml
@@ -0,0 +1,93 @@
+<t:root xmlns:t="test">
+
+ <list>1 2 3</list>
+
+ <union>abc</union>
+
+ <enumeration>left</enumeration>
+
+ <complex x="1">
+ <a>aaa</a>
+ </complex>
+ <complex x="1" y="2">
+ <a>aaa</a>
+ <b>bbb</b>
+ <c>c</c>
+ <c>cc</c>
+ <c>ccc</c>
+ </complex>
+
+ <choice/>
+ <choice><a>123</a></choice>
+ <choice><b>ab</b><b>cd</b><b>ef</b></choice>
+ <choice><c>12.34</c><d>false</d></choice>
+
+ <!-- integers -->
+ <byte>65</byte>
+ <unsigned_byte>66</unsigned_byte>
+ <short>-222</short>
+ <unsigned_short>57005</unsigned_short>
+ <int>-57005</int>
+ <unsigned_int>3735928559</unsigned_int>
+ <long>-2147483648</long>
+ <unsigned_long>2147483647</unsigned_long>
+ <integer>-2147483648</integer>
+ <non_positive_integer>-2147483648</non_positive_integer>
+ <non_negative_integer>2147483647</non_negative_integer>
+ <positive_integer>2147483647</positive_integer>
+ <negative_integer>-2147483648</negative_integer>
+
+
+ <!-- boolean -->
+ <boolean>true</boolean>
+
+
+ <!-- floats -->
+ <float>1234.1234</float>
+ <double>12345678.12345678</double>
+ <decimal>1234567812345678.1234567812345678</decimal>
+
+
+ <!-- strings -->
+ <string>string</string>
+ <normalized_string>normalized string</normalized_string>
+ <token>one two three</token>
+ <name>name</name>
+ <name_token>name-token</name_token>
+ <name_tokens>name tokens</name_tokens>
+ <ncname>ncname</ncname>
+ <language>en-us</language>
+
+ <!-- qualified name -->
+ <qname>xsi:schemaLocation</qname>
+
+
+ <!-- ID/IDREF -->
+ <id>elements1</id>
+ <id>elements2</id>
+ <id_ref>elements1</id_ref>
+ <id_refs>elements1 elements2</id_refs>
+
+
+ <!-- URI -->
+ <any_uri>http://www.codesynthesis.com</any_uri>
+
+
+ <!-- binary -->
+ <base64_binary>YmFzZTY0IGJpbmFyeQ==</base64_binary>
+ <hex_binary>6865782052696E617279</hex_binary>
+
+
+ <!-- date/time -->
+ <date>2001-10-26+02:00</date>
+ <date_time>2001-10-26T21:32:52+02:00</date_time>
+ <duration>P1Y2M3DT5H20M30S</duration>
+ <day>---01+02:00</day>
+ <month>--11+02:00</month>
+ <month_day>--11-02+02:00</month_day>
+ <year>2001+02:00</year>
+ <year_month>2001-11+02:00</year_month>
+ <time>21:32:52+02:00</time>
+
+
+</t:root>
diff --git a/tests/cxx/hybrid/binary/xdr/test.xsd b/tests/cxx/hybrid/binary/xdr/test.xsd
new file mode 100644
index 0000000..7a92c7e
--- /dev/null
+++ b/tests/cxx/hybrid/binary/xdr/test.xsd
@@ -0,0 +1,131 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="test"
+ targetNamespace="test">
+
+ <simpleType name="list">
+ <list itemType="int"/>
+ </simpleType>
+
+ <simpleType name="union">
+ <union memberTypes="int string"/>
+ </simpleType>
+
+ <simpleType name="enumeration">
+ <restriction base="string">
+ <enumeration value="top"/>
+ <enumeration value="left"/>
+ <enumeration value="bottom"/>
+ <enumeration value="right"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="base">
+ <sequence>
+ <element name="a" type="string"/>
+ </sequence>
+ <attribute name="x" type="int" use="required"/>
+ </complexType>
+
+ <complexType name="complex">
+ <complexContent>
+ <extension base="t:base">
+ <sequence>
+ <element name="b" type="string" minOccurs="0"/>
+ <element name="c" type="string" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="y" type="int"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="choice">
+ <choice>
+ <element name="a" type="int" minOccurs="0"/>
+ <element name="b" type="string" maxOccurs="unbounded"/>
+ <sequence>
+ <element name="c" type="double"/>
+ <element name="d" type="boolean"/>
+ </sequence>
+ </choice>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="list" type="t:list"/>
+ <element name="union" type="t:union"/>
+ <element name="enumeration" type="t:enumeration"/>
+ <element name="complex" type="t:complex" maxOccurs="unbounded"/>
+ <element name="choice" type="t:choice" maxOccurs="unbounded"/>
+
+ <!-- integers -->
+ <element name="byte" type="byte"/>
+ <element name="unsigned_byte" type="unsignedByte"/>
+ <element name="short" type="short"/>
+ <element name="unsigned_short" type="unsignedShort"/>
+ <element name="int" type="int"/>
+ <element name="unsigned_int" type="unsignedInt"/>
+ <element name="long" type="long"/>
+ <element name="unsigned_long" type="unsignedLong"/>
+ <element name="integer" type="integer"/>
+ <element name="non_positive_integer" type="nonPositiveInteger"/>
+ <element name="non_negative_integer" type="nonNegativeInteger"/>
+ <element name="positive_integer" type="positiveInteger"/>
+ <element name="negative_integer" type="negativeInteger"/>
+
+
+ <!-- boolean -->
+ <element name="boolean" type="boolean"/>
+
+
+ <!-- floats -->
+ <element name="float" type="float"/>
+ <element name="double" type="double"/>
+ <element name="decimal" type="decimal"/>
+
+
+ <!-- strings -->
+ <element name="string" type="string"/>
+ <element name="normalized_string" type="normalizedString"/>
+ <element name="token" type="token"/>
+ <element name="name" type="Name"/>
+ <element name="name_token" type="NMTOKEN"/>
+ <element name="name_tokens" type="NMTOKENS"/>
+ <element name="ncname" type="NCName"/>
+ <element name="language" type="language"/>
+
+ <!-- qualified name -->
+ <element name="qname" type="QName"/>
+
+
+ <!-- ID/IDREF -->
+ <element name="id" maxOccurs="2" type="ID"/>
+ <element name="id_ref" type="IDREF"/>
+ <element name="id_refs" type="IDREFS"/>
+
+
+ <!-- URI -->
+ <element name="any_uri" type="anyURI"/>
+
+
+ <!-- binary -->
+ <element name="base64_binary" type="base64Binary"/>
+ <element name="hex_binary" type="hexBinary"/>
+
+
+ <!-- date/time -->
+ <element name="date" type="date"/>
+ <element name="date_time" type="dateTime"/>
+ <element name="duration" type="duration"/>
+ <element name="day" type="gDay"/>
+ <element name="month" type="gMonth"/>
+ <element name="month_day" type="gMonthDay"/>
+ <element name="year" type="gYear"/>
+ <element name="year_month" type="gYearMonth"/>
+ <element name="time" type="time"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/hybrid/makefile b/tests/cxx/hybrid/makefile
index 3351241..84fed4c 100644
--- a/tests/cxx/hybrid/makefile
+++ b/tests/cxx/hybrid/makefile
@@ -10,6 +10,14 @@ tests := sequences
ifeq ($(xsde_iostream),y)
tests += built-in list test-template union
+ifeq ($(xsde_cdr),y)
+tests += binary/cdr
+endif
+
+ifeq ($(xsde_xdr),y)
+tests += binary/xdr
+endif
+
ifeq ($(xsde_parser_validation),y)
tests += choice
endif
diff --git a/xsde/cxx/hybrid/cli.hxx b/xsde/cxx/hybrid/cli.hxx
index 57aa3d4..be680ea 100644
--- a/xsde/cxx/hybrid/cli.hxx
+++ b/xsde/cxx/hybrid/cli.hxx
@@ -33,6 +33,8 @@ namespace CXX
extern Key suppress_validation;
extern Key suppress_parser_val;
extern Key suppress_serializer_val;
+ extern Key generate_insertion;
+ extern Key generate_extraction;
extern Key generate_inline;
extern Key generate_forward;
extern Key generate_xml_schema;
@@ -111,6 +113,8 @@ namespace CXX
suppress_validation, Boolean,
suppress_parser_val, Boolean,
suppress_serializer_val, Boolean,
+ generate_insertion, Cult::Containers::Vector<NarrowString>,
+ generate_extraction, Cult::Containers::Vector<NarrowString>,
generate_inline, Boolean,
generate_forward, Boolean,
generate_xml_schema, Boolean,
diff --git a/xsde/cxx/hybrid/elements.cxx b/xsde/cxx/hybrid/elements.cxx
index 454d0c3..c7609ff 100644
--- a/xsde/cxx/hybrid/elements.cxx
+++ b/xsde/cxx/hybrid/elements.cxx
@@ -41,11 +41,29 @@ namespace CXX
fwd_expr (fe),
hxx_expr (he),
ixx_expr (ie),
- ns_stack (ns_stack_)
+ ns_stack (ns_stack_),
+ istreams (ops.value<CLI::generate_extraction> ()),
+ ostreams (ops.value<CLI::generate_insertion> ()),
+ icdrstream (icdrstream_),
+ ocdrstream (ocdrstream_),
+ ixdrstream (ixdrstream_),
+ oxdrstream (oxdrstream_)
{
String xs_ns (xs_ns_name ());
string_type = L"::xsde::cxx::ro_string";
+
+ if (!ostreams.empty ())
+ {
+ ocdrstream = xs_ns + L"::ocdrstream";
+ oxdrstream = xs_ns + L"::oxdrstream";
+ }
+
+ if (!istreams.empty ())
+ {
+ icdrstream = xs_ns + L"::icdrstream";
+ ixdrstream = xs_ns + L"::ixdrstream";
+ }
}
// Parser
@@ -384,6 +402,28 @@ namespace CXX
}
}
+ String Context::
+ istream (NarrowString const& is) const
+ {
+ if (is == "CDR")
+ return icdrstream;
+ else if (is == "XDR")
+ return ixdrstream;
+ else
+ return is;
+ }
+
+ String Context::
+ ostream (NarrowString const& os) const
+ {
+ if (os == "CDR")
+ return ocdrstream;
+ else if (os == "XDR")
+ return oxdrstream;
+ else
+ return os;
+ }
+
// Namespace
//
Namespace::
diff --git a/xsde/cxx/hybrid/elements.hxx b/xsde/cxx/hybrid/elements.hxx
index 816c80f..73caa35 100644
--- a/xsde/cxx/hybrid/elements.hxx
+++ b/xsde/cxx/hybrid/elements.hxx
@@ -49,7 +49,13 @@ namespace CXX
fwd_expr (c.fwd_expr),
hxx_expr (c.hxx_expr),
ixx_expr (c.ixx_expr),
- ns_stack (c.ns_stack)
+ ns_stack (c.ns_stack),
+ istreams (c.istreams),
+ ostreams (c.ostreams),
+ icdrstream (c.icdrstream),
+ ocdrstream (c.ocdrstream),
+ ixdrstream (c.ixdrstream),
+ oxdrstream (c.oxdrstream)
{
}
@@ -66,7 +72,13 @@ namespace CXX
fwd_expr (c.fwd_expr),
hxx_expr (c.hxx_expr),
ixx_expr (c.ixx_expr),
- ns_stack (c.ns_stack)
+ ns_stack (c.ns_stack),
+ istreams (c.istreams),
+ ostreams (c.ostreams),
+ icdrstream (c.icdrstream),
+ ocdrstream (c.ocdrstream),
+ ixdrstream (c.ixdrstream),
+ oxdrstream (c.oxdrstream)
{
}
@@ -468,6 +480,13 @@ namespace CXX
}
public:
+ String
+ istream (NarrowString const& is) const;
+
+ String
+ ostream (NarrowString const& os) const;
+
+ public:
Void
close_ns ();
@@ -496,8 +515,22 @@ namespace CXX
NamespaceStack& ns_stack;
+ typedef Containers::Vector<NarrowString> Streams;
+ Streams const& istreams;
+ Streams const& ostreams;
+
+ String& icdrstream;
+ String& ocdrstream;
+ String& ixdrstream;
+ String& oxdrstream;
+
private:
NamespaceStack ns_stack_;
+
+ String icdrstream_;
+ String ocdrstream_;
+ String ixdrstream_;
+ String oxdrstream_;
};
//
diff --git a/xsde/cxx/hybrid/extraction-header.cxx b/xsde/cxx/hybrid/extraction-header.cxx
new file mode 100644
index 0000000..8b7490f
--- /dev/null
+++ b/xsde/cxx/hybrid/extraction-header.cxx
@@ -0,0 +1,255 @@
+// file : xsd/cxx/hybrid/extraction-header.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <cxx/hybrid/extraction-header.hxx>
+
+#include <xsd-frontend/semantic-graph.hxx>
+#include <xsd-frontend/traversal.hxx>
+
+namespace CXX
+{
+ namespace Hybrid
+ {
+ namespace
+ {
+ struct List : Traversal::List, Context
+ {
+ List (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (Type& l)
+ {
+ String name (ename (l));
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator>> (" << istream (*i) << "&," << endl
+ << name << "&);"
+ << endl;
+ }
+ }
+ };
+
+ struct Union : Traversal::Union, Context
+ {
+ Union (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (Type& u)
+ {
+ String name (ename (u));
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator>> (" << istream (*i) << "&," << endl
+ << name << "&);"
+ << endl;
+ }
+ }
+ };
+
+ //
+ // Nested classes.
+ //
+
+ struct All: Traversal::All, Context
+ {
+ All (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::All& a)
+ {
+ // For the all compositor, maxOccurs=1 and minOccurs={0,1}
+ // and it can only contain particles.
+ //
+ if (a.min () == 0)
+ {
+ String const& type (etype (a));
+ String const& scope (Context::scope (a));
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator>> (" << istream (*i) << "&," << endl
+ << scope << "::" << type << "&);"
+ << endl;
+ }
+ }
+ }
+ };
+
+ struct Choice: Traversal::Choice, Context
+ {
+ Choice (Context& c, Boolean in_choice)
+ : Context (c), in_choice_ (in_choice)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Choice& c)
+ {
+ // When choice is in choice we generate nested class even
+ // for min == max == 1.
+ //
+ if (in_choice_ || c.max () != 1 || c.min () == 0)
+ {
+ String const& type (etype (c));
+ String const& scope (Context::scope (c));
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator>> (" << istream (*i) << "&," << endl
+ << scope << "::" << type << "&);"
+ << endl;
+ }
+ }
+
+ Choice::contains (c);
+ }
+
+ private:
+ Boolean in_choice_;
+ };
+
+
+ struct Sequence: Traversal::Sequence, Context
+ {
+ Sequence (Context& c, Boolean in_choice)
+ : Context (c), in_choice_ (in_choice)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Sequence& s)
+ {
+ // When sequence is in choice we generate nested class even
+ // for min == max == 1.
+ //
+ if (in_choice_ || s.max () != 1 || s.min () == 0)
+ {
+ String const& type (etype (s));
+ String const& scope (Context::scope (s));
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator>> (" << istream (*i) << "&," << endl
+ << scope << "::" << type << "&);"
+ << endl;
+ }
+ }
+
+ Sequence::contains (s);
+ }
+
+ private:
+ Boolean in_choice_;
+ };
+
+ struct Complex : Traversal::Complex, Context
+ {
+ Complex (Context& c)
+ : Context (c),
+ all_ (c),
+ choice_in_choice_ (c, true),
+ choice_in_sequence_ (c, false),
+ sequence_in_choice_ (c, true),
+ sequence_in_sequence_ (c, false)
+ {
+ all_ >> all_contains_;
+
+ choice_in_choice_ >> choice_contains_;
+ choice_in_sequence_ >> choice_contains_;
+ choice_contains_ >> choice_in_choice_;
+ choice_contains_ >> sequence_in_choice_;
+
+ sequence_in_choice_ >> sequence_contains_;
+ sequence_in_sequence_ >> sequence_contains_;
+ sequence_contains_ >> choice_in_sequence_;
+ sequence_contains_ >> sequence_in_sequence_;
+
+ contains_compositor_ >> all_;
+ contains_compositor_ >> choice_in_sequence_;
+ contains_compositor_ >> sequence_in_sequence_;
+ }
+
+ virtual Void
+ traverse (Type& c)
+ {
+ if (!restriction_p (c))
+ {
+ String name (ename (c));
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator>> (" << istream (*i) << "&," << endl
+ << name << "&);"
+ << endl;
+ }
+
+ // Operators for nested classes.
+ //
+ if (c.contains_compositor_p ())
+ Complex::contains_compositor (c, contains_compositor_);
+ }
+ }
+
+ private:
+ All all_;
+ Choice choice_in_choice_;
+ Choice choice_in_sequence_;
+ Sequence sequence_in_choice_;
+ Sequence sequence_in_sequence_;
+ Traversal::ContainsParticle all_contains_;
+ Traversal::ContainsParticle choice_contains_;
+ Traversal::ContainsParticle sequence_contains_;
+
+ Traversal::ContainsCompositor contains_compositor_;
+ };
+ }
+
+ Void
+ generate_extraction_header (Context& ctx)
+ {
+ Traversal::Schema schema;
+ Traversal::Sources sources;
+ Traversal::Names names_ns, names;
+
+ Namespace ns (ctx);
+
+ List list (ctx);
+ Union union_ (ctx);
+ Complex complex (ctx);
+
+ schema >> sources >> schema;
+ schema >> names_ns >> ns >> names;
+
+ names >> list;
+ names >> union_;
+ names >> complex;
+
+ schema.dispatch (ctx.schema_root);
+ }
+ }
+}
diff --git a/xsde/cxx/hybrid/extraction-header.hxx b/xsde/cxx/hybrid/extraction-header.hxx
new file mode 100644
index 0000000..dc5b391
--- /dev/null
+++ b/xsde/cxx/hybrid/extraction-header.hxx
@@ -0,0 +1,22 @@
+// file : xsde/cxx/hybrid/extraction-header.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef CXX_HYBRID_EXTRACTION_HEADER_HXX
+#define CXX_HYBRID_EXTRACTION_HEADER_HXX
+
+#include <xsd-frontend/semantic-graph/schema.hxx>
+
+#include <cxx/hybrid/elements.hxx>
+
+namespace CXX
+{
+ namespace Hybrid
+ {
+ Void
+ generate_extraction_header (Context&);
+ }
+}
+
+#endif // CXX_HYBRID_EXTRACTION_HEADER_HXX
diff --git a/xsde/cxx/hybrid/extraction-source.cxx b/xsde/cxx/hybrid/extraction-source.cxx
new file mode 100644
index 0000000..44af7e0
--- /dev/null
+++ b/xsde/cxx/hybrid/extraction-source.cxx
@@ -0,0 +1,1063 @@
+// file : xsd/cxx/hybrid/extraction-source.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <cxx/hybrid/extraction-source.hxx>
+
+#include <xsd-frontend/semantic-graph.hxx>
+#include <xsd-frontend/traversal.hxx>
+
+namespace CXX
+{
+ namespace Hybrid
+ {
+ namespace
+ {
+ struct List : Traversal::List, Context
+ {
+ List (Context& c)
+ : Context (c), base_name_ (c, TypeName::seq)
+ {
+ }
+
+ virtual Void
+ traverse (Type& l)
+ {
+ String name (ename (l));
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator>> (" << istream (*i) << "& s," << endl
+ << name << "& x)"
+ << "{";
+
+ base_name_.dispatch (l.argumented ().type ());
+
+ os << "& b = x;"
+ << (exceptions ? "" : "return ") << "s >> b;"
+ << "}";
+ }
+ }
+
+ private:
+ TypeName base_name_;
+ };
+
+ struct Union : Traversal::Union, Context
+ {
+ Union (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (Type& u)
+ {
+ String name (ename (u));
+ String const& value (u.context ().get<String> ("value"));
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator>> (" << istream (*i) << "& s," << endl
+ << name << "& x)"
+ << "{"
+ << (stl ? "::std::string" : "char*") << " i;";
+
+ if (exceptions)
+ os << "s >> i;";
+ else
+ os << "if (!(s >> i))" << endl
+ << "return false;";
+
+ os << "x." << value << " (i);"
+ << (exceptions ? "" : "return true;")
+ << "}";
+ }
+ }
+ };
+
+ //
+ // Data.
+ //
+
+ struct AttributeData: Traversal::Attribute, Context
+ {
+ AttributeData (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Attribute& a)
+ {
+ SemanticGraph::Type& t (a.type ());
+
+ Boolean fl (fixed_length (t));
+ Boolean st (false);
+
+ String const& name (ename (a));
+
+ if (!fl)
+ {
+ StringType test (st);
+ test.dispatch (t);
+ }
+
+ os << "{";
+
+ if (a.optional ())
+ {
+ os << "bool p;";
+
+ if (exceptions)
+ os << "s >> p;";
+ else
+ os << endl
+ << "if (!(s >> p))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (p)"
+ << "{";
+
+ if (fl)
+ os << "x." << epresent (a) << " (true);";
+ }
+
+ if (st)
+ {
+ // C-string requires special handling.
+ //
+ os << "char* i;";
+
+ if (exceptions)
+ os << "s >> i;";
+ else
+ os << "if (!(s >> i))" << endl
+ << "return false;";
+
+ os << "x." << name << " (i);";
+ }
+ else
+ {
+ if (!fl)
+ {
+ String fq (fq_name (t));
+
+ if (exceptions)
+ os << "x." << name << " (new " << fq << ");";
+ else
+ os << fq << "* i = new " << fq << ";"
+ << endl
+ << "if (i == 0)" << endl
+ << "return false;"
+ << endl
+ << "x." << name << " (i);";
+ }
+
+ if (exceptions)
+ os << "s >> x." << name << " ();";
+ else
+ os << "if (!(s >> x." << name << " ()))" << endl
+ << "return false;";
+ }
+
+ if (a.optional ())
+ os << "}"
+ << "else" << endl
+ << "x." << epresent (a) << " (false);";
+
+ os << "}";
+ }
+ };
+
+
+ struct ElementData: Traversal::Element, Context
+ {
+ ElementData (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Element& e)
+ {
+ // See also ChoiceParticleData.
+ //
+ String const& name (ename (e));
+
+ if (e.max () != 1)
+ {
+ if (exceptions)
+ os << "s >> x." << name << " ();";
+ else
+ os << "if (!(s >> x." << name << " ()))" << endl
+ << "return false;";
+ }
+ else
+ {
+ SemanticGraph::Type& t (e.type ());
+
+ Boolean fl (fixed_length (t));
+ Boolean st (false);
+
+ if (!fl)
+ {
+ StringType test (st);
+ test.dispatch (t);
+ }
+
+ os << "{";
+
+ if (e.min () == 0)
+ {
+ os << "bool p;";
+
+ if (exceptions)
+ os << "s >> p;";
+ else
+ os << endl
+ << "if (!(s >> p))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (p)"
+ << "{";
+
+ if (fl)
+ os << "x." << epresent (e) << " (true);";
+ }
+
+ if (st)
+ {
+ // C-string requires special handling.
+ //
+ os << "char* i;";
+
+ if (exceptions)
+ os << "s >> i;";
+ else
+ os << "if (!(s >> i))" << endl
+ << "return false;";
+
+ os << "x." << name << " (i);";
+ }
+ else
+ {
+ if (!fl)
+ {
+ String fq (fq_name (t));
+
+ if (exceptions)
+ os << "x." << name << " (new " << fq << ");";
+ else
+ os << fq << "* i = new " << fq << ";"
+ << endl
+ << "if (i == 0)" << endl
+ << "return false;"
+ << endl
+ << "x." << name << " (i);";
+ }
+
+ if (exceptions)
+ os << "s >> x." << name << " ();";
+ else
+ os << "if (!(s >> x." << name << " ()))" << endl
+ << "return false;";
+ }
+
+ if (e.min () == 0)
+ os << "}"
+ << "else" << endl
+ << "x." << epresent (e) << " (false);";
+
+ os << "}";
+ }
+ }
+ };
+
+ struct AllData: Traversal::All, Context
+ {
+ AllData (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::All& a)
+ {
+ // For the all compositor, maxOccurs=1 and minOccurs={0,1}
+ // and it can only contain particles.
+ //
+ if (a.min () == 0)
+ {
+ Boolean fl (fixed_length (a));
+
+ String const& name (ename (a));
+ String const& present (epresent (a));
+
+ os << "{"
+ << "bool p;";
+
+ if (exceptions)
+ os << "s >> p;";
+ else
+ os << endl
+ << "if (!(s >> p))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (p)"
+ << "{";
+
+ if (fl)
+ os << "x." << present << " (true);";
+
+ if (!fl)
+ {
+ String fq (scope (a) + L"::" + etype (a));
+
+ if (exceptions)
+ os << "x." << name << " (new " << fq << ");";
+ else
+ os << fq << "* i = new " << fq << ";"
+ << endl
+ << "if (i == 0)" << endl
+ << "return false;"
+ << endl
+ << "x." << name << " (i);";
+ }
+
+ if (exceptions)
+ os << "s >> x." << name << " ();";
+ else
+ os << "if (!(s >> x." << name << " ()))" << endl
+ << "return false;";
+
+ os << "}"
+ << "else" << endl
+ << "x." << present << " (false);"
+ << "}";
+ }
+ else
+ All::contains (a);
+ }
+ };
+
+ struct ChoiceParticleData: Traversal::Element,
+ Traversal::Compositor,
+ Context
+ {
+ ChoiceParticleData (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Element& e)
+ {
+ os << "case " << scope (e) << "::" << etag (e) << ":"
+ << "{";
+
+ // Same as ElementData except that we don't need the extra scope.
+ //
+ String const& name (ename (e));
+
+ if (e.max () != 1)
+ {
+ if (exceptions)
+ os << "s >> x." << name << " ();";
+ else
+ os << "if (!(s >> x." << name << " ()))" << endl
+ << "return false;";
+ }
+ else
+ {
+ SemanticGraph::Type& t (e.type ());
+
+ Boolean fl (fixed_length (t));
+ Boolean st (false);
+
+ if (!fl)
+ {
+ StringType test (st);
+ test.dispatch (t);
+ }
+
+ if (e.min () == 0)
+ {
+ os << "bool p;";
+
+ if (exceptions)
+ os << "s >> p;";
+ else
+ os << endl
+ << "if (!(s >> p))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (p)"
+ << "{";
+
+ if (fl)
+ os << "x." << epresent (e) << " (true);";
+ }
+
+ if (st)
+ {
+ // C-string requires special handling.
+ //
+ os << "char* i;";
+
+ if (exceptions)
+ os << "s >> i;";
+ else
+ os << "if (!(s >> i))" << endl
+ << "return false;";
+
+ os << "x." << name << " (i);";
+ }
+ else
+ {
+ if (!fl)
+ {
+ String fq (fq_name (t));
+
+ if (exceptions)
+ os << "x." << name << " (new " << fq << ");";
+ else
+ os << fq << "* i = new " << fq << ";"
+ << endl
+ << "if (i == 0)" << endl
+ << "return false;"
+ << endl
+ << "x." << name << " (i);";
+ }
+
+ if (exceptions)
+ os << "s >> x." << name << " ();";
+ else
+ os << "if (!(s >> x." << name << " ()))" << endl
+ << "return false;";
+ }
+
+ if (e.min () == 0)
+ os << "}"
+ << "else" << endl
+ << "x." << epresent (e) << " (false);";
+ }
+
+ os << "break;"
+ << "}";
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Compositor& c)
+ {
+ os << "case " << scope (c) << "::" << etag (c) << ":"
+ << "{";
+
+ // A compositor in choice always results in a nested class.
+ //
+ String const& name (ename (c));
+
+ if (c.max () != 1)
+ {
+ String const& name (ename (c));
+
+ if (exceptions)
+ os << "s >> x." << name << " ();";
+ else
+ os << "if (!(s >> x." << name << " ()))" << endl
+ << "return false;";
+ }
+ else
+ {
+ Boolean fl (fixed_length (c));
+
+ if (c.min () == 0)
+ {
+ os << "bool p;";
+
+ if (exceptions)
+ os << "s >> p;";
+ else
+ os << endl
+ << "if (!(s >> p))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (p)"
+ << "{";
+
+ if (fl)
+ os << "x." << epresent (c) << " (true);";
+ }
+
+ if (!fl)
+ {
+ String fq (scope (c) + L"::" + etype (c));
+
+ if (exceptions)
+ os << "x." << name << " (new " << fq << ");";
+ else
+ os << fq << "* i = new " << fq << ";"
+ << endl
+ << "if (i == 0)" << endl
+ << "return false;"
+ << endl
+ << "x." << name << " (i);";
+ }
+
+ if (exceptions)
+ os << "s >> x." << name << " ();";
+ else
+ os << "if (!(s >> x." << name << " ()))" << endl
+ << "return false;";
+
+ if (c.min () == 0)
+ os << "}"
+ << "else" << endl
+ << "x." << epresent (c) << " (false);";
+ }
+
+ os << "break;"
+ << "}";
+ }
+ };
+
+ struct ChoiceInSequenceData: Traversal::Choice, Context
+ {
+ ChoiceInSequenceData (Context& c)
+ : Context (c), particle_data_ (c)
+ {
+ contains_data_ >> particle_data_;
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Choice& c)
+ {
+ if (c.max () != 1)
+ {
+ String const& name (ename (c));
+
+ if (exceptions)
+ os << "s >> x." << name << " ();";
+ else
+ os << "if (!(s >> x." << name << " ()))" << endl
+ << "return false;";
+ }
+ else if (c.min () == 0)
+ {
+ Boolean fl (fixed_length (c));
+
+ String const& name (ename (c));
+ String const& present (epresent (c));
+
+ os << "{"
+ << "bool p;";
+
+ if (exceptions)
+ os << "s >> p;";
+ else
+ os << endl
+ << "if (!(s >> p))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (p)"
+ << "{";
+
+ if (fl)
+ os << "x." << present << " (true);";
+
+ if (!fl)
+ {
+ String fq (scope (c) + L"::" + etype (c));
+
+ if (exceptions)
+ os << "x." << name << " (new " << fq << ");";
+ else
+ os << fq << "* i = new " << fq << ";"
+ << endl
+ << "if (i == 0)" << endl
+ << "return false;"
+ << endl
+ << "x." << name << " (i);";
+ }
+
+ if (exceptions)
+ os << "s >> x." << name << " ();";
+ else
+ os << "if (!(s >> x." << name << " ()))" << endl
+ << "return false;";
+
+ os << "}"
+ << "else" << endl
+ << "x." << present << " (false);"
+ << "}";
+ }
+ else
+ {
+ String const& arm (earm (c));
+
+ os << "{"
+ << "unsigned int i;";
+
+ if (exceptions)
+ os << "s >> i;";
+ else
+ os << "if (!(s >> i))" << endl
+ << "return false;";
+
+ os << "x." << arm << " (static_cast< " << scope (c) << "::" <<
+ earm_tag (c) << " > (i));";
+
+ os << "switch (x." << arm << " ())"
+ << "{";
+
+ Choice::contains (c, contains_data_);
+
+ os << "default:" << endl
+ << "break;"
+ << "}"
+ << "}";
+ }
+ }
+
+ private:
+ ChoiceParticleData particle_data_;
+ Traversal::ContainsParticle contains_data_;
+ };
+
+ struct SequenceInSequenceData: Traversal::Sequence, Context
+ {
+ SequenceInSequenceData (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Sequence& s)
+ {
+ if (s.max () != 1)
+ {
+ String const& name (ename (s));
+
+ if (exceptions)
+ os << "s >> x." << name << " ();";
+ else
+ os << "if (!(s >> x." << name << " ()))" << endl
+ << "return false;";
+ }
+ else if (s.min () == 0)
+ {
+ Boolean fl (fixed_length (s));
+
+ String const& name (ename (s));
+ String const& present (epresent (s));
+
+ os << "{"
+ << "bool p;";
+
+ if (exceptions)
+ os << "s >> p;";
+ else
+ os << endl
+ << "if (!(s >> p))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (p)"
+ << "{";
+
+ if (fl)
+ os << "x." << present << " (true);";
+
+ if (!fl)
+ {
+ String fq (scope (s) + L"::" + etype (s));
+
+ if (exceptions)
+ os << "x." << name << " (new " << fq << ");";
+ else
+ os << fq << "* i = new " << fq << ";"
+ << endl
+ << "if (i == 0)" << endl
+ << "return false;"
+ << endl
+ << "x." << name << " (i);";
+ }
+
+ if (exceptions)
+ os << "s >> x." << name << " ();";
+ else
+ os << "if (!(s >> x." << name << " ()))" << endl
+ << "return false;";
+
+ os << "}"
+ << "else" << endl
+ << "x." << present << " (false);"
+ << "}";
+ }
+ else
+ Sequence::contains (s);
+ }
+ };
+
+ //
+ // Nested classes.
+ //
+
+ struct All: Traversal::All, Context
+ {
+ All (Context& c, Traversal::ContainsParticle& contains_data)
+ : Context (c), contains_data_ (contains_data)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::All& a)
+ {
+ // For the all compositor, maxOccurs=1 and minOccurs={0,1}
+ // and it can only contain particles.
+ //
+ if (a.min () == 0)
+ {
+ String const& type (etype (a));
+ String const& scope (Context::scope (a));
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator>> (" << istream (*i) << "& s," << endl
+ << scope << "::" << type << "& x)"
+ << "{"
+ << "XSDE_UNUSED (s);"
+ << "XSDE_UNUSED (x);"
+ << endl;
+
+ All::contains (a, contains_data_);
+
+ os << (exceptions ? "" : "return true;")
+ << "}";
+ }
+ }
+ }
+
+ private:
+ Traversal::ContainsParticle& contains_data_;
+ };
+
+ struct Choice: Traversal::Choice, Context
+ {
+ Choice (Context& c, Boolean in_choice)
+ : Context (c), in_choice_ (in_choice), particle_data_ (c)
+ {
+ contains_data_ >> particle_data_;
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Choice& c)
+ {
+ // When choice is in choice we generate nested class even
+ // for min == max == 1.
+ //
+ if (in_choice_ || c.max () != 1 || c.min () == 0)
+ {
+ String const& arm (earm (c));
+ String const& type (etype (c));
+ String const& scope (Context::scope (c));
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator>> (" << istream (*i) << "& s," << endl
+ << scope << "::" << type << "& x)"
+ << "{"
+ << "XSDE_UNUSED (s);"
+ << endl
+ << "unsigned int i;";
+
+ if (exceptions)
+ os << "s >> i;";
+ else
+ os << "if (!(s >> i))" << endl
+ << "return false;";
+
+ os << "x." << arm << " (static_cast< " << scope << "::" <<
+ type << "::" << earm_tag (c) << " > (i));";
+
+ os << "switch (x." << arm << " ())"
+ << "{";
+
+ Choice::contains (c, contains_data_);
+
+ os << "default:" << endl
+ << "break;"
+ << "}"
+ << (exceptions ? "" : "return true;")
+ << "}";
+ }
+ }
+
+ Choice::contains (c);
+ }
+
+ private:
+ Boolean in_choice_;
+
+ ChoiceParticleData particle_data_;
+ Traversal::ContainsParticle contains_data_;
+ };
+
+
+ struct Sequence: Traversal::Sequence, Context
+ {
+ Sequence (Context& c,
+ Boolean in_choice,
+ Traversal::ContainsParticle& contains_data)
+ : Context (c),
+ in_choice_ (in_choice),
+ contains_data_ (contains_data)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Sequence& s)
+ {
+ // When sequence is in choice we generate nested class even
+ // for min == max == 1.
+ //
+ if (in_choice_ || s.max () != 1 || s.min () == 0)
+ {
+ String const& type (etype (s));
+ String const& scope (Context::scope (s));
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator>> (" << istream (*i) << "& s," << endl
+ << scope << "::" << type << "& x)"
+ << "{"
+ << "XSDE_UNUSED (s);"
+ << "XSDE_UNUSED (x);"
+ << endl;
+
+ Sequence::contains (s, contains_data_);
+
+ os << (exceptions ? "" : "return true;")
+ << "}";
+ }
+ }
+
+ Sequence::contains (s);
+ }
+
+ private:
+ Boolean in_choice_;
+ Traversal::ContainsParticle& contains_data_;
+ };
+
+ struct Complex : Traversal::Complex, Context
+ {
+ Complex (Context& c)
+ : Context (c),
+
+ // Use ret instead of base to get auto-conversion
+ // for fundamental types from the wrappers.
+ //
+ base_name_ (c, TypeName::ret),
+
+ // Data
+ //
+ attribute_data_ (c),
+ element_data_ (c),
+ all_data_ (c),
+ choice_in_sequence_data_ (c),
+ sequence_in_sequence_data_ (c),
+
+ // Nested classes.
+ //
+ all_ (c, all_contains_data_),
+ choice_in_choice_ (c, true),
+ choice_in_sequence_ (c, false),
+ sequence_in_choice_ (c, true, sequence_contains_data_),
+ sequence_in_sequence_ (c, false, sequence_contains_data_)
+ {
+ // Data.
+ //
+ attribute_names_data_ >> attribute_data_;
+
+ all_data_ >> all_contains_data_ >> element_data_;
+
+ sequence_in_sequence_data_ >> sequence_contains_data_;
+ sequence_contains_data_ >> element_data_;
+ sequence_contains_data_ >> choice_in_sequence_data_;
+ sequence_contains_data_ >> sequence_in_sequence_data_;
+
+ contains_compositor_data_ >> all_data_;
+ contains_compositor_data_ >> choice_in_sequence_data_;
+ contains_compositor_data_ >> sequence_in_sequence_data_;
+
+ // Nested classes.
+ //
+ all_ >> all_contains_;
+
+ choice_in_choice_ >> choice_contains_;
+ choice_in_sequence_ >> choice_contains_;
+ choice_contains_ >> choice_in_choice_;
+ choice_contains_ >> sequence_in_choice_;
+
+ sequence_in_choice_ >> sequence_contains_;
+ sequence_in_sequence_ >> sequence_contains_;
+ sequence_contains_ >> choice_in_sequence_;
+ sequence_contains_ >> sequence_in_sequence_;
+
+ contains_compositor_ >> all_;
+ contains_compositor_ >> choice_in_sequence_;
+ contains_compositor_ >> sequence_in_sequence_;
+ }
+
+ virtual Void
+ traverse (Type& c)
+ {
+ Boolean restriction (restriction_p (c));
+
+ String name (ename (c));
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator>> (" << istream (*i) << "& s," << endl
+ << name << "& x)"
+ << "{"
+ << "XSDE_UNUSED (s);"
+ << "XSDE_UNUSED (x);"
+ << endl;
+
+ if (c.inherits_p ())
+ {
+ SemanticGraph::Type& b (c.inherits ().base ());
+
+ Boolean c_str (false);
+
+ if (!stl)
+ {
+ StringType test (c_str);
+ test.dispatch (b);
+ }
+
+ // Special handling for C-string base.
+ //
+ if (c_str)
+ {
+ os << "char* b;";
+
+ if (exceptions)
+ os << "s >> b;";
+ else
+ os << "if (!(s >> b))" << endl
+ << "return false;"
+ << endl;
+
+ os << "x.base_value (b);"
+ << endl;
+ }
+ else
+ {
+ base_name_.dispatch (b);
+ os << " b = x;";
+
+ if (exceptions)
+ os << "s >> b;";
+ else
+ os << "if (!(s >> b))" << endl
+ << "return false;"
+ << endl;
+ }
+ }
+
+ if (!restriction)
+ {
+ Complex::names (c, attribute_names_data_);
+
+ if (c.contains_compositor_p ())
+ Complex::contains_compositor (c, contains_compositor_data_);
+ }
+
+ os << (exceptions ? "" : "return true;")
+ << "}";
+ }
+
+ // Operators for nested classes.
+ //
+ if (!restriction && c.contains_compositor_p ())
+ Complex::contains_compositor (c, contains_compositor_);
+ }
+
+ private:
+ TypeName base_name_;
+
+ // Data.
+ //
+ AttributeData attribute_data_;
+ Traversal::Names attribute_names_data_;
+
+ ElementData element_data_;
+ AllData all_data_;
+ ChoiceInSequenceData choice_in_sequence_data_;
+ SequenceInSequenceData sequence_in_sequence_data_;
+ Traversal::ContainsParticle all_contains_data_;
+ Traversal::ContainsParticle sequence_contains_data_;
+
+ Traversal::ContainsCompositor contains_compositor_data_;
+
+ // Nested classes.
+ //
+ All all_;
+ Choice choice_in_choice_;
+ Choice choice_in_sequence_;
+ Sequence sequence_in_choice_;
+ Sequence sequence_in_sequence_;
+ Traversal::ContainsParticle all_contains_;
+ Traversal::ContainsParticle choice_contains_;
+ Traversal::ContainsParticle sequence_contains_;
+
+ Traversal::ContainsCompositor contains_compositor_;
+ };
+ }
+
+ Void
+ generate_extraction_source (Context& ctx)
+ {
+ Traversal::Schema schema;
+ Traversal::Sources sources;
+ Traversal::Names names_ns, names;
+
+ Namespace ns (ctx);
+
+ List list (ctx);
+ Union union_ (ctx);
+ Complex complex (ctx);
+
+ schema >> sources >> schema;
+ schema >> names_ns >> ns >> names;
+
+ names >> list;
+ names >> union_;
+ names >> complex;
+
+ schema.dispatch (ctx.schema_root);
+ }
+ }
+}
diff --git a/xsde/cxx/hybrid/extraction-source.hxx b/xsde/cxx/hybrid/extraction-source.hxx
new file mode 100644
index 0000000..ee65b3e
--- /dev/null
+++ b/xsde/cxx/hybrid/extraction-source.hxx
@@ -0,0 +1,22 @@
+// file : xsde/cxx/hybrid/extraction-source.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef CXX_HYBRID_EXTRACTION_SOURCE_HXX
+#define CXX_HYBRID_EXTRACTION_SOURCE_HXX
+
+#include <xsd-frontend/semantic-graph/schema.hxx>
+
+#include <cxx/hybrid/elements.hxx>
+
+namespace CXX
+{
+ namespace Hybrid
+ {
+ Void
+ generate_extraction_source (Context&);
+ }
+}
+
+#endif // CXX_HYBRID_EXTRACTION_SOURCE_HXX
diff --git a/xsde/cxx/hybrid/generator.cxx b/xsde/cxx/hybrid/generator.cxx
index b6215f9..495e649 100644
--- a/xsde/cxx/hybrid/generator.cxx
+++ b/xsde/cxx/hybrid/generator.cxx
@@ -11,13 +11,17 @@
#include <cxx/hybrid/tree-size-processor.hxx>
#include <cxx/hybrid/tree-name-processor.hxx>
-
#include <cxx/hybrid/tree-forward.hxx>
#include <cxx/hybrid/tree-header.hxx>
#include <cxx/hybrid/tree-inline.hxx>
#include <cxx/hybrid/tree-source.hxx>
#include <cxx/hybrid/tree-type-map.hxx>
+#include <cxx/hybrid/insertion-header.hxx>
+#include <cxx/hybrid/insertion-source.hxx>
+#include <cxx/hybrid/extraction-header.hxx>
+#include <cxx/hybrid/extraction-source.hxx>
+
#include <cxx/hybrid/parser-name-processor.hxx>
#include <cxx/hybrid/parser-header.hxx>
#include <cxx/hybrid/parser-source.hxx>
@@ -117,6 +121,8 @@ namespace CXX
extern Key suppress_validation = "suppress-validation";
extern Key suppress_parser_val = "suppress-parser-val";
extern Key suppress_serializer_val = "suppress-serializer-val";
+ extern Key generate_insertion = "generate-insertion";
+ extern Key generate_extraction = "generate-extraction";
extern Key generate_inline = "generate-inline";
extern Key generate_forward = "generate-forward";
extern Key generate_xml_schema = "generate-xml-schema";
@@ -238,6 +244,16 @@ namespace CXX
<< " serializer."
<< endl;
+ e << "--generate-insertion <os>" << endl
+ << " Generate data representation stream insertion\n"
+ << " operators for the <os> output stream type."
+ << endl;
+
+ e << "--generate-extraction <is>" << endl
+ << " Generate data representation stream extraction\n"
+ << " operators for the <is> input stream type."
+ << endl;
+
e << "--generate-inline" << endl
<< " Generate certain functions inline."
<< endl;
@@ -1491,6 +1507,12 @@ namespace CXX
generate_tree_forward (ctx, false);
generate_tree_header (ctx);
+
+ if (!ops.value<CLI::generate_insertion> ().empty ())
+ generate_insertion_header (ctx);
+
+ if (!ops.value<CLI::generate_extraction> ().empty ())
+ generate_extraction_header (ctx);
}
else
generate_tree_forward (ctx, true);
@@ -1650,6 +1672,12 @@ namespace CXX
generate_tree_source (ctx);
+ if (!ops.value<CLI::generate_insertion> ().empty ())
+ generate_insertion_source (ctx);
+
+ if (!ops.value<CLI::generate_extraction> ().empty ())
+ generate_extraction_source (ctx);
+
cxx << "#include <xsde/cxx/post.hxx>" << endl
<< endl;
}
diff --git a/xsde/cxx/hybrid/insertion-header.cxx b/xsde/cxx/hybrid/insertion-header.cxx
new file mode 100644
index 0000000..050b58f
--- /dev/null
+++ b/xsde/cxx/hybrid/insertion-header.cxx
@@ -0,0 +1,255 @@
+// file : xsd/cxx/hybrid/insertion-header.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <cxx/hybrid/insertion-header.hxx>
+
+#include <xsd-frontend/semantic-graph.hxx>
+#include <xsd-frontend/traversal.hxx>
+
+namespace CXX
+{
+ namespace Hybrid
+ {
+ namespace
+ {
+ struct List : Traversal::List, Context
+ {
+ List (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (Type& l)
+ {
+ String name (ename (l));
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "&," << endl
+ << "const " << name << "&);"
+ << endl;
+ }
+ }
+ };
+
+ struct Union : Traversal::Union, Context
+ {
+ Union (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (Type& u)
+ {
+ String name (ename (u));
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "&," << endl
+ << "const " << name << "&);"
+ << endl;
+ }
+ }
+ };
+
+ //
+ // Nested classes.
+ //
+
+ struct All: Traversal::All, Context
+ {
+ All (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::All& a)
+ {
+ // For the all compositor, maxOccurs=1 and minOccurs={0,1}
+ // and it can only contain particles.
+ //
+ if (a.min () == 0)
+ {
+ String const& type (etype (a));
+ String const& scope (Context::scope (a));
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "&," << endl
+ << "const " << scope << "::" << type << "&);"
+ << endl;
+ }
+ }
+ }
+ };
+
+ struct Choice: Traversal::Choice, Context
+ {
+ Choice (Context& c, Boolean in_choice)
+ : Context (c), in_choice_ (in_choice)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Choice& c)
+ {
+ // When choice is in choice we generate nested class even
+ // for min == max == 1.
+ //
+ if (in_choice_ || c.max () != 1 || c.min () == 0)
+ {
+ String const& type (etype (c));
+ String const& scope (Context::scope (c));
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "&," << endl
+ << "const " << scope << "::" << type << "&);"
+ << endl;
+ }
+ }
+
+ Choice::contains (c);
+ }
+
+ private:
+ Boolean in_choice_;
+ };
+
+
+ struct Sequence: Traversal::Sequence, Context
+ {
+ Sequence (Context& c, Boolean in_choice)
+ : Context (c), in_choice_ (in_choice)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Sequence& s)
+ {
+ // When sequence is in choice we generate nested class even
+ // for min == max == 1.
+ //
+ if (in_choice_ || s.max () != 1 || s.min () == 0)
+ {
+ String const& type (etype (s));
+ String const& scope (Context::scope (s));
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "&," << endl
+ << "const " << scope << "::" << type << "&);"
+ << endl;
+ }
+ }
+
+ Sequence::contains (s);
+ }
+
+ private:
+ Boolean in_choice_;
+ };
+
+ struct Complex : Traversal::Complex, Context
+ {
+ Complex (Context& c)
+ : Context (c),
+ all_ (c),
+ choice_in_choice_ (c, true),
+ choice_in_sequence_ (c, false),
+ sequence_in_choice_ (c, true),
+ sequence_in_sequence_ (c, false)
+ {
+ all_ >> all_contains_;
+
+ choice_in_choice_ >> choice_contains_;
+ choice_in_sequence_ >> choice_contains_;
+ choice_contains_ >> choice_in_choice_;
+ choice_contains_ >> sequence_in_choice_;
+
+ sequence_in_choice_ >> sequence_contains_;
+ sequence_in_sequence_ >> sequence_contains_;
+ sequence_contains_ >> choice_in_sequence_;
+ sequence_contains_ >> sequence_in_sequence_;
+
+ contains_compositor_ >> all_;
+ contains_compositor_ >> choice_in_sequence_;
+ contains_compositor_ >> sequence_in_sequence_;
+ }
+
+ virtual Void
+ traverse (Type& c)
+ {
+ if (!restriction_p (c))
+ {
+ String name (ename (c));
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "&," << endl
+ << "const " << name << "&);"
+ << endl;
+ }
+
+ // Operators for nested classes.
+ //
+ if (c.contains_compositor_p ())
+ Complex::contains_compositor (c, contains_compositor_);
+ }
+ }
+
+ private:
+ All all_;
+ Choice choice_in_choice_;
+ Choice choice_in_sequence_;
+ Sequence sequence_in_choice_;
+ Sequence sequence_in_sequence_;
+ Traversal::ContainsParticle all_contains_;
+ Traversal::ContainsParticle choice_contains_;
+ Traversal::ContainsParticle sequence_contains_;
+
+ Traversal::ContainsCompositor contains_compositor_;
+ };
+ }
+
+ Void
+ generate_insertion_header (Context& ctx)
+ {
+ Traversal::Schema schema;
+ Traversal::Sources sources;
+ Traversal::Names names_ns, names;
+
+ Namespace ns (ctx);
+
+ List list (ctx);
+ Union union_ (ctx);
+ Complex complex (ctx);
+
+ schema >> sources >> schema;
+ schema >> names_ns >> ns >> names;
+
+ names >> list;
+ names >> union_;
+ names >> complex;
+
+ schema.dispatch (ctx.schema_root);
+ }
+ }
+}
diff --git a/xsde/cxx/hybrid/insertion-header.hxx b/xsde/cxx/hybrid/insertion-header.hxx
new file mode 100644
index 0000000..8f17968
--- /dev/null
+++ b/xsde/cxx/hybrid/insertion-header.hxx
@@ -0,0 +1,22 @@
+// file : xsde/cxx/hybrid/insertion-header.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef CXX_HYBRID_INSERTION_HEADER_HXX
+#define CXX_HYBRID_INSERTION_HEADER_HXX
+
+#include <xsd-frontend/semantic-graph/schema.hxx>
+
+#include <cxx/hybrid/elements.hxx>
+
+namespace CXX
+{
+ namespace Hybrid
+ {
+ Void
+ generate_insertion_header (Context&);
+ }
+}
+
+#endif // CXX_HYBRID_INSERTION_HEADER_HXX
diff --git a/xsde/cxx/hybrid/insertion-source.cxx b/xsde/cxx/hybrid/insertion-source.cxx
new file mode 100644
index 0000000..58fe9f5
--- /dev/null
+++ b/xsde/cxx/hybrid/insertion-source.cxx
@@ -0,0 +1,694 @@
+// file : xsd/cxx/hybrid/insertion-source.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <cxx/hybrid/insertion-source.hxx>
+
+#include <xsd-frontend/semantic-graph.hxx>
+#include <xsd-frontend/traversal.hxx>
+
+namespace CXX
+{
+ namespace Hybrid
+ {
+ namespace
+ {
+ struct List : Traversal::List, Context
+ {
+ List (Context& c)
+ : Context (c), base_name_ (c, TypeName::seq)
+ {
+ }
+
+ virtual Void
+ traverse (Type& l)
+ {
+ String name (ename (l));
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "& s," << endl
+ << "const " << name << "& x)"
+ << "{"
+ << "const ";
+
+ base_name_.dispatch (l.argumented ().type ());
+
+ os << "& b = x;"
+ << (exceptions ? "" : "return ") << "s << b;"
+ << "}";
+ }
+ }
+
+ private:
+ TypeName base_name_;
+ };
+
+ struct Union : Traversal::Union, Context
+ {
+ Union (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (Type& u)
+ {
+ String name (ename (u));
+ String const& value (u.context ().get<String> ("value"));
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "& s," << endl
+ << "const " << name << "& x)"
+ << "{"
+ << (exceptions ? "" : "return ") << "s << x." << value << " ();"
+ << "}";
+ }
+ }
+ };
+
+ //
+ // Data.
+ //
+
+ struct AttributeData: Traversal::Attribute, Context
+ {
+ AttributeData (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Attribute& a)
+ {
+ if (a.optional ())
+ {
+ String const& present (epresent (a));
+
+ if (exceptions)
+ os << "s << x." << present << " ();";
+ else
+ os << "if (!(s << x." << present << " ()))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (x." << present << " ())"
+ << "{";
+ }
+
+ String const& name (ename (a));
+
+ if (exceptions)
+ os << "s << x." << name << " ();";
+ else
+ os << "if (!(s << x." << name << " ()))" << endl
+ << "return false;";
+
+ if (a.optional ())
+ os << "}";
+ }
+ };
+
+
+ struct ElementData: Traversal::Element, Context
+ {
+ ElementData (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Element& e)
+ {
+ if (e.max () == 1 && e.min () == 0)
+ {
+ String const& present (epresent (e));
+
+ if (exceptions)
+ os << "s << x." << present << " ();";
+ else
+ os << "if (!(s << x." << present << " ()))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (x." << present << " ())"
+ << "{";
+ }
+
+ String const& name (ename (e));
+
+ if (exceptions)
+ os << "s << x." << name << " ();";
+ else
+ os << "if (!(s << x." << name << " ()))" << endl
+ << "return false;";
+
+ if (e.max () == 1 && e.min () == 0)
+ os << "}";
+ }
+ };
+
+ struct AllData: Traversal::All, Context
+ {
+ AllData (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::All& a)
+ {
+ // For the all compositor, maxOccurs=1 and minOccurs={0,1}
+ // and it can only contain particles.
+ //
+ if (a.min () == 0)
+ {
+ String const& name (ename (a));
+ String const& present (epresent (a));
+
+ if (exceptions)
+ os << "s << x." << present << " ();";
+ else
+ os << "if (!(s << x." << present << " ()))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (x." << present << " ())"
+ << "{";
+
+ if (exceptions)
+ os << "s << x." << name << " ();";
+ else
+ os << "if (!(s << x." << name << " ()))" << endl
+ << "return false;";
+
+ os << "}";
+ }
+ else
+ All::contains (a);
+ }
+ };
+
+ struct ChoiceParticleData: ElementData,
+ Traversal::Compositor
+ {
+ ChoiceParticleData (Context& c)
+ : ElementData (c)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Element& e)
+ {
+ os << "case " << scope (e) << "::" << etag (e) << ":"
+ << "{";
+
+ ElementData::traverse (e);
+
+ os << "break;"
+ << "}";
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Compositor& c)
+ {
+ os << "case " << scope (c) << "::" << etag (c) << ":"
+ << "{";
+
+ // A compositor in choice always results in a nested class.
+ //
+ if (c.max () == 1 && c.min () == 0)
+ {
+ String const& present (epresent (c));
+
+ if (exceptions)
+ os << "s << x." << present << " ();";
+ else
+ os << "if (!(s << x." << present << " ()))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (x." << present << " ())"
+ << "{";
+ }
+
+ String const& name (ename (c));
+
+ if (exceptions)
+ os << "s << x." << name << " ();";
+ else
+ os << "if (!(s << x." << name << " ()))" << endl
+ << "return false;";
+
+ if (c.max () == 1 && c.min () == 0)
+ os << "}";
+
+ os << "break;"
+ << "}";
+ }
+ };
+
+ struct ChoiceInSequenceData: Traversal::Choice, Context
+ {
+ ChoiceInSequenceData (Context& c)
+ : Context (c), particle_data_ (c)
+ {
+ contains_data_ >> particle_data_;
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Choice& c)
+ {
+ if (c.max () != 1)
+ {
+ String const& name (ename (c));
+
+ if (exceptions)
+ os << "s << x." << name << " ();";
+ else
+ os << "if (!(s << x." << name << " ()))" << endl
+ << "return false;";
+ }
+ else if (c.min () == 0)
+ {
+ String const& name (ename (c));
+ String const& present (epresent (c));
+
+ if (exceptions)
+ os << "s << x." << present << " ();";
+ else
+ os << "if (!(s << x." << present << " ()))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (x." << present << " ())"
+ << "{";
+
+ if (exceptions)
+ os << "s << x." << name << " ();";
+ else
+ os << "if (!(s << x." << name << " ()))" << endl
+ << "return false;";
+
+ os << "}";
+ }
+ else
+ {
+ String const& arm (earm (c));
+
+ if (exceptions)
+ os << "s << static_cast< unsigned int > (x." << arm << " ());";
+ else
+ os << "if (!(s << static_cast< unsigned int > (x." <<
+ arm << " ())))" << endl
+ << "return false;";
+
+ os << "switch (x." << arm << " ())"
+ << "{";
+
+ Choice::contains (c, contains_data_);
+
+ os << "default:" << endl
+ << "break;"
+ << "}";
+ }
+ }
+
+ private:
+ ChoiceParticleData particle_data_;
+ Traversal::ContainsParticle contains_data_;
+ };
+
+ struct SequenceInSequenceData: Traversal::Sequence, Context
+ {
+ SequenceInSequenceData (Context& c)
+ : Context (c)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Sequence& s)
+ {
+ if (s.max () != 1)
+ {
+ String const& name (ename (s));
+
+ if (exceptions)
+ os << "s << x." << name << " ();";
+ else
+ os << "if (!(s << x." << name << " ()))" << endl
+ << "return false;";
+ }
+ else if (s.min () == 0)
+ {
+ String const& name (ename (s));
+ String const& present (epresent (s));
+
+ if (exceptions)
+ os << "s << x." << present << " ();";
+ else
+ os << "if (!(s << x." << present << " ()))" << endl
+ << "return false;";
+
+ os << endl
+ << "if (x." << present << " ())"
+ << "{";
+
+ if (exceptions)
+ os << "s << x." << name << " ();";
+ else
+ os << "if (!(s << x." << name << " ()))" << endl
+ << "return false;";
+
+ os << "}";
+ }
+ else
+ Sequence::contains (s);
+ }
+ };
+
+ //
+ // Nested classes.
+ //
+
+ struct All: Traversal::All, Context
+ {
+ All (Context& c, Traversal::ContainsParticle& contains_data)
+ : Context (c), contains_data_ (contains_data)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::All& a)
+ {
+ // For the all compositor, maxOccurs=1 and minOccurs={0,1}
+ // and it can only contain particles.
+ //
+ if (a.min () == 0)
+ {
+ String const& type (etype (a));
+ String const& scope (Context::scope (a));
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "& s," << endl
+ << "const " << scope << "::" << type << "& x)"
+ << "{"
+ << "XSDE_UNUSED (s);"
+ << "XSDE_UNUSED (x);"
+ << endl;
+
+ All::contains (a, contains_data_);
+
+ os << (exceptions ? "" : "return true;")
+ << "}";
+ }
+ }
+ }
+
+ private:
+ Traversal::ContainsParticle& contains_data_;
+ };
+
+ struct Choice: Traversal::Choice, Context
+ {
+ Choice (Context& c, Boolean in_choice)
+ : Context (c), in_choice_ (in_choice), particle_data_ (c)
+ {
+ contains_data_ >> particle_data_;
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Choice& c)
+ {
+ // When choice is in choice we generate nested class even
+ // for min == max == 1.
+ //
+ if (in_choice_ || c.max () != 1 || c.min () == 0)
+ {
+ String const& arm (earm (c));
+ String const& type (etype (c));
+ String const& scope (Context::scope (c));
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "& s," << endl
+ << "const " << scope << "::" << type << "& x)"
+ << "{"
+ << "XSDE_UNUSED (s);"
+ << endl;
+
+ if (exceptions)
+ os << "s << static_cast< unsigned int > (x." << arm << " ());";
+ else
+ os << "if (!(s << static_cast< unsigned int > (x." <<
+ arm << " ())))" << endl
+ << "return false;";
+
+ os << "switch (x." << earm (c) << " ())"
+ << "{";
+
+ Choice::contains (c, contains_data_);
+
+ os << "default:" << endl
+ << "break;"
+ << "}"
+ << (exceptions ? "" : "return true;")
+ << "}";
+ }
+ }
+
+ Choice::contains (c);
+ }
+
+ private:
+ Boolean in_choice_;
+
+ ChoiceParticleData particle_data_;
+ Traversal::ContainsParticle contains_data_;
+ };
+
+
+ struct Sequence: Traversal::Sequence, Context
+ {
+ Sequence (Context& c,
+ Boolean in_choice,
+ Traversal::ContainsParticle& contains_data)
+ : Context (c),
+ in_choice_ (in_choice),
+ contains_data_ (contains_data)
+ {
+ }
+
+ virtual Void
+ traverse (SemanticGraph::Sequence& s)
+ {
+ // When sequence is in choice we generate nested class even
+ // for min == max == 1.
+ //
+ if (in_choice_ || s.max () != 1 || s.min () == 0)
+ {
+ String const& type (etype (s));
+ String const& scope (Context::scope (s));
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "& s," << endl
+ << "const " << scope << "::" << type << "& x)"
+ << "{"
+ << "XSDE_UNUSED (s);"
+ << "XSDE_UNUSED (x);"
+ << endl;
+
+ Sequence::contains (s, contains_data_);
+
+ os << (exceptions ? "" : "return true;")
+ << "}";
+ }
+ }
+
+ Sequence::contains (s);
+ }
+
+ private:
+ Boolean in_choice_;
+ Traversal::ContainsParticle& contains_data_;
+ };
+
+ struct Complex : Traversal::Complex, Context
+ {
+ Complex (Context& c)
+ : Context (c),
+
+ // Use ro_ret instead of base to get auto-conversion
+ // for fundamental types from the wrappers.
+ //
+ base_name_ (c, TypeName::ro_ret),
+
+ // Data
+ //
+ attribute_data_ (c),
+ element_data_ (c),
+ all_data_ (c),
+ choice_in_sequence_data_ (c),
+ sequence_in_sequence_data_ (c),
+
+ // Nested classes.
+ //
+ all_ (c, all_contains_data_),
+ choice_in_choice_ (c, true),
+ choice_in_sequence_ (c, false),
+ sequence_in_choice_ (c, true, sequence_contains_data_),
+ sequence_in_sequence_ (c, false, sequence_contains_data_)
+ {
+ // Data.
+ //
+ attribute_names_data_ >> attribute_data_;
+
+ all_data_ >> all_contains_data_ >> element_data_;
+
+ sequence_in_sequence_data_ >> sequence_contains_data_;
+ sequence_contains_data_ >> element_data_;
+ sequence_contains_data_ >> choice_in_sequence_data_;
+ sequence_contains_data_ >> sequence_in_sequence_data_;
+
+ contains_compositor_data_ >> all_data_;
+ contains_compositor_data_ >> choice_in_sequence_data_;
+ contains_compositor_data_ >> sequence_in_sequence_data_;
+
+ // Nested classes.
+ //
+ all_ >> all_contains_;
+
+ choice_in_choice_ >> choice_contains_;
+ choice_in_sequence_ >> choice_contains_;
+ choice_contains_ >> choice_in_choice_;
+ choice_contains_ >> sequence_in_choice_;
+
+ sequence_in_choice_ >> sequence_contains_;
+ sequence_in_sequence_ >> sequence_contains_;
+ sequence_contains_ >> choice_in_sequence_;
+ sequence_contains_ >> sequence_in_sequence_;
+
+ contains_compositor_ >> all_;
+ contains_compositor_ >> choice_in_sequence_;
+ contains_compositor_ >> sequence_in_sequence_;
+ }
+
+ virtual Void
+ traverse (Type& c)
+ {
+ Boolean restriction (restriction_p (c));
+
+ String name (ename (c));
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ os << (exceptions ? "void" : "bool") << endl
+ << "operator<< (" << ostream (*i) << "& s," << endl
+ << "const " << name << "& x)"
+ << "{"
+ << "XSDE_UNUSED (s);"
+ << "XSDE_UNUSED (x);"
+ << endl;
+
+ if (c.inherits_p ())
+ {
+ base_name_.dispatch (c.inherits ().base ());
+ os << " b = x;";
+
+ if (exceptions)
+ os << "s << b;";
+ else
+ os << "if (!(s << b))" << endl
+ << "return false;"
+ << endl;
+ }
+
+ if (!restriction)
+ {
+ Complex::names (c, attribute_names_data_);
+
+ if (c.contains_compositor_p ())
+ Complex::contains_compositor (c, contains_compositor_data_);
+ }
+
+ os << (exceptions ? "" : "return true;")
+ << "}";
+ }
+
+ // Operators for nested classes.
+ //
+ if (!restriction && c.contains_compositor_p ())
+ Complex::contains_compositor (c, contains_compositor_);
+ }
+
+ private:
+ TypeName base_name_;
+
+ // Data.
+ //
+ AttributeData attribute_data_;
+ Traversal::Names attribute_names_data_;
+
+ ElementData element_data_;
+ AllData all_data_;
+ ChoiceInSequenceData choice_in_sequence_data_;
+ SequenceInSequenceData sequence_in_sequence_data_;
+ Traversal::ContainsParticle all_contains_data_;
+ Traversal::ContainsParticle sequence_contains_data_;
+
+ Traversal::ContainsCompositor contains_compositor_data_;
+
+ // Nested classes.
+ //
+ All all_;
+ Choice choice_in_choice_;
+ Choice choice_in_sequence_;
+ Sequence sequence_in_choice_;
+ Sequence sequence_in_sequence_;
+ Traversal::ContainsParticle all_contains_;
+ Traversal::ContainsParticle choice_contains_;
+ Traversal::ContainsParticle sequence_contains_;
+
+ Traversal::ContainsCompositor contains_compositor_;
+ };
+ }
+
+ Void
+ generate_insertion_source (Context& ctx)
+ {
+ Traversal::Schema schema;
+ Traversal::Sources sources;
+ Traversal::Names names_ns, names;
+
+ Namespace ns (ctx);
+
+ List list (ctx);
+ Union union_ (ctx);
+ Complex complex (ctx);
+
+ schema >> sources >> schema;
+ schema >> names_ns >> ns >> names;
+
+ names >> list;
+ names >> union_;
+ names >> complex;
+
+ schema.dispatch (ctx.schema_root);
+ }
+ }
+}
diff --git a/xsde/cxx/hybrid/insertion-source.hxx b/xsde/cxx/hybrid/insertion-source.hxx
new file mode 100644
index 0000000..fe6463c
--- /dev/null
+++ b/xsde/cxx/hybrid/insertion-source.hxx
@@ -0,0 +1,22 @@
+// file : xsde/cxx/hybrid/insertion-source.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef CXX_HYBRID_INSERTION_SOURCE_HXX
+#define CXX_HYBRID_INSERTION_SOURCE_HXX
+
+#include <xsd-frontend/semantic-graph/schema.hxx>
+
+#include <cxx/hybrid/elements.hxx>
+
+namespace CXX
+{
+ namespace Hybrid
+ {
+ Void
+ generate_insertion_source (Context&);
+ }
+}
+
+#endif // CXX_HYBRID_INSERTION_SOURCE_HXX
diff --git a/xsde/cxx/hybrid/tree-forward.cxx b/xsde/cxx/hybrid/tree-forward.cxx
index f1c0dfa..32f1180 100644
--- a/xsde/cxx/hybrid/tree-forward.cxx
+++ b/xsde/cxx/hybrid/tree-forward.cxx
@@ -415,6 +415,7 @@ namespace CXX
virtual Void
traverse (SemanticGraph::Fundamental::Base64Binary&)
{
+ gen_using ("::xsde::cxx::buffer");
gen_typedef ("base64_binary", "::xsde::cxx::buffer");
}
@@ -431,6 +432,7 @@ namespace CXX
virtual Void
traverse (SemanticGraph::Fundamental::Date&)
{
+ gen_using ("::xsde::cxx::time_zone");
gen_using ("::xsde::cxx::date");
}
@@ -534,6 +536,66 @@ namespace CXX
<< "using ::xsde::cxx::strndupx;";
}
+ // sequences
+ //
+ os << endl
+ << "using ::xsde::cxx::hybrid::pod_seq;"
+ << "using ::xsde::cxx::hybrid::fix_seq;"
+ << "using ::xsde::cxx::hybrid::var_seq;"
+ << "using ::xsde::cxx::hybrid::str_seq;"
+ << "using ::xsde::cxx::hybrid::data_seq;";
+
+ // Data representation stream types.
+ //
+ Boolean icdr (false), ocdr (false);
+ Boolean ixdr (false), oxdr (false);
+
+ for (Streams::ConstIterator i (istreams.begin ());
+ i != istreams.end (); ++i)
+ {
+ if (*i == "CDR")
+ icdr = true;
+ else if (*i == "XDR")
+ ixdr = true;
+ }
+
+ for (Streams::ConstIterator i (ostreams.begin ());
+ i != ostreams.end (); ++i)
+ {
+ if (*i == "CDR")
+ ocdr = true;
+ else if (*i == "XDR")
+ oxdr = true;
+ }
+
+ if (icdr || ocdr)
+ {
+ os << endl;
+
+ if (exceptions)
+ os << "using ::xsde::cxx::hybrid::cdr_exception;";
+
+ if (icdr)
+ os << "using ::xsde::cxx::hybrid::icdrstream;";
+
+ if (ocdr)
+ os << "using ::xsde::cxx::hybrid::ocdrstream;";
+ }
+
+ if (ixdr || oxdr)
+ {
+ os << endl;
+
+ if (exceptions)
+ os << "using ::xsde::cxx::hybrid::xdr_exception;";
+
+ if (ixdr)
+ os << "using ::xsde::cxx::hybrid::ixdrstream;";
+
+ if (oxdr)
+ os << "using ::xsde::cxx::hybrid::oxdrstream;";
+ }
+
post (ns);
}
};
@@ -561,8 +623,33 @@ namespace CXX
ctx.os << "#include <xsde/cxx/strdupx.hxx>" << endl;
ctx.os << "#include <xsde/cxx/hybrid/xml-schema.hxx>" << endl
+ << "#include <xsde/cxx/hybrid/sequence.hxx>" << endl
<< endl;
+ // Data representation stream includes.
+ //
+ for (Context::Streams::ConstIterator i (ctx.istreams.begin ());
+ i != ctx.istreams.end (); ++i)
+ {
+ if (*i == "CDR")
+ ctx.os << "#include <xsde/cxx/hybrid/cdr/istream.hxx>" << endl
+ << endl;
+ else if (*i == "XDR")
+ ctx.os << "#include <xsde/cxx/hybrid/xdr/istream.hxx>" << endl
+ << endl;
+ }
+
+ for (Context::Streams::ConstIterator i (ctx.ostreams.begin ());
+ i != ctx.ostreams.end (); ++i)
+ {
+ if (*i == "CDR")
+ ctx.os << "#include <xsde/cxx/hybrid/cdr/ostream.hxx>" << endl
+ << endl;
+ else if (*i == "XDR")
+ ctx.os << "#include <xsde/cxx/hybrid/xdr/ostream.hxx>" << endl
+ << endl;
+ }
+
if (generate_xml_schema)
{
Traversal::Schema schema;
diff --git a/xsde/cxx/hybrid/tree-header.cxx b/xsde/cxx/hybrid/tree-header.cxx
index c7231c9..2412b86 100644
--- a/xsde/cxx/hybrid/tree-header.cxx
+++ b/xsde/cxx/hybrid/tree-header.cxx
@@ -2379,9 +2379,6 @@ namespace CXX
Void
generate_tree_header (Context& ctx)
{
- ctx.os << "#include <xsde/cxx/hybrid/sequence.hxx>" << endl
- << endl;
-
Boolean inline_ (ctx.options.value<CLI::generate_inline> ());
// Emit header includes.
diff --git a/xsde/makefile b/xsde/makefile
index 953fbdb..a8a4928 100644
--- a/xsde/makefile
+++ b/xsde/makefile
@@ -60,6 +60,10 @@ cxx_tun += cxx/hybrid/elements.cxx \
cxx/hybrid/tree-inline.cxx \
cxx/hybrid/tree-source.cxx \
cxx/hybrid/tree-type-map.cxx \
+ cxx/hybrid/insertion-header.cxx \
+ cxx/hybrid/insertion-source.cxx \
+ cxx/hybrid/extraction-header.cxx \
+ cxx/hybrid/extraction-source.cxx \
cxx/hybrid/parser-name-processor.cxx \
cxx/hybrid/parser-header.cxx \
cxx/hybrid/parser-source.cxx \