/** @file FileUtil.h * * @author Robert Fourer, Jun Ma, Kipp Martin, * @version 1.0, 10/05/2005 * @since OS1.0 * * \remarks * Copyright (C) 2005, Robert Fourer, Jun Ma, Kipp Martin, * Northwestern University, and the University of Chicago. * All Rights Reserved. * This software is licensed under the Common Public License. * Please see the accompanying LICENSE file in root directory for terms. * */ #ifndef FILEUTIL_H #define FILEUTIL_H #include #include #include #include /*! \class FileUtil * \brief class used to make it easy to read and write files. * * @author Robert Fourer, Jun Ma, Kipp Martin * @version 1.0, 03/14/2004 * @since OS 1.0 * * \remarks *

The FileUtil class contains methods for reading * and writing files from strings used by many classes in the * Optimization Services (OS) framework.

* */ class FileUtil{ public: public: /** the class constructor */ FileUtil(); /** the class destructor */ ~FileUtil(); /** * read a file and return contents as a string. * * @param fname holds the name of the file. * @return the file contents as a sring. */ std::string getFileAsString(const char* fname); /** * read a file and return contents as a char pointer. * * @param fname holds the name of the file. * @return the file contents as a char pointer. */ char* getFileAsChar(const char* fname); /** * write a file from an input string. * * @param fname holds the name of the file to be written. * @param thestring holds the string to be written to the file. * @return true if file successfuly written. */ bool writeFileFromString(char* fname, std::string thestring); /** * write a file from an input string. * * @param fname holds the name of the file to be written. * @param thestring holds the string to be written to the file. * @return true if file successfuly written. */ bool writeFileFromString(std::string fname, std::string thestring); /** * write a file from an input char pointer. * * @param fname holds the name of the file to be written. * @param ch holds a pointer to a char array to be written to the file. * @return true if file successfuly written. */ bool writeFileFromChar(char* fname, char* ch); };//class FileUtil #endif