Merge branch 'master' into pygromacs
[alexxy/gromacs.git] / src / gromacs / utility / stringstream.h
index 899a304a12668cefe6d06de78dccdbf70e7edf62..4011688facc71121723d2768e95d41a0081ef191 100644 (file)
@@ -46,7 +46,6 @@
 
 #include <string>
 
-#include "gromacs/utility/classhelpers.h"
 #include "gromacs/utility/textstream.h"
 
 namespace gmx
@@ -75,6 +74,41 @@ class StringOutputStream : public TextOutputStream
         std::string str_;
 };
 
+template<typename T> class ConstArrayRef;
+
+/*! \libinternal \brief
+ * Helper class to convert static string data to a stream.
+ *
+ * Provides a text input stream that returns lines from a string
+ */
+class StringInputStream : public TextInputStream
+{
+    public:
+        /*! \brief
+         * Constructor that stores input lines in a string.
+         *
+         * The string is internally but no processing is done.
+         *
+         * \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 array of char * is stored as a string separated by newline.
+         *
+         * \param[in] input Array of char * to be served by the stream.
+         */
+        explicit StringInputStream(ConstArrayRef<const char *> const &input);
+
+        // From TextInputStream
+        virtual bool readLine(std::string *line);
+        virtual void close() {};
+    private:
+        std::string input_;
+        size_t      pos_;
+};
+
 } // namespace gmx
 
 #endif