ESLA
Embeddable Scriting LAnguage
Stanford University, Rock Fracture Project research group
© 2003
00001 /************************************************************************* 00002 * ESLA: Embeddable Scripting LAnguage 00003 * Copyright (C) 2003 Frantz Maerten 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License as 00007 * published by the Free Software Foundation; either version 2 of the 00008 * License, or (at your option) any later version. 00009 * 00010 * If you modify this software, you should contact the author, include 00011 * a notice giving the name of the person performing the modification, 00012 * the date of modification, and the reason for such modification. 00013 * 00014 * Note that the GNU General Public License does not permit 00015 * incorporating the Software into proprietary programs. 00016 * 00017 * Contact: Frantz Maerten 00018 * frantz@pangea.stanford.edu 00019 * 00020 * Dept. of Geological & Environmental Sciences 00021 * Stanford University 00022 * Stanford, CA 94305-2115 00023 * USA 00024 *************************************************************************/ 00025 00026 00027 #ifndef INPUT_STREAM 00028 #define INPUT_STREAM 00029 00030 #include "../esla_namespace.h" 00031 #include <string> 00032 #include <fstream> 00033 #include <iostream> 00034 00035 BEGIN_LIB_NAMESPACE 00036 00037 class Logger ; 00038 00039 class IfStream { 00040 typedef std::ifstream parent ; 00041 public: 00042 IfStream() ; 00043 IfStream(const IfStream&) ; 00044 IfStream(const std::string&) ; 00045 IfStream(const char*) ; 00046 virtual ~IfStream() ; 00047 IfStream& operator=(const IfStream&) ; 00048 00049 IfStream& getline(char*, int size, char _delim='\n') ; 00050 int line_count() const ; 00051 const std::string& cur_line() const ; 00052 const std::string& file_name() const ; 00053 int bad() const ; 00054 int eof() ; 00055 00056 Logger* get_logger() const ; 00057 void set_logger(Logger* log) ; 00058 void message(const std::string&, bool extra=true) const ; 00059 00060 private: 00061 int line_count_ ; 00062 std::string cur_line_ ; 00063 std::string file_name_ ; 00064 std::ifstream* is_ ; 00065 Logger* log_ ; 00066 00067 } ; 00068 00069 // --------------------------------------------------- 00070 00071 inline int IfStream::line_count() const { 00072 return line_count_ ; 00073 } 00074 00075 inline const std::string& IfStream::cur_line() const { 00076 return cur_line_ ; 00077 } 00078 00079 inline const std::string& IfStream::file_name() const { 00080 return file_name_ ; 00081 } 00082 00083 END_LIB_NAMESPACE 00084 00085 #endif