Blob.h terse/types/DynArray.h InputArchive.h InputArchive.h OutputArchive.h OutputArchive.h terse::Blob terse //CopyrightEpicGames,Inc.AllRightsReserved. #pragmaonce #include"terse/types/DynArray.h" namespaceterse{ //Blobisawrappertypearoundabyte-arrayessentially,andisusedtoserializebinaryblobs, //whosesizeispredefinedbyanotherentity(e.g.anArchiveSizeobject). //Duringserialization,theamountofbyteseitherwrittentoorreadfromthestreamwillbe //controlledbytheuser(bysettingthesizeontheblobtypethroughthesetSizememberfunction). //Fortext-basedserializers,binaryblobsareBase64encoded/decoded. template<typenameT,typenameTAllocator> classBlob{ public: static_assert(sizeof(T)==sizeof(char),"Blobsupportsonlynativebyte-sizedtypes."); usingvalue_type=T; usingallocator_type=TAllocator; public: Blob()=default; explicitBlob(constallocator_type&alloc):bytes{alloc}{ } Blob(std::size_tsize,constallocator_type&alloc):bytes{size,alloc}{ } allocator_typeget_allocator()constnoexcept{ returnbytes.get_allocator(); } value_type*data(){ returnbytes.data(); } constvalue_type*data()const{ returnbytes.data(); } std::size_tsize()const{ returnbytes.size(); } voidsetSize(std::size_tnewSize){ bytes.resize_uninitialized(newSize); } private: DynArray<value_type, allocator_type>bytes; }; }//namespaceterse