JSONStreamReaderImpl.cpp dna/stream/JSONStreamReaderImpl.h dna/TypeDefs.h dna/types/Limits.h status/Provider.h trio/utils/StreamScope.h cstddef limits tuple dna //CopyrightEpicGames,Inc.AllRightsReserved. #include"dna/stream/JSONStreamReaderImpl.h" #include"dna/TypeDefs.h" #include"dna/types/Limits.h" #include<status/Provider.h> #include<trio/utils/StreamScope.h> #ifdef_MSC_VER #pragmawarning(push) #pragmawarning(disable:43654987) #endif #include<cstddef> #include<limits> #include<tuple> #ifdef_MSC_VER #pragmawarning(pop) #endif namespacedna{ //Note:JSONStreamReader::statushasn'tbeeninitializeddeliberately,asitusesthesameerrorcodesthatwere //alreadyregisteredinBinaryStreamReader,andsincetheyareallregisteredinasingle,globalerrorcoderegistry, //thiswouldtriggeranassertthere. JSONStreamReader::~JSONStreamReader()=default; JSONStreamReader*JSONStreamReader::create(BoundedIOStream*stream,MemoryResource*memRes){ PolyAllocator<JSONStreamReaderImpl>alloc{memRes}; returnalloc.newObject(stream,memRes); } voidJSONStreamReader::destroy(JSONStreamReader*instance){ //NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast) autoreader=static_cast<JSONStreamReaderImpl*>(instance); PolyAllocator<JSONStreamReaderImpl>alloc{reader->getMemoryResource()}; alloc.deleteObject(reader); } JSONStreamReaderImpl::JSONStreamReaderImpl(BoundedIOStream*stream_,MemoryResource*memRes_): BaseImpl{memRes_}, ReaderImpl{memRes_}, stream{stream_}, archive{stream_}{ } voidJSONStreamReaderImpl::unload(DataLayerlayer){ if((layer==DataLayer::All)|| (layer==DataLayer::AllWithoutBlendShapes)|| (layer==DataLayer::Descriptor)){ dna=DNA{memRes}; }elseif((layer==DataLayer::Geometry)||(layer==DataLayer::GeometryWithoutBlendShapes)){ dna.unloadGeometry(); }elseif(layer==DataLayer::Behavior){ dna.unloadBehavior(); }elseif(layer==DataLayer::Definition){ dna.unloadGeometry(); dna.unloadBehavior(); dna.unloadDefinition(); } } voidJSONStreamReaderImpl::read(){ //Duetopossibleusageofcustomstreamimplementations,thestatusactuallymustbeclearedatthispoint //asexternalstreamsdonothaveaccesstothestatusresetAPI status.reset(); trio::StreamScopescope{stream}; if(!sc::Status::isOk()){ return; } archive>>dna; if(!sc::Status::isOk()){ return; } if(!dna.signature.matches()){ status.set(SignatureMismatchError,dna.signature.value.expected.data(),dna.signature.value.got.data()); return; } if(!dna.version.matches()){ status.set(VersionMismatchError, dna.version.generation.expected, dna.version.version.expected, dna.version.generation.got, dna.version.version.got); return; } } }//namespacedna