Add convenience functions to PotentialFileReader

This commit is contained in:
Richard Berger 2020-06-04 11:18:33 -04:00
parent 9291d2a9d7
commit 34ff7aa1fe
No known key found for this signature in database
GPG Key ID: A9E83994E0BA0CAB
2 changed files with 63 additions and 0 deletions

View File

@ -51,6 +51,10 @@ PotentialFileReader::~PotentialFileReader() {
delete reader;
}
void PotentialFileReader::ignore_comments(bool value) {
reader->ignore_comments = value;
}
void PotentialFileReader::skip_line() {
try {
reader->skip_line();
@ -76,6 +80,56 @@ void PotentialFileReader::next_dvector(int n, double * list) {
}
}
double PotentialFileReader::next_double() {
try {
char * line = reader->next_line(1);
return ValueTokenizer(line).next_double();
} catch (FileReaderException & e) {
error->one(FLERR, e.what());
}
return 0.0;
}
int PotentialFileReader::next_int() {
try {
char * line = reader->next_line(1);
return ValueTokenizer(line).next_int();
} catch (FileReaderException & e) {
error->one(FLERR, e.what());
}
return 0;
}
tagint PotentialFileReader::next_tagint() {
try {
char * line = reader->next_line(1);
return ValueTokenizer(line).next_tagint();
} catch (FileReaderException & e) {
error->one(FLERR, e.what());
}
return 0;
}
bigint PotentialFileReader::next_bigint() {
try {
char * line = reader->next_line(1);
return ValueTokenizer(line).next_bigint();
} catch (FileReaderException & e) {
error->one(FLERR, e.what());
}
return 0;
}
std::string PotentialFileReader::next_string() {
try {
char * line = reader->next_line(1);
return ValueTokenizer(line).next_string();
} catch (FileReaderException & e) {
error->one(FLERR, e.what());
}
return "";
}
/* ----------------------------------------------------------------------
open a potential file as specified by name
if fails, search in dir specified by env variable LAMMPS_POTENTIALS

View File

@ -38,9 +38,18 @@ namespace LAMMPS_NS
PotentialFileReader(class LAMMPS *lmp, const std::string &filename, const std::string &potential_name);
virtual ~PotentialFileReader();
void ignore_comments(bool value);
void skip_line();
char * next_line(int nparams = 0);
void next_dvector(int n, double * list);
// convenience functions
double next_double();
int next_int();
tagint next_tagint();
bigint next_bigint();
std::string next_string();
};
} // namespace LAMMPS_NS