Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

Commit

Permalink
Merge pull request #614 from votca/fix_readers_on_windows
Browse files Browse the repository at this point in the history
readers: getline() -> tools::getline()
  • Loading branch information
junghans authored Nov 16, 2020
2 parents 4d86424 + f64940a commit 7165e42
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 68 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ For more detailed information about the changes see the history of the
* add gmx2021 builds to CI (#607)
* remove set-env call from CI (#608)
* use master .clang-format in format action (#610)
* strip windows line endings in readers (#614)

## Version 1.6.2 _SuperGitta_ (released 22.08.20)
* move CI to GitHub Actions (#563, #567, #569)
Expand Down
15 changes: 7 additions & 8 deletions CMakeModules/CheckFunctionExists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@

char CHECK_FUNCTION_EXISTS();
#ifdef __CLASSIC_C__
int main(){
int main() {
int ac;
char*av[];
char* av[];
#else
int main(int ac, char*av[]){
int main(int ac, char* av[]) {
#endif
CHECK_FUNCTION_EXISTS();
if(ac > 1000)
{
if (ac > 1000) {
return *av[0];
}
}
return 0;
}

#else /* CHECK_FUNCTION_EXISTS */
#else /* CHECK_FUNCTION_EXISTS */

# error "CHECK_FUNCTION_EXISTS has to specify the function"
#error "CHECK_FUNCTION_EXISTS has to specify the function"

#endif /* CHECK_FUNCTION_EXISTS */
9 changes: 5 additions & 4 deletions include/votca/csg/xyzreader.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2019 The VOTCA Development Team (http://www.votca.org)
* Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,7 @@
#include <votca/csg/topologyreader.h>
#include <votca/csg/trajectoryreader.h>
#include <votca/tools/constants.h>
#include <votca/tools/getline.h>

#include <type_traits>
namespace votca {
Expand Down Expand Up @@ -104,7 +105,7 @@ class XYZReader : public TrajectoryReader, public TopologyReader {
template <bool topology, class T>
inline bool XYZReader::ReadFrame(T &container) {
std::string line;
std::getline(_fl, line);
tools::getline(_fl, line);
++_line;
if (!_fl.eof()) {
// read the number of atoms
Expand All @@ -121,11 +122,11 @@ inline bool XYZReader::ReadFrame(T &container) {
"number of beads in topology and trajectory differ");
}
// the title line
getline(_fl, line);
tools::getline(_fl, line);
++_line;
// read atoms
for (Index i = 0; i < natoms; ++i) {
getline(_fl, line);
tools::getline(_fl, line);
++_line;
if (_fl.eof()) {
throw std::runtime_error("unexpected end of file in xyz file");
Expand Down
5 changes: 3 additions & 2 deletions src/csg_boltzmann/main.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2019 The VOTCA Development Team (http://www.votca.org)
* Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,6 +29,7 @@
#include <math.h>
#include <string>
#include <votca/csg/csgapplication.h>
#include <votca/tools/getline.h>
#include <votca/tools/rangeparser.h>
#include <votca/tools/tokenizer.h>

Expand Down Expand Up @@ -181,7 +182,7 @@ void CsgBoltzmann::InteractiveMode() {
while (1) {
string line;
cout << "> ";
getline(cin, line);
votca::tools::getline(cin, line);

boost::trim(line);

Expand Down
6 changes: 3 additions & 3 deletions src/libcsg/imcio.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2019 The VOTCA Development Team (http://www.votca.org)
* Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -115,7 +115,7 @@ Eigen::MatrixXd imcio_read_matrix(const std::string &filename) {
std::vector<double> result;
Index numrows = 0;
size_t numcols = 0;
while (getline(intt, line)) {
while (tools::getline(intt, line)) {
if (line[0] == '#') {
continue;
}
Expand Down Expand Up @@ -148,7 +148,7 @@ std::vector<std::pair<std::string, tools::RangeParser> > imcio_read_index(
std::vector<std::pair<std::string, tools::RangeParser> > indeces;
string line;
// read till the first data line
while (getline(in, line)) {
while (tools::getline(in, line)) {
// remove comments and xmgrace stuff
line = line.substr(0, line.find("#"));
line = line.substr(0, line.find("@"));
Expand Down
6 changes: 3 additions & 3 deletions src/libcsg/modules/io/dlpolytopologyreader.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2019 The VOTCA Development Team (http://www.votca.org)
* Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,7 +47,7 @@ string DLPOLYTopologyReader::_NextKeyline(ifstream &fs, const char *wspace)
size_t i_nws = 0;

do {
getline(fs, line);
tools::getline(fs, line);

if (fs.eof()) {
throw std::runtime_error("Error: unexpected end of dlpoly file '" +
Expand Down Expand Up @@ -374,7 +374,7 @@ bool DLPOLYTopologyReader::ReadTopology(string file, Topology &top) {
}

#ifdef DEBUG
getline(fl, line); // is "close" found?
tools::getline(fl, line); // is "close" found?
if (line == "close") {
cout << "Read from dlpoly file '" << _fname << "' : '" << line
<< "' - done with topology" << endl;
Expand Down
16 changes: 8 additions & 8 deletions src/libcsg/modules/io/dlpolytrajectoryreader.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2019 The VOTCA Development Team (http://www.votca.org)
* Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -102,14 +102,14 @@ bool DLPOLYTrajectoryReader::NextFrame(Topology &conf) {

if (_first_frame) {

getline(_fl, line); // title
tools::getline(_fl, line); // title

#ifdef DEBUG
cout << "Read from dlpoly file '" << _fname << "' : '" << line
<< "' - header" << endl;
#endif

getline(_fl, line); // 2nd header line
tools::getline(_fl, line); // 2nd header line

#ifdef DEBUG
cout << "Read from dlpoly file '" << _fname << "' : '" << line
Expand Down Expand Up @@ -179,8 +179,8 @@ bool DLPOLYTrajectoryReader::NextFrame(Topology &conf) {
// read normal frame

if (!_isConfig) {
getline(_fl, line); // timestep line - only present in HISTORY, and not in
// CONFIG
tools::getline(_fl, line); // timestep line - only present in HISTORY, and
// not in CONFIG
#ifdef DEBUG
cout << "Read from dlpoly file '" << _fname << "' : '" << line << "'"
<< endl;
Expand Down Expand Up @@ -283,7 +283,7 @@ bool DLPOLYTrajectoryReader::NextFrame(Topology &conf) {
Eigen::Matrix3d box = Eigen::Matrix3d::Zero();
for (Index i = 0; i < 3; i++) { // read 3 box/cell lines

getline(_fl, line);
tools::getline(_fl, line);

#ifdef DEBUG
cout << "Read from dlpoly file '" << _fname << "' : '" << line
Expand All @@ -308,7 +308,7 @@ bool DLPOLYTrajectoryReader::NextFrame(Topology &conf) {
for (Index i = 0; i < natoms; i++) {

{
getline(_fl, line); // atom header line
tools::getline(_fl, line); // atom header line

#ifdef DEBUG
cout << "Read from dlpoly file '" << _fname << "' : '" << line << "'"
Expand Down Expand Up @@ -336,7 +336,7 @@ bool DLPOLYTrajectoryReader::NextFrame(Topology &conf) {
Eigen::Matrix3d atom_vecs = Eigen::Matrix3d::Zero();
for (Index j = 0; j < std::min(navecs, Index(2)) + 1; j++) {

getline(_fl, line); // read atom positions
tools::getline(_fl, line); // read atom positions

#ifdef DEBUG
cout << "Read from dlpoly file '" << _fname << "' : '" << line << "'"
Expand Down
10 changes: 5 additions & 5 deletions src/libcsg/modules/io/groreader.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2019 The VOTCA Development Team (http://www.votca.org)
* Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -61,11 +61,11 @@ bool GROReader::FirstFrame(Topology &top) {

bool GROReader::NextFrame(Topology &top) {
string tmp;
getline(_fl, tmp); // title
tools::getline(_fl, tmp); // title
if (_fl.eof()) {
return !_fl.eof();
}
getline(_fl, tmp); // number atoms
tools::getline(_fl, tmp); // number atoms
Index natoms = std::stoi(tmp);
if (!_topology && natoms != top.BeadCount()) {
throw std::runtime_error(
Expand All @@ -74,7 +74,7 @@ bool GROReader::NextFrame(Topology &top) {

for (Index i = 0; i < natoms; i++) {
string line;
getline(_fl, line);
tools::getline(_fl, line);
string resNum, resName, atName, x, y, z;
try {
resNum = string(line, 0, 5); // %5i
Expand Down Expand Up @@ -142,7 +142,7 @@ bool GROReader::NextFrame(Topology &top) {
}
}

getline(_fl, tmp); // read box line
tools::getline(_fl, tmp); // read box line
if (_fl.eof()) {
throw std::runtime_error(
"unexpected end of file in poly file, when boxline");
Expand Down
Loading

0 comments on commit 7165e42

Please sign in to comment.