This file is indexed.

/usr/include/hfst/HfstOutputStream.h is in libhfst45-dev 3.10.0~r2798-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// Copyright (c) 2016 University of Helsinki                          
//                                                                    
// This library is free software; you can redistribute it and/or      
// modify it under the terms of the GNU Lesser General Public         
// License as published by the Free Software Foundation; either       
// version 3 of the License, or (at your option) any later version.
// See the file COPYING included with this distribution for more      
// information.

#ifndef _HFST_OUTPUTSTREAM_H_
#define _HFST_OUTPUTSTREAM_H_

#if HAVE_CONFIG_H
#  include <config.h>
#endif

#include "HfstDataTypes.h"

#include "hfstdll.h"

/** @file HfstOutputStream.h
    \brief Declaration of class HfstOutputStream. */

namespace hfst
{

  namespace implementations {
#if HAVE_OPENFST
#if HAVE_OPENFST_LOG
    class LogWeightOutputStream;
#endif
    class TropicalWeightOutputStream;
#endif
#if HAVE_SFST
    class SfstOutputStream;
#endif
#if HAVE_FOMA
    class FomaOutputStream;
#endif    
#if HAVE_XFSM
    class XfsmOutputStream;
#endif    
#if HAVE_MY_TRANSDUCER_LIBRARY
    class MyTransducerLibraryOutputStream;
#endif
    class HfstOlOutputStream;
  }


  /** \brief A stream for writing binary transducers. 

      An example:
\verbatim
#include "HfstOutputStream.h"

      ...

      // Write three HFST transducers in binary format to file named "testfile"
      HfstOutputStream out("testfile", FOMA_TYPE);
      out << foma_transducer1 
          << foma_transducer2 
          << foma_transducer3;
      out.close();
\endverbatim

For more information on HFST transducer structure, see 
<a href="HeaderFormatAndConversions.html">this page</a>.

  **/
  class HfstOutputStream
  {
  protected:
    union StreamImplementation
    {
#if HAVE_OPENFST
#if HAVE_OPENFST_LOG
      hfst::implementations::LogWeightOutputStream * log_ofst;
#endif
      hfst::implementations::TropicalWeightOutputStream * tropical_ofst;
#endif
#if HAVE_SFST
      hfst::implementations::SfstOutputStream * sfst;
#endif
#if HAVE_FOMA
      hfst::implementations::FomaOutputStream * foma;
#endif
#if HAVE_XFSM
      hfst::implementations::XfsmOutputStream * xfsm;
#endif

#if HAVE_MY_TRANSDUCER_LIBRARY
      hfst::implementations::MyTransducerLibraryOutputStream * 
        my_transducer_library;
#endif

      hfst::implementations::HfstOlOutputStream * hfst_ol;
    };
    ImplementationType type; // type of the stream implementation
    // whether an hfst header is written before every transducer
    bool hfst_format;  
    StreamImplementation implementation; // backend implementation

    // write data to stream
    void write(const std::string &s);
    void write(const std::vector<char> &s);
    void write(const char &c);

    // if file is open
    bool is_open;

    // append string s to vector str and a '\0'
    static void append(std::vector<char> &str, const std::string &s);

    // append obligatory HFST header data to \a header
    void append_hfst_header_data(std::vector<char> &header);
    /* append implementation-specific header data collected from 
       \a transducer to \a header */
    void append_implementation_specific_header_data
      (std::vector<char> &header, HfstTransducer &transducer);


  public:

    /** \brief Create a stream to standard output for writing 
        binary transducers of type \a type. 
        \a hfst_format defines whether transducers are written 
        in hfst format or as such in their backend format. 
    */
    HFSTDLL HfstOutputStream(ImplementationType type, bool hfst_format=true);

    /** \brief Open a stream to file \a filename for writing binary transducers
        of type \a type. 
        \a hfst_format defines whether transducers are written in hfst format 
        or as such in their backend format.

        If the file exists, it is overwritten. 
    */
    HFSTDLL HfstOutputStream(const std::string &filename, ImplementationType type, bool hfst_format=true);

    /** \brief Destructor. */
    HFSTDLL ~HfstOutputStream(void);  

    /** \brief Flush the stream.

     If the stream is of XFSM_TYPE, all transducers inserted with the operator<<
     are actually written to the stream. Else, does nothing. */
    HFSTDLL HfstOutputStream &flush();

    /** \brief Write the transducer \a transducer in binary format 
        to the stream. 

        All transducers must have the same type as the stream, else a
        TransducerTypeMismatchException is thrown. 

        If the stream is of XFSM_TYPE, \a transducer is stored to a list
        and written when flush() is called for the stream.

        @throws TransducerTypeMismatchException
    */
    HFSTDLL HfstOutputStream &operator<< (HfstTransducer &transducer);

    /** @brief An alias for operator<<. 

     @see operator<< */
    HFSTDLL HfstOutputStream& redirect (HfstTransducer &transducer);

    /** \brief Close the stream. 

        If the stream points to standard output, nothing is done. */
    HFSTDLL void close(void);
  };




}



#endif