Refactor PotentialFileReader
This commit is contained in:
68
src/text_file_reader.h
Normal file
68
src/text_file_reader.h
Normal file
@ -0,0 +1,68 @@
|
||||
/* -*- c++ -*- ----------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Richard Berger (Temple U)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_TEXT_FILE_READER_H
|
||||
#define LMP_TEXT_FILE_READER_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <exception>
|
||||
|
||||
namespace LAMMPS_NS
|
||||
{
|
||||
class TextFileReader {
|
||||
std::string filename;
|
||||
std::string filetype;
|
||||
static const int MAXLINE = 1024;
|
||||
char line[MAXLINE];
|
||||
FILE *fp;
|
||||
|
||||
public:
|
||||
bool ignore_comments;
|
||||
|
||||
TextFileReader(const std::string &filename, const std::string &filetype);
|
||||
~TextFileReader();
|
||||
|
||||
void skip_line();
|
||||
char * next_line(int nparams = 0);
|
||||
|
||||
void next_dvector(int n, double * list);
|
||||
};
|
||||
|
||||
class FileReaderException : public std::exception {
|
||||
std::string message;
|
||||
public:
|
||||
FileReaderException(const std::string & msg) : message(msg) {
|
||||
}
|
||||
|
||||
~FileReaderException() throw() {
|
||||
}
|
||||
|
||||
virtual const char * what() const throw() {
|
||||
return message.c_str();
|
||||
}
|
||||
};
|
||||
|
||||
class EOFException : public FileReaderException {
|
||||
public:
|
||||
EOFException(const std::string & msg) : FileReaderException(msg) {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user