I have many C ++ classes that read data from a file stream. The functions are as follows.
bool LoadFromFile(class ifstream &file);
I am creating a new function to read from memory instead of a file. So I googled around, and istringstream seems to do the trick without any changes to the code.
bool LoadFromData(class istringstream &file);
Now my question. I need to build this stream to read from a char array. The line does not end with zero, this is pure binary data, and I got an integer with size. I tried to assign it to a string and create a stream from the string, however the string ends after the null character .. and the data is copied.
int size;
char *data;
string s = *data;
How to create a string from a char array pointer without copying data + with indicating the size of the pointer data? Do you know any other solution besides a string?