35 if (m.size() == 0) {
throw "Line " + line +
" is malformed"; }
36 return {std::string(m[1]),
37 {std::atof(std::string(m[2]).c_str()),
38 std::atof(std::string(m[3]).c_str()),
39 std::atof(std::string(m[4]).c_str())}};
42 std::vector<Atom>
parseFile(
const std::string &fileName) {
43 std::fstream f(fileName);
45 std::vector<Atom> atoms;
46 if (!f.good())
throw "File " + fileName +
" not found";
47 if (!f.is_open())
throw "File IO error: " + fileName;
49 std::getline(f, line);
50 const int natoms = std::atoi(line.c_str());
52 std::getline(f, line);
55 for (
int i(0); i < natoms; i++) {
56 std::getline(f, line);
const Str lower("[[:lower:]]")
const Str blank("[[:blank:]]")
const Str upper("[[:upper:]]")
const std::function< Str(Str)> capture([](const Str &i) { return "("+i+")";})
const Str realNumber("[-eE+\\d.]+")
Definition XyzParser.hpp:12
double x
Definition XyzParser.hpp:15
const struct Atom::@8 position
const std::string symbol
Definition XyzParser.hpp:13
double y
Definition XyzParser.hpp:15
double z
Definition XyzParser.hpp:15
Definition Parsing.hpp:45
const std::regex r
Definition Parsing.hpp:47
const std::string s
Definition Parsing.hpp:46
Definition XyzParser.hpp:21
const Regex atom
Definition XyzParser.hpp:25
const Regex xyz_line
Definition XyzParser.hpp:27
std::vector< Atom > parseFile(const std::string &fileName)
Definition XyzParser.hpp:42
const Regex sep
Definition XyzParser.hpp:23
Atom parseLine(const std::string &line)
Definition XyzParser.hpp:32