I am writing a custom Streamer, which is supposed to save my object as a CSV file and read it accordingly. As far as I understand, this is just a matter of implementing a
void Streamer(TBuffer&) method and writing/reading data to/from
My problem is that I cannot find any examples of reading from TBuffer, nor I could find unit tests in the ROOT sources which would demonstrate this. I tried the following ways:
root  std::string out; root  TBufferFile f(TBuffer::EMode::kRead, 13, (void*)"first\nsecond"); root  f >> out; ROOT_prompt_2:1:3: error: invalid operands to binary expression ('TBufferFile' and 'std::string' (aka 'basic_string<char>')) f >> out; ~ ^ ~~~
root  f.ReadStdString(out); root  out (std::string &) "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
As you can see, they seem to fail. That being said, I am aware that I could use
f.Buffer(), but I am not sure if I can assume that returned string will contain always the whole file/message/object (not 1024 first characters for example). In this case, I can see that the string is there indeed:
root  f.Buffer() (char *) "first second"
Could I ask you for some recommendations on how should I approach this? Getting the input line-by-line would be ideal in the case of CSV format.
ROOT Version: v6.24.06
Compiler: GCC v7.3.0