istream

IWebBrowser: How to specify the encoding when loading html from a stream?

Using the concepts from the sample code provided by Microsoft for loading HTML content into an IWebBrowser from an IStream using the web browser's IPersistStreamInit interface: pseudocode: void LoadWebBrowserFromStream(IWebBrowser webBrowser, IStream stream) { IPersistStreamInit persist = webBrowser.Document as IPersistStreamInit; ...

How do I declare an IStream in idl so visual studio maps it to s.w.interop.comtypes?

hi I have a COM object that takes needs to take a stream from a C# client and processes it. It would appear that I should use IStream. So I write my idl like below. Then I use MIDL to compile to a tlb, and compile up my solution, register it, and then add a reference to my library to a C# project. Visual Studio creates an IStream defin...

In which DLL is the COM interface iStream defined?

I'm a complete newbie to Windows and COM programming, trying to use com4j in order to call a COM object from Java. Com4j generates Java interfaces from COM definitions "often found in .ocx, .dll, .exe, and/or .tlb files" . It was easy for me to locate the .ocx file of my target COM object, but I have no clue regarding the standard inte...

Accessing "Mapi32.dll" with C#. [not solved]

Hello, I am using VS 2008 C# Windows Application. I have this DLL Import I am trying to use. [DllImport("Mapi32.dll", PreserveSig = true)] private static extern void WrapCompressedRTFStream( [MarshalAs(UnmanagedType.Interface)] UCOMIStream lpCompressedRTFStream, uint ulflags, [MarshalAs(UnmanagedType.Interface)] out UCOMIStream lpUnco...

How to create C++ istringstream from a char array with null(0) characters?

I have a char array which contains null characters at random locations. I tried to create an iStringStream using this array (encodedData_arr) as below, I use this iStringStream to insert binary data(imagedata of Iplimage) to a MySQL database blob field(using MySQL Connector/C++'s setBlob(istream *is) ) it only stores the characters upt...

Copying from istream never stops

This bit of code runs infinitely: copy(istream_iterator<char>(cin), istream_iterator<char>(), back_inserter(buff)); The behavior I was expecting is that it will stop when I press enter. However it doesn't. buff is a vector of chars. ...

istream stop at \n

Is there any way of telling istream to keep going until it hits \n instead of normal white space and with out the use of getline and also keeping any format options in the stream? Thanks. ...

std::ostream interface to an OLE IStream

I have a Visual Studio 2008 C++ application using IStreams. I would like to use the IStream connection in a std::ostream. Something like this: IStream* stream = /*create valid IStream instance...*/; IStreamBuf< WIN32_FIND_DATA > sb( stream ); std::ostream os( &sb ); WIN32_FIND_DATA d = { 0 }; // send the structure along the IStream os...

Extracting bool from istream in a templated function

I'm converting my fields class read functions into one template function. I have field classes for int, unsigned int, long, and unsigned long. These all use the same method for extracting a value from an istringstream (only the types change): template <typename Value_Type> Value_Type Extract_Value(const std::string& input_string) { ...

copying from a std::istreambuf_iterator<> to a std::vector<>

I have a Visual Studio 2008 C++ application where I would like to treat a stream as a set of iterators. For example, if I were to receive an array of WIN32_FIND_DATA structures over the stream, I would like to be able to do something like this: IStreamBuf< WIN32_FIND_DATA > sb( stream ); std::vector< WIN32_FIND_DATA > buffer; std::copy...

Reading from istream

How can I extract data (contents) from istream without using operator>>() ?. ...

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 pushed to an istream for subsequent programmatic manipulation. Is this possible? I would...

non-copying istringstream

So istringstream copies the contents of a string when initialised, e.g string moo("one two three four"); istringstream iss(moo.c_str()); I was wondering if there's a way to make std::istringstream use the given c_str as its buffer without copying things. This way, it wont have to copy large bits of memory before passing the std::istri...

download a file using windows IStream

I'm implementing dragging a virtual file out of a website and onto the desktop with an activex control. How do I create an IStream on my http url, so Windows can execute the drop? The example I'm looking at uses SHCreateStreamOnFile to copy a local file; there must be an analogous function for other types of streams like http file dow...

How do I implement seekg() for a custom istream/streambuf?

I used to be a C++ expert a decade ago, but for the past 10 years I've been programming Java. I just started a C++ project that uses a small third-party XML parser. The XML parser accepts an STL istream. My XML data is coming from a Windows COM IStream. I thought I'd do the Right Thing and create an adapter to take the IStream data and p...

Unexpected behaviour of getline() with ifstream

To simplify, I'm trying to read the content of a CSV-file using the ifstream class and its getline() member function. Here is this CSV-file: 1,2,3 4,5,6 And the code: #include <iostream> #include <typeinfo> #include <fstream> using namespace std; int main() { char csvLoc[] = "/the_CSV_file_localization/"; ifstream csvFile; ...

Find the end of stream for cin & ifstream?

Hi, I'm running myself through a C++ text book that I have as a refresher to C++ programming. One of the practice problems (without going into too much detail) wants me to define a function that can be passed ifstream or cin (e.g. istream) as an argument. From there, I have to read through the stream. Trouble is, I can't figure out a wa...

Why does istream_iterator<unsigned char, unsigned char> throw std::bad_cast?

What is going on? #include <iostream> #include <iterator> #include <sstream> int main() { std::basic_stringbuf<unsigned char> buf; std::basic_istream<unsigned char> stream(&buf); // the next line throws std::bad_cast on g++ 4.4 std::istream_iterator<unsigned char, unsigned char> it(stream); } I've tried stream.write(s...

"carbon-copy" a c++ istream?

For my very own little parser framework, I am trying to define (something like) the following function: template <class T> // with operator>>( std::istream&, T& ) void tryParse( std::istream& is, T& tgt ) { is >> tgt /* , *BUT* store every character that is consumed by this operation in some string. If afterwards, is.fail() (whi...

C++ common interface for "cin" and "File"

Is there a common interface for cin and file input? I want to make a program that has an optional parameter prog [input-file] If an input file is specified, then it should read from the file, and if not, it should read from cin. From what I can tell, they both implement istream. How would you set up it so that I could do something l...