rem: string fileName; fileName.assign("Image"); fileName.append( TypeConstants<UInt32>::putToString(counter++) ); fileName.append(".pnm"); inVal->write(fileName.c_str()); outStr.assign( "\"" ); outStr.append( fileName ); outStr.append( "\"" );
add: if(inVal != NULL) { fileName.assign("Image"); fileName.append( TypeConstants<UInt32>::putToString(counter++) ); fileName.append(".pnm"); inVal->write(fileName.c_str()); }  outStr.assign( "\"" ); if(inVal != NULL) { outStr.append( fileName ); } outStr.append( "\"" );
context: OSG_BEGIN_NAMESPACE/** \ingroup FieldLib *  \ingroup SingleFields *  \ingroup MultiFields *  \brief  base field traits  */template <>struct FieldDataTraits<ImageP> : public FieldTraitsRecurseBase<ImageP>{    static DataType                      _type;    enum             { StringConvertable = ToStringConvertable   |                                           FromStringConvertable };    static DataType &getType      (void) { return _type;         }    static Char8    *getSName     (void) { return "SFImageP";    }    static Char8    *getMName     (void) { return "MFImageP";    }    static ImageP    getDefault   (void) { return NULL;          }        //Attention: This does expect a filename as arg inVal not a string with    //the complete image data in it.    static bool      getFromString(      ImageP  &outVal,                                   const Char8   *&inVal)    {        outVal = new Image();        cerr << "Reading from File: " << inVal;        cerr << " " << outVal->read( inVal ) << endl;        return true;    }    //This image into a file and returns the name in outStr    static void             putToString(const ImageP &inVal,                                              string &outStr)    {        static UInt32 counter = 0;        string fileName;        fileName.assign("Image");        fileName.append( TypeConstants<UInt32>::putToString(counter++) );        fileName.append(".pnm");        inVal->write(fileName.c_str());        outStr.assign( "\"" );        outStr.append( fileName );        outStr.append( "\"" );    }    static UInt32 getBinSize(const ImageP &oObject)    {        ImageFileType *type;        type = ImageFileHandler::the().getFileType("MTD");        if(oObject)        {            return type->maxBufferSize(*oObject) +                    sizeof(UInt32);        }        return sizeof(UInt32);    }    static UInt32 getBinSize(const ImageP   *pObjectStore,                                   UInt32    uiNumObjects)    {        UInt32 size = 0;        // defaut: individual field sizes        for(UInt32 i=0; i <uiNumObjects; ++i)        {            size += getBinSize(pObjectStore, uiNumObjects);        }        return size;    }    static void copyToBin(      BinaryDataHandler &pMem,                           const ImageP   &oObject)    {        UInt32 imgSize=0;        ImageFileType *type;        type = ImageFileHandler::the().getFileType("MTD");        if(oObject)        {            imgSize=(UInt32)type->maxBufferSize(*oObject);        }        pMem.putValue(imgSize);        if(oObject)        {            UInt8 *image = new UInt8 [imgSize];            type->store(*oObject,image);            pMem.putAndFree(image,imgSize);        }    }    static void copyToBin(      BinaryDataHandler &pMem,                           const ImageP            *pObjectStore,                                UInt32             uiNumObjects)    {        // defaut: copy each element        for(UInt32 i=0; i < uiNumObjects; ++i)        {            copyToBin(pMem, pObjectStore[i]);        }    }    static void copyFromBin(BinaryDataHandler &pMem,                             ImageP       &oObject)    {        ImageFileType *type;        UInt32 imgSize=0;        type = ImageFileHandler::the().getFileType("MTD");        if(oObject)        {            delete oObject;            oObject=NULL;        }        pMem.getValue(imgSize);        if(imgSize)        {            UInt8 *image;            oObject=new Image();            pMem.getAndAlloc(image,imgSize);            type->restore(*oObject,image);            delete [] image;        }    }    static void copyFromBin(BinaryDataHandler &pMem,                             ImageP            *pObjectStore,                            UInt32             uiNumObjects)    {        // defaut: copy each element        for(UInt32 i = 0; i < uiNumObjects; ++i)        {            copyFromBin(pMem, pObjectStore[i]);        }    }};