|
/********************************************************************\
created: 2001/03/04
created: 4:3:2001 13:58
filename: Parser\prsProject.cpp
file path: .\Parser
file base: prsProject
file ext: cpp
author: Alex Kucherenko
purpose:
\********************************************************************/
#include "stdafx.h"
// Include helper path functions
#include <shlwapi.h>
// Disable some warnings while using STL
#pragma warning (disable : 4800 4290 4786 4503 )
#include "prsExceptions.h"
#include "prsBase.h"
#include "prsSingle.h"
#include "prsProject.h"
//////////////////////////////////////////////////////////////////////////
// Default constructor of our class
CToDoProjectParse::CToDoProjectParse()
{
char dir[2048];
SetSearchWord( "SOURCE=" );
GetCurrentDirectory( sizeof( dir ), dir );
m_strOldDir = dir;
// Fill array of extansions
m_vecExtesions.push_back( ".cpp" );
m_vecExtesions.push_back( ".hpp" );
m_vecExtesions.push_back( ".c" );
m_vecExtesions.push_back( ".h" );
m_vecExtesions.push_back( ".cxx" );
m_vecExtesions.push_back( ".hxx" );
}
//////////////////////////////////////////////////////////////////////////
// Constructor which set File name
CToDoProjectParse::CToDoProjectParse( const string FileName )
{
char drive[10], dir[2048], fname[_MAX_FNAME], ext[_MAX_EXT];
CToDoBaseParser::SetFileName( FileName );
SetSearchWord( "SOURCE=" );
_splitpath( GetFileName().c_str(), drive, dir, fname, ext );
m_strCurrentDir = string( drive ) + dir;
GetCurrentDirectory( sizeof( dir ), dir );
m_strOldDir = dir;
// Fill array of extensions
m_vecExtesions.push_back( ".cpp" );
m_vecExtesions.push_back( ".hpp" );
m_vecExtesions.push_back( ".c" );
m_vecExtesions.push_back( ".h" );
m_vecExtesions.push_back( ".cxx" );
m_vecExtesions.push_back( ".hxx" );
}
//////////////////////////////////////////////////////////////////////////
// Constructor which set file name and extensions array
CToDoProjectParse::CToDoProjectParse( const string FileName, const TStrArray &Extensions )
{
char drive[10], dir[2048], fname[_MAX_FNAME], ext[_MAX_EXT];
CToDoBaseParser::SetFileName( FileName );
SetSearchWord( "SOURCE=" );
_splitpath( GetFileName().c_str(), drive, dir, fname, ext );
m_strCurrentDir = string( drive ) + dir;
GetCurrentDirectory( sizeof( dir ), dir );
m_strOldDir = dir;
m_vecExtesions = Extensions;
}
//////////////////////////////////////////////////////////////////////////
// Destructor. Return our class to start directory.
CToDoProjectParse::~CToDoProjectParse()
{
SetCurrentDirectory( m_strOldDir.c_str() );
}
//////////////////////////////////////////////////////////////////////////
// Engine of our class. Make all needed work.
long CToDoProjectParse::ParseEngine() throw ( CToDoFileWork )
{
FILE *tmpFile = fopen( CToDoBaseParser::GetFileName().c_str(), "rt" );
if( tmpFile == NULL ) throw CToDoFileWork();
long lCounter = 0,
lMainCount = 0;
char MainStr[ MAX_STRING_LENGTH ];
char fullPath[ MAX_STRING_LENGTH ] ;
char tmpFind[ MAX_STRING_LENGTH ];
TLineMapper &tmpLines = GetMap();
// NOTE: For project parsing default directory must be chaged to .dsp file folder
SetCurrentDirectory( m_strCurrentDir.c_str( ) );
do
{
char *tmp = fgets( MainStr, MAX_STRING_LENGTH, tmpFile );
if( tmp == NULL ) break;
lCounter++;
int count = 0;
tmp = strstr( MainStr, GetSearchWord().c_str() );
if( tmp != NULL )
{
strcpy( tmpFind, tmp + GetSearchWord().length() );
PathUnquoteSpaces( tmpFind );
char *exten = PathFindExtension( tmpFind );
// Needed in NT4 only ( not fully tested )
if( exten[ strlen(exten)-1 ] == 0x0A ) exten[ strlen(exten)-1 ] = 0;
TStrArrayIter k;
for( k = m_vecExtesions.begin(); k != m_vecExtesions.end(); k++, count++ )
{
if( stricmp( exten, k->c_str() ) != 0 ) continue;
char * cRetCode = _fullpath( fullPath, tmpFind, MAX_STRING_LENGTH );
if( cRetCode == NULL ) continue;
strlwr( fullPath );
tmpLines.insert( TLineMapper::value_type( lCounter, string( fullPath ) ) );
lMainCount++;
break;
}
}
} while( !feof( tmpFile ) );
fclose( tmpFile );
// Set main counter
SetElementsQuatity( lMainCount );
return lMainCount;
}
//:> End of file
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.