/*--------------------------------------------------------------- vectorToBinaryFile ---------------------------------------------------------------*/ bool mrpt::system::vectorToBinaryFile( const vector_byte &vec, const std::string &fileName ) { try { mrpt::utils::CFileOutputStream of(fileName); if (!vec.empty()) of.WriteBuffer( &vec[0], sizeof(vec[0])*vec.size() ); return true; } catch(...) { return false; } }
/* ----------------------------------------------------------------------- OctetVectorToObject ----------------------------------------------------------------------- */ void utils::OctetVectorToObject(const vector_byte & in_data, CSerializablePtr &obj) { try { obj.clear_unique(); if (in_data.empty()) return; CMemoryStream tmp( &in_data[0], in_data.size()); obj = tmp.ReadObject(); } catch (std::bad_alloc &e) { throw e; } catch(std::exception &e) { std::cerr << "[OctetVectorToObject] Exception: " << e.what() << std::endl; } catch(...) { std::cerr << "[OctetVectorToObject] Unknown exception" << std::endl; } }