Go to Overview over all GrAL packages.
Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Utility/checked-istream.h

Go to the documentation of this file.
00001 #ifndef NMWR_UTILITY_CHECKED_ISTREAM_H
00002 #define NMWR_UTILITY_CHECKED_ISTREAM_H
00003 
00004 // $LICENSE
00005 
00006 #include <iostream>
00007 #include "Utility/pre-post-conditions.h"
00008 
00018 class checked_istream {
00019 private:
00020   std::istream* in;
00021 public:
00022   checked_istream(std::istream* in_ = 0) : in(in_) {}
00023 
00024   template<class T>
00025   friend checked_istream& operator>>(checked_istream& in, T & t)
00026   { 
00027     REQUIRE( (in.in != 0), "no istream!\n",1);
00028     *(in.in) >> t; 
00029     REQUIRE( (in.in->good()), "bad istream, reading " << t << " failed!\n",1);
00030     return in;
00031   }
00032 };
00033 
00034 #endif

Copyright (c) Guntram Berti 1997-2002. See the GrAL Homepage for up-to-date information.

Generated at Tue Feb 26 15:57:02 2002 for Utilities by doxygen 1.2.11-20011104 written by Dimitri van Heesch, © 1997-2000