Add convenience method next_values

This commit is contained in:
Richard Berger
2020-06-04 16:27:27 -04:00
parent 57821c7bea
commit 8689b31bca
4 changed files with 18 additions and 1 deletions

View File

@ -83,6 +83,15 @@ void PotentialFileReader::next_dvector(int n, double * list) {
}
}
ValueTokenizer PotentialFileReader::next_values(int nparams, const std::string & seperators) {
try {
return reader->next_values(nparams, seperators);
} catch (FileReaderException & e) {
error->one(FLERR, e.what());
}
return ValueTokenizer("");
}
double PotentialFileReader::next_double() {
try {
char * line = reader->next_line(1);

View File

@ -21,6 +21,7 @@
#include <string>
#include "pointers.h"
#include "tokenizer.h"
#include "text_file_reader.h"
namespace LAMMPS_NS
@ -43,6 +44,7 @@ namespace LAMMPS_NS
void skip_line();
char * next_line(int nparams = 0);
void next_dvector(int n, double * list);
ValueTokenizer next_values(int nparams, const std::string & seperators = TOKENIZER_DEFAULT_SEPERATORS);
// convenience functions
double next_double();

View File

@ -115,3 +115,7 @@ void TextFileReader::next_dvector(int n, double * list) {
}
}
}
ValueTokenizer TextFileReader::next_values(int nparams, const std::string & seperators) {
return ValueTokenizer(next_line(nparams), seperators);
}

View File

@ -21,6 +21,7 @@
#include <cstdio>
#include <string>
#include <exception>
#include "tokenizer.h"
namespace LAMMPS_NS
{
@ -39,8 +40,9 @@ namespace LAMMPS_NS
void skip_line();
char * next_line(int nparams = 0);
void next_dvector(int n, double * list);
ValueTokenizer next_values(int nparams, const std::string & seperators = TOKENIZER_DEFAULT_SEPERATORS);
};
class FileReaderException : public std::exception {