1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2
3 #line 1 "file-ostream.oo.h"
4 /* Output stream referring to an stdio FILE.
5 Copyright (C) 2006, 2020 Free Software Foundation, Inc.
6 Written by Bruno Haible <bruno@clisp.org>, 2006.
7
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.
12
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.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
20
21 #ifndef _FILE_OSTREAM_H
22 #define _FILE_OSTREAM_H
23
24 #include <stdbool.h>
25 #include <stdio.h>
26
27 #include "ostream.h"
28
29
30 #line 31 "file-ostream.h"
31 struct file_ostream_representation;
32 /* file_ostream_t is defined as a pointer to struct file_ostream_representation.
33 In C++ mode, we use a smart pointer class.
34 In C mode, we have no other choice than a typedef to the root class type. */
35 #if IS_CPLUSPLUS
36 struct file_ostream_t
37 {
38 private:
39 struct file_ostream_representation *_pointer;
40 public:
41 file_ostream_t () : _pointer (NULL) {}
42 file_ostream_t (struct file_ostream_representation *pointer) : _pointer (pointer) {}
43 struct file_ostream_representation * operator -> () { return _pointer; }
44 operator struct file_ostream_representation * () { return _pointer; }
45 operator struct any_ostream_representation * () { return (struct any_ostream_representation *) _pointer; }
46 operator void * () { return _pointer; }
47 bool operator == (const void *p) { return _pointer == p; }
48 bool operator != (const void *p) { return _pointer != p; }
49 operator ostream_t () { return (ostream_t) (struct any_ostream_representation *) _pointer; }
50 explicit file_ostream_t (ostream_t x) : _pointer ((struct file_ostream_representation *) (void *) x) {}
51 };
52 #else
53 typedef ostream_t file_ostream_t;
54 #endif
55
56 /* Functions that invoke the methods. */
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 extern void file_ostream_write_mem (file_ostream_t first_arg, const void *data, size_t len);
61 extern void file_ostream_flush (file_ostream_t first_arg, ostream_flush_scope_t scope);
62 extern void file_ostream_free (file_ostream_t first_arg);
63 extern FILE * file_ostream_get_stdio_stream (file_ostream_t first_arg);
64 #ifdef __cplusplus
65 }
66 #endif
67
68 /* Type representing an implementation of file_ostream_t. */
69 struct file_ostream_implementation
70 {
71 const typeinfo_t * const *superclasses;
72 size_t superclasses_length;
73 size_t instance_size;
74 #define THIS_ARG file_ostream_t first_arg
75 #include "file_ostream.vt.h"
76 #undef THIS_ARG
77 };
78
79 /* Public portion of the object pointed to by a file_ostream_t. */
80 struct file_ostream_representation_header
81 {
82 const struct file_ostream_implementation *vtable;
83 };
84
85 #if HAVE_INLINE
86
87 /* Define the functions that invoke the methods as inline accesses to
88 the file_ostream_implementation.
89 Use #define to avoid a warning because of extern vs. static. */
90
91 # define file_ostream_write_mem file_ostream_write_mem_inline
92 static inline void
93 file_ostream_write_mem (file_ostream_t first_arg, const void *data, size_t len)
94 {
95 const struct file_ostream_implementation *vtable =
96 ((struct file_ostream_representation_header *) (struct file_ostream_representation *) first_arg)->vtable;
97 vtable->write_mem (first_arg,data,len);
98 }
99
100 # define file_ostream_flush file_ostream_flush_inline
101 static inline void
102 file_ostream_flush (file_ostream_t first_arg, ostream_flush_scope_t scope)
103 {
104 const struct file_ostream_implementation *vtable =
105 ((struct file_ostream_representation_header *) (struct file_ostream_representation *) first_arg)->vtable;
106 vtable->flush (first_arg,scope);
107 }
108
109 # define file_ostream_free file_ostream_free_inline
110 static inline void
111 file_ostream_free (file_ostream_t first_arg)
112 {
113 const struct file_ostream_implementation *vtable =
114 ((struct file_ostream_representation_header *) (struct file_ostream_representation *) first_arg)->vtable;
115 vtable->free (first_arg);
116 }
117
118 # define file_ostream_get_stdio_stream file_ostream_get_stdio_stream_inline
119 static inline FILE *
120 file_ostream_get_stdio_stream (file_ostream_t first_arg)
121 {
122 const struct file_ostream_implementation *vtable =
123 ((struct file_ostream_representation_header *) (struct file_ostream_representation *) first_arg)->vtable;
124 return vtable->get_stdio_stream (first_arg);
125 }
126
127 #endif
128
129 extern const typeinfo_t file_ostream_typeinfo;
130 #define file_ostream_SUPERCLASSES &file_ostream_typeinfo, ostream_SUPERCLASSES
131 #define file_ostream_SUPERCLASSES_LENGTH (1 + ostream_SUPERCLASSES_LENGTH)
132
133 extern const struct file_ostream_implementation file_ostream_vtable;
134
135 #line 33 "file-ostream.oo.h"
136
137
138 #ifdef __cplusplus
139 extern "C" {
140 #endif
141
142
143 /* Create an output stream referring to FP.
144 Note that the resulting stream must be closed before FP can be closed. */
145 extern file_ostream_t file_ostream_create (FILE *fp);
146
147
148 /* Test whether a given output stream is a file_ostream. */
149 extern bool is_instance_of_file_ostream (ostream_t stream);
150
151
152 #ifdef __cplusplus
153 }
154 #endif
155
156 #endif /* _FILE_OSTREAM_H */