43 static const int bufferSize = 47 + 256;
46 char buffer[ bufferSize ];
52 setp( buffer, buffer + ( bufferSize - 1 ) );
58 catch( std::ios_base::failure &e ) {
59 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
60 throw( std::ios_base::failure( msg ) );
62 catch( std::bad_alloc &e ) {
63 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
64 throw( std::runtime_error( msg ) );
66 catch( std::runtime_error &e ) {
67 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
68 throw( std::runtime_error( msg ) );
70 catch(
const std::out_of_range &e ) {
71 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
72 throw( std::out_of_range( msg ) );
74 catch(
const std::logic_error &e ) {
75 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
76 "Image, window end, and/or window size dimensions do not match." ) );
77 throw( std::logic_error( msg ) );
103 void open(
const char *name,
int open_mode );
122 catch( std::ios_base::failure &e ) {
123 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
124 throw( std::ios_base::failure( msg ) );
126 catch( std::bad_alloc &e ) {
127 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
128 throw( std::runtime_error( msg ) );
130 catch( std::runtime_error &e ) {
131 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
132 throw( std::runtime_error( msg ) );
134 catch(
const std::out_of_range &e ) {
135 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
136 throw( std::out_of_range( msg ) );
138 catch(
const std::logic_error &e ) {
139 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
140 "Image, window end, and/or window size dimensions do not match." ) );
141 throw( std::logic_error( msg ) );
146 catch( std::ios_base::failure &e ) {
147 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
148 throw( std::ios_base::failure( msg ) );
150 catch( std::bad_alloc &e ) {
151 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
152 throw( std::runtime_error( msg ) );
154 catch( std::runtime_error &e ) {
155 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
156 throw( std::runtime_error( msg ) );
158 catch(
const std::out_of_range &e ) {
159 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
160 throw( std::out_of_range( msg ) );
162 catch(
const std::logic_error &e ) {
163 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
164 "Image, window end, and/or window size dimensions do not match." ) );
165 throw( std::logic_error( msg ) );
169 open_mode ),
std::istream( &buf ) {
171 catch( std::ios_base::failure &e ) {
172 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
173 throw( std::ios_base::failure( msg ) );
175 catch( std::bad_alloc &e ) {
176 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
177 throw( std::runtime_error( msg ) );
179 catch( std::runtime_error &e ) {
180 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
181 throw( std::runtime_error( msg ) );
183 catch(
const std::out_of_range &e ) {
184 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
185 throw( std::out_of_range( msg ) );
187 catch(
const std::logic_error &e ) {
188 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
189 "Image, window end, and/or window size dimensions do not match." ) );
190 throw( std::logic_error( msg ) );
197 catch( std::ios_base::failure &e ) {
198 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
199 throw( std::ios_base::failure( msg ) );
201 catch( std::bad_alloc &e ) {
202 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
203 throw( std::runtime_error( msg ) );
205 catch( std::runtime_error &e ) {
206 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
207 throw( std::runtime_error( msg ) );
209 catch(
const std::out_of_range &e ) {
210 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
211 throw( std::out_of_range( msg ) );
213 catch(
const std::logic_error &e ) {
214 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
215 throw( std::logic_error( msg ) );
223 catch( std::ios_base::failure &e ) {
224 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
225 throw( std::ios_base::failure( msg ) );
227 catch( std::bad_alloc &e ) {
228 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
229 throw( std::runtime_error( msg ) );
231 catch( std::runtime_error &e ) {
232 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
233 throw( std::runtime_error( msg ) );
235 catch(
const std::out_of_range &e ) {
236 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
237 throw( std::out_of_range( msg ) );
239 catch(
const std::logic_error &e ) {
240 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
241 throw( std::logic_error( msg ) );
249 catch( std::ios_base::failure &e ) {
250 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
251 throw( std::ios_base::failure( msg ) );
253 catch( std::bad_alloc &e ) {
254 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
255 throw( std::runtime_error( msg ) );
257 catch( std::runtime_error &e ) {
258 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
259 throw( std::runtime_error( msg ) );
261 catch(
const std::out_of_range &e ) {
262 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
263 throw( std::out_of_range( msg ) );
265 catch(
const std::logic_error &e ) {
266 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
267 throw( std::logic_error( msg ) );
277 catch( std::ios_base::failure &e ) {
278 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
279 throw( std::ios_base::failure( msg ) );
281 catch( std::bad_alloc &e ) {
282 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
283 throw( std::runtime_error( msg ) );
285 catch( std::runtime_error &e ) {
286 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
287 throw( std::runtime_error( msg ) );
289 catch(
const std::out_of_range &e ) {
290 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
291 throw( std::out_of_range( msg ) );
293 catch(
const std::logic_error &e ) {
294 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
295 "Image, window end, and/or window size dimensions do not match." ) );
296 throw( std::logic_error( msg ) );
301 catch( std::ios_base::failure &e ) {
302 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
303 throw( std::ios_base::failure( msg ) );
305 catch( std::bad_alloc &e ) {
306 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
307 throw( std::runtime_error( msg ) );
309 catch( std::runtime_error &e ) {
310 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
311 throw( std::runtime_error( msg ) );
313 catch(
const std::out_of_range &e ) {
314 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
315 throw( std::out_of_range( msg ) );
317 catch(
const std::logic_error &e ) {
318 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
319 "Image, window end, and/or window size dimensions do not match." ) );
320 throw( std::logic_error( msg ) );
325 catch( std::ios_base::failure &e ) {
326 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
327 throw( std::ios_base::failure( msg ) );
329 catch( std::bad_alloc &e ) {
330 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
331 throw( std::runtime_error( msg ) );
333 catch( std::runtime_error &e ) {
334 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
335 throw( std::runtime_error( msg ) );
337 catch(
const std::out_of_range &e ) {
338 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
339 throw( std::out_of_range( msg ) );
341 catch(
const std::logic_error &e ) {
342 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
343 "Image, window end, and/or window size dimensions do not match." ) );
344 throw( std::logic_error( msg ) );
351 catch( std::ios_base::failure &e ) {
352 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
353 throw( std::ios_base::failure( msg ) );
355 catch( std::bad_alloc &e ) {
356 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
357 throw( std::runtime_error( msg ) );
359 catch( std::runtime_error &e ) {
360 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
361 throw( std::runtime_error( msg ) );
363 catch(
const std::out_of_range &e ) {
364 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
365 throw( std::out_of_range( msg ) );
367 catch(
const std::logic_error &e ) {
368 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
369 throw( std::logic_error( msg ) );
377 catch( std::ios_base::failure &e ) {
378 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
379 throw( std::ios_base::failure( msg ) );
381 catch( std::bad_alloc &e ) {
382 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
383 throw( std::runtime_error( msg ) );
385 catch( std::runtime_error &e ) {
386 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
387 throw( std::runtime_error( msg ) );
389 catch(
const std::out_of_range &e ) {
390 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
391 throw( std::out_of_range( msg ) );
393 catch(
const std::logic_error &e ) {
394 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
395 throw( std::logic_error( msg ) );
403 catch( std::ios_base::failure &e ) {
404 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
405 throw( std::ios_base::failure( msg ) );
407 catch( std::bad_alloc &e ) {
408 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
409 throw( std::runtime_error( msg ) );
411 catch( std::runtime_error &e ) {
412 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
413 throw( std::runtime_error( msg ) );
415 catch(
const std::out_of_range &e ) {
416 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
417 throw( std::out_of_range( msg ) );
419 catch(
const std::logic_error &e ) {
420 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
421 throw( std::logic_error( msg ) );
444 if( ( mode & std::ios::ate ) || ( mode & std::ios::app ) ||
449 char *fmodeptr = fmode;
450 if( mode & std::ios::in ) {
453 else if( mode & std::ios::out ) {
465 catch( std::ios_base::failure &e ) {
466 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
467 throw( std::ios_base::failure( msg ) );
469 catch( std::bad_alloc &e ) {
470 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
471 throw( std::runtime_error( msg ) );
473 catch( std::runtime_error &e ) {
474 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
475 throw( std::runtime_error( msg ) );
477 catch(
const std::out_of_range &e ) {
478 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
479 throw( std::out_of_range( msg ) );
481 catch(
const std::logic_error &e ) {
482 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
483 throw( std::logic_error( msg ) );
498 catch( std::ios_base::failure &e ) {
499 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
500 throw( std::ios_base::failure( msg ) );
502 catch( std::bad_alloc &e ) {
503 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
504 throw( std::runtime_error( msg ) );
506 catch( std::runtime_error &e ) {
507 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
508 throw( std::runtime_error( msg ) );
510 catch(
const std::out_of_range &e ) {
511 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
512 throw( std::out_of_range( msg ) );
514 catch(
const std::logic_error &e ) {
515 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
516 throw( std::logic_error( msg ) );
522 if( gptr( ) && ( gptr( ) < egptr( ) ) ) {
523 return( *reinterpret_cast< unsigned char* >( gptr( ) ) );
529 int n_putback = gptr( ) - eback( );
530 if( n_putback > 4 ) {
533 memcpy( buffer + ( 4 - n_putback ), gptr( ) - n_putback, n_putback );
540 setg( buffer + ( 4 - n_putback ),
545 return( *reinterpret_cast< unsigned char* >( gptr( ) ) );
547 catch( std::ios_base::failure &e ) {
548 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
549 throw( std::ios_base::failure( msg ) );
551 catch( std::bad_alloc &e ) {
552 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
553 throw( std::runtime_error( msg ) );
555 catch( std::runtime_error &e ) {
556 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
557 throw( std::runtime_error( msg ) );
559 catch(
const std::out_of_range &e ) {
560 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
561 throw( std::out_of_range( msg ) );
563 catch(
const std::logic_error &e ) {
564 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
565 throw( std::logic_error( msg ) );
569 inline int gzstreambuf::flush_buffer( ) {
575 int w = std::streambuf::pptr( ) - std::streambuf::pbase( );
576 if(
gzwrite(
file, std::streambuf::pbase( ), w ) != w ) {
582 catch( std::ios_base::failure &e ) {
583 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
584 throw( std::ios_base::failure( msg ) );
586 catch( std::bad_alloc &e ) {
587 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
588 throw( std::runtime_error( msg ) );
590 catch( std::runtime_error &e ) {
591 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
592 throw( std::runtime_error( msg ) );
594 catch(
const std::out_of_range &e ) {
595 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
596 throw( std::out_of_range( msg ) );
598 catch(
const std::logic_error &e ) {
599 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
600 throw( std::logic_error( msg ) );
610 *std::streambuf::pptr( ) = c;
613 if( flush_buffer( ) == EOF ) {
618 catch( std::ios_base::failure &e ) {
619 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
620 throw( std::ios_base::failure( msg ) );
622 catch( std::bad_alloc &e ) {
623 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
624 throw( std::runtime_error( msg ) );
626 catch( std::runtime_error &e ) {
627 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
628 throw( std::runtime_error( msg ) );
630 catch(
const std::out_of_range &e ) {
631 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
632 throw( std::out_of_range( msg ) );
634 catch(
const std::logic_error &e ) {
635 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
636 throw( std::logic_error( msg ) );
642 if( std::streambuf::pptr( ) && ( std::streambuf::pptr( ) > std::streambuf::pbase( ) ) ) {
643 if( flush_buffer( ) == EOF ) {
649 catch( std::ios_base::failure &e ) {
650 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
651 throw( std::ios_base::failure( msg ) );
653 catch( std::bad_alloc &e ) {
654 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
655 throw( std::runtime_error( msg ) );
657 catch( std::runtime_error &e ) {
658 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
659 throw( std::runtime_error( msg ) );
661 catch(
const std::out_of_range &e ) {
662 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
663 throw( std::out_of_range( msg ) );
665 catch(
const std::logic_error &e ) {
666 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
667 throw( std::logic_error( msg ) );
678 catch( std::ios_base::failure &e ) {
679 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
680 throw( std::ios_base::failure( msg ) );
682 catch( std::bad_alloc &e ) {
683 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
684 throw( std::runtime_error( msg ) );
686 catch( std::runtime_error &e ) {
687 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
688 throw( std::runtime_error( msg ) );
690 catch(
const std::out_of_range &e ) {
691 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
692 throw( std::out_of_range( msg ) );
694 catch(
const std::logic_error &e ) {
695 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
696 throw( std::logic_error( msg ) );
704 catch( std::ios_base::failure &e ) {
705 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
706 throw( std::ios_base::failure( msg ) );
708 catch( std::bad_alloc &e ) {
709 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
710 throw( std::runtime_error( msg ) );
712 catch( std::runtime_error &e ) {
713 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
714 throw( std::runtime_error( msg ) );
716 catch(
const std::out_of_range &e ) {
717 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
718 throw( std::out_of_range( msg ) );
720 catch(
const std::logic_error &e ) {
721 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
722 throw( std::logic_error( msg ) );
728 if( !buf.open( name, open_mode ) ) {
729 clear( rdstate( ) | std::ios::badbit );
732 catch( std::ios_base::failure &e ) {
733 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
734 throw( std::ios_base::failure( msg ) );
736 catch( std::bad_alloc &e ) {
737 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
738 throw( std::runtime_error( msg ) );
740 catch( std::runtime_error &e ) {
741 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
742 throw( std::runtime_error( msg ) );
744 catch(
const std::out_of_range &e ) {
745 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
746 throw( std::out_of_range( msg ) );
748 catch(
const std::logic_error &e ) {
749 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
750 throw( std::logic_error( msg ) );
756 if( buf.is_open( ) ) {
757 if( !buf.close( ) ) {
758 clear( rdstate( ) | std::ios::badbit );
762 catch( std::ios_base::failure &e ) {
763 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"I/O error while reading file." ) );
764 throw( std::ios_base::failure( msg ) );
766 catch( std::bad_alloc &e ) {
767 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Memory allocation error." ) );
768 throw( std::runtime_error( msg ) );
770 catch( std::runtime_error &e ) {
771 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Runtime error." ) );
772 throw( std::runtime_error( msg ) );
774 catch(
const std::out_of_range &e ) {
775 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Out of range exception." ) );
776 throw( std::out_of_range( msg ) );
778 catch(
const std::logic_error &e ) {
779 std::string msg( e.what( ) + std::string(
"\n" ) +
BIAL_ERROR(
"Logic Error." ) );
780 throw( std::logic_error( msg ) );
void open(const char *name, int open_mode=std::ios::in)
virtual int overflow(int c=EOF)
void open(const char *name, int open_mode)
#define BIAL_ERROR(exp)
Use BIAL_ERROR to compose runtime error messages. Note that ERROR generates a string, instead of a stream, because it is better to throw an exception, rather than exiting the program. This way, the exception may be threated by a higher level program, like an user IDE.
int gzread(gzFile file, voidp buf, unsigned len)
gzFile gzopen(char *path, char *mode)
Content: Commonly used macros, types, static variables and functions. Description: Some macros used...
igzstream(const char *name, int open_mode=std::ios::in)
Adjacency relation with indexes following gray code sequency. Future add-on's: none.
ogzstream(const char *name, int mode=std::ios::out)
static int out(void *out_desc, unsigned char *buf, unsigned len)
gzstreambuf * open(const char *name, int open_mode)
static unsigned in(void *in_desc, z_const unsigned char **buf)
void open(const char *name, int open_mode=std::ios::out)
int gzwrite(gzFile file, voidpc buf, unsigned len)