1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 
3 #if !IS_CPLUSPLUS
4 #define noop_styled_ostream_representation any_ostream_representation
5 #endif
6 #line 1 "noop-styled-ostream.oo.c"
7 /* Output stream with no-op styling.
8    Copyright (C) 2006, 2019 Free Software Foundation, Inc.
9    Written by Bruno Haible <bruno@clisp.org>, 2019.
10 
11    This program is free software: you can redistribute it and/or modify
12    it under the terms of the GNU General Public License as published by
13    the Free Software Foundation; either version 3 of the License, or
14    (at your option) any later version.
15 
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19    GNU General Public License for more details.
20 
21    You should have received a copy of the GNU General Public License
22    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
23 
24 #include <config.h>
25 
26 /* Specification.  */
27 #include "noop-styled-ostream.h"
28 
29 #include "xalloc.h"
30 
31 
32 #line 33 "noop-styled-ostream.c"
33 #include "noop_styled_ostream.priv.h"
34 
35 const typeinfo_t noop_styled_ostream_typeinfo = { "noop_styled_ostream" };
36 
37 static const typeinfo_t * const noop_styled_ostream_superclasses[] =
38   { noop_styled_ostream_SUPERCLASSES };
39 
40 #define super styled_ostream_vtable
41 
42 #line 36 "noop-styled-ostream.oo.c"
43 
44 /* Implementation of ostream_t methods.  */
45 
46 static void
noop_styled_ostream__write_mem(noop_styled_ostream_t stream,const void * data,size_t len)47 noop_styled_ostream__write_mem (noop_styled_ostream_t stream,
48                                 const void *data, size_t len)
49 {
50   ostream_write_mem (stream->destination, data, len);
51 }
52 
53 static void
noop_styled_ostream__flush(noop_styled_ostream_t stream,ostream_flush_scope_t scope)54 noop_styled_ostream__flush (noop_styled_ostream_t stream,
55                             ostream_flush_scope_t scope)
56 {
57   ostream_flush (stream->destination, scope);
58 }
59 
60 static void
noop_styled_ostream__free(noop_styled_ostream_t stream)61 noop_styled_ostream__free (noop_styled_ostream_t stream)
62 {
63   if (stream->own_destination)
64     ostream_free (stream->destination);
65   free (stream->hyperlink_ref);
66   free (stream->hyperlink_id);
67   free (stream);
68 }
69 
70 /* Implementation of styled_ostream_t methods.  */
71 
72 static void
noop_styled_ostream__begin_use_class(noop_styled_ostream_t stream,const char * classname)73 noop_styled_ostream__begin_use_class (noop_styled_ostream_t stream,
74                                       const char *classname)
75 {
76 }
77 
78 static void
noop_styled_ostream__end_use_class(noop_styled_ostream_t stream,const char * classname)79 noop_styled_ostream__end_use_class (noop_styled_ostream_t stream,
80                                     const char *classname)
81 {
82 }
83 
84 static const char *
noop_styled_ostream__get_hyperlink_ref(noop_styled_ostream_t stream)85 noop_styled_ostream__get_hyperlink_ref (noop_styled_ostream_t stream)
86 {
87   return stream->hyperlink_ref;
88 }
89 
90 static const char *
noop_styled_ostream__get_hyperlink_id(noop_styled_ostream_t stream)91 noop_styled_ostream__get_hyperlink_id (noop_styled_ostream_t stream)
92 {
93   return stream->hyperlink_id;
94 }
95 
96 static void
noop_styled_ostream__set_hyperlink(noop_styled_ostream_t stream,const char * ref,const char * id)97 noop_styled_ostream__set_hyperlink (noop_styled_ostream_t stream,
98                                     const char *ref, const char *id)
99 {
100   char *ref_copy = (ref != NULL ? xstrdup (ref) : NULL);
101   char *id_copy = (id != NULL ? xstrdup (id) : NULL);
102 
103   free (stream->hyperlink_ref);
104   stream->hyperlink_ref = ref_copy;
105   free (stream->hyperlink_id);
106   stream->hyperlink_id = id_copy;
107 }
108 
109 static void
noop_styled_ostream__flush_to_current_style(noop_styled_ostream_t stream)110 noop_styled_ostream__flush_to_current_style (noop_styled_ostream_t stream)
111 {
112   ostream_flush (stream->destination, FLUSH_THIS_STREAM);
113 }
114 
115 /* Constructor.  */
116 
117 noop_styled_ostream_t
noop_styled_ostream_create(ostream_t destination,bool pass_ownership)118 noop_styled_ostream_create (ostream_t destination, bool pass_ownership)
119 {
120   noop_styled_ostream_t stream =
121     XMALLOC (struct noop_styled_ostream_representation);
122 
123   stream->base.base.vtable = &noop_styled_ostream_vtable;
124   stream->destination = destination;
125   stream->own_destination = pass_ownership;
126   stream->hyperlink_ref = NULL;
127   stream->hyperlink_id = NULL;
128 
129   return stream;
130 }
131 
132 #line 133 "noop-styled-ostream.c"
133 
134 const struct noop_styled_ostream_implementation noop_styled_ostream_vtable =
135 {
136   noop_styled_ostream_superclasses,
137   sizeof (noop_styled_ostream_superclasses) / sizeof (noop_styled_ostream_superclasses[0]),
138   sizeof (struct noop_styled_ostream_representation),
139   noop_styled_ostream__write_mem,
140   noop_styled_ostream__flush,
141   noop_styled_ostream__free,
142   noop_styled_ostream__begin_use_class,
143   noop_styled_ostream__end_use_class,
144   noop_styled_ostream__get_hyperlink_ref,
145   noop_styled_ostream__get_hyperlink_id,
146   noop_styled_ostream__set_hyperlink,
147   noop_styled_ostream__flush_to_current_style,
148 };
149 
150 #if !HAVE_INLINE
151 
152 /* Define the functions that invoke the methods.  */
153 
154 void
noop_styled_ostream_write_mem(noop_styled_ostream_t first_arg,const void * data,size_t len)155 noop_styled_ostream_write_mem (noop_styled_ostream_t first_arg, const void *data, size_t len)
156 {
157   const struct noop_styled_ostream_implementation *vtable =
158     ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
159   vtable->write_mem (first_arg,data,len);
160 }
161 
162 void
noop_styled_ostream_flush(noop_styled_ostream_t first_arg,ostream_flush_scope_t scope)163 noop_styled_ostream_flush (noop_styled_ostream_t first_arg, ostream_flush_scope_t scope)
164 {
165   const struct noop_styled_ostream_implementation *vtable =
166     ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
167   vtable->flush (first_arg,scope);
168 }
169 
170 void
noop_styled_ostream_free(noop_styled_ostream_t first_arg)171 noop_styled_ostream_free (noop_styled_ostream_t first_arg)
172 {
173   const struct noop_styled_ostream_implementation *vtable =
174     ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
175   vtable->free (first_arg);
176 }
177 
178 void
noop_styled_ostream_begin_use_class(noop_styled_ostream_t first_arg,const char * classname)179 noop_styled_ostream_begin_use_class (noop_styled_ostream_t first_arg, const char *classname)
180 {
181   const struct noop_styled_ostream_implementation *vtable =
182     ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
183   vtable->begin_use_class (first_arg,classname);
184 }
185 
186 void
noop_styled_ostream_end_use_class(noop_styled_ostream_t first_arg,const char * classname)187 noop_styled_ostream_end_use_class (noop_styled_ostream_t first_arg, const char *classname)
188 {
189   const struct noop_styled_ostream_implementation *vtable =
190     ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
191   vtable->end_use_class (first_arg,classname);
192 }
193 
194 const char *
noop_styled_ostream_get_hyperlink_ref(noop_styled_ostream_t first_arg)195 noop_styled_ostream_get_hyperlink_ref (noop_styled_ostream_t first_arg)
196 {
197   const struct noop_styled_ostream_implementation *vtable =
198     ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
199   return vtable->get_hyperlink_ref (first_arg);
200 }
201 
202 const char *
noop_styled_ostream_get_hyperlink_id(noop_styled_ostream_t first_arg)203 noop_styled_ostream_get_hyperlink_id (noop_styled_ostream_t first_arg)
204 {
205   const struct noop_styled_ostream_implementation *vtable =
206     ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
207   return vtable->get_hyperlink_id (first_arg);
208 }
209 
210 void
noop_styled_ostream_set_hyperlink(noop_styled_ostream_t first_arg,const char * ref,const char * id)211 noop_styled_ostream_set_hyperlink (noop_styled_ostream_t first_arg,                               const char *ref, const char *id)
212 {
213   const struct noop_styled_ostream_implementation *vtable =
214     ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
215   vtable->set_hyperlink (first_arg,ref,id);
216 }
217 
218 void
noop_styled_ostream_flush_to_current_style(noop_styled_ostream_t first_arg)219 noop_styled_ostream_flush_to_current_style (noop_styled_ostream_t first_arg)
220 {
221   const struct noop_styled_ostream_implementation *vtable =
222     ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
223   vtable->flush_to_current_style (first_arg);
224 }
225 
226 #endif
227