]> git.lyx.org Git - lyx.git/blob - src/support/lxtl.h
small changes read ChangeLog
[lyx.git] / src / support / lxtl.h
1 // -*- C++ -*-
2 /* lxtl.h
3  * LyX eXternalization Template Library
4  * This file is part of
5  * ====================================================== 
6  *
7  *           LyX, The Document Processor
8  *
9  *           Copyright 1995 Matthias Ettrich
10  *           Copyright 1995-2000 The LyX Team.
11  *
12  *           This file Copyright 2000
13  *           Allan Rae
14  * ======================================================
15  */
16
17 #ifndef LXTL_H
18 #define LXTL_H
19 #include <xtl/autobuf.h>
20 #include <xtl/objio.h>
21 #include <xtl/giop.h>
22 #include <xtl/xdr.h>
23
24 // XDR_format causes an abort that's hard to track down.  GDB says the abort
25 // occurs in code from a different function to the one being run before the
26 // abort!  (XTL-1.3.pl.11)
27 typedef GIOP_format<auto_mem_buffer> gui_format;
28
29 //@name XTL assistants
30 //@{
31 /** Simplify the use of the XTL.  The caller is responsible for creating their
32     own memory buffer.  The buffer type isn't a template parameter because I 
33     need/want the forward declared buffer class in some other header files
34     thereby avoiding an extra file dependency.
35     ARRae 20000423
36  */
37 /// Externalize a structure into a buffer.
38 template<class Input>
39 void getInMem(Input const & in, auto_mem_buffer & mb) {
40         gui_format gf(mb);
41         obj_output<gui_format> output(gf);
42         output.simple(in);
43         mb.rewind();
44 }
45
46 /// Internalize a structure from a buffer.
47 template<class Input>
48 void setFromMem(Input & in, auto_mem_buffer & mb) {
49         gui_format gf(mb);
50         obj_input<gui_format> input(gf);
51         input.simple(in);
52 }
53 //@}
54
55 #endif