cartobase  5.0.5
cuifstream.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 #ifndef CARTOBASE_STREAM_CUIFSTREAM_H
35 #define CARTOBASE_STREAM_CUIFSTREAM_H
36 
37 
38 //=============================================================================
39 // H E A D E R F I L E S
40 //=============================================================================
41 
43 #ifndef CARTOBASE_STREAM_FISTREAMBUF_H
45 #endif
46 #ifndef CARTOBASE_STREAM_COUNTER_H
48 #endif
49 #ifndef CARTOBASE_STREAM_UNCOMMENT_H
51 #endif
52 #include <fstream>
53 
54 namespace carto
55 {
56 
57  //===========================================================================
58  // C L A S S D E C L A R A T I O N
59  //===========================================================================
60 
63  class CARTOBASE_API cuifstream : public std::istream
64  {
65 
66  public:
69 #if defined( __GNUC__ ) && ( __GNUC__-0 < 3 )
70  typedef int openmode;
71 #else
72  typedef std::ios_base::openmode openmode;
73 #endif
74 
75  //---------------------------------------------------------------------
77  //---------------------------------------------------------------------
79 
80  cuifstream();
81  cuifstream(const char *name, openmode mode = in);
82 
83  virtual ~cuifstream();
84 
86 
87  //---------------------------------------------------------------------
89  //---------------------------------------------------------------------
91 
92  virtual void open(const char *name, openmode mode = in);
93  virtual void close();
94 
96 
97  //---------------------------------------------------------------------
99  //---------------------------------------------------------------------
101 
105  int line() const;
106 
108 
109  //---------------------------------------------------------------------
111  //---------------------------------------------------------------------
113 
116  virtual bool operator!() const;
117 
120  virtual bool is_open() const;
121  void enableUncomment( bool );
122  bool uncommentEnabled() const { return _enableuncomment; }
123  virtual bool eof() const;
124 
126 
127  protected:
128 
129  //---------------------------------------------------------------------
131  //---------------------------------------------------------------------
133 
134  virtual void init_buffers();
135  virtual void destroy_buffers();
136 
138 
139  //---------------------------------------------------------------------
141  //---------------------------------------------------------------------
143 
144  mutable std::ifstream _base; // mutable because is_open is not
145  // const on gcc-3
149 
151  };
152 
153 
154  //===========================================================================
155  // I N L I N E M E T H O D S
156  //===========================================================================
157 
158  inline
159  int
161  {
162  return _counter->extractor().line();
163  }
164 
165 }
166 
167 #endif
bool uncommentEnabled() const
Definition: cuifstream.h:122
std::ios_base::openmode openmode
open modes are not a standard type in C++, they changed from int in g++ 2.9x to std::ios_base::openmo...
Definition: cuifstream.h:72
Filtering input stream.
Definition: fistreambuf.h:59
int line() const
Get the current line number.
Definition: cuifstream.h:160
fistreambuf< UncommentExtractor > * _uncomment
Definition: cuifstream.h:147
#define CARTOBASE_API
fistreambuf< CounterExtractor > * _counter
Definition: cuifstream.h:146
Filtering ifstream - counts lines and skips comments.
Definition: cuifstream.h:63
std::ifstream _base
Definition: cuifstream.h:144