mitab/mitab_miffile.cpp
int MIFFile::SetFeatureDefn(OGRFeatureDefn *poFeatureDefn,
                         TABFieldType *paeMapInfoNativeFieldTypes /* =NULL */)
{
    int numFields;
    int nStatus = 0;

    /*-----------------------------------------------------------------
     * Check that call happens at the right time in dataset's life.
     *----------------------------------------------------------------*/
    if ( m_eAccessMode == TABWrite && m_bHeaderWrote )
    {
        CPLError(CE_Failure, CPLE_AssertionFailed,
                 "SetFeatureDefn() must be called after opening a new "
                 "dataset, but before writing the first feature to it.");
        return -1;
    }

    /*-----------------------------------------------------------------
     * Delete current feature defn if there is already one.
     * AddFieldNative() will take care of creating a new one for us.
     *----------------------------------------------------------------*/
    if (m_poDefn && m_poDefn->Dereference() == 0)
        delete m_poDefn;
    m_poDefn = NULL;

    /*-----------------------------------------------------------------
     * Copy field information
     *----------------------------------------------------------------*/
    numFields = poFeatureDefn->GetFieldCount();

    for(int iField=0; iField<numFields; iField++)
    {
        TABFieldType eMapInfoType;
        OGRFieldDefn *poFieldDefn = poFeatureDefn->GetFieldDefn(iField);

        if (paeMapInfoNativeFieldTypes)
        {
            eMapInfoType = paeMapInfoNativeFieldTypes[iField];
        }
        else
        {
            /*---------------------------------------------------------
             * Map OGRFieldTypes to MapInfo native types
             *--------------------------------------------------------*/
            switch(poFieldDefn->GetType())
            {
              case OFTInteger:
                eMapInfoType = TABFInteger;
                break;
              case OFTReal:
                eMapInfoType = TABFFloat;
                break;
              case OFTString:
              default:
                eMapInfoType = TABFChar;
            }
        }

        nStatus = AddFieldNative(poFieldDefn->GetNameRef(), eMapInfoType,
                                 poFieldDefn->GetWidth(),
                                 poFieldDefn->GetPrecision(), FALSE, FALSE);
    }

    return nStatus;
}
/**********************************************************************
 *                   MIFFile::SetFeatureDefn()
 *
 * Pass a reference to the OGRFeatureDefn that will be used to create
 * features in this dataset.  This function should be called after
 * creating a new dataset, but before writing the first feature.
 * All features that will be written to this dataset must share this same
 * OGRFeatureDefn.
 *
 * This function will use poFeatureDefn to create a local copy that 
 * will be used to build the .MID file, etc.
 *
 * Returns 0 on success, -1 on error.
 **********************************************************************/
:SetFeatureDefn()
Pass a reference to the OGRFeatureDefn that will be used to create
features in this dataset.  This function should be called after
creating a new dataset, but before writing the first feature.
All features that will be written to this dataset must share this same
OGRFeatureDefn.

This function will use poFeatureDefn to create a local copy that
will be used to build the .MID file, etc.

Returns 0 on success, -1 on error.
: SetFeatureDefn () Pass a reference to the OGRFeatureDefn that will be used to create features in this dataset . This function should be called after creating a new dataset but before writing the first feature . All features that will be written to this dataset must share this same OGRFeatureDefn . This function will use poFeatureDefn to create a local copy that will be used to build the . MID file etc . Returns 0 on success - 1 on error .
int MIFFile::SetFeatureDefn(OGRFeatureDefn *poFeatureDefn,
                         TABFieldType *paeMapInfoNativeFieldTypes )
{
    int numFields;
    int nStatus = 0;
    if ( m_eAccessMode == TABWrite && m_bHeaderWrote )
    {
        CPLError(CE_Failure, CPLE_AssertionFailed,
                 "SetFeatureDefn() must be called after opening a new "
                 "dataset, but before writing the first feature to it.");
        return -1;
    }
    if (m_poDefn && m_poDefn->Dereference() == 0)
        delete m_poDefn;
    m_poDefn = NULL;
    numFields = poFeatureDefn->GetFieldCount();
    for(int iField=0; iField<numFields; iField++)
    {
        TABFieldType eMapInfoType;
        OGRFieldDefn *poFieldDefn = poFeatureDefn->GetFieldDefn(iField);
        if (paeMapInfoNativeFieldTypes)
        {
            eMapInfoType = paeMapInfoNativeFieldTypes[iField];
        }
        else
        {
            switch(poFieldDefn->GetType())
            {
              case OFTInteger:
                eMapInfoType = TABFInteger;
                break;
              case OFTReal:
                eMapInfoType = TABFFloat;
                break;
              case OFTString:
              default:
                eMapInfoType = TABFChar;
            }
        }
        nStatus = AddFieldNative(poFieldDefn->GetNameRef(), eMapInfoType,
                                 poFieldDefn->GetWidth(),
                                 poFieldDefn->GetPrecision(), FALSE, FALSE);
    }
    return nStatus;
}
int MIFFile :: SetFeatureDefn ( OGRFeatureDefn * poFeatureDefn , TABFieldType * paeMapInfoNativeFieldTypes ) { int numFields ; int nStatus = 0 ; if ( m_eAccessMode == TABWrite && m_bHeaderWrote ) { CPLError ( CE_Failure , CPLE_AssertionFailed , " " " " ) ; return -1 ; } if ( m_poDefn && m_poDefn -> Dereference ( ) == 0 ) delete m_poDefn ; m_poDefn = NULL ; numFields = poFeatureDefn -> GetFieldCount ( ) ; for ( int iField = 0 ; iField < numFields ; iField ++ ) { TABFieldType eMapInfoType ; OGRFieldDefn * poFieldDefn = poFeatureDefn -> GetFieldDefn ( iField ) ; if ( paeMapInfoNativeFieldTypes ) { eMapInfoType = paeMapInfoNativeFieldTypes [ iField ] ; } else { switch ( poFieldDefn -> GetType ( ) ) { case OFTInteger : eMapInfoType = TABFInteger ; break ; case OFTReal : eMapInfoType = TABFFloat ; break ; case OFTString : default : eMapInfoType = TABFChar ; } } nStatus = AddFieldNative ( poFieldDefn -> GetNameRef ( ) , eMapInfoType , poFieldDefn -> GetWidth ( ) , poFieldDefn -> GetPrecision ( ) , FALSE , FALSE ) ; } return nStatus ; }
MIFFile::SetFeatureDefn()
 Pass a reference to the OGRFeatureDefn that will be used to create
 features in this dataset.
MIFFile :: SetFeatureDefn () Pass a reference to the OGRFeatureDefn that will be used to create features in this dataset .
/* =NULL */ /*-----------------------------------------------------------------
     * Check that call happens at the right time in dataset's life.
     *----------------------------------------------------------------*/ /*-----------------------------------------------------------------
     * Delete current feature defn if there is already one.
     * AddFieldNative() will take care of creating a new one for us.
     *----------------------------------------------------------------*/ /*-----------------------------------------------------------------
     * Copy field information
     *----------------------------------------------------------------*/ /*---------------------------------------------------------
             * Map OGRFieldTypes to MapInfo native types
             *--------------------------------------------------------*/