#include <string>
+#include "gromacs/utility/arrayref.h"
+#include "gromacs/utility/stringutil.h"
+
namespace gmx
{
{
}
+StringInputStream::StringInputStream(const std::string &input)
+ : input_(input), pos_(0)
+{
+}
+
+StringInputStream::StringInputStream(ConstArrayRef<const char *> const &input)
+ : input_(joinStrings(input.begin(), input.end(), "\n")), pos_(0)
+{
+ input_.append("\n");
+}
+
+bool StringInputStream::readLine(std::string *line)
+{
+ if (pos_ == input_.size())
+ {
+ line->clear();
+ return false;
+ }
+ else
+ {
+ size_t newpos = input_.find("\n", pos_);
+ if (newpos == std::string::npos)
+ {
+ newpos = input_.size();
+ }
+ else
+ {
+ // To include the newline as well!
+ newpos += 1;
+ }
+ line->assign(input_.substr(pos_, newpos-pos_));
+ pos_ = newpos;
+ return true;
+ }
+}
+
} // namespace gmx