initializing a C++ std::istringstream from an in memory buffer?

前端 未结 4 925
时光取名叫无心
时光取名叫无心 2020-11-30 06:22

I have a memory block (opaque), that I want to store in a Blob in mySQL through their C++ adapter. The adapter expects a istream:

virtual void setBlob(unsign         


        
4条回答
  •  失恋的感觉
    2020-11-30 06:39

    Untested but perhaps worth a test...

    std::stringstream ss;
    ss.write( blockPtr, blockLength );
    ss.seekg(0);
    

    Then call that setBlob function with ss. Your still have that internal buffer in std::stringstream as jalf already mentioned though.

提交回复
热议问题