mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add readStream helper in libsolutil
This commit is contained in:
parent
b24f2e0215
commit
1a3feff9ec
@ -68,14 +68,14 @@ string solidity::util::readFileAsString(string const& _file)
|
||||
return readFile<string>(_file);
|
||||
}
|
||||
|
||||
string solidity::util::readStandardInput()
|
||||
string solidity::util::readStream(istream& _stream)
|
||||
{
|
||||
string ret;
|
||||
while (!cin.eof())
|
||||
while (!_stream.eof())
|
||||
{
|
||||
string tmp;
|
||||
// NOTE: this will read until EOF or NL
|
||||
getline(cin, tmp);
|
||||
getline(_stream, tmp);
|
||||
ret.append(tmp);
|
||||
ret.append("\n");
|
||||
}
|
||||
|
@ -36,8 +36,11 @@ namespace solidity::util
|
||||
/// If the file is empty, returns an empty string.
|
||||
std::string readFileAsString(std::string const& _file);
|
||||
|
||||
/// Returns the contents of the stream (until EOF).
|
||||
std::string readStream(std::istream& _stream);
|
||||
|
||||
/// Retrieve and returns the contents of standard input (until EOF).
|
||||
std::string readStandardInput();
|
||||
inline std::string readStandardInput() { return readStream(std::cin); }
|
||||
|
||||
/// Retrieve and returns a character from standard input (without waiting for EOL).
|
||||
int readStandardInputChar();
|
||||
|
Loading…
Reference in New Issue
Block a user