|
simple.cc
// // $Id: simple.cc,v 1.7 2004/10/30 15:51:08 cholm Exp $ // // simple.cc // Copyright (C) 2003 Christian Holm <cholm@linux.HAL3000> // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License // as published by the Free Software Foundation; either version 2.1 // of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA // 02111-1307 USA // /** @file tests/simple.cc @author Christian Holm @date Tue Jan 28 01:46:50 2003 @brief A simple test */ #ifdef HAVE_CONFIG_H # include "config.hh" #endif #ifndef FILEMM_streambuf # include <filemm/streambuf.hh> #endif #ifndef FILEMM_util # include "util.hh" #endif #ifndef __STDEXCEPT__ # include <stdexcept> #endif /** A simple program to test @b FILE-- @param argc Number of arguments from runtime system @param argv The command line arguments from runtime system @return always 0 @ingroup examples */ int main(int argc, char** argv) { try { // Get the command line arguments std::string file; getargs(argc, argv, file); if (file.empty()) throw std::runtime_error("no file name given"); // Open the file filemm::streambuf sb(fopen(file.c_str(), "r")); // Wrap the FILE pointer in a regular std::istream object std::istream in(&sb); // Read the file while (true) { std::string line; std::getline(in, line); if (in.eof()) break; std::cout << line << std::endl; } // Close the file fclose(sb); } catch (std::exception& e) { std::cerr << e.what() << std::endl; return 1; } return 0; } // // EOF // Last update Wed Apr 13 07:51:02 2005 Christian Holm Created by DoxyGen 1.4.2 |