mercredi 2 mars 2016

Decompress file from Boost filtering_streambuf to std::vector

I am writing a program that performs ssl 3.1 encryption decryption data exchange. I receive data which is also compressed in the gzip format. I am able to decrypt this data and print it to my console, using this chuck of code :

void decompress(unsigned char * arr, int nCopySize, std::vector <unsigned char>& vecArg)
{
    using namespace boost::iostreams;
    using namespace boost::interprocess;
    std::string str1(reinterpret_cast<const char *>(arr), nCopySize);
    auto sizeT = str1.size();
    stringstream file2(str1, ios_base::in | ios_base::binary);
    filtering_streambuf<input> iin;
    iin.push(gzip_decompressor());
    iin.push(file2);
    boost::iostreams::copy(iin, cout);

//stops working here (the decompressed code was successfully printed in console)

    boost::interprocess::basic_vectorstream<std::vector<char>> vectorStream;
    boost::iostreams::copy(iin, vectorStream); // this produces compile time error
    std::vector<unsigned char> chars(
        vectorStream.vector().begin(),
        vectorStream.vector().end()
        );


}

I am trying to store the decompressed code into an unsigned char vector but while using the last chunk of code found here : Decompress file from Boost filtering_streambuf to std::vector<char>? I am having this compile time error :

Error   5   error C2243: 'type cast' : conversion from 'boost::interprocess::basic_vectorstream<std::vector<char,std::allocator<char>>,std::char_traits<char>> *' to 'volatile const std::basic_streambuf<char,std::char_traits<char>> *' exists, but is inaccessible   c:\boost_1_59_0\boost\iostreams\traits.hpp  57  1   TeraLauncher

I have done other tries, using char arrays or string, managed to compile but ran into run time crash. Ideally, I would like it to work with the code I have written (std::vector). Thanks

Aucun commentaire:

Enregistrer un commentaire