This file is indexed.

/usr/include/tse3/file/XML.h is in libtse3-dev 0.3.1-4.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
/*
 * @(#)file/XML.h 3.00 10 Aug 2001
 *
 * Copyright (c) 2001 Pete Goodliffe (pete@cthree.org)
 *
 * This file is part of TSE3 - the Trax Sequencer Engine version 3.00.
 *
 * This library is modifiable/redistributable under the terms of the GNU
 * General Public License.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; see the file COPYING. If not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 */

#ifndef TSE3_FILE_XML_H
#define TSE3_FILE_XML_H

#include <iosfwd>
#include <iomanip>
#include <cstddef>
#include <string>
#include <map>
#include <sstream>

#include "tse3/Midi.h"

namespace TSE3
{
    class Song;
    class Progress;

    namespace File
    {

        /**
         * Data structure used by the @ref Serializable class during loading.
         * It contains information that has been gained about the file, mostly
         * from the "Header" chunk. Most @ref Serializable classes will not need
         * to write to this struct, but will almost certainly need to read it
         * (at least to convert local file PPQN resolution to TSE3 system PPQN).
         */
        struct XmlLoadInfo
        {
            /**
             * The PPQN resolution of timestamps in this file. You can use
             * this to convert timestamps to the correct values in use in the
             * TSE3 library. See @ref Clock's convert() method.
             * This information is read from the file's "Header" chunk.
             */
            int PPQN;

            /**
             * The current Song. This is set once by the @ref TSE3MDL class.
             * You may not write over this value afterwards or you will
             * create undefined behaviour.
             */
            Song *song;

            /**
             * The files's najor version number, read from it's "Header" chunk.
             * This should be informational since the TSE3MDL file format is
             * forwards and backwards compatible.
             *
             * The (invalid) value -1 means that no major version has been read.
             */
            int major;

            /**
             * The file's minor version number, read from it's "Header" chunk.
             * This should be informational since the TSE3MDL file format is
             * forwards and backwards compatible.
             *
             * The (invalid) value -1 means that no minor version has been read.
             */
            int minor;

            /**
             * A boolean flag which reports whether the loading encountered
             * any unknown chunks (which will have been skipped over).
             *
             * If you are not using the @ref FileBlockParser class to perform
             * parsing, you must set this flag to true if you come across any
             * unrecognised chunks. The @ref FileBlockParser class does this
             * automatically.
             */
            bool unknownChunks;

            /**
             * A boolean flag which reports whether the loading encountered
             * any unknown data lines (which will have been ignored).
             *
             * If you are not using the @ref FileBlockParser class to perform
             * parsing, you must set this flag to true if you come across any
             * unrecognised data lines. The @ref FileBlockParser class does this
             * automatically.
             */
            bool unknownData;

            /**
             * A counter which reports how many chunks (and sub-chunks) were
             * in the file.
             *
             * If you are not using the @ref FileBlockParser class to perform
             * parsing, you must increment this counter if you come across a new
             * chunk. The @ref FileBlockParser class does this automatically.
             */
            size_t noChunks;

            /**
             * If the operation that triggered this serializable operation
             * provided a @ref Progress callback object, this points to it.
             *
             * This information is used by the @ref FileBlockParser utility.
             * You do not need to handle this in client code.
             */
            Progress *progress;

            /**
             * Sets up some default values for the struct values.
             *
             * These are:
             * @li PPQN          - @ref Clock::PPQN
             * @li song          - 0
             * @li major         - -1
             * @li minor         - -1
             * @li unknownChunks - false
             * @li unknownData   - false
             * @li progress      - 0
             */
            XmlLoadInfo();
        };


        /**********************************************************************
         * Writing XML files
         *********************************************************************/

        /**
         * A utility class to make writing XML files easier.
         */
        class XmlFileWriter
        {
            public:

                XmlFileWriter(std::ostream &out);
                ~XmlFileWriter();

                void openElement(const std::string &name);
                void closeElement();

                void element(const std::string &name, const std::string &value);
                void element(const std::string &name, const char        *value);
                void element(const std::string &name, int                value);
                void element(const std::string &name, unsigned int       value);
		void element(const std::string &name, unsigned long      value);
                void element(const std::string &name, bool               value);

                void comment(const std::string &comment);

                class AutoElement
                {
                    public:
                        AutoElement(TSE3::File::XmlFileWriter &writer,
                                    const std::string &name)
                        : _writer(writer)
                        {
                            _writer.openElement(name);
                        }
                        ~AutoElement()
                        {
                            _writer.closeElement();
                        }
                    private:
                        TSE3::File::XmlFileWriter &_writer;
                };

            private:

                void indent(std::ostream &out);

                std::ostream &out;
                int           indentLevel;

                class XmlFileWriterImpl *pimpl;
        };

        /**
         * A utility class to make reading TSE3MDL files easier.
         */
        class XmlFileReader
        {
            public:

                XmlFileReader(std::istream &in);
                ~XmlFileReader();

                TSE3::Song *load();
            private:
                std::istream &in;
        };


        /**********************************************************************
         * Reading XML files
         *********************************************************************/

        class XmlElementParser;

        class XmlBlockParser
        {
            public:
                typedef void (block_handler_t)();

                XmlBlockParser();

                void add(const std::string &tag, XmlBlockParser &handler);
                void add(const std::string &tag, XmlElementParser &handler);
                void add(XmlElementParser &handler);

                void parse(std::istream &in, const std::string &tag,
                           XmlLoadInfo &info);

            private:

                void skipBlock(std::istream &in);

                std::map<std::string, XmlElementParser*>  elements;
                std::map<std::string, XmlBlockParser*>    blocks;
                XmlElementParser                         *catchAll;
        };


        class XmlElementParser
        {
            public:

                XmlElementParser() {}
                virtual ~XmlElementParser() = 0;

                /**
                 * This method is called by the @ref XmlBlockParser when it
                 * finds a data line that is handled by this XmlElementParser.
                 *
                 * @param data The data from the "value" attribute to be
                 *             handled.
                 */
                virtual void parse(const std::string &data) = 0;

            private:

                XmlElementParser &operator=(const XmlElementParser &);
                XmlElementParser(const XmlElementParser &);
        };

        /**
         * A TSE3 utility class.
         *
         * A utility class implementing a specific type of @ref XmlElementParser.
         * This class will call a member function with signature
         * void setXXX(reason r, bool) with the boolean value of the data string.
         *
         * @short   Internal utility for parsing boolean values with reason codes
         * @short   Internal utility for parsing numeric data lines
         * @author  Pete Goodliffe
         * @version 1.00
         */
        template<class T, class reason>
        class XmlElementParser_ReasonOnOff : public XmlElementParser
        {
            public:
                typedef void (T::*fn_t)(reason, bool);
                XmlElementParser_ReasonOnOff(T *obj, fn_t mfun, reason r)
                : obj(obj), r(r) , mfun(mfun){}
                /**
                 * @reimplemented
                 */
                void parse(const std::string &data)
                {
                    (obj->*mfun)(r, (data == "On" || data == "Yes"));
                }
            private:
                T      *obj;
                reason  r;
                fn_t    mfun;
        };

        /**
         * A TSE3 utility class.
         *
         * A utility class implementing a specific type of @ref XmlElementParser.
         * This class will call a member function with signature void setXXX(int)
         * with the numeric value of the data string in a similar manner to
         * XmlElementParser_OnOff.
         *
         * @short   Internal utility for parsing numeric data lines
         * @author  Pete Goodliffe
         * @version 1.00
         */
        template <class T>
        class XmlElementParser_Number : public XmlElementParser
        {
            public:
                typedef void (T::*fn_t)(int);
                XmlElementParser_Number(T *obj, fn_t mfun)
                : obj(obj), mfun(mfun) {}
                /**
                 * @reimplemented
                 */
                void parse(const std::string &data)
                {
                    int i;
                    std::istringstream si(data);
                    si >> i;
                    (obj->*mfun)(i);
                }
            private:
                T    *obj;
                fn_t  mfun;
        };

        /**
         * A TSE3 utility class.
         *
         * A utility class implementing a specific type of @ref XmlElementParser.
         * This class will call a member function with signature
         * void setXXX(Clock) with the numeric value of the data string in
         * a similar manner to XmlElementParser_OnOff.
         *
         * This XmlElementParser looks partically identical to the _Number version.
         *
         * @short   Internal utility for parsing @ref Clock data lines
         * @author  Pete Goodliffe
         * @version 1.00
         */
        template <class T>
        class XmlElementParser_Clock : public XmlElementParser
        {
            public:
                typedef void (T::*fn_t)(Clock);
                XmlElementParser_Clock(T *obj, fn_t mfun)
                : obj(obj), mfun(mfun) {}
                /**
                 * @reimplemented
                 */
                void parse(const std::string &data)
                {
                    int i;
                    std::istringstream si(data);
                    si >> i;
                    (obj->*mfun)(i);
                }
            private:
                T    *obj;
                fn_t  mfun;
        };

        /**
         * A TSE3 utility class.
         *
         * A utility class implementing a specific type of @ref XmlElementParser.
         * This class will call a member function with signature
         * void setXXX(const string &) with the string in the data string.
         *
         * @short   Internal utility for parsing string data lines
         * @author  Pete Goodliffe
         * @version 1.00
         */
        template <class T>
        class XmlElementParser_String : public XmlElementParser
        {
            public:
                typedef void (T::*fn_t)(const std::string &);
                XmlElementParser_String(T *obj, fn_t mfun)
                : obj(obj), mfun(mfun) {}
                /**
                 * @reimplemented
                 */
                void parse(const std::string &data)
                {
                    (obj->*mfun)(data);
                }
            private:
                T    *obj;
                fn_t  mfun;
        };
    }
}

#endif