- Main Page
- Classes
- Files

- File List

# OptFrame/Parallel/MapReduce++/util/Scanner++/File.h

    00001 // File Object - Scanner++
    00002
    00003 // Copyright (C) 2009
    00004 // Igor Machado - Mario Henrique Perche - Pablo Munhoz - Sabir Ribas
    00005 //
    00006 // This file is part of the Scanner++ Library v0.91.  This library is free
    00007 // software; you can redistribute it and/or modify it under the
    00008 // terms of the GNU Lesser General Public License v3 as published by the
    00009 // Free Software Foundation.
    00010
    00011 // This library is distributed in the hope that it will be useful,
    00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00014 // GNU Lesser General Public License v3 for more details.
    00015
    00016 // You should have received a copy of the GNU Lesser General Public License v3
    00017 // along with this library; see the file COPYING.  If not, write to the Free
    00018 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
    00019 // USA.
    00020
    00021 #ifndef FILE_H_
    00022 #define FILE_H_
    00023
    00024 #include<fstream>
    00025 #include<string>
    00026
    00027 using namespace std;
    00028 #include<iostream>
    00029
    00030 class FileNotFound
    00031 {
    00032 private:
    00033         string file;
    00034 public:
    00035         FileNotFound(string str){file = str;};
    00036 };
    00037
    00038 class File
    00039 {
    00040 public:
    00041         std::ifstream* file;
    00042
    00043         //File(const char* filename);
    00044         File(string filename)
    00045         {
    00046                 std::fstream foo;
    00047
    00048                 foo.open(filename.c_str());
    00049
    00050         if(foo.is_open() == true)
    00051                 foo.close();
    00052         else
    00053         {
    00054                 cerr << "File Doesn't Exist: "<<filename << endl;
    00055                 throw FileNotFound(filename);
    00056         }
    00057
    00058                 file = new std::ifstream(filename.c_str(), std::ifstream::in);
    00059
    00060         }
    00061
    00062         virtual ~File() { close();}
    00063
    00064         int get(){ return file->get();}
    00065
    00066         bool eof(){ return file->eof();}
    00067
    00068         void close(){ file->close();}
    00069 };
    00070
    00071 #endif /*FILE_H_*/

All Classes Functions