Modernize read_inpfile
authorMark Abraham <mark.j.abraham@gmail.com>
Wed, 21 Dec 2016 05:19:22 +0000 (16:19 +1100)
committerMark Abraham <mark.j.abraham@gmail.com>
Mon, 13 Mar 2017 12:40:44 +0000 (13:40 +0100)
commitc69bdc60aea80edc753825a1781a0832632bc526
treedcc62463d7bece9d8f6ace4861c44233d5cd8733
parent93c7f07bdc117a3d69c500ce93418083225b0acf
Modernize read_inpfile

Used std::string and gmx::TextReader to simplify this. It is likely no
longer as efficient because it now makes several std::string objects
per line, but this is not a significant part of the execution time of
e.g. grompp.

Move COMMENTSIGN to cstringutil.cpp, now that this is an
implementation detail of string-handling code, rather than also used
in readinp.cpp.

Moved responsibility for stripping of comments to TextReader, reworked
its whitespace-trimming behaviour, and introduced some tests for that
class.

Introduced some TODO items to reconsider multiple behaviours where
read_inpfile ignores what could be malformed input. It is used for
grompp, xpm2ps and membed, however, so it is not immediately clear
what fixes might be appropriate, and we might anyway remove this
code shortly.

Introduced catches for exceptions that might be thrown while calling
read_inpfile (and related code that might change soon).

Added tests for newly introduced split-and-trim functionality that
supports read_inpfile.

Refs #2074

Change-Id: Id9c46d60a3ec7ecdcdb9529bba2fdb68ce241914
17 files changed:
src/gromacs/commandline/cmdlinehelpmodule.cpp
src/gromacs/fileio/readinp.cpp
src/gromacs/fileio/readinp.h
src/gromacs/gmxana/gmx_xpm2ps.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/readir.cpp
src/gromacs/utility/cstringutil.cpp
src/gromacs/utility/cstringutil.h
src/gromacs/utility/stringutil.cpp
src/gromacs/utility/stringutil.h
src/gromacs/utility/tests/CMakeLists.txt
src/gromacs/utility/tests/stringutil.cpp
src/gromacs/utility/tests/textreader.cpp [new file with mode: 0644]
src/gromacs/utility/textreader.cpp
src/gromacs/utility/textreader.h
src/programs/mdrun/membed.cpp
src/testutils/stringtest.h