void Decoder::decodeSegmentBody( DataSource & source, Codecs::PresenceMap & pmap, const Codecs::SegmentBodyCPtr & segment, Messages::ValueMessageBuilder & messageBuilder) { size_t instructionCount = segment->size(); for( size_t nField = 0; nField < instructionCount; ++nField) { PROFILE_POINT("decode field"); const Codecs::FieldInstructionCPtr & instruction = segment->getInstruction(nField); if(verboseOut_) { (*verboseOut_) <<std::endl << "Decode instruction[" <<nField << "]: " << instruction->getIdentity()->name() << std::endl; } source.beginField(instruction->getIdentity()->name()); (void)instruction->decode(source, pmap, *this, messageBuilder); } }
void Encoder::encodeSegmentBody( DataDestination & destination, Codecs::PresenceMap & pmap, const Codecs::SegmentBodyCPtr & segment, const Messages::MessageAccessor & accessor) { size_t instructionCount = segment->size(); for( size_t nField = 0; nField < instructionCount; ++nField) { PROFILE_POINT("encode field"); Codecs::FieldInstructionCPtr instruction; if(segment->getInstruction(nField, instruction)) { destination.startField(*(instruction->getIdentity())); instruction->encode(destination, pmap, *this, accessor); destination.endField(*(instruction->getIdentity())); } } }
void Decoder::decodeGroup( DataSource & source, const Codecs::SegmentBodyCPtr & group, Messages::ValueMessageBuilder & messageBuilder) { size_t presenceMapBits = group->presenceMapBitCount(); Codecs::PresenceMap pmap(presenceMapBits); if(this->verboseOut_) { pmap.setVerbose(verboseOut_); } if(presenceMapBits > 0) { static const std::string pm("PMAP"); source.beginField(pm); pmap.decode(source); } // for debugging: pmap.setVerbose(source.getEcho()); decodeSegmentBody(source, pmap, group, messageBuilder); }