1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 2 3#line 1 "ostream.oo.h" 4/* Abstract output stream data type. 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#ifndef _OSTREAM_H 22#define _OSTREAM_H 23 24#include <stddef.h> 25#include <string.h> 26 27#include "moo.h" 28 29/* An output stream is an object to which one can feed a sequence of bytes. */ 30 31#line 32 "ostream.h" 32struct 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. */ 36#if IS_CPLUSPLUS 37struct ostream_t 38{ 39private: 40 struct any_ostream_representation *_pointer; 41public: 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; } 49}; 50#else 51typedef struct any_ostream_representation * ostream_t; 52#endif 53 54/* Functions that invoke the methods. */ 55extern void ostream_write_mem (ostream_t first_arg, const void *data, size_t len); 56extern void ostream_flush (ostream_t first_arg); 57extern void ostream_free (ostream_t first_arg); 58 59/* Type representing an implementation of ostream_t. */ 60struct ostream_implementation 61{ 62 const typeinfo_t * const *superclasses; 63 size_t superclasses_length; 64 size_t instance_size; 65#define THIS_ARG ostream_t first_arg 66#include "ostream.vt.h" 67#undef THIS_ARG 68}; 69 70/* Public portion of the object pointed to by a ostream_t. */ 71struct ostream_representation_header 72{ 73 const struct ostream_implementation *vtable; 74}; 75 76#if HAVE_INLINE 77 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. */ 81 82# define ostream_write_mem ostream_write_mem_inline 83static inline void 84ostream_write_mem (ostream_t first_arg, const void *data, size_t len) 85{ 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); 89} 90 91# define ostream_flush ostream_flush_inline 92static inline void 93ostream_flush (ostream_t first_arg) 94{ 95 const struct ostream_implementation *vtable = 96 ((struct ostream_representation_header *) (struct any_ostream_representation *) first_arg)->vtable; 97 vtable->flush (first_arg); 98} 99 100# define ostream_free ostream_free_inline 101static inline void 102ostream_free (ostream_t first_arg) 103{ 104 const struct ostream_implementation *vtable = 105 ((struct ostream_representation_header *) (struct any_ostream_representation *) first_arg)->vtable; 106 vtable->free (first_arg); 107} 108 109#endif 110 111extern const typeinfo_t ostream_typeinfo; 112#define ostream_SUPERCLASSES &ostream_typeinfo, NULL 113#define ostream_SUPERCLASSES_LENGTH (1 + 1) 114 115extern const struct ostream_implementation ostream_vtable; 116 117#line 41 "ostream.oo.h" 118 119#ifdef __cplusplus 120extern "C" { 121#endif 122 123/* Write a string's contents to a stream. */ 124extern void ostream_write_str (ostream_t stream, const char *string); 125 126#if HAVE_INLINE 127 128#define ostream_write_str ostream_write_str_inline 129static inline void 130ostream_write_str (ostream_t stream, const char *string) 131{ 132 ostream_write_mem (stream, string, strlen (string)); 133} 134 135#endif 136 137#ifdef __cplusplus 138} 139#endif 140 141#endif /* _OSTREAM_H */ 142