c++ Programming Glossary: membuf
Creating an input stream from constant memory http://stackoverflow.com/questions/13059091/creating-an-input-stream-from-constant-memory done like this #include streambuf #include istream struct membuf std streambuf membuf char const base size_t size char p const_cast.. streambuf #include istream struct membuf std streambuf membuf char const base size_t size char p const_cast char base this.. char base this setg p p p size struct imemstream virtual membuf std istream imemstream char const base size_t size membuf base..
Simpler way to create a C++ memorystream from (char*, size_t), without copying the data? http://stackoverflow.com/questions/2079912/simpler-way-to-create-a-c-memorystream-from-char-size-t-without-copying-t couldn't find anything ready made so I came up with class membuf public basic_streambuf char public membuf char p size_t n setg.. up with class membuf public basic_streambuf char public membuf char p size_t n setg p p p n setp p p n Usage char mybuffer.. length ... allocate mybuffer put data into it set length membuf mb mybuffer length istream reader mb use reader I know of stringstream..
Get an istream from a char* http://stackoverflow.com/questions/7781898/get-an-istream-from-a-char #include istream #include streambuf #include string struct membuf std streambuf membuf char begin char end this setg begin begin.. streambuf #include string struct membuf std streambuf membuf char begin char end this setg begin begin end int main char.. buffer I'm a buffer with embedded nulls 0and line n feeds membuf sbuf buffer buffer sizeof buffer std istream in sbuf std string..
|