Rework using libsolutil

This commit is contained in:
Alex Beregszaszi 2021-05-13 19:37:39 +01:00
parent 1a3feff9ec
commit 2169880d85
2 changed files with 6 additions and 26 deletions

View File

@ -489,28 +489,6 @@ string TestFileParser::parseString()
return literal; return literal;
} }
namespace {
string _readStream(istream& _stream)
{
string ret;
while (!_stream.eof())
{
string tmp;
// NOTE: this will read until EOF or NL
getline(_stream, tmp);
ret.append(tmp);
ret.append("\n");
}
return ret;
}
}
void TestFileParser::Scanner::readStream(istream& _stream)
{
m_line = _readStream(_stream);
m_char = m_line.begin();
}
void TestFileParser::Scanner::scanNextToken() void TestFileParser::Scanner::scanNextToken()
{ {
// Make code coverage happy. // Make code coverage happy.

View File

@ -16,6 +16,7 @@
#include <liblangutil/Exceptions.h> #include <liblangutil/Exceptions.h>
#include <libsolutil/CommonData.h> #include <libsolutil/CommonData.h>
#include <libsolutil/CommonIO.h>
#include <test/libsolidity/util/SoltestTypes.h> #include <test/libsolidity/util/SoltestTypes.h>
#include <iosfwd> #include <iosfwd>
@ -71,10 +72,11 @@ private:
public: public:
/// Constructor that takes an input stream \param _stream to operate on. /// Constructor that takes an input stream \param _stream to operate on.
/// It reads all lines into one single line, keeping the newlines. /// It reads all lines into one single line, keeping the newlines.
Scanner(std::istream& _stream) { readStream(_stream); } Scanner(std::istream& _stream):
m_line(readStream(_stream))
/// Reads input stream into a single line and resets the current iterator. {
void readStream(std::istream& _stream); m_char = m_line.begin();
}
/// Reads character stream and creates token. /// Reads character stream and creates token.
void scanNextToken(); void scanNextToken();