Questions tagged [istream]

In C++ std::istream is the base class for input streams.

696 questions
5
votes
4 answers

Understanding the design of std::istream::read

std::istream has the prototype istream& read (char* s, streamsize n) the actual number of bytes read should be gotten by calling istream::gcount(), also the validity of the istream can be known from ios::good. I was discussing another stream class'…
legends2k
  • 31,634
  • 25
  • 118
  • 222
5
votes
4 answers

"carbon-copy" a c++ istream?

For my very own little parser framework, I am trying to define (something like) the following function: template // with operator>>( std::istream&, T& ) void tryParse( std::istream& is, T& tgt ) { is >> tgt /* , *BUT* store every…
srs
  • 558
  • 4
  • 9
5
votes
2 answers

Is the std::istream type EqualityComparable?

My question would have a boolean answer: yes or not. Whichever it would be, can someone explain how the following code is compiled by both GNU-g++ 4.9.2 and clang 3.5, while GNU-g++ 5.1.1 no longer accepts it, claiming that there is no matching…
GSi
  • 649
  • 3
  • 10
5
votes
1 answer

Can one read a remote file as an istream with libcurl?

I'd like to use the libcurl library to open a remote date file and iterate through it with an istream. I've looked through the nice example in this thread but it writes the remote file to a local file. Instead I'd like to have the remote reads be…
jobu
  • 93
  • 4
5
votes
2 answers

Using a regex_iterator on an istream

I want to be able to solve problems like this: Getting std :: ifstream to handle LF, CR, and CRLF? where an istream needs to be tokenized by a complex delimiter; such that the only way to tokenize the istream is to: Read it in the istream a…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
5
votes
1 answer

How to dump (write) IStream's content into file (Image)

I have an IStream which I know it contains a PNG file, but I can't write its content into a file like normal I/O stream, I don't know if I am doing something wrong or I should do a different thing for writing IStream into file. IStream…
Am1rr3zA
  • 7,115
  • 18
  • 83
  • 125
5
votes
3 answers

Input stream iterators and exceptions

I was playing around with istream iterators and exception handling a few days ago and I came across with this curiousity: #include #include #include #include using namespace std; int main(int argc, char*…
5
votes
1 answer

C++ istream: Is gcount() always set after a read() even if it fails?

I am reading some data using an istream and read(). I would like to know if I can just test gcount() for the bytes or if I need to test some combination of good(), eof(), etc before calling gcount(). In other words, is gcount() always set after a…
loop
  • 3,460
  • 5
  • 34
  • 57
5
votes
3 answers

Skipping input stream values

Is there any easy mechanism to skip until the next whitespace with a C++ input stream (like ifstream)? I know that I can use ignore if I know how many characters to skip or what delimiter to expect. But IMO it's ugly to use ignore when operator>>…
Excelcius
  • 1,680
  • 1
  • 14
  • 31
5
votes
2 answers

Reading SDL_RWops from a std::istream

I'm quite surprised that Google didn't find a solution. I'm searching for a solution that allows SDL_RWops to be used with std::istream. SDL_RWops is the alternative mechanism for reading/writing data in SDL. Any links to sites that tackle the…
Kornel Kisielewicz
  • 55,802
  • 15
  • 111
  • 149
5
votes
3 answers

C# and IStream.Read

I'm trying to use System.Runtime.InteropServices.ComTypes.IStream from C#, but I'm having some trouble. According to MSDN, the C# definition looks like this: void Read( byte[] pv, int cb, IntPtr pcbRead ) Basically, I can read data…
Jeff Godfrey
  • 718
  • 8
  • 18
5
votes
2 answers

What implicit conversions happen with istream?

I found a piece of C-ish C++ code and asked myself the (slightly academic) question, what implicit type conversions happen here to arrive at the bool that if requires? int val; if( (std::cin >> val) == 0 ) ... I got this far: std::cin >> val…
towi
  • 21,587
  • 28
  • 106
  • 187
5
votes
2 answers

C++: how is istream is converted to bool inside a conditional expression

The istream operator>> is used to read the data and the function returns reference to istream. For example, istream& operator>> (bool& val); But how does the istream is converted into a bool when it is used inside the conditional statement. For…
veda
  • 6,416
  • 15
  • 58
  • 78
5
votes
3 answers

Something like istream::getline() but with alternative delim characters?

What's the cleanest way of getting the effect of istream::getline(string, 256, '\n' OR ';')? I know it's quite straightforward to write a loop, but I feel that I might be missing something. Am I? What I used: while ((is.peek() != '\n') && (is.peek()…
Erika
  • 416
  • 5
  • 14
5
votes
2 answers

Drag and drop from C# to Windows Explorer with IStorage/IStream

I've been working on what sounds like simple functionality for way too long now. The idea is that I have an application with a TreeView. This treeview represents contents of a database organized into files and folders, much like Windows Explorer. So…
Eric