/*! Write the contents of the field with the given \a fieldId to the stream. \param[in] fieldId Id of the field to write. */ void OSBCommonElement::writeFieldContent(const UInt32 fieldId) { OSG_OSB_LOG(("OSBCommonElement::writeFieldContent\n")); BinaryWriteHandler *wh = editRoot()->getWriteHandler(); FieldContainer *fc = getContainer(); const FieldDescriptionBase *fieldDesc = fc->getFieldDescription(fieldId); const BitVector fieldMask = fieldDesc->getFieldMask( ); fc->copyToBin(*wh, fieldMask); }
/*! Writes all fields to the stream, except for those whose name is in \a excludeFields. Optionally writes an end marker. The excludeFields string has the format: "'name1' 'name2' 'name3'", the spaces between the "'" are mandatory. \param[in] excludeFields String of field names that shall be skipped. \param[in] endMarker Write an end marker to the stream after all fields are processed. */ void OSBCommonElement::writeFields( const std::string &excludeFields, const bool endMarker) { OSG_OSB_LOG(("OSBCommonElement::writeFields: " "excludeFields: [%s]\n", excludeFields.c_str())); FieldContainer *fc = getContainer(); UInt32 fieldCount = fc->getType().getNumFieldDescs(); // go through all fields and write them. for(UInt32 fieldId = 1; fieldId <= fieldCount; ++fieldId) { const FieldDescriptionBase *fieldDesc = fc->getFieldDescription(fieldId); const std::string &fieldName = fieldDesc->getName(); // skip internal fields if(fieldDesc->isInternal()) { OSG_OSB_LOG(("OSBCommonElement::writeFields: " "Skipping internal field: [%s]\n", fieldName.c_str())); continue; } // skip excluded fields if((!excludeFields.empty() ) && (excludeFields.find("'" + fieldName + "'") != std::string::npos) ) { OSG_OSB_LOG(("OSBCommonElement::writeFields: " "Skipping excluded field: [%s]\n", fieldName.c_str())); continue; } const FieldType &fieldType = fieldDesc->getFieldType(); const std::string &fieldTypeName = fieldType .getName (); BitVector fieldMask = fieldDesc->getFieldMask(); UInt32 fieldSize = UInt32(fc->getBinSize(fieldMask)); writeFieldHeader (fieldName, fieldTypeName, fieldSize); writeFieldContent(fieldId ); } if(endMarker) { writeEndMarker(); } }