c++ memorystream


ByteUtils.h


사용법

   //
    //write
    //
    byte_utils::mem_ostream out;
    out << "this is header";
    out << png_data.size();
    for (int i = 0; i < png_data.size(); i++)
    {
        out << png_data.getBinaryBuffer()[i];
    }

    

    //
    //read
    //
    int read_size = out.get_internal_vec().size();
    byte_utils::mem_istream in(out.get_ptr() , read_size);
    cout << " out.get_internal_vec() :  " << out.get_internal_vec().size() << endl;
    cout << " in size " << in.get_internal_vec().size() << endl;


    string header;
    in >> header;
    cout << "header : " << header << endl;
    int len = 0;
    in >> len;
    char* _real_data = new char[len];
    for (int i = 0; i < len; i++)
    {
        in >> _real_data[i];
    }


ㅁㅁ

장점 << 와 >> 로 손쉽게 순서에 맞추어 사용이 가능 하다.


출처 : http://www.codeproject.com/Tips/808776/Cplusplus-Simplistic-Binary-Streams

Yamecoder 야매코더_
C++(일반) 2016.03.25 22:01

댓글을 달아 주세요

Powerd by Tistory, designed by criuce
rss