Для тех из вас, кто ищет ответ, вот что я придумал, чтобы прочитать консольный буфер в std::string
.
// Create a mock stream just for this example
Glib::RefPtr<Gio::MemoryOutputStream> bufStream =
Gio::MemoryOutputStream::create(NULL, 0, &realloc, &free);
// Create the stringstream to use as an ostream
std::stringstream ss;
// Get the stream size so we know how much to allocate
gsize streamSize = bufStream->get_data_size();
char *charBuf = new char[streamSize+1];
// Copy over the data from the buffer to the charBuf
memcpy(charBuf, bufStream->get_data(), streamSize);
// Add the null terminator to the "string"
charBuf[streamSize] = '\0';
// Create a string from it
ss << charBuf;
Надеюсь, что это поможет кому-то в будущем, ктосталкивается с аналогичной проблемой.