(root)/
gettext-0.22.4/
libtextstyle/
lib/
memory-ostream.h
       1  /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
       2  
       3  #line 1 "memory-ostream.oo.h"
       4  /* Output stream that accumulates the output in memory.
       5     Copyright (C) 2006, 2019-2020 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 <https://www.gnu.org/licenses/>.  */
      20  
      21  #ifndef _MEMORY_OSTREAM_H
      22  #define _MEMORY_OSTREAM_H
      23  
      24  #include <stdbool.h>
      25  #include <stddef.h>
      26  
      27  #include "ostream.h"
      28  
      29  #line 30 "memory-ostream.h"
      30  struct memory_ostream_representation;
      31  /* memory_ostream_t is defined as a pointer to struct memory_ostream_representation.
      32     In C++ mode, we use a smart pointer class.
      33     In C mode, we have no other choice than a typedef to the root class type.  */
      34  #if IS_CPLUSPLUS
      35  struct memory_ostream_t
      36  {
      37  private:
      38    struct memory_ostream_representation *_pointer;
      39  public:
      40    memory_ostream_t () : _pointer (NULL) {}
      41    memory_ostream_t (struct memory_ostream_representation *pointer) : _pointer (pointer) {}
      42    struct memory_ostream_representation * operator -> () { return _pointer; }
      43    operator struct memory_ostream_representation * () { return _pointer; }
      44    operator struct any_ostream_representation * () { return (struct any_ostream_representation *) _pointer; }
      45    operator void * () { return _pointer; }
      46    bool operator == (const void *p) { return _pointer == p; }
      47    bool operator != (const void *p) { return _pointer != p; }
      48    operator ostream_t () { return (ostream_t) (struct any_ostream_representation *) _pointer; }
      49    explicit memory_ostream_t (ostream_t x) : _pointer ((struct memory_ostream_representation *) (void *) x) {}
      50  };
      51  #else
      52  typedef ostream_t memory_ostream_t;
      53  #endif
      54  
      55  /* Functions that invoke the methods.  */
      56  #ifdef __cplusplus
      57  extern "C" {
      58  #endif
      59  extern        void memory_ostream_write_mem (memory_ostream_t first_arg, const void *data, size_t len);
      60  extern         void memory_ostream_flush (memory_ostream_t first_arg, ostream_flush_scope_t scope);
      61  extern         void memory_ostream_free (memory_ostream_t first_arg);
      62  extern          void memory_ostream_contents (memory_ostream_t first_arg, const void **bufp, size_t *buflenp);
      63  #ifdef __cplusplus
      64  }
      65  #endif
      66  
      67  /* Type representing an implementation of memory_ostream_t.  */
      68  struct memory_ostream_implementation
      69  {
      70    const typeinfo_t * const *superclasses;
      71    size_t superclasses_length;
      72    size_t instance_size;
      73  #define THIS_ARG memory_ostream_t first_arg
      74  #include "memory_ostream.vt.h"
      75  #undef THIS_ARG
      76  };
      77  
      78  /* Public portion of the object pointed to by a memory_ostream_t.  */
      79  struct memory_ostream_representation_header
      80  {
      81    const struct memory_ostream_implementation *vtable;
      82  };
      83  
      84  #if HAVE_INLINE
      85  
      86  /* Define the functions that invoke the methods as inline accesses to
      87     the memory_ostream_implementation.
      88     Use #define to avoid a warning because of extern vs. static.  */
      89  
      90  # define memory_ostream_write_mem memory_ostream_write_mem_inline
      91  static inline void
      92  memory_ostream_write_mem (memory_ostream_t first_arg, const void *data, size_t len)
      93  {
      94    const struct memory_ostream_implementation *vtable =
      95      ((struct memory_ostream_representation_header *) (struct memory_ostream_representation *) first_arg)->vtable;
      96    vtable->write_mem (first_arg,data,len);
      97  }
      98  
      99  # define memory_ostream_flush memory_ostream_flush_inline
     100  static inline void
     101  memory_ostream_flush (memory_ostream_t first_arg, ostream_flush_scope_t scope)
     102  {
     103    const struct memory_ostream_implementation *vtable =
     104      ((struct memory_ostream_representation_header *) (struct memory_ostream_representation *) first_arg)->vtable;
     105    vtable->flush (first_arg,scope);
     106  }
     107  
     108  # define memory_ostream_free memory_ostream_free_inline
     109  static inline void
     110  memory_ostream_free (memory_ostream_t first_arg)
     111  {
     112    const struct memory_ostream_implementation *vtable =
     113      ((struct memory_ostream_representation_header *) (struct memory_ostream_representation *) first_arg)->vtable;
     114    vtable->free (first_arg);
     115  }
     116  
     117  # define memory_ostream_contents memory_ostream_contents_inline
     118  static inline void
     119  memory_ostream_contents (memory_ostream_t first_arg, const void **bufp, size_t *buflenp)
     120  {
     121    const struct memory_ostream_implementation *vtable =
     122      ((struct memory_ostream_representation_header *) (struct memory_ostream_representation *) first_arg)->vtable;
     123    vtable->contents (first_arg,bufp,buflenp);
     124  }
     125  
     126  #endif
     127  
     128  extern const typeinfo_t memory_ostream_typeinfo;
     129  #define memory_ostream_SUPERCLASSES &memory_ostream_typeinfo, ostream_SUPERCLASSES
     130  #define memory_ostream_SUPERCLASSES_LENGTH (1 + ostream_SUPERCLASSES_LENGTH)
     131  
     132  extern const struct memory_ostream_implementation memory_ostream_vtable;
     133  
     134  #line 35 "memory-ostream.oo.h"
     135  
     136  #ifdef __cplusplus
     137  extern "C" {
     138  #endif
     139  
     140  
     141  /* Create an output stream that accumulates the output in a memory buffer.  */
     142  extern memory_ostream_t memory_ostream_create (void);
     143  
     144  
     145  /* Test whether a given output stream is a memory_ostream.  */
     146  extern bool is_instance_of_memory_ostream (ostream_t stream);
     147  
     148  
     149  #ifdef __cplusplus
     150  }
     151  #endif
     152  
     153  #endif /* _MEMORY_OSTREAM_H */