This file is indexed.

/usr/include/itpp/base/binfile.h is in libitpp-dev 4.3.1-2.

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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
/*!
 * \file
 * \brief Binary file formats definitions
 * \author Tony Ottosson, Thomas Eriksson, Adam Piatyszek and Andy Panov
 *
 * -------------------------------------------------------------------------
 *
 * Copyright (C) 1995-2013  (see AUTHORS file for a list of contributors)
 *
 * This file is part of IT++ - a C++ library of mathematical, signal
 * processing, speech processing, and communications classes and functions.
 *
 * IT++ is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * IT++ is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along
 * with IT++.  If not, see <http://www.gnu.org/licenses/>.
 *
 * -------------------------------------------------------------------------
 */

#ifndef BINFILE_H
#define BINFILE_H

#include <itpp/itexports.h>

#include <itpp/base/ittypes.h>
#include <itpp/base/binary.h>
#include <fstream>

#ifdef _MSC_VER
#pragma warning( disable : 4250 )
#endif

namespace itpp
{

/*!
  \brief Checks if a file named \c name already exists on the disk
  \ingroup itfile
*/
bool exist(const std::string& name);

/*!
  \brief Base class for binary file classes
  \ingroup itfile

  This class serves as a base class for the classes \c bofstream,
  \c bifstream, and \c bfstream. It controls the endianity (i.e. the
  byte order of multibyte numbers on the disk) of the inhereted classes.
*/
class ITPP_EXPORT bfstream_base
{
public:
  /*!
    \brief Definition of the endian data type

    The Endianness defines the order in which multibyte numbers are stored
    in the file. The two orders are called "Little Endian" (\c l_endian )
    and "Big Endian" (\c b_endian ).

    "Little Endian" means that the low-order byte of the number is stored
    at the lowest address (i.e. the little end comes first). "Big Endian"
    means that the high-order byte of the number is stored in memory at
    the lowest address (i.e. the big end comes first)
  */
  enum endian { l_endian, b_endian };

  /*!
    \brief Class Constructor

    \param e Defines the endianity of the class. Possible values are \c
    l_endian for little endian or \c b_endian for big endian. The default
    value is \c b_endian.
  */
  bfstream_base(endian e = b_endian);

  /*!
    \brief Returns the endianity of the class
  */
  endian get_endianity() const {
    if (switch_endianity) {
      if (native_endianity == l_endian)
        return b_endian;
      else
        return l_endian;
    }
    else
      return native_endianity;
  }

  /*!
    \brief Returns the native endianity for this computer architecture

    Intel processors use "Little Endian" byte ordering while e.g. Motorola
    processors use "Big Endian" byte ordering.
  */
  endian get_native_endianity() const { return native_endianity; }

  /*!
    \brief Set the endianity for this class
  */
  void set_endianity(endian e) {
    if (native_endianity == e)
      switch_endianity = false;
    else
      switch_endianity = true;
  }

  /*!
    \brief Set the endianity of this class to the native endianity for
    this computer architecture
  */
  void set_native_endianity() { switch_endianity = false; }

protected:
  //! Indicates if the endianity of the processed data needs to be changed
  bool switch_endianity;
  //! The native endianity for this computer architecture
  endian native_endianity;
};

namespace binfile_details
{
/*!
  \brief Ofstream Interface Facade for Binary Streams.
  \ingroup itfile

  This class implements std::ofstream facade to make ITPP binary file streams exportable from dll.
  This facade implements basic functionality only. It does not provide an access
  to the following stream facilities (all of them are useless for binary streams)
  1. locale(imbue) It does not make sence to change locale settings for binary streams.
  Changes in formatting or char conversion can result in compatibility problems
  with resulting binary files
  2. stream buffer (rdbuf). DLL and application can use different versions of runtime ,
  so it would be dangerous to use buffer created in DLL in application context
  3. stream insertion operators. It is assumed that stream insertion is defined in binary stream
  classes derived from this class
  4. formatting interface (copyfmt, fill, narrow, widen). This is not relevant to binary streams
  5. ios_base-related stuff. These things are excluded since they provide unnecessarily formatting
  facilities.
*/
  class ITPP_EXPORT Ofstream_Binfile_Facade
  {
    std::ofstream* _str;
    //following makes class non-copiable
    Ofstream_Binfile_Facade(const Ofstream_Binfile_Facade& o);
    void operator= (const Ofstream_Binfile_Facade& o);
  public:
    //! Default Constructor
    Ofstream_Binfile_Facade ( );
    //! Constructor from filename and stream mode
    explicit Ofstream_Binfile_Facade ( const char * filename,
      std::ios_base::openmode mode = std::ios_base::out | std::ios_base::binary);
    //! Open state
    bool is_open() {return _str->is_open();}
    //! Method to open corresponding file
    void open ( const char * filename,
      std::ios_base::openmode mode = std::ios_base::out | std::ios_base::binary )
    {_str->open(filename,mode);}
    //! Method to close corresponding file
    void close()
    {_str->close();}
    //! Output multiple characters
    Ofstream_Binfile_Facade& write (const char* c, std::streamsize n)
    {_str->write(c,n); return *this;}
    //! Output single char
    Ofstream_Binfile_Facade& put (const char c)
    {_str->put(c); return *this;};
    //! Get position
    std::streampos tellp()
    {return _str->tellp();}
    //! Set position
    Ofstream_Binfile_Facade& seekp (std::streampos pos)
    {_str->seekp(pos); return *this;}
    //! Set relative position
    Ofstream_Binfile_Facade& seekp (std::streamoff pos, std::ios_base::seekdir way)
    {_str->seekp(pos,way); return *this;}
    //! Flushes stream buffer
    Ofstream_Binfile_Facade& flush()
    {_str->flush(); return *this;}

    //! This method returns true is stream state is good
    bool good() const {return _str->good();}
    //! This method returns true if eof is reached
    bool eof() const {return _str->eof();}
    //! This method returns true if either failbit or badbit is set
    bool fail() const {return _str->fail();}
    //! This method returns true if badbit is set
    bool bad() const {return _str->bad();}

    //! Unary not operator to check the stream state
    bool operator!() const {return _str->fail();}
    //! Conversion to bool to validate stream state
    operator bool() const {return _str->good();}

    //! Method to read stream state flags
    std::ios_base::iostate rdstate() const {return _str->rdstate();}
    //! Method to set the stream state (combines already set flags with flags provide by user)
    void setstate (std::ios_base::iostate state) {_str->setstate(state);}
    //! Method to set stream state (overwrites stream state flags)
    void clear (std::ios_base::iostate state = std::ios_base::goodbit) {_str->clear(state);}
    //! Method to get the exceptions mask
    std::ios_base::iostate exceptions() const {return _str->exceptions();}
    //! Method to set the exceptions mask
    void exceptions (std::ios_base::iostate except) {_str->exceptions(except);}

    //! Destructor
    virtual ~Ofstream_Binfile_Facade();
  protected:
    //! Access to internal stream for derived classes
    std::ofstream* stream() {return _str;}
  };

/*!
  \brief Ifstream Interface Facade for Binary Streams.
  \ingroup itfile

  This class implements std::ofstream facade to make ITPP binary file streams exportable from dll.
  This facade implements basic functionality only. It does not provide an access
  to the following stream facilities (all of them are useless for binary streams)
  1. locale(imbue) It does not make sence to change locale settings for binary streams.
  Changes in formatting or char conversion can result in compatibility problems
  with resulting binary files
  2. stream buffer (rdbuf). DLL and application can use different versions of runtime ,
  so it would be dangerous to use buffer created in DLL in application context
  3. stream extraction operators. It is assumed that stream extraction is defined in binary stream
  classes derived from this class
  4. formatting interface (copyfmt, fill, narrow, widen). This is not relevant to binary streams
  5. ios_base-related stuff. These things are excluded since they provide unnecessarily formatting
  facilities.
*/
  class ITPP_EXPORT Ifstream_Binfile_Facade
  {
    std::ifstream* _str;
    //following makes class non-copiable
    Ifstream_Binfile_Facade(const Ifstream_Binfile_Facade& o);
    void operator= (const Ifstream_Binfile_Facade& o);
  public:
    //! Default Constructor
    Ifstream_Binfile_Facade ( );
    //! Constructor from filename and stream mode
    explicit Ifstream_Binfile_Facade ( const char * filename,
      std::ios_base::openmode mode = std::ios_base::in | std::ios_base::binary);
    //! Open state
    bool is_open()
    {return _str->is_open();}
    //! Method to open corresponding file
    void open ( const char * filename,
      std::ios_base::openmode mode = std::ios_base::in | std::ios_base::binary)
    {_str->open(filename,mode);}
    //! Method to close corresponding file
    void close() {_str->close();}
    //! Last extracted chars count
    std::streamsize gcount() const {return _str->gcount();}
    //! Get single char
    int get() {return _str->get();}
    //! Get single char
    Ifstream_Binfile_Facade& get(char& c) {_str->get(c); return *this;}
    //! Get multiple chars to c-string and add trailing 0
    Ifstream_Binfile_Facade& get (char* s, std::streamsize n)
    {_str->get(s,n); return *this;}
    //! Get multiple chars to c-string without trailing 0
    Ifstream_Binfile_Facade& get (char* s, std::streamsize n, char delim)
    {_str->get(s,n,delim); return *this;}
    //! Get multiple chars to c-string without trailing 0
    Ifstream_Binfile_Facade& getline (char* s, std::streamsize n )
    {_str->getline(s,n); return *this;}
    Ifstream_Binfile_Facade& getline (char* s, std::streamsize n, char delim )
    {_str->getline(s,n,delim); return *this;}
    //! Extract and ignore chars
    Ifstream_Binfile_Facade& ignore (std::streamsize n = 1, int delim = EOF)
    {_str->ignore(n,delim); return *this;}
    //! Peak single char from the top of the buffer
    int peek() {return _str->peek();}
    //! Read n chars from stream
    Ifstream_Binfile_Facade& read (char* s, std::streamsize n)
    {_str->read(s,n); return *this;}
    //! Read up to n available chars from stream
    std::streamsize readsome (char* s, std::streamsize n)
    {return _str->readsome(s,n);}
    //! This method attempts to put back single char
    Ifstream_Binfile_Facade& putback (char c)
    {_str->putback(c); return *this;}
    //! Unget last extracted char
    Ifstream_Binfile_Facade& unget()  {_str->unget(); return *this;}
    //! Get position
    std::streampos tellg() {return _str->tellg();}
    //! Set position
    Ifstream_Binfile_Facade& seekg (std::streampos pos)
    {_str->seekg(pos); return *this;}
    //! Set relative position
    Ifstream_Binfile_Facade& seekg (std::streamoff pos, std::ios_base::seekdir way)
    {_str->seekg(pos,way); return *this;}

    //! This method returns true is stream state is good
    bool good() const {return _str->good();}
    //! This method returns true if eof is reached
    bool eof() const {return _str->eof();}
    //! This method returns true if either failbit or badbit is set
    bool fail() const {return _str->fail();}
    //! This method returns true if badbit is set
    bool bad() const {return _str->bad();}

    //! Unary not operator to check the stream state
    bool operator!() const {return _str->fail();}
    //! Conversion to bool to validate stream state
    operator bool() const {return _str->good();}

    //! Method to read stream state flags
    std::ios_base::iostate rdstate() const {return _str->rdstate();}
    //! Method to set the stream state (combines already set flags with flags provide by user)
    void setstate (std::ios_base::iostate state) {_str->setstate(state);}
    //! Method to set stream state (overwrites stream state flags)
    void clear (std::ios_base::iostate state = std::ios_base::goodbit) {_str->clear(state);}
    //! Method to get the exceptions mask
    std::ios_base::iostate exceptions() const {return _str->exceptions();}
    //! Method to set the exceptions mask
    void exceptions (std::ios_base::iostate except) {_str->exceptions(except);}

    //! Destructor
    virtual ~Ifstream_Binfile_Facade();
  protected:
    //! Access to internal stream for derived classes
    std::ifstream* stream() {return _str;}
  };

/*!
  \brief Fstream Interface Facade for Binary Streams.
  \ingroup itfile

  This class implements std::fstream facade to make ITPP binary file streams exportable from dll.
  This facade implements basic functionality only. It does not provide an access
  to the following stream facilities (all of them are useless for binary streams)
  1. locale(imbue) It does not make sence to change locale settings for binary streams.
  Changes in formatting or char conversion can result in compatibility problems
  with resulting binary files
  2. stream buffer (rdbuf). DLL and application can use different versions of runtime ,
  so it would be dangerous to use buffer created in DLL in application context
  3. stream extraction operators. It is assumed that stream extraction is defined in binary stream
  classes derived from this class
  4. stream insertion operators. It is assumed that stream insertion is defined in binary stream
  classes derived from this class
  5. formatting interface (copyfmt, fill, narrow, widen). This is not relevant to binary streams
  6. ios_base-related stuff. These things are excluded since they provide unnecessarily formatting facilities.
*/
  class ITPP_EXPORT Fstream_Binfile_Facade
  {
    std::fstream* _str;
    //following makes class non-copiable
    Fstream_Binfile_Facade(const Fstream_Binfile_Facade& o);
    void operator= (const Fstream_Binfile_Facade& o);
  public:
    //! Default Constructor
    Fstream_Binfile_Facade ( );
    //! Constructor from filename and stream mode
    explicit Fstream_Binfile_Facade ( const char * filename,
      std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out | std::ios_base::binary);
    //! Open state
    bool is_open() {return _str->is_open();}
    //! Method to open corresponding file
    void open ( const char * filename,
      std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out | std::ios_base::binary)
    {_str->open(filename,mode);}
    //! Method to close corresponding file
    void close() {_str->close();}

    //! Output multiple characters
    Fstream_Binfile_Facade& write (const char* c, std::streamsize n)
    {_str->write(c,n); return *this;};
    //! Output single char
    Fstream_Binfile_Facade& put (const char c)
    {_str->put(c); return *this;};
    //! Get position
    std::streampos tellp() {return _str->tellp();}
    //! Set position
    Fstream_Binfile_Facade& seekp (std::streampos pos)
    {_str->seekp(pos); return *this;}
    //! Set relative position
    Fstream_Binfile_Facade& seekp (std::streamoff pos, std::ios_base::seekdir way)
    {_str->seekp(pos,way); return *this;}
    //! Flushes stream buffer
    Fstream_Binfile_Facade& flush() {_str->flush(); return *this;}
    //! Last extracted chars count
    std::streamsize gcount() const {return _str->gcount();}
    //! Get single char
    int get() {return _str->get();}
    //! Get single char
    Fstream_Binfile_Facade& get(char& c){_str->get(c); return *this;}
    //! Get multiple chars to c-string and add trailing 0
    Fstream_Binfile_Facade& get(char* s, std::streamsize n)
    {_str->get(s,n); return *this;}
    //! Get multiple chars to c-string without trailing 0
    Fstream_Binfile_Facade& get(char* s, std::streamsize n, char delim)
    {_str->get(s,n,delim); return *this;}
    //! Get multiple chars to c-string without trailing 0
    Fstream_Binfile_Facade& getline(char* s, std::streamsize n)
    {_str->getline(s,n); return *this;}
    Fstream_Binfile_Facade& getline(char* s, std::streamsize n, char delim)
    {_str->getline(s,n,delim); return *this;}
    //! Extract and ignore chars
    Fstream_Binfile_Facade& ignore (std::streamsize n = 1, int delim = EOF)
    {_str->ignore(n,delim); return *this;}
    //! Peak single char from the top of the buffer
    int peek() {return _str->peek();}
    //! Read n chars from stream
    Fstream_Binfile_Facade& read (char* s, std::streamsize n)
    {_str->read(s,n); return *this;}
    //! Read up to n available chars from stream
    std::streamsize readsome (char* s, std::streamsize n)
    {return _str->readsome(s,n);}
    //! This method attempts to put back single char
    Fstream_Binfile_Facade& putback (char c)
    {_str->putback(c); return *this;}
    //! Unget last extracted char
    Fstream_Binfile_Facade& unget()
    {_str->unget(); return *this;}
    //! Get position
    std::streampos tellg() {return _str->tellg();}
    //! Set position
    Fstream_Binfile_Facade& seekg (std::streampos pos)
    {_str->seekg(pos); return *this;}
    //! Set relative position
    Fstream_Binfile_Facade& seekg (std::streamoff pos, std::ios_base::seekdir way)
    {_str->seekg(pos,way); return *this;}

    //! This method returns true is stream state is good
    bool good() const {return _str->good();}
    //! This method returns true if eof is reached
    bool eof() const {return _str->eof();}
    //! This method returns true if either failbit or badbit is set
    bool fail() const {return _str->fail();}
    //! This method returns true if badbit is set
    bool bad() const {return _str->bad();}

    //! Unary not operator to check the stream state
    bool operator!() const {return _str->fail();}
    //! Conversion to bool to validate stream state
    operator bool() const {return _str->good();}

    //! Method to read stream state flags
    std::ios_base::iostate rdstate() const {return _str->rdstate();}
    //! Method to set the stream state (combines already set flags with flags provide by user)
    void setstate (std::ios_base::iostate state) {_str->setstate(state);}
    //! Method to set stream state (overwrites stream state flags)
    void clear (std::ios_base::iostate state = std::ios_base::goodbit)
    {_str->clear(state);}
    //! Method to get the exceptions mask
    std::ios_base::iostate exceptions() const {return _str->exceptions();}
    //! Method to set the exceptions mask
    void exceptions (std::ios_base::iostate except) {_str->exceptions(except);}

    //! Destructor
    virtual ~Fstream_Binfile_Facade();
  protected:
    //! Access to internal stream for derived classes
    std::fstream* stream() {return _str;}
  };


}

/*!
  \brief Binary Outfile Class
  \ingroup itfile
*/
class ITPP_EXPORT bofstream : public bfstream_base, public binfile_details::Ofstream_Binfile_Facade
{
public:
  /*!
    \brief Class constructor that opens a file and sets the endianity

    \param name The name of the file to open
    \param e Defines the endianity of the class. Possible values are
    \c l_endian for "Little Endian" or \c b_endian for "Big Endian". The
    default value is \c b_endian.
    Set \c truncate to true to discard file contents.
  */
  bofstream(const std::string& name, endian e = b_endian);

  //! Class Constructor
  bofstream();

  //! Class Destructor
  ~bofstream() { }

  /*!
    \brief Open a file for writing and set the endianity

    \param name The name of the file to open
    \param e Defines the endianity of the class (default value is
    \c b_endian )
    Set \c trunc to true to discard file contents.
  */
  void open(const std::string& name, bool trunc = false, endian e = b_endian);

  //! Writes a signed char variable to the binary output file
  bofstream& operator<<(char a);
  //! Writes a 8-bit signed integer variable to the binary file
  bofstream& operator<<(int8_t a);
  //! Writes a 8-bit unsigned integer variable to the binary file
  bofstream& operator<<(uint8_t a);
  //! Writes a 16-bit signed integer variable to the binary output file
  bofstream& operator<<(int16_t a);
  //! Writes a 16-bit unsigned integer variable to the binary output file
  bofstream& operator<<(uint16_t a);
  //! Writes a 32-bit signed integer variable to the binary output file
  bofstream& operator<<(int32_t a);
  //! Writes a 32-bit unsigned integer variable to the binary output file
  bofstream& operator<<(uint32_t a);
  //! Writes a 64-bit signed integer variable to the binary output file
  bofstream& operator<<(int64_t a);
  //! Writes a 64-bit unsigned ingeger variable to the binary output file
  bofstream& operator<<(uint64_t a);
  //! Writes a float variable to the binary output file
  bofstream& operator<<(float a);
  //! Writes a double variable to the binary output file
  bofstream& operator<<(double a);
  //! Writes a binary variable to the binary output file
  bofstream& operator<<(bin a);
  //! Writes a char* string to the binary output file
  bofstream& operator<<(const char* a);
  //! Writes a string variable to the binary output file
  bofstream& operator<<(const std::string& a);
};

/*!
  \brief Binary Infile Class
  \ingroup itfile
*/
class ITPP_EXPORT bifstream : public bfstream_base, public binfile_details::Ifstream_Binfile_Facade
{
public:
  /*!
    \brief Class constructor that opens a file and sets the endianity

    \param name The name of the file to open
    \param e Defines the endianity of the class. Possible values are
    \c l_endian for "Little Endian" or \c b_endian for "Big Endian". The
    default value is \c b_endian.
  */
  bifstream(const std::string& name, endian e = b_endian);

  //! Class Constructor
  bifstream();

  //! Class Destructor
  ~bifstream() { }

  /*!
    \brief Open a file for reading and set the endianity

    \param name The name of the file to open
    \param e Defines the endianity of the class (default value is
    \c b_endian )
  */
  void open(const std::string& name, endian e = b_endian);

  //! Returns the length in bytes of the file
  int length();

  //! Reads a signed char variable from the binary input file
  bifstream& operator>>(char& a);
  //! Reads a 8-bit signed integer variable from the binary input file
  bifstream& operator>>(int8_t& a);
  //! Reads a 8-bit unsigned integer variable from the binary input file
  bifstream& operator>>(uint8_t& a);
  //! Reads a 16-bit signed integer variable from the binary input file
  bifstream& operator>>(int16_t& a);
  //! Reads a 16-bit unsigned integer variable from the binary input file
  bifstream& operator>>(uint16_t& a);
  //! Reads a 32-bit signed integer variable from the binary input file
  bifstream& operator>>(int32_t& a);
  //! Reads a 32-bit unsigned integer variable from the binary input file
  bifstream& operator>>(uint32_t& a);
  //! Reads a 64-bit signed integer variable from the binary input file
  bifstream& operator>>(int64_t& a);
  //! Reads a 64-bit unsigned ingeger variable from the binary input file
  bifstream& operator>>(uint64_t& a);
  //! Reads a float variable from the binary input file
  bifstream& operator>>(float& a);
  //! Reads a double variable from the binary input file
  bifstream& operator>>(double& a);
  //! Reads a binary variable from the binary input file
  bifstream& operator>>(bin& a);
  //! Reads a char* string from the binary input file
  bifstream& operator>>(char* a);
  //! Reads a string variable from the binary input file
  bifstream& operator>>(std::string& a);
};

/*!
  \brief Binary in/out-file Class
  \ingroup itfile
*/
class ITPP_EXPORT bfstream : public bfstream_base, public binfile_details::Fstream_Binfile_Facade
{
public:
  /*!
    \brief Class constructor that opens a file and sets the endianity

    \param name The name of the file to open
    \param e Defines the endianity of the class. Possible values are
    \c l_endian for "Little Endian" or \c b_endian for "Big Endian".
    The default value is \c b_endian.
  */
  bfstream(const std::string& name, endian e = b_endian);

  //! Class Constructor
  bfstream();

  //! Class Destructor
  ~bfstream() { }

  /*!
    \brief Open a file for reading and writing and set the endianity

    \param name The name of the file to open
    \param trunc Rewrite the file if it exists (default value is \c false)
    \param e Defines the endianity of the class (default value is
    \c b_endian )
  */
  void open(const std::string& name, bool trunc = false, endian e = b_endian);

  /*!
    \brief Open a file for reading only and set the endianity

    \param name The name of the file to open
    \param e Defines the endianity of the class (default value is
    \c b_endian )
  */
  void open_readonly(const std::string& name, endian e = b_endian);

  //! Returns the length in bytes of the file
  int length();

  //! Writes an char variable to the binary file
  bfstream& operator<<(char a);
  //! Writes a 8-bit signed integer variable to the binary file
  bfstream& operator<<(int8_t a);
  //! Writes a 8-bit unsigned integer variable to the binary file
  bfstream& operator<<(uint8_t a);
  //! Writes a 16-bit signed integer variable to the binary file
  bfstream& operator<<(int16_t a);
  //! Writes a 16-bit unsigned integer variable to the binary file
  bfstream& operator<<(uint16_t a);
  //! Writes a 32-bit signed integer variable to the binary file
  bfstream& operator<<(int32_t a);
  //! Writes a 32-bit unsigned integer variable to the binary file
  bfstream& operator<<(uint32_t a);
  //! Writes a 64-bit signed integer variable to the binary file
  bfstream& operator<<(int64_t a);
  //! Writes a 64-bit unsigned ingeger variable to the binary file
  bfstream& operator<<(uint64_t a);
  //! Writes a float variable to the binary file
  bfstream& operator<<(float a);
  //! Writes a double variable to the binary file
  bfstream& operator<<(double a);
  //! Writes a binary variable to the binary file
  bfstream& operator<<(bin a);
  //! Writes a char* string to the binary file
  bfstream& operator<<(const char* a);
  //! Writes a string variable to the binary file
  bfstream& operator<<(const std::string& a);

  //! Reads a char variable from the binary file
  bfstream& operator>>(char& a);
  //! Reads a 8-bit signed integer variable from the binary file
  bfstream& operator>>(int8_t& a);
  //! Reads a 8-bit unsigned integer variable from the binary file
  bfstream& operator>>(uint8_t & a);
  //! Reads a 16-bit signed integer variable from the binary file
  bfstream& operator>>(int16_t& a);
  //! Reads a 16-bit unsigned integer variable from the binary file
  bfstream& operator>>(uint16_t& a);
  //! Reads a 32-bit signed integer variable from the binary file
  bfstream& operator>>(int32_t& a);
  //! Reads a 32-bit unsigned integer variable from the binary file
  bfstream& operator>>(uint32_t& a);
  //! Reads a 64-bit signed integer variable from the binary file
  bfstream& operator>>(int64_t& a);
  //! Reads a 64-bit unsigned ingeger variable from the binary file
  bfstream& operator>>(uint64_t& a);
  //! Reads a float variable from the binary file
  bfstream& operator>>(float& a);
  //! Reads a double variable from the binary file
  bfstream& operator>>(double& a);
  //! Reads a binary variable from the binary file
  bfstream& operator>>(bin& a);
  //! Reads a char* string from the binary file
  bfstream& operator>>(char* a);
  //! Reads a string variable from the binary file
  bfstream& operator>>(std::string& a);
};

} //namespace itpp


#endif // #ifndef BINFILE_H