사용법
// //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
'C++(일반)' 카테고리의 다른 글
_memcpy(...) with start Index. (0) | 2016.03.27 |
---|---|
char 와 unsigned char (0) | 2016.03.27 |
c++ memorystream (0) | 2016.03.25 |
istream(ofstream) 사용시 주의점 ios::binary (0) | 2016.03.25 |
VisualStudio용 StaticLib 적용하기를 도와주는 헬퍼 유틸 (0) | 2016.03.19 |
libjepg.lib 를 VS 버전에 맞게 쉽게 얻기 (0) | 2016.03.16 |