cartobase  5.0.5
ioexcept.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_EXCEPTION_IOEXCEPT_H
35 #define CARTOBASE_EXCEPTION_IOEXCEPT_H
36 
38 #include <stdexcept>
39 #include <string>
40 
41 namespace carto
42 {
43 
45  class io_error : public std::runtime_error
46  {
47  public:
48  io_error( const std::string & arg, const std::string & filename = "" );
49  virtual ~io_error() throw();
50  virtual const char* what() const throw();
51  std::string filename() const { return _filename; }
52 
53  static void launchErrnoExcept( const std::string & filename = "" );
54  static void keepExceptionPriority( std::exception & e, int & prio,
55  int & type, std::string & message,
56  int raiseprio = 0 );
57  static void launchExcept( int code, const std::string & msg,
58  const std::string & defmsg = "" );
59 
60  private:
61  std::string _filename;
62  mutable std::string _formed_msg;
63  };
64 
65 
67  class open_error : public io_error
68  {
69  public:
70  open_error( const std::string & arg, const std::string & filename = "" );
71  virtual ~open_error() throw();
72  };
73 
74 
78  {
79  public:
80  file_not_found_error( const std::string & arg,
81  const std::string & filename );
82  file_not_found_error( const std::string & filename = "" );
83  virtual ~file_not_found_error() throw();
84  };
85 
86 
89  {
90  public:
91  permission_error( const std::string & arg, const std::string & filename );
92  permission_error( const std::string & filename = "" );
93  virtual ~permission_error() throw();
94  };
95 
96 
98  class is_dir_error : public open_error
99  {
100  public:
101  is_dir_error( const std::string & arg, const std::string & filename );
102  is_dir_error( const std::string & filename = "" );
103  virtual ~is_dir_error() throw();
104  };
105 
106 
110  {
111  public:
112  no_dir_error( const std::string & arg, const std::string & filename );
113  no_dir_error( const std::string & filename = "" );
114  virtual ~no_dir_error() throw();
115  };
116 
117 
120  {
121  public:
122  too_many_descriptors_error( const std::string & arg,
123  const std::string & filename );
124  too_many_descriptors_error( const std::string & filename = "" );
125  virtual ~too_many_descriptors_error() throw();
126  };
127 
128 
131  class read_write_error : public io_error
132  {
133  public:
134  read_write_error( const std::string & arg,
135  const std::string & filename = "" );
136  virtual ~read_write_error() throw();
137  };
138 
139 
142  {
143  public:
144  bad_medium_error( const std::string & arg, const std::string & filename );
145  bad_medium_error( const std::string & filename = "" );
146  virtual ~bad_medium_error() throw();
147  };
148 
149 
152  {
153  public:
154  disk_full_error( const std::string & arg, const std::string & filename );
155  disk_full_error( const std::string & filename = "" );
156  virtual ~disk_full_error() throw();
157  };
158 
159 
162  {
163  public:
164  quota_exceeded_error( const std::string & arg,
165  const std::string & filename );
166  quota_exceeded_error( const std::string & filename = "" );
167  virtual ~quota_exceeded_error() throw();
168  };
169 
170 
173  {
174  public:
175  stream_state_error( const std::string & arg,
176  const std::string & filename = "" );
177  virtual ~stream_state_error() throw();
178  };
179 
180 
183  {
184  public:
185  eof_error( const std::string & arg, const std::string & filename );
186  eof_error( const std::string & filename = "" );
187  virtual ~eof_error() throw();
188  };
189 
190 
193  {
194  public:
195  not_open_error( const std::string & arg, const std::string & filename );
196  not_open_error( const std::string & filename = "" );
197  virtual ~not_open_error() throw();
198  };
199 
200 
203  {
204  public:
205  stream_fail_error( const std::string & arg, const std::string & filename );
206  stream_fail_error( const std::string & filename = "" );
207  virtual ~stream_fail_error() throw();
208  };
209 
210 
212  class format_error : public io_error
213  {
214  public:
215  format_error( const std::string & arg, const std::string & filename );
216  format_error( const std::string & filename = "" );
217  virtual ~format_error() throw();
218  };
219 
220 
223  {
224  public:
225  wrong_format_error( const std::string & arg,
226  const std::string & filename );
227  wrong_format_error( const std::string & filename = "" );
228  virtual ~wrong_format_error() throw();
229  };
230 
231 
234  {
235  public:
236  format_mismatch_error( const std::string & arg,
237  const std::string & filename );
238  format_mismatch_error( const std::string & filename = "" );
239  virtual ~format_mismatch_error() throw();
240  };
241 
242 
245  {
246  public:
247  corrupt_stream_error( const std::string & arg,
248  const std::string & filename );
249  corrupt_stream_error( const std::string & filename = "" );
250  virtual ~corrupt_stream_error() throw();
251  };
252 
253 
257  {
258  public:
259  invalid_format_error( const std::string & arg,
260  const std::string & filename );
261  invalid_format_error( const std::string & filename = "" );
262  virtual ~invalid_format_error() throw();
263  };
264 
265 
269  {
270  public:
271  datatype_format_error( const std::string & arg,
272  const std::string & filename );
273  datatype_format_error( const std::string & filename = "" );
274  virtual ~datatype_format_error() throw();
275  };
276 
277 
280  {
281  public:
288  parse_error( const std::string& what_arg,
289  const std::string& token_arg,
290  const std::string& filename_arg,
291  int line_arg );
297  parse_error( const std::string& what_arg,
298  const std::string& token_arg,
299  int line_arg );
300  /* DO NOT USE! DEPRECIATED
301  @param what_arg not used
302  @param line_arg number of the line in the file
303  @param filename_arg name of the file
304  */
305  parse_error( const std::string& what_arg, int line_arg,
306  const std::string& filename_arg = std::string() )
308 
309  virtual ~parse_error() throw ();
310 
311  int line() const;
312 
313  private:
314  static std::string init( const std::string& what_arg,
315  const std::string& token_arg,
316  const std::string& filename_arg,
317  int line_arg );
318  static std::string init( const std::string& what_arg,
319  const std::string& token_arg,
320  int line_arg );
321 
322  const std::string _filename;
323  const int _line;
324  };
325 
326 
328  {
329  public:
330  syntax_check_error( const std::string & arg,
331  const std::string & filename );
332  syntax_check_error( const std::string & filename = "" );
333  virtual ~syntax_check_error() throw();
334  };
335 
336 }
337 
338 #endif
339 
340 
#define __deprecated__(msg)
virtual ~io_error()
format-related errors (file parsing / interpreting)
Definition: ioexcept.h:212
disk / network failure
Definition: ioexcept.h:141
parsing error
Definition: ioexcept.h:279
static void keepExceptionPriority(std::exception &e, int &prio, int &type, std::string &message, int raiseprio=0)
stream not open
Definition: ioexcept.h:192
format is recognized but contains parameters that can not be handled by curent parser ...
Definition: ioexcept.h:256
too many open files
Definition: ioexcept.h:119
read or write permission denied
Definition: ioexcept.h:88
write in a non-existing directory (more precise than file_not_found_error )
Definition: ioexcept.h:109
general IO error (should be specialized)
Definition: ioexcept.h:45
static void launchErrnoExcept(const std::string &filename="")
corrupt data: not understood by current format
Definition: ioexcept.h:244
file not found: trying to read an non-existing file, or write in a non-existing directory ...
Definition: ioexcept.h:77
format is recognized but something goes wrong
Definition: ioexcept.h:233
disk full or quota exceeded (specialize for quota)
Definition: ioexcept.h:151
open as a file something which is a directory
Definition: ioexcept.h:98
stream state flags errors
Definition: ioexcept.h:172
static void launchExcept(int code, const std::string &msg, const std::string &defmsg="")
open failed (read or write), generally specialized
Definition: ioexcept.h:67
format is recognized but contains data types that can not be read by curent reader ...
Definition: ioexcept.h:268
read / write failed (bad medium, disk full, quota exceeded...).
Definition: ioexcept.h:131
io_error(const std::string &arg, const std::string &filename="")
fail or bad bit is set
Definition: ioexcept.h:202
#define __attribute__(a)
virtual const char * what() const
std::string filename() const
Definition: ioexcept.h:51