+2002-06-05 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+
+ * xtl/*: get rid of xtl, which is not in use anyway
+
+ * LyXAction.C (init):
+ * commandtags.h: remove BUFFER_PRINT and BUFFER_PARAMS_GET, which
+ were unimplemented xtl experimentation
2002-06-04 André Pönitz <poenitz@gmx.net>
{ LFUN_EXPORT, "buffer-export", N_("Export to"), ReadOnly },
{ LFUN_IMPORT, "buffer-import",
N_("Import document"), NoBuffer },
- { LFUN_BUFFER_PRINT, "buffer-print-xtl", N_("Print"),
- ReadOnly },
- { LFUN_PRINTER_PARAMS_GET, "printer-params-get",
- N_("Get the printer parameters"), ReadOnly },
{ LFUN_MENUNEW, "buffer-new", N_("New document") , NoBuffer },
{ LFUN_MENUNEWTMPLT,"buffer-new-template",
N_("New document from template"), NoBuffer },
LFUN_TOCVIEW, // 10
LFUN_PREVIEW,
LFUN_CLOSEBUFFER,
- LFUN_BUFFER_PRINT, // ARRae 20000313
- LFUN_PRINTER_PARAMS_GET, // ARRae 20000313
LFUN_QUIT,
LFUN_AUTOSAVE,
LFUN_UNDO,
+++ /dev/null
- GNU LIBRARY GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1991 Free Software Foundation, Inc.
- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the library GPL. It is
- numbered 2 because it goes with version 2 of the ordinary GPL.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Library General Public License, applies to some
-specially designated Free Software Foundation software, and to any
-other libraries whose authors decide to use it. You can use it for
-your libraries, 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 library, or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link a program with the library, you must provide
-complete object files to the recipients so that they can relink them
-with the library, after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- Our method of protecting your rights has two steps: (1) copyright
-the library, and (2) offer you this license which gives you legal
-permission to copy, distribute and/or modify the library.
-
- Also, for each distributor's protection, we want to make certain
-that everyone understands that there is no warranty for this free
-library. If the library is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original
-version, so that any problems introduced by others will not reflect on
-the original authors' reputations.
-\f
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that companies distributing free
-software will individually obtain patent licenses, thus in effect
-transforming the program into proprietary software. To prevent this,
-we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
- Most GNU software, including some libraries, is covered by the ordinary
-GNU General Public License, which was designed for utility programs. This
-license, the GNU Library General Public License, applies to certain
-designated libraries. This license is quite different from the ordinary
-one; be sure to read it in full, and don't assume that anything in it is
-the same as in the ordinary license.
-
- The reason we have a separate public license for some libraries is that
-they blur the distinction we usually make between modifying or adding to a
-program and simply using it. Linking a program with a library, without
-changing the library, is in some sense simply using the library, and is
-analogous to running a utility program or application program. However, in
-a textual and legal sense, the linked executable is a combined work, a
-derivative of the original library, and the ordinary General Public License
-treats it as such.
-
- Because of this blurred distinction, using the ordinary General
-Public License for libraries did not effectively promote software
-sharing, because most developers did not use the libraries. We
-concluded that weaker conditions might promote sharing better.
-
- However, unrestricted linking of non-free programs would deprive the
-users of those programs of all benefit from the free status of the
-libraries themselves. This Library General Public License is intended to
-permit developers of non-free programs to use free libraries, while
-preserving your freedom as a user of such programs to change the free
-libraries that are incorporated in them. (We have not seen how to achieve
-this as regards changes in header files, but we have achieved it as regards
-changes in the actual functions of the Library.) The hope is that this
-will lead to faster development of free libraries.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, while the latter only
-works together with the library.
-
- Note that it is possible for a library to be covered by the ordinary
-General Public License rather than by this special one.
-\f
- GNU LIBRARY GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library which
-contains a notice placed by the copyright holder or other authorized
-party saying it may be distributed under the terms of this Library
-General Public License (also called "this License"). Each licensee is
-addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, 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 library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete 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 distribute a copy of this License along with the
-Library.
-
- 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.
-\f
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-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 Library, 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 Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-\f
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you 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.
-
- If distribution of 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 satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
- 6. As an exception to the Sections above, you may also compile or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- c) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- d) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. 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.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library 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.
-
- 9. 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 Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-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.
-\f
- 11. 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 Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library 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 Library.
-
-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.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library 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.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Library 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 Library
-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 Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-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
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "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
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. 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 LIBRARY 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
-LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-\f
- Appendix: How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. 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 library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
+++ /dev/null
-AUTOMAKE_OPTIONS = foreign 1.4
-DISTCLEANFILES= *.orig *.rej *~ *.bak core
-MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
-EXTRA_DIST = README COPYING.LIB
-ETAGS_ARGS = --lang=c++
-SOURCES = \
- autobuf.h \
- autoio.h \
- config.h \
- giop.h \
- graphio.h \
- macros.h \
- objio.h \
- text.h \
- vobjio.h \
- xdr.h
+++ /dev/null
-XTL-1.3.pl11
-This directory contains the subset of XTL required by LyX.
-The full distribution includes extensive tests and documentation.
-If you encounter compiler errors in xtl code when compiling LyX please
-get a copy of the full distribution and run the regression tests on your
-system. Report any problems found to the xtl mailing list.
-
-See: http://gsd.di.uminho.pt/jop/xtl/
-
--------------------------===========================----------------------
-
-
-The eXternalization Template Library (XTL)
-------------------------------------------
-
-The XTL is a library of template classes and functions for
-reading/writing structured data to/from an external (platform
-independent) representation. This process is also usually known as
-marshalling, serialization or pickling, and is useful both for
-heterogeneous network programming and portable persistent storage.
-
-Currently, the XTL supports XDR (RFC1014), GIOP CDR (CORBA) and
-readable ascii text (write-only) as data formats. Memory buffers
-are usable as data sources/targets. C file streams, C++
-iostreams and POSIX iovecs are also planned.
-
-Besides the usual C data types (basic, structs, pointers, unions), the
-XTL also supports C++ constructs, such as pointers to base classes and
-template types, namely, STL containers.
-
-The XTL does not include any kind of IDL, and as such, the programmer
-is required to write a "filter" for each data type. The API is
-somewhat modeled on the original XDR library by Sun, in that the same
-filter is used for both reading and writing.
-
-However, heavy usage of templates makes the API simpler and type safe.
-Function inlining and careful avoidance of pointers or virtual
-functions, also make generated code faster. This is a sample
-benchmark:
-
- PPRO 200 Mhz + output -> membuffer + size ~= 280 bytes
-
- -O16 not opt
- memcpy 2.8 us 2.2 us
- *XTL* XDR 9.3 us 47.7 us
- *XTL* "little" XDR 7.8 us 45.8 us
- *XTL* GIOP 8.5 us 58.3 us
- Sun XDR 25.0 us 28.5 us
-
-For more information and to download a distribution, visit
-http://gil.di.uminho.pt/~jop/xtl/ .
-
-Files under /include and /doc are distributed acording to
-the GNU LGPL. See COPYING.LIB for licensing details.
-
-Everything else is public domain.
-
-Contributors
-------------
-- José Orlando Pereira
- jop@di.uminho.pt, http://gsd.di.uminho.pt/~jop
- Departamento de Informatica, Universidade do Minho
- Campus de Gualtar, 4710-057 Braga, Portugal
-
-- Asger Alstrup Nielsen
- alstrup@sophusmedical.dk
-
-- Allan Rae
- allan.rae@mailbox.uq.edu.au
-
- - Angus Leeming
- a.leeming@ic.ac.uk
- Department of Biological & Medical Systems, Imperial College, London, UK
-
+++ /dev/null
-/* Automatic buffer driver for XTL
- *
- * Copyright (C) 2000 Allan Rae, allan.rae@mailbox.uq.edu.au
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, jop@di.uminho.pt
- */
-/* XTL - eXternalization Template Library - http://gsd.di.uminho.pt/~jop/xtl
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, Universidade do Minho
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA
- *
- * Id: autobuf.h 1.4 Fri, 05 May 2000 18:57:58 +0100 jop
- */
-
-#ifndef __XTL_AUTOBUF
-#define __XTL_AUTOBUF
-
-#include <xtl/config.h>
-#include <xtl/objio.h>
-
-/** Based on mem_buffer. It automatically increases it's capacity when being
- written too. It still throws an exception if there is insufficient data
- when reading. As a result the input and output routines memory handling
- had to be separated (mem_buffer uses the same code for both) into required
- memory (input) and desired memory (output). ARRae 20000423
-
- Possible improvements:
- auto_mem_buffer(char *, size_t) same constructor as mem_buffer
- reserve(size_t) make it bigger if need be.
-
- Rewrite XTL to use an iterator interface; at least at the buffer level.
-*/
-class auto_mem_buffer {
-public:
- class buffer_overflow_error: public std::overflow_error {
- public:
- int bytes_left;
- int bytes_needed;
-
- buffer_overflow_error(int left, int needed):
- std::overflow_error("XTL auto_mem_buffer overflow"),
- bytes_left(left),bytes_needed(needed) {}
- };
-
- auto_mem_buffer() : buffer(0), pos(0), lim(32) {
- buffer = new char[lim];
- }
-
- auto_mem_buffer(size_t size) : buffer(0), pos(0), lim(4) {
- // the smallest useful size is probably 8 bytes (4*2)
- do {
- lim *= 2;
- } while (lim < size);
- buffer = new char[lim];
- }
-
-// I haven't figured out why yet but this code causes a segfault upon
-// destruction of the copy after the destruction of the original.
-// HOWEVER, this only occurs in LyX, it doesn't occur in my test program
-// which is almost identical to the way LyX operates. The major differences
-// between LyX and the test program are the presense of libsigc++ and xforms.
-// The contents of the mem buffer are used to build up an xforms dialog.
-// ARRae 20000423
-//
-// auto_mem_buffer(auto_mem_buffer const & o)
-// : buffer(0), pos(o.pos), lim(o.lim) {
-// buffer = new char[lim];
-// memcpy(buffer, o.buffer, (pos > 0) ? pos : lim);
-// }
-
- ~auto_mem_buffer() {
- delete[] buffer;
- }
-
- inline void read(char* ptr, int size) {
- memcpy(ptr, require(size), size);
- }
-
- inline void write(char const* ptr, int size) {
- memcpy(desire(size), ptr, size);
- }
-
- inline void* require(int size) {
- size_t aux = pos;
- if ((pos += size) > lim)
- throw buffer_overflow_error(lim - aux, size);
- return buffer + aux;
- }
-
- inline void* desire(int size) {
- size_t const aux = pos;
- if ((pos += size) > lim) {
- do {
- lim *= 2;
- } while (lim < pos);
- char * tmp = new char[lim];
- memcpy(tmp, buffer, aux);
- delete[] buffer;
- buffer = tmp;
- }
- return buffer + aux;
- }
-
- inline void flush()
- {}
-
- inline void unrequire(int n)
- { pos -= n; }
-
- inline void undesire(int n)
- { pos -= n; }
-
- inline void rewind()
- { pos = 0; }
-
- inline int size()
- { return pos; }
-
- inline char* data()
- { return buffer; }
-
- template <class Format>
- inline void composite(obj_input<Format>& stream) {
- int size, idx;
- stream.array(buffer, size).simple(idx);
- pos = idx;
- lim = size;
- count = 1;
- }
-
- template <class Format>
- inline void composite(obj_output<Format>& stream) {
- stream.array(buffer, lim).simple(pos);
- }
-private:
- auto_mem_buffer(auto_mem_buffer const &);
-
- char * buffer;
- size_t pos, lim;
-};
-
-#endif
-
+++ /dev/null
-/*
- * Automatic object hierarchy externalization for XTL
- *
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, Universidade do Minho
- */
-/* XTL - eXternalization Template Library - http://gsd.di.uminho.pt/~jop/xtl
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, Universidade do Minho
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA
- *
- * Id: autoio.h 1.4 Fri, 05 May 2000 18:57:58 +0100 jop
- */
-
-#ifndef __XTL_AUTOIO
-#define __XTL_AUTOIO
-
-#include <xtl/objio.h>
-#include <xtl/vobjio.h>
-#include <map>
-#include <stdexcept>
-
-class reader;
-
-typedef std::map<int, reader*> externalizable_index;
-
-class externalizable_base;
-
-class reader {
- private:
- int id;
-
- public:
- reader(int i, std::map<int, reader*>& repo):id(i) {
- std::map<int, reader*>::const_iterator t=repo.find(id);
- if (t!=repo.end())
- throw std::logic_error("registering duplicate class id");
- repo.insert(std::make_pair(id, this));
- }
-
- virtual externalizable_base* read(obj_input<v_format>& stream)=0;
-
- int classid() const {return id;}
-};
-
-template <class T>
-class concrete_reader: public reader {
- public:
- concrete_reader(int i, std::map<int, reader*>& repo):reader(i, repo) {}
-
- virtual externalizable_base* read(obj_input<v_format>& stream) {
- T* ptr=new T;
- ptr->vcomposite(stream);
- return ptr;
- }
-};
-
-class externalizable_base {
- public:
- int classid() const {return info().classid();}
- virtual reader& info() const=0;
-
- virtual void vcomposite(obj_output<v_format>& stream) const=0;
- virtual void vcomposite(obj_input<v_format>& stream)=0;
-};
-
-class auto_obj_input: public obj_input<v_format> {
- private:
- const std::map<int, reader*>& repo;
-
- public:
- auto_obj_input(v_format& f, const std::map<int, reader*>& r):
- obj_input<v_format>(f), repo(r) {}
-
- template <class T>
- auto_obj_input& auto_object(T*& data) {
- int id=0;
- simple(id);
- std::map<int, reader*>::const_iterator t=repo.find(id);
- if (t==repo.end())
- throw std::logic_error("unknown class id");
- externalizable_base* ptr=(*t).second->read(*this);
- data=dynamic_cast<T*>(ptr);
- return *this;
- }
-};
-
-class auto_obj_output: public obj_output<v_format> {
- public:
- auto_obj_output(v_format& f):obj_output<v_format>(f) {}
-
- template <class T>
- auto_obj_output& auto_object(T*& data) {
- const externalizable_base* ptr=data;
- int id=ptr->classid();
- simple(id);
- ptr->vcomposite(*this);
- return *this;
- }
-};
-
-#define decl_externalizable(name)\
-public:\
- virtual reader& info() const {return myinfo;}\
- virtual void vcomposite(obj_output<v_format>& stream) const\
- {const_cast<name*>(this)->composite(stream);}\
- virtual void vcomposite(obj_input<v_format>& stream)\
- {composite(stream);}\
-private:\
- static concrete_reader<name> myinfo
-
-#define impl_externalizable(name, id, index)\
-concrete_reader<name> name::myinfo(id, index)
-
-#endif
+++ /dev/null
-/*
- * Automatic configuration file for XTL
- *
- * Copyright (C) 2000 Asger Nielsen, alstrup@sophusmedical.dk
- * Copyright (C) 2000 Angus Leeming, a.leeming@ic.ac.uk
- * Copyright (C) 2000 Jose' Orlando Pereira, jop@di.uminho.pt
- */
-/* XTL - eXternalization Template Library - http://gsd.di.uminho.pt/~jop/xtl
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, Universidade do Minho
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA
- *
- * Id: config.h 1.7 Fri, 12 May 2000 18:23:14 +0100 jop
- */
-
-#ifndef __XTL_CONFIG
-#define __XTL_CONFIG
-
-#define XTL_CONFIG_CHOICE_MACROS
-
-#if defined(__GNUC__)
-# if __GNUC__ >2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >=95 ) // >= G++ 2.95
-# define XTL_CONFIG_SIMPLE_CONTAINERS
-# endif
-
- typedef long long longlong;
- typedef unsigned long long unsignedlonglong;
-
-#elif defined (__DECCXX)
-# define XTL_CONFIG_SIMPLE_CONTAINERS
-
- typedef long long int longlong;
- typedef unsigned long long int unsignedlonglong;
-
-#elif defined (__sgi)
-# define XTL_CONFIG_SIMPLE_CONTAINERS
-
- typedef long long int longlong;
- typedef unsigned long long int unsignedlonglong;
-
-#elif defined (_WIN32)
-
-# define XTL_CONFIG_COMPOSITE_BUG
-# define XTL_CONFIG_LACK_ENDIAN_H
-
- typedef __int64 longlong;
- typedef unsigned __int64 unsignedlonglong;
-
- // Disable some stupid warnings
-# pragma warning(disable:4127 4786 4800)
-
- // Work around for broken for-scoping with Visual C++ 6.0
-# define for if(0);else for
-
- // Enable a bunch of useful warnings
-# pragma warning(3:4019 4032 4057 4061 4125 4130 4152 4189 4201 4706)
-
-#endif
-
-// Establish __BYTE_ORDER
-#ifdef __linux__
-# include <endian.h>
-#else
-# define __LITTLE_ENDIAN 1234
-# define __BIG_ENDIAN 4321
-#endif
-
-#if defined(__alpha) || defined(__alpha__)
-# ifndef __BYTE_ORDER
-# define __BYTE_ORDER __LITTLE_ENDIAN
-# endif
-
-#elif defined __sgi
-# ifndef __BYTE_ORDER
-# define __BYTE_ORDER __BIG_ENDIAN
-# endif
-#endif
-
-#if ((__BYTE_ORDER != __LITTLE_ENDIAN) && (__BYTE_ORDER != __BIG_ENDIAN))
-# error "Architecture not supported."
-#endif
-
-// Don't use byteswap.h on Alpha machines because its buggy
-#if defined(__linux__) && !(defined(__alpha) || defined(__alpha__))
-# include <byteswap.h>
-#else
-inline unsigned short bswap_16(unsigned short b) {
- return ((b&0xff00)>>8)|((b&0x00ff)>>8);
-}
-
-inline unsigned int bswap_32(unsigned int b) {
- return ((b&0xff000000)>>24)|((b&0x00ff0000)>>8)|
- ((b&0x0000ff00)<<8)|((b&0x000000ff)<<24);
-}
-
-inline unsignedlonglong bswap_64(unsignedlonglong b) {
- return ( ((b&0xff00000000000000) >> 56) |
- ((b&0x00ff000000000000) >> 40) |
- ((b&0x0000ff0000000000) >> 24) |
- ((b&0x000000ff00000000) >> 8) |
- ((b&0x00000000ff000000) << 8) |
- ((b&0x0000000000ff0000) << 24) |
- ((b&0x000000000000ff00) << 40) |
- ((b&0x00000000000000ff) << 56) );
-}
-#endif
-
-// We need this for memcpy
-#if (defined(__alpha) || defined(__alpha__)) && !defined(__GNUC__)
-#include <string.h>
-#else
-#include <cstring>
-#endif
-
-#endif
+++ /dev/null
-/*
- * GIOP format driver for XTL
- *
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, jop@di.uminho.pt
- * Copyright (C) 2000 Angus Leeming, a.leeming@ic.ac.uk
- */
-/* XTL - eXternalization Template Library - http://gsd.di.uminho.pt/~jop/xtl
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, Universidade do Minho
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA
- *
- * Id: giop.h 1.14 Fri, 12 May 2000 17:21:18 +0100 jop
- */
-
-#ifndef __XTL_GIOP
-#define __XTL_GIOP
-
-// These should be static const fields of GIOP_format, but some
-// compilers prefer them like this.
-#if (__BYTE_ORDER == __LITTLE_ENDIAN)
-# define machineEndianess 1
-#elif (__BYTE_ORDER == __BIG_ENDIAN)
-# define machineEndianess 0
-#endif
-
-// Data is written to the buffer with the byte order of the local machine.
-// When reading a buffer (which may come from a different machine), the
-// ordering must be accounted for.
-// These must be global due to a joint g++/glibc/i386 "feature".
-inline void _xtl_n2hs(char const in[2], short* out, bool _bufferEndianess) {
- if( _bufferEndianess == machineEndianess )
- *out=*reinterpret_cast<short const*>( in );
- else
- *out=bswap_16(*reinterpret_cast<unsigned short const*>( in ));
-}
-
-inline void _xtl_n2hl(char const in[4], int* out, bool _bufferEndianess) {
- if( _bufferEndianess == machineEndianess )
- *out=*reinterpret_cast<int const*>( in );
- else
- *out=bswap_32(*reinterpret_cast<unsigned int const*>( in ));
-}
-
-inline void _xtl_n2hh(char const in[8], longlong* out, bool _bufferEndianess) {
- if( _bufferEndianess == machineEndianess )
- *out=*reinterpret_cast<longlong const*>( in );
- else
- *out=bswap_64(*reinterpret_cast<unsignedlonglong const*>( in ));
-}
-
-template <class Buffer>
-class GIOP_format: public generic_format<Buffer> {
- private:
- unsigned char bufferEndianess;
- int align;
-
- // Add padding so that data (of size n) is aligned on
- // n byte boundaries
- int padding( int n ) {
- int pad = ((align % n) ? (n - (align % n)) : 0);
- align += n + pad;
- return pad;
- }
-
- char* req_align( int n ) {
- int pad = padding( n );
- return ( reinterpret_cast<char*>( require(n+pad) ) + pad );
- }
-
- char* des_align( int n ) {
- int pad = padding( n );
- return ( reinterpret_cast<char*>( desire(n+pad) ) + pad );
- }
-
- inline void h2ns( short const* in, char out[2] )
- { *reinterpret_cast<short*>( out ) = *in; }
-
- inline void h2nl( int const* in, char out[4] )
- { *reinterpret_cast<int*>( out ) = *in; }
-
- inline void h2nh( longlong const* in, char out[8] )
- { *reinterpret_cast<longlong*>( out ) = *in; }
-
- public:
- typedef Buffer buffer;
-
- GIOP_format(Buffer& buf):
- generic_format<Buffer>(buf),
- bufferEndianess(machineEndianess),
- align(0) {}
-
- // Allows data output on one machine to be read on another with
- // (possibly) different byte ordering
- void input_start()
- { input_simple(bufferEndianess); }
-
- void input_start_array(int& n)
- { input_simple(n); }
- bool input_end_array(int& n)
- { return n--<=0; }
-
- void input_simple( bool& data )
- { data=!!*req_align(1); }
- void input_simple( char& data )
- { data=*req_align(1); }
- void input_simple( unsigned char& data )
- { data=*req_align(1); }
- void input_simple( short& data )
- { _xtl_n2hs(req_align(2), &data, bufferEndianess); }
- void input_simple( unsigned short& data )
- { _xtl_n2hs(req_align(2), reinterpret_cast<short*>( &data ), bufferEndianess); }
- void input_simple( int& data )
- { _xtl_n2hl(req_align(4), &data, bufferEndianess); }
- void input_simple( unsigned int& data )
- { _xtl_n2hl(req_align(4), reinterpret_cast<int*>( &data ), bufferEndianess); }
- // long is stored as longlong to allow communication
- // between 32 and 64 bit machines
- void input_simple( long& data )
- { _xtl_n2hh(req_align(8), reinterpret_cast<longlong*>( &data ), bufferEndianess); }
- void input_simple( unsigned long& data )
- { _xtl_n2hh(req_align(8), reinterpret_cast<longlong*>( &data ), bufferEndianess); }
- void input_simple( longlong& data )
- { _xtl_n2hh(req_align(8), &data, bufferEndianess); }
- void input_simple( unsignedlonglong& data )
- { _xtl_n2hh(req_align(8), reinterpret_cast<longlong*>( &data ), bufferEndianess); }
- void input_simple( float& data )
- {_xtl_n2hl(req_align(4), reinterpret_cast<int*>( &data ), bufferEndianess); }
- void input_simple(double& data)
- {_xtl_n2hh(req_align(8), reinterpret_cast<longlong*>( &data ), bufferEndianess); }
-
- void input_chars(char* data, int size) {
- input_raw(data, size);
- }
-
- void input_raw(char* data, int size) {
- int i;
- for(i=0;i<(size>>8)-1;i++,data+=256)
- memcpy(data, require(256), 256);
- int res=size-(i<<8);
- memcpy(data, require(res), res);
- align+=res;
- }
-
- void output_start() {
- align = 0;
- output_simple(bufferEndianess);
- }
-
- void output_start_array(int n) {output_simple(n);}
- void output_end_array() {}
-
- void output_simple( bool const& data )
- { *des_align(1)=data?1:0; }
- void output_simple( char const& data )
- { *des_align(1)=data; }
- void output_simple( unsigned char const& data )
- { *des_align(1)=data; }
- void output_simple( short const& data )
- { h2ns(&data, des_align(2)); }
- void output_simple( unsigned short const& data )
- { h2ns(reinterpret_cast<short const*>( &data ), des_align(2)); }
- void output_simple( int const& data )
- { h2nl(&data, des_align(4)); }
- void output_simple( unsigned int const& data )
- { h2nl(reinterpret_cast<int const*>( &data ), des_align(4)); }
- void output_simple( long const& data )
- { h2nh(reinterpret_cast<longlong const*>( &data ), des_align(8)); }
- void output_simple( unsigned long const& data )
- { h2nh(reinterpret_cast<longlong const*>( &data ), des_align(8)); }
- void output_simple( longlong const& data )
- { h2nh(&data, des_align(8)); }
- void output_simple( unsignedlonglong const& data )
- { h2nh(reinterpret_cast<longlong const*>( &data ), des_align(8)); }
- void output_simple( float const& data )
- { h2nl(reinterpret_cast<int const*>( &data ), des_align(4)); }
- void output_simple( double const& data )
- { h2nh(reinterpret_cast<longlong const*>( &data ), des_align(8)); }
-
- void output_chars(char const* data, int size) {
- output_raw(data, size);
- }
-
- void output_raw(char const* data, int size) {
- int i;
- for(i=0;i<(size>>8)-1;i++,data+=256)
- memcpy(desire(256), data, 256);
- int res=size-(i<<8);
- memcpy(desire(res), data, res);
- align+=res;
- }
-};
-
-#endif // __XTL_GIOP
+++ /dev/null
-/*
- * Automatic object graph externalization for XTL
- *
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, jop@di.uminho.pt
- */
-/* XTL - eXternalization Template Library - http://gsd.di.uminho.pt/~jop/xtl
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, Universidade do Minho
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA
- *
- * Id: graphio.h 1.8 Fri, 05 May 2000 18:57:58 +0100 jop
- */
-
-#ifndef __XTL_GRAPHIO
-#define __XTL_GRAPHIO
-
-#include <map>
-
-class graph_refs {
- private:
- int label;
-
- typedef std::map<void*,int> trans_type;
- trans_type trans;
-
- public:
- graph_refs(): label(1) {}
-
- template <class Format, class Refs, class T>
- void reference(obj_input<Format, Refs>& stream, T*& ptr) {
- int x;
- stream.simple(x);
- if (x==0) {
- ptr=new T;
- trans.insert(pair<void*,int>(label, (void*)ptr));
- label++;
- stream.content(*ptr);
- } else
- ptr=(T*)trans[x];
- }
-
- template <class Format, class Refs, class T>
- void reference(obj_output<Format, Refs>& stream, T const* ptr) {
- trans_type::iterator i=trans.find((void*)ptr);
- if (i!=trans.end())
- stream.simple((*i).second);
- else {
- stream.simple(0);
- trans.insert(std::pair<void*,int>((void*)ptr, label));
- int tmp=label;
- label++;
- stream.content(*ptr);
- }
- }
-};
-
-#endif
-
+++ /dev/null
-/*
- * Some ugly macros for XTL. Keep out!
- *
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, jop@di.uminho.pt
- */
-/* XTL - eXternalization Template Library - http://gsd.di.uminho.pt/~jop/xtl
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, Universidade do Minho
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA
- *
- * Id: macros.h 1.3 Fri, 05 May 2000 18:57:58 +0100 jop
- */
-
-#ifndef __XTL_MACROS
-#define __XTL_MACROS
-
-// Extremely yucky pre-processor wizardry. Don't look. Just pretend it
-// is not here. :-)
-
-#define tparam(i) class T##i
-
-#define ci_param(i) T##i& val##i
-#define co_param(i) const T##i& val##i
-#define c_case(i) case i:\
- simple(val##i);\
- break;
-
-#define o_param(i) T##i* tag##i
-#define o_case(i) case i:\
- reference(tag##i);\
- ptr=(Base*)tag##i;\
- break;
-#define o_elseif(i) else if (typeid(*ptr)==typeid(T##i)) { \
- simple(i); \
- tag##i=(T##i*)ptr; \
- reference(tag##i); \
- }
-
-#define tparam_2 tparam(0), tparam(1)
-#define tparam_3 tparam_2, tparam(2)
-#define tparam_4 tparam_3, tparam(3)
-#define tparam_5 tparam_4, tparam(4)
-
-#define X_tparam(i) tparam_##i
-
-#define ci_param_2 ci_param(0), ci_param(1)
-#define ci_param_3 ci_param_2, ci_param(2)
-#define ci_param_4 ci_param_3, ci_param(3)
-#define ci_param_5 ci_param_4, ci_param(4)
-
-#define X_ci_param(i) ci_param_##i
-
-#define co_param_2 co_param(0), co_param(1)
-#define co_param_3 co_param_2, co_param(2)
-#define co_param_4 co_param_3, co_param(3)
-#define co_param_5 co_param_4, co_param(4)
-
-#define X_co_param(i) co_param_##i
-
-#define c_case_2 c_case(0) c_case(1)
-#define c_case_3 c_case_2 c_case(2)
-#define c_case_4 c_case_3 c_case(3)
-#define c_case_5 c_case_4 c_case(4)
-
-#define X_c_case(i) c_case_##i
-
-#define o_param_2 o_param(0), o_param(1)
-#define o_param_3 o_param_2, o_param(2)
-#define o_param_4 o_param_3, o_param(3)
-#define o_param_5 o_param_4, o_param(4)
-
-#define X_o_param(i) o_param_##i
-
-#define o_case_2 o_case(0) o_case(1)
-#define o_case_3 o_case_2 o_case(2)
-#define o_case_4 o_case_3 o_case(3)
-#define o_case_5 o_case_4 o_case(4)
-
-#define X_o_case(i) o_case_##i
-
-#define o_elseif_2 o_elseif(1)
-#define o_elseif_3 o_elseif_2 o_elseif(2)
-#define o_elseif_4 o_elseif_3 o_elseif(3)
-#define o_elseif_5 o_elseif_4 o_elseif(4)
-
-#define X_o_elseif(i) o_elseif_##i
-
-#define decl_ich_method(i) \
- template <class Discr, X_tparam(i)> \
- inline obj_input& choices(Discr& discr, X_ci_param(i)) { \
- simple(discr); \
- switch(discr) { \
- X_c_case(i) \
- default: \
- throw std::range_error("XTL invalid choice"); \
- }; \
- return *this; \
- }
-
-#define decl_och_method(i) \
- template <class Discr, X_tparam(i)> \
- inline obj_output& choices(const Discr& discr, X_co_param(i)) { \
- simple(discr); \
- switch(discr) { \
- X_c_case(i) \
- default: \
- throw std::range_error("XTL invalid choice"); \
- }; \
- return *this; \
- }
-
-#define decl_iobj_method(i) \
- template <class Base, X_tparam(i)> \
- inline obj_input& object(Base*& ptr, X_o_param(i)) { \
- int discr; \
- simple(discr); \
- switch(discr) { \
- X_o_case(i) \
- default: \
- throw std::range_error("XTL invalid choice"); \
- }; \
- return *this; \
- }
-
-#define decl_oobj_method(i) \
- template <class Base, X_tparam(i)> \
- inline obj_output& object(Base*& ptr, X_o_param(i)) { \
- if (typeid(*ptr)==typeid(T0)) { \
- simple(0); \
- tag0=(T0*)ptr; \
- reference(tag0); \
- } X_o_elseif(i) \
- else \
- throw std::range_error("XTL invalid choice"); \
- return *this; \
- }
-
-#endif
+++ /dev/null
-/*
- * Core externaliztion utilities
- *
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, jop@di.uminho.pt
- */
-/* XTL - eXternalization Template Library - http://gsd.di.uminho.pt/~jop/xtl
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, Universidade do Minho
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA
- *
- * Id: objio.h 1.20 Fri, 05 May 2000 18:57:58 +0100 jop
- */
-
-#ifndef __XTL_OBJIO
-#define __XTL_OBJIO
-
-#include <xtl/config.h>
-
-#include <typeinfo>
-#include <stdexcept>
-#include <string>
-
-template <class Buffer>
-class generic_format {
-private:
- Buffer& buffer;
-protected:
- void* require(int n) {return buffer.require(n);}
- void unrequire(int n) {buffer.unrequire(n);}
- void* desire(int n) {return buffer.desire(n);}
- void undesire(int n) {buffer.undesire(n);}
-
- void read(char* data, int size) {buffer.read(data, size);}
- void write(char const* data, int size) {buffer.write(data, size);}
-public:
- generic_format(Buffer& buf):buffer(buf) {}
-
- void input_start() {}
-
- void input_start_composite() {}
- void input_end_composite() {}
-
- void input_start_vector() {}
- void input_end_vector() {}
-
- virtual void output_start() {}
-
- void output_start_composite() {}
- void output_end_composite() {}
-
- void output_start_vector() {}
- void output_end_vector() {}
-
- void reset_buffer() {
- buffer.rewind();
- output_start();
- }
-};
-
-/*
- void input_start_array(int& n) {simple(n);}
- bool input_end_array(int& n) {return n--<=0;}
-
- void output_start_array(int n) {simple(n);}
- void output_end_array() {}
- */
-
-template <class Buffer>
-class raw_format: public generic_format<Buffer> {
- public:
- typedef Buffer buffer;
-
- raw_format(Buffer& buf):generic_format<Buffer>(buf) {}
-
- template <class T>
- inline void input_simple(T& data)
- {data=*((T*)require(sizeof(T)));}
-
- void input_start_array(int& n) {input_simple(n);}
- bool input_end_array(int& n) {return !(n-->0);}
-
- void input_chars(char* data, int size) {input_raw(data, size);}
-
- void input_raw(char* data, int size) {
- int i;
- for(i=0;i<(size>>8)-1;i++,data+=256)
- memcpy(data, require(256), 256);
- int res=size-(i<<8);
- memcpy(data, require(res), res);
- }
-
- template <class T>
- inline void output_simple(T const& data)
- {*((T*)desire(sizeof(T)))=data;}
-
- void output_start_array(int n) {output_simple(n);}
- void output_end_array() {}
-
- void output_chars(char const* data, int size) {output_raw(data, size);}
-
- void output_raw(char const* data, int size) {
- int i;
- for(i=0;i<(size>>8)-1;i++,data+=256)
- memcpy(desire(256), data, 256);
- int res=size-(i<<8);
- memcpy(desire(res), data, res);
- }
-};
-
-#ifdef XTL_CONFIG_CHOICE_MACROS
-#include <xtl/macros.h>
-#endif
-
-#ifdef XTL_CONFIG_COMPOSITE_BUG
-#define content(d) composite(d)
-#else
-#define content(d) simple(d)
-#define array_s array
-#define vector_s vector
-#endif
-
-class no_refs;
-
-#define def_simple_input(type) \
- inline obj_input& simple(type& data) { \
- format.input_simple(data); \
- return *this; \
- }
-
-template <class Format, class References=no_refs>
-class obj_input {
- private:
- Format& format;
- References refs;
-
- public:
- obj_input(Format& buf):format(buf)
- {format.input_start();}
-
- def_simple_input(bool);
- def_simple_input(char);
- def_simple_input(unsigned char);
- def_simple_input(short);
- def_simple_input(unsigned short);
- def_simple_input(int);
- def_simple_input(unsigned int);
- def_simple_input(long);
- def_simple_input(unsigned long);
- def_simple_input(longlong);
- def_simple_input(unsignedlonglong);
- def_simple_input(float);
- def_simple_input(double);
-
- inline obj_input& cstring(char*& data) {
- int size;
- format.input_start_array(size);
- data=new char[size+1];
- format.input_chars(data, size);
- data[size]=0;
- format.input_end_array(size);
- return *this;
- }
-
- inline obj_input& cstring(char* data, int max) {
- int size;
- format.input_start_array(size);
- format.input_chars(data, size>max?max:size);
- data[size>max?max:size]=0;
- format.input_end_array(size);
- return *this;
- }
-
- inline obj_input& simple(std::string& data) {
- int size;
- format.input_start_array(size);
- char* tmp=new char[size];
- format.input_chars(tmp, size);
- data=std::string(tmp, size);
- // FIXME: This causes a crash. Investigate...
- //delete[] tmp;
- format.input_end_array(size);
- return *this;
- }
-
- template <class T>
- inline obj_input& vector(T data[], int size) {
- format.input_start_vector();
- for(int i=0;i<size;i++)
- content(data[i]);
- format.input_end_vector();
- return *this;
- }
-
- template <class T>
- inline obj_input& array(T*& data, int& size) {
- format.input_start_array(size);
- data=new T[size];
- for(int j=size,i=0;!format.input_end_array(j);i++)
- content(data[i]);
- return *this;
- }
-
-#ifdef XTL_CONFIG_COMPOSITE_BUG
- template <class T>
- inline obj_input& vector_s(T data[], int size) {
- format.input_start_vector();
- for(int i=0;i<size;i++)
- simple(data[i]);
- format.input_end_vector();
- return *this;
- }
-
- template <class T>
- inline obj_input& array_s(T*& data, int& size) {
- format.input_start_array(size);
- data=new T[size];
- for(int j=size,i=0;!format.input_end_array(j);i++)
- simple(data[i]);
- return *this;
- }
-#endif
-
- inline obj_input& opaque(char data[], int size) {
- format.input_start_vector();
- format.input_raw(data, size);
- format.input_end_vector();
- return *this;
- }
-
- inline obj_input& bytes(char*& data, int& size) {
- int s=size;
- format.input_start_array(size);
- data=new char[size];
- format.input_raw(data, size);
- format.input_end_array(s);
- return *this;
- }
-
- // This is for compilers which do not support specialization
- // If possible, use simple(T&) below.
- template <class T>
- inline obj_input& composite(T& data) {
- format.input_start_composite();
- ::composite(*this, data);
- format.input_end_composite();
- return *this;
- }
-
-#ifndef XTL_CONFIG_COMPOSITE_BUG
- template <class T>
- inline obj_input& simple(T& data) {
- format.input_start_composite();
- ::composite(*this, data);
- format.input_end_composite();
- return *this;
- }
-#endif
-
- template <class T>
- inline obj_input& reference(T*& data) {
- refs.reference(*this, data);
- return *this;
- }
-
- template <class T>
- inline obj_input& pointer(T*& data) {
- bool exists;
- simple(exists);
- if (exists)
- reference(data);
- return *this;
- }
-
- template <class T>
- inline obj_input& container(T& data) {
- int j=0;
- format.input_start_array(j);
- while(!format.input_end_array(j)) {
- typename T::value_type v;
- content(v);
- data.insert(data.end(), v);
- }
- return *this;
- }
-
-#ifdef XTL_CONFIG_CHOICE_MACROS
- decl_ich_method(2)
- decl_ich_method(3)
- decl_ich_method(4)
- decl_ich_method(5)
-
- decl_iobj_method(2)
- decl_iobj_method(3)
- decl_iobj_method(4)
- decl_iobj_method(5)
-#endif
-};
-
-#define def_simple_output(type) \
- inline obj_output& simple(type const& data) { \
- format.output_simple(data); \
- return *this; \
- }
-
-template <class Format, class References=no_refs>
-class obj_output {
- private:
- Format& format;
- References refs;
-
- public:
- obj_output(Format& buf):format(buf)
- {format.output_start();}
-
- def_simple_output(bool);
- def_simple_output(char);
- def_simple_output(unsigned char);
- def_simple_output(short);
- def_simple_output(unsigned short);
- def_simple_output(int);
- def_simple_output(unsigned int);
- def_simple_output(long);
- def_simple_output(unsigned long);
- def_simple_output(longlong);
- def_simple_output(unsignedlonglong);
- def_simple_output(float);
- def_simple_output(double);
-
- inline obj_output& cstring(char const* data) {
- int size=strlen(data);
- format.output_start_array(size);
- format.output_chars(data, size);
- format.output_end_array();
- return *this;
- }
-
- inline obj_output& cstring(char const* data, int max) {
- int size=strlen(data);
- format.output_start_array(size);
- format.output_chars(data, size);
- format.output_end_array();
- return *this;
- }
-
- inline obj_output& simple(const std::string& data) {
- int size=data.size();
- format.output_start_array(size);
- format.output_chars(data.data(), size);
- format.output_end_array();
- return *this;
- }
-
- template <class T>
- inline obj_output& vector(const T data[], int size) {
- format.output_start_vector();
- for(int i=0;i<size;i++)
- content(data[i]);
- format.output_end_vector();
- return *this;
- }
-
- template <class T>
- inline obj_output& array(T const* data, int size) {
- format.output_start_array(size);
- for(int i=0;i<size;i++)
- content(data[i]);
- format.output_end_array();
- return *this;
- }
-#ifdef XTL_CONFIG_COMPOSITE_BUG
- template <class T>
- inline obj_output& vector_s(const T data[], int size) {
- format.output_start_vector();
- for(int i=0;i<size;i++)
- simple(data[i]);
- format.output_end_vector();
- return *this;
- }
-
- template <class T>
- inline obj_output& array_s(T const* data, int size) {
- format.output_start_array(size);
- for(int i=0;i<size;i++)
- simple(data[i]);
- format.output_end_array();
- return *this;
- }
-#endif
-
- inline obj_output& opaque(const char data[], int size) {
- format.output_start_vector();
- format.output_raw(data, size);
- format.output_end_vector();
- return *this;
- }
-
- inline obj_output& bytes(char const* data, int size) {
- format.output_start_array(size);
- format.output_raw(data, size);
- format.output_end_array();
- return *this;
- }
-
- // This is for compilers which do not support specialization
- // If possible, use simple(T&) below.
- template <class T>
- inline obj_output& composite(T const& data) {
- format.output_start_composite();
- ::composite(*this, const_cast<T&>(data));
- format.output_end_composite();
- return *this;
- }
-
-#ifndef XTL_CONFIG_COMPOSITE_BUG
- template <class T>
- inline obj_output& simple(T const& data) {
- format.output_start_composite();
- ::composite(*this, const_cast<T&>(data));
- format.output_end_composite();
- return *this;
- }
-#endif
-
- template <class T>
- inline obj_output& reference(T const* data) {
- refs.reference(*this, data);
- return *this;
- }
-
- template <class T>
- inline obj_output& pointer(T const* data) {
- bool exists=data!=NULL;
- simple(exists);
- if (exists)
- reference(data);
- return *this;
- }
-
- template <class T>
- inline obj_output& container(T const& data) {
- int j=data.size();
- format.output_start_array(j);
- for(typename T::const_iterator i=data.begin();
- i!=data.end();
- i++)
- content(*i);
- format.output_end_array();
- return *this;
- }
-
-#ifdef XTL_CONFIG_CHOICE_MACROS
- decl_och_method(2)
- decl_och_method(3)
- decl_och_method(4)
- decl_och_method(5)
-
- decl_oobj_method(2)
- decl_oobj_method(3)
- decl_oobj_method(4)
- decl_oobj_method(5)
-
-#define option(t) (t*)NULL
-
-#endif
-};
-
-#undef def_simple_input
-#undef def_simple_output
-
-template <class Stream, class T>
-inline void composite(Stream& stream, T& data) {
- data.composite(stream);
-}
-
-class no_refs {
- public:
- template <class Format, class T>
- void reference(obj_input<Format>& stream, T*& data) {
- delete data;
- data=new T;
- stream.content(*data);
- }
-
- template <class Format, class T>
- void reference(obj_output<Format>& stream, T const* data) {
- stream.content(*data);
- }
-};
-
-// mem_buffer
-
-class mem_buffer {
- private:
- char *buffer, *ptr, *lim;
-
- public:
- class buffer_overflow_error: public std::overflow_error {
- public:
- int bytes_left;
- int bytes_needed;
-
- buffer_overflow_error(int left, int needed):
- std::overflow_error("XTL mem_buffer overflow"),
- bytes_left(left),bytes_needed(needed) {}
- };
-
- mem_buffer(void *buf, int size):
- buffer((char*)buf),ptr((char*)buf),lim(((char*)buf)+size) {}
-
- inline void read(char* ptr, int size)
- {memcpy(ptr, require(size), size);}
- inline void write(char const* ptr, int size)
- {memcpy(desire(size), ptr, size);}
-
- inline void* require(int size) {
- char* aux=ptr;
- if ((ptr+=size)>lim)
- throw buffer_overflow_error(lim-aux,size);
- return aux;
- }
- inline void* desire(int size)
- {return require(size);}
- inline void flush()
- {}
-
- inline void unrequire(int n)
- {ptr-=n;}
- inline void undesire(int n)
- {unrequire(n);}
- inline void rewind()
- {ptr=buffer;}
- inline int size()
- {return ptr-buffer;}
- inline char* data()
- {return buffer;}
-
- template <class Format>
- inline void composite(obj_input<Format>& stream) {
- int size, idx;
- stream.array(buffer, size).simple(idx);
- ptr=buffer+idx;
- lim=buffer+size;
- }
-
- template <class Format>
- inline void composite(obj_output<Format>& stream) {
- stream.array(buffer, lim-buffer).simple((int)ptr-buffer);
- }
-
-};
-
-#ifdef XTL_CONFIG_SIMPLE_CONTAINERS
-
-#include <utility>
-#include <vector>
-#include <list>
-#include <map>
-
-template <class Stream, class T1, class T2>
-inline void composite(Stream& stream, std::pair<const T1,T2>& data) {
- stream.simple(const_cast<T1&>(data.first));
- stream.simple(data.second);
-}
-
-template <class Stream, class T1, class T2>
-inline void composite(Stream& stream, std::pair<T1,T2>& data) {
- stream.simple(data.first);
- stream.simple(data.second);
-}
-
-template <class Stream, class T>
-inline void composite(Stream& stream, std::list<T>& data) {
- stream.container(data);
-}
-
-template <class Stream, class T>
-inline void composite(Stream& stream, std::vector<T>& data) {
- stream.container(data);
-}
-
-template <class Stream, class T1, class T2>
-inline void composite(Stream& stream, std::map<T1, T2>& data) {
- stream.container(data);
-}
-
-#endif
-
-#endif
+++ /dev/null
-/*
- * Text format driver for XTL
- *
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, jop@di.uminho.pt
- * Copyright (C) 2000 Angus Leeming, a.leeming@ic.ac.uk
- */
-/* XTL - eXternalization Template Library - http://gsd.di.uminho.pt/~jop/xtl
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, Universidade do Minho
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA
- *
- * Id: text.h 1.14 Fri, 05 May 2000 18:57:58 +0100 jop
- */
-
-#ifndef __XTL_TEXT
-#define __XTL_TEXT
-
-#include <strstream>
-
-#define def_simple_output(type) \
- void output_simple(type const& data) { \
- space(); \
- std::ostrstream os((char*)desire(20), 20); \
- os << data; \
- undesire(20-os.pcount()); \
- }
-
-// Required to compile "long long" with DEC cxx -std strict_ansi
-#define def_simple_output_ll(type) \
- void output_simple(type const& data) { \
- space(); \
- std::ostrstream os((char*)desire(20), 20); \
- os << static_cast<long>( data ); \
- undesire(20-os.pcount()); \
- }
-
-
-template <class Buffer>
-class text_format: public generic_format<Buffer> {
-#if 0
- // Not yet...
- private:
- void gchar(int c) {}
- public:
- void input_start_composite() {gchar('{');}
- void input_end_composite() {gchar('}');}
-
- void input_start_vector() {gchar('[');}
- void input_end_vector() {gchar(']');}
-
- void input_start_array(int& n) {gchar('<');}
- bool input_end_array(int& n) {gchar('>');}
-
- void input_simple(int& data)
- {data=69;return *this;}
-#endif
-
- private:
- bool need;
-
- void space() {if (need) pchar(' ');need=true;}
- void pchar(int c) {*(char*)desire(1)=c;}
- public:
- typedef Buffer buffer;
-
- text_format(Buffer& buf):generic_format<Buffer>(buf),need(false) {}
-
- void output_start_composite() {space();pchar('{');need=false;}
- void output_end_composite() {pchar('}');need=true;}
-
- void output_start_vector() {space();pchar('[');need=false;}
- void output_end_vector() {pchar(']');need=true;}
-
- void output_start_array(int n) {space();pchar('<');need=false;}
- void output_end_array() {pchar('>');need=true;}
-
- def_simple_output(bool)
- def_simple_output(char)
- def_simple_output(unsigned char)
- def_simple_output(short)
- def_simple_output(unsigned short)
- def_simple_output(int)
- def_simple_output(unsigned int)
- def_simple_output(long)
- def_simple_output(unsigned long)
- def_simple_output_ll(longlong)
- def_simple_output_ll(unsignedlonglong)
- def_simple_output(float)
- def_simple_output(double)
-
- void output_chars(char const* data, int size) {
- output_simple('"');
- write(data, size);
- need=false;
- output_simple('"');
- }
-
- void output_raw(char const* data, int size) {
- output_chars(data, size);
- }
-};
-
-#undef def_simple_output
-#undef def_simple_output_ll
-
-#endif
+++ /dev/null
-/*
- * Run-time polymorphic streams for XTL
- *
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, jop@di.uminho.pt
- */
-/* XTL - eXternalization Template Library - http://gsd.di.uminho.pt/~jop/xtl
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, Universidade do Minho
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA
- *
- * Id: vobjio.h 1.12 Fri, 05 May 2000 18:57:58 +0100 jop
- */
-
-#ifndef __XTL_VOBJIO
-#define __XTL_VOBJIO
-
-class v_buffer {
- public:
- virtual void read(char* ptr, int size)=0;
- virtual void write(char const* ptr, int size)=0;
-
- virtual void* require(int size)=0;
- virtual void flush()=0;
-};
-
-template <class Buffer>
-class v_buffer_wrap: public v_buffer {
- protected:
- Buffer buf;
-
- public:
- virtual void read(char* ptr, int size) {buf.read(ptr, size);}
- virtual void write(char const* ptr, int size) {buf.write(ptr, size);}
-
- virtual void* require(int size) {return buf.require(size);}
- virtual void flush() {buf.flush();}
-};
-
-class v_mem_buffer: public v_buffer {
- private:
- mem_buffer buf;
-
- public:
- v_mem_buffer(void *b, int size):buf(b, size) {}
-
- virtual void read(char* ptr, int size) {buf.read(ptr, size);}
- virtual void write(char const* ptr, int size) {buf.write(ptr, size);}
-
- virtual void* require(int size) {return buf.require(size);}
- virtual void flush() {buf.flush();}
-};
-
-#define def_simple_input(type) \
- virtual void input_simple(type& data)=0;
-
-#define def_simple_output(type) \
- virtual void output_simple(const type& data)=0;
-
-class v_format {
- public:
- def_simple_input(bool)
- def_simple_input(char)
- def_simple_input(unsigned char)
- def_simple_input(short)
- def_simple_input(unsigned short)
- def_simple_input(int)
- def_simple_input(unsigned int)
- def_simple_input(long)
- def_simple_input(unsigned long)
- def_simple_input(longlong)
- def_simple_input(unsignedlonglong)
- def_simple_input(float)
- def_simple_input(double)
-
- virtual void input_start()=0;
-
- virtual void input_start_composite()=0;
- virtual void input_end_composite()=0;
-
- virtual void input_start_vector()=0;
- virtual void input_end_vector()=0;
-
- virtual void input_start_array(int& n)=0;
- virtual bool input_end_array(int& n)=0;
-
- virtual void input_chars(char* data, int size)=0;
- virtual void input_raw(char* data, int size)=0;
-
- def_simple_output(bool)
- def_simple_output(char)
- def_simple_output(unsigned char)
- def_simple_output(short)
- def_simple_output(unsigned short)
- def_simple_output(int)
- def_simple_output(unsigned int)
- def_simple_output(long)
- def_simple_output(unsigned long)
- def_simple_output(longlong)
- def_simple_output(unsignedlonglong)
- def_simple_output(float)
- def_simple_output(double)
-
- virtual void output_start()=0;
-
- virtual void output_start_composite()=0;
- virtual void output_end_composite()=0;
-
- virtual void output_start_vector()=0;
- virtual void output_end_vector()=0;
-
- virtual void output_start_array(int n)=0;
- virtual void output_end_array()=0;
-
- virtual void output_chars(char const* data, int size)=0;
- virtual void output_raw(char const* data, int size)=0;
-
- virtual void reset_buffer()=0;
-};
-
-#undef def_simple_input
-#undef def_simple_output
-
-#define def_simple_input(type) \
- virtual void input_simple(type& data) { \
- rep.input_simple(data); \
- }
-
-#define def_simple_output(type) \
- virtual void output_simple(const type& data) { \
- rep.output_simple(data); \
- }
-
-template <class Format>
-class v_format_wrap: public v_format {
- protected:
- Format rep;
-
- public:
- typedef typename Format::buffer buffer;
-
- v_format_wrap(buffer& buf):rep(buf) {}
-
- def_simple_input(bool);
- def_simple_input(char);
- def_simple_input(unsigned char);
- def_simple_input(short);
- def_simple_input(unsigned short);
- def_simple_input(int);
- def_simple_input(unsigned int);
- def_simple_input(long);
- def_simple_input(unsigned long);
- def_simple_input(longlong);
- def_simple_input(unsignedlonglong);
- def_simple_input(float);
- def_simple_input(double);
-
- virtual void input_start() {rep.input_start();}
-
- virtual void input_start_composite() {rep.input_start_composite();}
- virtual void input_end_composite() {rep.input_end_composite();}
-
- virtual void input_start_vector() {rep.input_start_vector();}
- virtual void input_end_vector() {rep.input_end_vector();}
-
- virtual void input_start_array(int& n) {rep.input_start_array(n);}
- virtual bool input_end_array(int& n) {return rep.input_end_array(n);}
-
- virtual void input_chars(char* data, int size) {rep.input_chars(data, size);}
- virtual void input_raw(char* data, int size) {rep.input_raw(data, size);}
-
- def_simple_output(bool);
- def_simple_output(char);
- def_simple_output(unsigned char);
- def_simple_output(short);
- def_simple_output(unsigned short);
- def_simple_output(int);
- def_simple_output(unsigned int);
- def_simple_output(long);
- def_simple_output(unsigned long);
- def_simple_output(longlong);
- def_simple_output(unsignedlonglong);
- def_simple_output(float);
- def_simple_output(double);
-
- virtual void output_start() {rep.output_start();}
-
- virtual void output_start_composite() {rep.output_start_composite();}
- virtual void output_end_composite() {rep.output_end_composite();}
-
- virtual void output_start_vector() {rep.output_start_vector();}
- virtual void output_end_vector() {rep.output_end_vector();}
-
- virtual void output_start_array(int n) {rep.output_start_array(n);}
- virtual void output_end_array() {rep.output_end_array();}
-
- virtual void output_chars(char const* data, int size) {rep.output_chars(data, size);}
- virtual void output_raw(char const* data, int size) {rep.output_raw(data, size);}
-
- virtual void reset_buffer() { rep.reset_buffer(); }
-};
-
-#undef def_simple_input
-#undef def_simple_output
-
-#endif
-
+++ /dev/null
-/*
- * XDR format driver for XTL
- *
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, jop@di.uminho.pt
- * Copyright (C) 2000 Angus Leeming, a.leeming@ic.ac.uk
- */
-/* XTL - eXternalization Template Library - http://gsd.di.uminho.pt/~jop/xtl
- * Copyright (C) 1998-2000 Jose' Orlando Pereira, Universidade do Minho
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA
- *
- * Id: xdr.h 1.16 Fri, 12 May 2000 17:21:18 +0100 jop
- */
-
-#ifndef __XTL_XDR
-#define __XTL_XDR
-
-// Macros to keep things neat and tidy in class XDR_format.
-// All data is stored in 32 bit chunks (XDR standard), those
-// types longer than 32 bits being accessed through a union to avoid
-// "unaligned access errors" on 64 bit machines.
-#define def_input_simple_i(type1, type2) \
- void input_simple(type1& data) { \
- type2 store; \
- _xtl_big_end( reinterpret_cast<char*>( require(4) ), \
- reinterpret_cast<char*>( &store ) ); \
- data = static_cast<type1>( store ); \
- }
-
-#define def_input_simple_ll(type1, type2) \
- void input_simple(type1& data) { \
- union { type2 ll; int i[2]; } store; \
- _xtl_big_end( reinterpret_cast<char*>( require(4) ), \
- reinterpret_cast<char*>( &store.i[0] ) ); \
- _xtl_big_end( reinterpret_cast<char*>( require(4) ), \
- reinterpret_cast<char*>( &store.i[1] ) ); \
- data = static_cast<type1>( store.ll ); \
- }
-
-#define def_output_simple_i(type1, type2) \
- void output_simple(type1 const& data) { \
- type2 store = static_cast<type2>( data ); \
- _xtl_big_end( reinterpret_cast<char*>( &store ), \
- reinterpret_cast<char*>( require(4) ) ); \
- }
-
-#define def_output_simple_ll(type1, type2) \
- void output_simple(type1 const& data) { \
- union { type2 ll; int i[2]; } store; \
- store.ll = static_cast<type2>( data ); \
- _xtl_big_end( reinterpret_cast<char*>( &store.i[0] ), \
- reinterpret_cast<char*>( require(4) ) ); \
- _xtl_big_end( reinterpret_cast<char*>( &store.i[1] ), \
- reinterpret_cast<char*>( require(4) ) ); \
- }
-
-// data is stored with big endian ordering (XDR standard)
-// this must be global due to a joint g++/glibc/i386 "feature"
-#if (__BYTE_ORDER == __LITTLE_ENDIAN)
-inline void _xtl_big_end(char const in[], char out[]) {
- *reinterpret_cast<unsigned int*>(out) =
- bswap_32(*reinterpret_cast<const unsigned int*>(in));
-}
-
-#elif (__BYTE_ORDER == __BIG_ENDIAN)
-void _xtl_big_end(char const in[], char out[]) {
- *reinterpret_cast<unsigned int*>(out) =
- *reinterpret_cast<const unsigned int*>(in);
-}
-#endif
-
-template <class Buffer>
-class XDR_format: public generic_format<Buffer> {
- private:
- public:
- typedef Buffer buffer;
-
- XDR_format(Buffer& buf):generic_format<Buffer>(buf) {}
-
- void input_start_array(int& n) {input_simple(n);}
- bool input_end_array(int& n) {return n--<=0;}
-
- def_input_simple_i(bool, int)
- def_input_simple_i(char, int)
- def_input_simple_i(unsigned char, int)
- def_input_simple_i(short, int)
- def_input_simple_i(unsigned short, int)
- def_input_simple_i(int, int)
- def_input_simple_i(unsigned int, int)
- def_input_simple_i(long, int)
- def_input_simple_i(unsigned long, int)
- def_input_simple_ll(longlong, longlong)
- def_input_simple_ll(unsignedlonglong, longlong)
- def_input_simple_i(float, float)
- def_input_simple_ll(double, double)
-
- void input_chars(char* data, int size) {
- input_raw(data, size);
- }
-
- // This routine is identical to that in GIOP_format
- void input_raw(char* data, int size) {
- int i;
- for(i=0;i<(size>>8)-1;i++,data+=256)
- memcpy(data, require(256), 256);
- int res=size-(i<<8);
- memcpy(data, require(res), res);
- if (res%4!=0)
- require(4-res%4);
- }
-
- void output_start_array(int n) {output_simple(n);}
- void output_end_array() {}
-
- def_output_simple_i(bool, int)
- def_output_simple_i(char, int)
- def_output_simple_i(unsigned char, int)
- def_output_simple_i(short, int)
- def_output_simple_i(unsigned short, int)
- def_output_simple_i(int, int)
- def_output_simple_i(unsigned int, int)
- def_output_simple_i(long, int)
- def_output_simple_i(unsigned long, int)
- def_output_simple_ll(longlong, longlong)
- def_output_simple_ll(unsignedlonglong, longlong)
- def_output_simple_i(float, float)
- def_output_simple_ll(double, double)
-
- void output_chars(char const* data, int size) {
- output_raw(data, size);
- }
-
- // This routine is identical to that in GIOP_format
- void output_raw(char const* data, int size) {
- int i;
- for(i=0;i<(size>>8)-1;i++,data+=256)
- memcpy(desire(256), data, 256);
- int res=size-(i<<8);
- memcpy(desire(res), data, res);
- if (res%4!=0)
- memset(desire(4-res%4), 0, 4-res%4);
- }
-};
-
-#undef def_input_simple_i
-#undef def_input_simple_ll
-#undef def_output_simple_i
-#undef def_output_simple_ll
-
-#endif