(root)/
gettext-0.22.4/
libtextstyle/
lib/
ostream.c
       1  /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
       2  
       3  #if !IS_CPLUSPLUS
       4  #define ostream_representation any_ostream_representation
       5  #endif
       6  #line 1 "ostream.oo.c"
       7  /* Abstract output stream data type.
       8     Copyright (C) 2006, 2019 Free Software Foundation, Inc.
       9     Written by Bruno Haible <bruno@clisp.org>, 2006.
      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 "ostream.h"
      28  
      29  #include <stdio.h>
      30  
      31  #line 32 "ostream.c"
      32  #include "ostream.priv.h"
      33  
      34  const typeinfo_t ostream_typeinfo = { "ostream" };
      35  
      36  static const typeinfo_t * const ostream_superclasses[] =
      37    { ostream_SUPERCLASSES };
      38  
      39  #line 29 "ostream.oo.c"
      40  
      41  #if !HAVE_INLINE
      42  
      43  void
      44  ostream_write_str (ostream_t stream, const char *string)
      45  {
      46    ostream_write_mem (stream, string, strlen (string));
      47  }
      48  
      49  #endif
      50  
      51  ptrdiff_t
      52  ostream_printf (ostream_t stream, const char *format, ...)
      53  {
      54    va_list args;
      55    char *temp_string;
      56    ptrdiff_t ret;
      57  
      58    va_start (args, format);
      59    ret = vasprintf (&temp_string, format, args);
      60    va_end (args);
      61    if (ret >= 0)
      62      {
      63        if (ret > 0)
      64          ostream_write_str (stream, temp_string);
      65        free (temp_string);
      66      }
      67    return ret;
      68  }
      69  
      70  ptrdiff_t
      71  ostream_vprintf (ostream_t stream, const char *format, va_list args)
      72  {
      73    char *temp_string;
      74    ptrdiff_t ret = vasprintf (&temp_string, format, args);
      75    if (ret >= 0)
      76      {
      77        if (ret > 0)
      78          ostream_write_str (stream, temp_string);
      79        free (temp_string);
      80      }
      81    return ret;
      82  }
      83  
      84  #line 85 "ostream.c"
      85  void ostream__write_mem (ostream_t first_arg, const void *data, size_t len);
      86  void
      87  ostream__write_mem (ostream_t first_arg, const void *data, size_t len)
      88  {
      89    /* Abstract (unimplemented) method called.  */
      90    abort ();
      91    #ifndef __GNUC__
      92    ostream__write_mem (first_arg,data,len);
      93    #endif
      94  }
      95  
      96  void ostream__flush (ostream_t first_arg, ostream_flush_scope_t scope);
      97  void
      98  ostream__flush (ostream_t first_arg, ostream_flush_scope_t scope)
      99  {
     100    /* Abstract (unimplemented) method called.  */
     101    abort ();
     102    #ifndef __GNUC__
     103    ostream__flush (first_arg,scope);
     104    #endif
     105  }
     106  
     107  void ostream__free (ostream_t first_arg);
     108  void
     109  ostream__free (ostream_t first_arg)
     110  {
     111    /* Abstract (unimplemented) method called.  */
     112    abort ();
     113    #ifndef __GNUC__
     114    ostream__free (first_arg);
     115    #endif
     116  }
     117  
     118  
     119  const struct ostream_implementation ostream_vtable =
     120  {
     121    ostream_superclasses,
     122    sizeof (ostream_superclasses) / sizeof (ostream_superclasses[0]),
     123    sizeof (struct ostream_representation),
     124    ostream__write_mem,
     125    ostream__flush,
     126    ostream__free,
     127  };
     128  
     129  #if !HAVE_INLINE
     130  
     131  /* Define the functions that invoke the methods.  */
     132  
     133  void
     134  ostream_write_mem (ostream_t first_arg, const void *data, size_t len)
     135  {
     136    const struct ostream_implementation *vtable =
     137      ((struct ostream_representation_header *) (struct any_ostream_representation *) first_arg)->vtable;
     138    vtable->write_mem (first_arg,data,len);
     139  }
     140  
     141  void
     142  ostream_flush (ostream_t first_arg, ostream_flush_scope_t scope)
     143  {
     144    const struct ostream_implementation *vtable =
     145      ((struct ostream_representation_header *) (struct any_ostream_representation *) first_arg)->vtable;
     146    vtable->flush (first_arg,scope);
     147  }
     148  
     149  void
     150  ostream_free (ostream_t first_arg)
     151  {
     152    const struct ostream_implementation *vtable =
     153      ((struct ostream_representation_header *) (struct any_ostream_representation *) first_arg)->vtable;
     154    vtable->free (first_arg);
     155  }
     156  
     157  #endif