1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 2 3#line 1 "file-ostream.oo.c" 4/* Output stream referring to an stdio FILE. 5 Copyright (C) 2006 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 <http://www.gnu.org/licenses/>. */ 20 21#include <config.h> 22 23/* Specification. */ 24#include "file-ostream.h" 25 26#include <stdlib.h> 27 28#include "xalloc.h" 29 30#line 31 "file-ostream.c" 31#if !IS_CPLUSPLUS 32#define file_ostream_representation any_ostream_representation 33#endif 34#include "file_ostream.priv.h" 35 36const typeinfo_t file_ostream_typeinfo = { "file_ostream" }; 37 38static const typeinfo_t * const file_ostream_superclasses[] = 39 { file_ostream_SUPERCLASSES }; 40 41#define super ostream_vtable 42 43#line 32 "file-ostream.oo.c" 44 45/* Implementation of ostream_t methods. */ 46 47static void 48file_ostream__write_mem (file_ostream_t stream, const void *data, size_t len) 49{ 50 if (len > 0) 51 fwrite (data, 1, len, stream->fp); 52} 53 54static void 55file_ostream__flush (file_ostream_t stream) 56{ 57 /* This ostream has no internal buffer. No need to fflush (stream->fp), 58 since it's external to this ostream. */ 59} 60 61static void 62file_ostream__free (file_ostream_t stream) 63{ 64 free (stream); 65} 66 67/* Constructor. */ 68 69file_ostream_t 70file_ostream_create (FILE *fp) 71{ 72 file_ostream_t stream = XMALLOC (struct file_ostream_representation); 73 74 stream->base.vtable = &file_ostream_vtable; 75 stream->fp = fp; 76 77 return stream; 78} 79 80#line 81 "file-ostream.c" 81 82const struct file_ostream_implementation file_ostream_vtable = 83{ 84 file_ostream_superclasses, 85 sizeof (file_ostream_superclasses) / sizeof (file_ostream_superclasses[0]), 86 sizeof (struct file_ostream_representation), 87 file_ostream__write_mem, 88 file_ostream__flush, 89 file_ostream__free, 90}; 91 92#if !HAVE_INLINE 93 94/* Define the functions that invoke the methods. */ 95 96void 97file_ostream_write_mem (file_ostream_t first_arg, const void *data, size_t len) 98{ 99 const struct file_ostream_implementation *vtable = 100 ((struct file_ostream_representation_header *) (struct file_ostream_representation *) first_arg)->vtable; 101 vtable->write_mem (first_arg,data,len); 102} 103 104void 105file_ostream_flush (file_ostream_t first_arg) 106{ 107 const struct file_ostream_implementation *vtable = 108 ((struct file_ostream_representation_header *) (struct file_ostream_representation *) first_arg)->vtable; 109 vtable->flush (first_arg); 110} 111 112void 113file_ostream_free (file_ostream_t first_arg) 114{ 115 const struct file_ostream_implementation *vtable = 116 ((struct file_ostream_representation_header *) (struct file_ostream_representation *) first_arg)->vtable; 117 vtable->free (first_arg); 118} 119 120#endif 121