Ejemplo n.º 1
0
int main( int nArgc, char ** papszArgv )

{
    DDFModule   oModule;
    const char  *pszFilename;
    int         i;

    if( nArgc > 1 )
        pszFilename = papszArgv[1];
    else
    {
        printf( "Usage: 8211view filename\n" );
        exit( 1 );
    }

    for( i = 0; i < 40; i++ )
    {
/* -------------------------------------------------------------------- */
/*      Open the file.  Note that by default errors are reported to     */
/*      stderr, so we don't bother doing it ourselves.                  */
/* -------------------------------------------------------------------- */
        if( !oModule.Open( pszFilename ) )
        {
            exit( 1 );
        }

/* -------------------------------------------------------------------- */
/*      Loop reading records till there are none left.                  */
/* -------------------------------------------------------------------- */
        DDFRecord       *poRecord;
        int             nRecordCount = 0;
        int             nFieldCount = 0;
            
    
        while( (poRecord = oModule.ReadRecord()) != NULL )
        {
            /* ------------------------------------------------------------ */
            /*      Loop over each field in this particular record.         */
            /* ------------------------------------------------------------ */
            for( int iField = 0; iField < poRecord->GetFieldCount(); iField++ )
            {
                DDFField        *poField = poRecord->GetField( iField );

                ViewRecordField( poField );

                nFieldCount++;
            }

            nRecordCount++;
        }

        oModule.Close();

        printf( "Read %d records, %d fields.\n", nRecordCount, nFieldCount );
    }
}
Ejemplo n.º 2
0
int main( int nArgc, char ** papszArgv )

{
    DDFModule   oModule;
    const char  *pszFilename = nullptr;
    int         bFSPTHack = FALSE;

    for( int iArg = 1; iArg < nArgc; iArg++ )
    {
        if( EQUAL(papszArgv[iArg],"-fspt_repeating") )
            bFSPTHack = TRUE;
        else
            pszFilename = papszArgv[iArg];
    }

    if( pszFilename == nullptr )
    {
        printf( "Usage: 8211view filename\n" );
        exit( 1 );
    }

/* -------------------------------------------------------------------- */
/*      Open the file.  Note that by default errors are reported to     */
/*      stderr, so we don't bother doing it ourselves.                  */
/* -------------------------------------------------------------------- */
    if( !oModule.Open( pszFilename ) )
    {
        exit( 1 );
    }

    if( bFSPTHack )
    {
        DDFFieldDefn *poFSPT = oModule.FindFieldDefn( "FSPT" );

        if( poFSPT == nullptr )
            fprintf( stderr,
                     "unable to find FSPT field to set repeating flag.\n" );
        else
            poFSPT->SetRepeatingFlag( TRUE );
    }

/* -------------------------------------------------------------------- */
/*      Loop reading records till there are none left.                  */
/* -------------------------------------------------------------------- */
    DDFRecord *poRecord = nullptr;
    int iRecord = 0;

    while( (poRecord = oModule.ReadRecord()) != nullptr )
    {
        printf( "Record %d (%d bytes)\n",
                ++iRecord, poRecord->GetDataSize() );

        /* ------------------------------------------------------------ */
        /*      Loop over each field in this particular record.         */
        /* ------------------------------------------------------------ */
        for( int iField = 0; iField < poRecord->GetFieldCount(); iField++ )
        {
            DDFField    *poField = poRecord->GetField( iField );

            ViewRecordField( poField );
        }
    }
}