(root)/
gettext-0.22.4/
libtextstyle/
lib/
noop-styled-ostream.c
       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-2020 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
      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
      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
      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
      73  noop_styled_ostream__begin_use_class (noop_styled_ostream_t stream,
      74                                        const char *classname)
      75  {
      76  }
      77  
      78  static void
      79  noop_styled_ostream__end_use_class (noop_styled_ostream_t stream,
      80                                      const char *classname)
      81  {
      82  }
      83  
      84  static const char *
      85  noop_styled_ostream__get_hyperlink_ref (noop_styled_ostream_t stream)
      86  {
      87    return stream->hyperlink_ref;
      88  }
      89  
      90  static const char *
      91  noop_styled_ostream__get_hyperlink_id (noop_styled_ostream_t stream)
      92  {
      93    return stream->hyperlink_id;
      94  }
      95  
      96  static void
      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
     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
     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  /* Accessors.  */
     133  
     134  static ostream_t
     135  noop_styled_ostream__get_destination (noop_styled_ostream_t stream)
     136  {
     137    return stream->destination;
     138  }
     139  
     140  static bool
     141  noop_styled_ostream__is_owning_destination (noop_styled_ostream_t stream)
     142  {
     143    return stream->own_destination;
     144  }
     145  
     146  /* Instanceof test.  */
     147  
     148  bool
     149  is_instance_of_noop_styled_ostream (ostream_t stream)
     150  {
     151    return IS_INSTANCE (stream, ostream, noop_styled_ostream);
     152  }
     153  
     154  #line 155 "noop-styled-ostream.c"
     155  
     156  const struct noop_styled_ostream_implementation noop_styled_ostream_vtable =
     157  {
     158    noop_styled_ostream_superclasses,
     159    sizeof (noop_styled_ostream_superclasses) / sizeof (noop_styled_ostream_superclasses[0]),
     160    sizeof (struct noop_styled_ostream_representation),
     161    noop_styled_ostream__write_mem,
     162    noop_styled_ostream__flush,
     163    noop_styled_ostream__free,
     164    noop_styled_ostream__begin_use_class,
     165    noop_styled_ostream__end_use_class,
     166    noop_styled_ostream__get_hyperlink_ref,
     167    noop_styled_ostream__get_hyperlink_id,
     168    noop_styled_ostream__set_hyperlink,
     169    noop_styled_ostream__flush_to_current_style,
     170    noop_styled_ostream__get_destination,
     171    noop_styled_ostream__is_owning_destination,
     172  };
     173  
     174  #if !HAVE_INLINE
     175  
     176  /* Define the functions that invoke the methods.  */
     177  
     178  void
     179  noop_styled_ostream_write_mem (noop_styled_ostream_t first_arg, const void *data, size_t len)
     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->write_mem (first_arg,data,len);
     184  }
     185  
     186  void
     187  noop_styled_ostream_flush (noop_styled_ostream_t first_arg, ostream_flush_scope_t scope)
     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->flush (first_arg,scope);
     192  }
     193  
     194  void
     195  noop_styled_ostream_free (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    vtable->free (first_arg);
     200  }
     201  
     202  void
     203  noop_styled_ostream_begin_use_class (noop_styled_ostream_t first_arg, const char *classname)
     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    vtable->begin_use_class (first_arg,classname);
     208  }
     209  
     210  void
     211  noop_styled_ostream_end_use_class (noop_styled_ostream_t first_arg, const char *classname)
     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->end_use_class (first_arg,classname);
     216  }
     217  
     218  const char *
     219  noop_styled_ostream_get_hyperlink_ref (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    return vtable->get_hyperlink_ref (first_arg);
     224  }
     225  
     226  const char *
     227  noop_styled_ostream_get_hyperlink_id (noop_styled_ostream_t first_arg)
     228  {
     229    const struct noop_styled_ostream_implementation *vtable =
     230      ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
     231    return vtable->get_hyperlink_id (first_arg);
     232  }
     233  
     234  void
     235  noop_styled_ostream_set_hyperlink (noop_styled_ostream_t first_arg,                               const char *ref, const char *id)
     236  {
     237    const struct noop_styled_ostream_implementation *vtable =
     238      ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
     239    vtable->set_hyperlink (first_arg,ref,id);
     240  }
     241  
     242  void
     243  noop_styled_ostream_flush_to_current_style (noop_styled_ostream_t first_arg)
     244  {
     245    const struct noop_styled_ostream_implementation *vtable =
     246      ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
     247    vtable->flush_to_current_style (first_arg);
     248  }
     249  
     250  ostream_t
     251  noop_styled_ostream_get_destination (noop_styled_ostream_t first_arg)
     252  {
     253    const struct noop_styled_ostream_implementation *vtable =
     254      ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
     255    return vtable->get_destination (first_arg);
     256  }
     257  
     258  bool
     259  noop_styled_ostream_is_owning_destination (noop_styled_ostream_t first_arg)
     260  {
     261    const struct noop_styled_ostream_implementation *vtable =
     262      ((struct noop_styled_ostream_representation_header *) (struct noop_styled_ostream_representation *) first_arg)->vtable;
     263    return vtable->is_owning_destination (first_arg);
     264  }
     265  
     266  #endif