1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
4 /* Abstract output stream data type.
5 Copyright (C) 2006, 2015 Free Software Foundation, Inc.
6 Written by Bruno Haible <bruno@clisp.org>, 2006.
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
29 /* An output stream is an object to which one can feed a sequence of bytes. */
32 struct any_ostream_representation;
33 /* ostream_t is defined as a pointer to struct any_ostream_representation.
34 In C++ mode, we use a smart pointer class.
35 In C mode, we have no other choice than a typedef to the root class type. */
40 struct any_ostream_representation *_pointer;
42 ostream_t () : _pointer (NULL) {}
43 ostream_t (struct any_ostream_representation *pointer) : _pointer (pointer) {}
44 struct any_ostream_representation * operator -> () { return _pointer; }
45 operator struct any_ostream_representation * () { return _pointer; }
46 operator void * () { return _pointer; }
47 bool operator == (const void *p) { return _pointer == p; }
48 bool operator != (const void *p) { return _pointer != p; }
51 typedef struct any_ostream_representation * ostream_t;
54 /* Functions that invoke the methods. */
55 extern void ostream_write_mem (ostream_t first_arg, const void *data, size_t len);
56 extern void ostream_flush (ostream_t first_arg);
57 extern void ostream_free (ostream_t first_arg);
59 /* Type representing an implementation of ostream_t. */
60 struct ostream_implementation
62 const typeinfo_t * const *superclasses;
63 size_t superclasses_length;
65 #define THIS_ARG ostream_t first_arg
66 #include "ostream.vt.h"
70 /* Public portion of the object pointed to by a ostream_t. */
71 struct ostream_representation_header
73 const struct ostream_implementation *vtable;
78 /* Define the functions that invoke the methods as inline accesses to
79 the ostream_implementation.
80 Use #define to avoid a warning because of extern vs. static. */
82 # define ostream_write_mem ostream_write_mem_inline
84 ostream_write_mem (ostream_t first_arg, const void *data, size_t len)
86 const struct ostream_implementation *vtable =
87 ((struct ostream_representation_header *) (struct any_ostream_representation *) first_arg)->vtable;
88 vtable->write_mem (first_arg,data,len);
91 # define ostream_flush ostream_flush_inline
93 ostream_flush (ostream_t first_arg)
95 const struct ostream_implementation *vtable =
96 ((struct ostream_representation_header *) (struct any_ostream_representation *) first_arg)->vtable;
97 vtable->flush (first_arg);
100 # define ostream_free ostream_free_inline
102 ostream_free (ostream_t first_arg)
104 const struct ostream_implementation *vtable =
105 ((struct ostream_representation_header *) (struct any_ostream_representation *) first_arg)->vtable;
106 vtable->free (first_arg);
111 extern const typeinfo_t ostream_typeinfo;
112 #define ostream_SUPERCLASSES &ostream_typeinfo, NULL
113 #define ostream_SUPERCLASSES_LENGTH (1 + 1)
115 extern const struct ostream_implementation ostream_vtable;
117 #line 41 "ostream.oo.h"
123 /* Write a string's contents to a stream. */
124 extern void ostream_write_str (ostream_t stream, const char *string);
128 #define ostream_write_str ostream_write_str_inline
130 ostream_write_str (ostream_t stream, const char *string)
132 ostream_write_mem (stream, string, strlen (string));
141 #endif /* _OSTREAM_H */