Add convenience method next_values
This commit is contained in:
@ -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);
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <exception>
|
||||
#include "tokenizer.h"
|
||||
|
||||
namespace LAMMPS_NS
|
||||
{
|
||||
@ -41,6 +42,7 @@ namespace LAMMPS_NS
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user