Added additional constructor to StringStream class for convenience.
authorDavid van der Spoel <spoel@xray.bmc.uu.se>
Sun, 2 Aug 2015 09:11:44 +0000 (11:11 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Fri, 28 Aug 2015 10:04:55 +0000 (12:04 +0200)
Change-Id: Ia2b7753991ffbb6b1f80bd0dcbdf81af9271a69b

src/gromacs/utility/stringstream.cpp
src/gromacs/utility/stringstream.h

index 77e2388ea2487cb7067790e9d13cf1e1c3b49687..f5ab8858424f416752f30f713124cfa2f3802fef 100644 (file)
@@ -65,6 +65,12 @@ StringInputStream::StringInputStream(const std::string &input)
 {
 }
 
+StringInputStream::StringInputStream(const std::vector<std::string> &input)
+    : input_(joinStrings(input.begin(), input.end(), "\n")), pos_(0)
+{
+    input_.append("\n");
+}
+
 StringInputStream::StringInputStream(ConstArrayRef<const char *> const &input)
     : input_(joinStrings(input.begin(), input.end(), "\n")), pos_(0)
 {
index 4011688facc71121723d2768e95d41a0081ef191..19c42c9864b004f5be86507c16125a8523892510 100644 (file)
@@ -45,6 +45,7 @@
 #define GMX_UTILITY_STRINGSTREAM_H
 
 #include <string>
+#include <vector>
 
 #include "gromacs/utility/textstream.h"
 
@@ -92,6 +93,14 @@ class StringInputStream : public TextInputStream
          * \param[in] input String to be served by the stream.
          */
         explicit StringInputStream(const std::string &input);
+        /*! \brief
+         * Constructor that stores input lines in a string.
+         *
+         * The vector of strings is stored as a string separated by newline.
+         *
+         * \param[in] input String to be served by the stream.
+         */
+        explicit StringInputStream(const std::vector<std::string> &input);
         /*! \brief
          * Constructor that stores input lines in a string.
          *