Good afternoon, there was a need to work with a certain block of memory through the istream interface, without copying this data. I read the help on the streams here: www.cplusplus.com , but I still have not figured out what to do.
I suppose you need to create an istringstream class object and associate a buffer with a specific block of memory? If this is true, then how to do it? The buffer is a closed member, and I saw only the rdbuf () method for reading the buffer address, how to determine the pointer to the buffer, I did not understand ... In short, I have no idea what to do, I will be grateful for the help and hints .
Here is what I did, “to make it work right now”:
HRSRC hRes=FindResource(0,L"coordsx",RT_RCDATA); HGLOBAL hGlob=LoadResource(0,hRes); unsigned int sz = SizeofResource(0,hRes); std::string ts((char*)hGlob,sz); std::istringstream ins(ts,std::ios_base::in|std::ios_base::binary);
ins is here a target object, it has an istream interface, which is what is required in my situation, but as far as I understand, in this process there is already twice as much data copying - a simple area of memory => std :: string => std :: stringbuf , here I want to somehow manage to do without unnecessary copying ...