I need to call a function with the following prototype:
XmlDocument( std::basic_istream< TCHAR > & stream )
I'm trying to open a file and pass the stream in, but I can't figure out how to convert an istream into a basic_istream.
I need to call a function with the following prototype:
XmlDocument( std::basic_istream< TCHAR > & stream )
I'm trying to open a file and pass the stream in, but I can't figure out how to convert an istream into a basic_istream.
What kind of stream is it? ifstream? An ifstream is a basic_istream<char> and should work if UNICODE is not defined for your project. A wifstream is a basic_istream<wchar_t> and should work if UNICODE is defined for your project. I don't know if this exists but a tifstream would be either an ifstream or a wifstream depending on whether UNICODE was defined or not, and therefore a tifstream would always work.
If UNICODE is defined, but you have an ifstream and you cannot change it to use a wifstream or tifstream, then you will have to do some extra work.
If tifstream doesn't exist maybe you could define it yourself. Examples should be readily available.
As you can see from here, istream is defined as
Also, from here you can see that the default second template argument is char_traits<charT>:Code:typedef basic_istream<char, char_traits<char> > istream;
So you need to convert an istream (a.k.a. basic_istream<char, char_traits<char> >) to a basic_istream<TCHAR> (a.k.a. basic_istream<TCHAR, char_traits<TCHAR> >). If you assume that char and TCHAR are the same thing, you can just use a cast -- but that's probably a bad thing to assume. [edit] See Daved's post above. [/edit]Code:namespace std { template<class charT, class traits = char_traits<charT> > class basic_istream; }
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
You can't use a cast. It either works automatically or it doesn't because UNICODE is defined and the character types are different.