// --------------------------------------------------------------- // Translate // // Translates the data in inSource to the type outType and stores // the translated data in outDestination. // // Preconditions: // // Parameters: inSource, the data to be translated // // inInfo, hint about the data in inSource (not used) // // ioExtension, configuration options for the // translator // // outType, the type to convert inSource to // // outDestination, where the translated data is // put // // Postconditions: // // Returns: B_BAD_VALUE, if the options in ioExtension are bad // // B_NO_TRANSLATOR, if this translator doesn't understand the data // // B_ERROR, if there was an error allocating memory or converting // data // // B_OK, if all went well // --------------------------------------------------------------- status_t BaseTranslator::Translate(BPositionIO *inSource, const translator_info *inInfo, BMessage *ioExtension, uint32 outType, BPositionIO *outDestination) { switch (fTranGroup) { case B_TRANSLATOR_BITMAP: return BitsTranslate(inSource, inInfo, ioExtension, outType, outDestination); default: return DerivedTranslate(inSource, inInfo, ioExtension, outType, outDestination, -1); } }
status_t BaseTranslator::BitsTranslate(BPositionIO *inSource, const translator_info *inInfo, BMessage *ioExtension, uint32 outType, BPositionIO *outDestination) { status_t result = BitsCheck(inSource, ioExtension, outType); if (result == B_OK && outType == B_TRANSLATOR_BITMAP) { result = translate_from_bits_to_bits(inSource, outType, outDestination); } else if (result >= B_OK) { // If NOT B_TRANSLATOR_BITMAP type it could be the derived format result = DerivedTranslate(inSource, inInfo, ioExtension, outType, outDestination, (result == B_OK)); } return result; }