Unverified Commit 8689b31b authored by Richard Berger's avatar Richard Berger
Browse files

Add convenience method next_values

parent 57821c7b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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);
+2 −0
Original line number Diff line number Diff line
@@ -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();
+4 −0
Original line number Diff line number Diff line
@@ -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);
}
+3 −1
Original line number Diff line number Diff line
@@ -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 {