O
Otac0n
This seems to be an impossible task, but here goes:
Im looking for a C++ stl non-blocking input routine.
I would normally be able to whip one up myself,
if the STL functions were behaving in MSVC++.
(This doesnt have to be portable necessarily, but at least mus work on
VC++)
I have:
-----------------------------------------------
// Fastforward
std::cin.seekg(std::ios_base::end);
// Execute all commands available in the buffer
while((int)std::cin.tellg() > 0)
{
// Rewind
std::cin.seekg(0);
// Extrapolate one line from the stream
std::cin.getline(buffer, 99, '\n');
command = buffer;
Execute(command);
// Fastforward
std::cin.seekg(std::ios_base::end);
}
-----------------------------------------------
But that seems to get stuck inside the while-loop after the first line
of text is passed (through a pipe).
It should also be noted that in every state of execution,
cin.rdbuf()->in_avail()
returns zero.
If someone could shed light on WHY
(int)std::cin.tellg()
returns 2 at the end of an empty input stream, that would be
appreciated as well.
Thank you in advance,
John Gietzen
"Spoonful of Tactic"
Im looking for a C++ stl non-blocking input routine.
I would normally be able to whip one up myself,
if the STL functions were behaving in MSVC++.
(This doesnt have to be portable necessarily, but at least mus work on
VC++)
I have:
-----------------------------------------------
// Fastforward
std::cin.seekg(std::ios_base::end);
// Execute all commands available in the buffer
while((int)std::cin.tellg() > 0)
{
// Rewind
std::cin.seekg(0);
// Extrapolate one line from the stream
std::cin.getline(buffer, 99, '\n');
command = buffer;
Execute(command);
// Fastforward
std::cin.seekg(std::ios_base::end);
}
-----------------------------------------------
But that seems to get stuck inside the while-loop after the first line
of text is passed (through a pipe).
It should also be noted that in every state of execution,
cin.rdbuf()->in_avail()
returns zero.
If someone could shed light on WHY
(int)std::cin.tellg()
returns 2 at the end of an empty input stream, that would be
appreciated as well.
Thank you in advance,
John Gietzen
"Spoonful of Tactic"