Click here to Skip to main content
15,886,362 members
Articles / Desktop Programming / MFC

SmartReplace AddIn [VC 6.0]

Rate me:
Please Sign up or sign in to vote.
4.62/5 (16 votes)
23 Aug 20033 min read 68.5K   2K   32  
Yet another replace dialog
//***************************************************************************
//*
//*	File:			dswl_configuration.cpp
//*	Description:	Wrapper for IConfiguration interface
//*
//***************************************************************************

//
//--------------------------------------------------------------- PRECOMPILED
//

#include "stdafx.h"

//
//--------------------------------------------------- DECLARATION DEPENDENCIES
//

//
//--------------------------------------------------------------- DECLARATION
//

#include "../Inc/dswl_configuration.h"

//
//--------------------------------------------------- DEFINITION DEPENDENCIES
//

//
//-------------------------------------------------------------- PREPROCESSOR
//

#ifdef	_DEBUG
#define new DEBUG_NEW
#undef	THIS_FILE
static	char THIS_FILE[] = __FILE__;
#endif

//
//---------------------------------------------------------------- DEFINITION
//

/*
static void g_TestCasts()
{
	// test _safe_ conversions
	IConfiguration* pITest;
	CIConfiguration test	 ( pITest );
	CIConfiguration test2 = pITest ;

	test = test2;
	test = pITest;

	#ifdef _DSWL_SWITCH_USE_AUTOCAST

	// test _critical_ conversions
	pITest = test;
	CComPtr< IConfiguration > tmplTest = test;

	#endif
}
*/

//
//---------------------------------------------------------------------------------------------------
//*************************************     CON/DESTRUCTION     *************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																					  Constructor
//***************************************************************************************************
//**	@DOC		CONSTRUCTION
//**	@MFUNC		Default constructor
//**	@PARM		[in] A pointer to the interface to attach to
//**	@END
//***************************************************************************************************
//inline
CIConfiguration::CIConfiguration( IConfiguration* a_pIConfiguration /*= NULL*/ )
{
	this->m_pIConfiguration = a_pIConfiguration;
}

//***************************************************************************************************
//**																					   Destructor
//***************************************************************************************************
//**	@DOC		CONSTRUCTION
//**	@MFUNC		Default destructor
//**	@END
//***************************************************************************************************
//inline
CIConfiguration::~CIConfiguration()
{
	this->m_pIConfiguration = NULL;	// explicitly release the interface now
}

//
//---------------------------------------------------------------------------------------------------
//***************************************     PROPERTIES     ****************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																				   GetApplication 
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Determines the application this configuration belongs to
//**	@RDESC		A pointer to the application's interface
//**	@END
//***************************************************************************************************
//inline
CIApplication CIConfiguration::GetApplication( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return NULL;
	}

	//
	//	DELEGATE
	//
	IDispatch*	pIDispatch = NULL;

	DSWL_VERIFY( this->m_pIConfiguration->get_Application( &pIDispatch ) );

	//
	//	QUERY INTERFACE
	//
	CComQIPtr< IApplication, &IID_IApplication > pIApplication ( pIDispatch );	

	//
	//	REPELASE DISPATCH INTERFACE
	//
	DSWL_RELEASE_EX( pIDispatch, CIConfiguration::GetApplication );

	//
	//	RETURN QUERIED INTERFACE
	//
	return pIApplication.p;												
}

//***************************************************************************************************
//**																				GetConfigurations
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Determines the configuration container this configuration belongs to
//**	@RDESC		A pointer to the configuration container's interface
//**	@END
//***************************************************************************************************
//inline
CIConfigurations CIConfiguration::GetConfigurations( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return NULL;
	}

	//
	//	DELEGATE
	//
	IConfigurations* pIConfigurations = NULL;

	DSWL_VERIFY( this->m_pIConfiguration->get_Configurations( &pIConfigurations ) );

	//
	//	STORE A SMART POINTER TO THE INTERFACE
	//
	CComPtr< IConfigurations > pITemp = pIConfigurations;

	//
	//	RELEASE THE INTERFACE
	//
	DSWL_RELEASE_EX( pIConfigurations, CIConfiguration::GetConfigurations );

	//
	//	RETURN SMART POINTER
	//
	return pITemp;
}

//***************************************************************************************************
//**																					   GetProject
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Determines the application this configuration belongs to
//**	@RDESC		A pointer to the project's generic interface
//**	@END
//***************************************************************************************************
//inline
CIGenericProject CIConfiguration::GetProject( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return NULL;
	}

	//
	//	DELEGATE
	//
	IDispatch*	pIDispatch = NULL;

	DSWL_VERIFY( this->m_pIConfiguration->get_Parent( &pIDispatch ) );

	//
	//	QUERY INTERFACE
	//
	CComQIPtr< IGenericProject, &IID_IGenericProject > pIGenericProject ( pIDispatch );	

	//
	//	REPELASE DISPATCH INTERFACE
	//
	DSWL_RELEASE_EX( pIDispatch, CIConfiguration::GetProject );

	//
	//	RETURN QUERIED INTERFACE
	//
	return pIGenericProject.p;												
}

//***************************************************************************************************
//**																						  GetName
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the configuration's name
//**	@RDESC		The configuration's name
//**	@END
//***************************************************************************************************
//inline
CString CIConfiguration::GetName( void ) const 
{
	ASSERT( TRUE == this->IsValid() );

	//
	//	DELEGATE
	//
	CComBSTR bszName( _T("") );

	DSWL_VERIFY( this->m_pIConfiguration->get_Name( &bszName ) );

	return bszName;
}

//
//---------------------------------------------------------------------------------------------------
//***************************************     INFORMATION     ***************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																						   IsNull
//***************************************************************************************************
//**	@DOC		INFORMATION
//**	@MFUNC		Determines whether the internal pointer is <t NULL>
//**	@RDESC		<t TRUE> if the internal pointer is <t NULL>, <t FALSE> otherwise.
//**	@END
//***************************************************************************************************
//inline
BOOL CIConfiguration::IsNull( void ) const
{
	return ( NULL == this->m_pIConfiguration.p );
}

//***************************************************************************************************
//**																						  IsValid
//***************************************************************************************************
//**	@DOC		INFORMATION
//**	@MFUNC		Determines whether the internal pointer differs from <t NULL>
//**	@RDESC		<t TRUE> if the internal pointer differs from <t NULL>, <t FALSE> otherwise.
//**	@END
//***************************************************************************************************
//inline
BOOL CIConfiguration::IsValid( void ) const
{
	return ( NULL != this->m_pIConfiguration.p );
}

//
//---------------------------------------------------------------------------------------------------
//**************************************     MODIFICATION     ***************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																				  AddFileSettings		
//***************************************************************************************************
//**	@DOC		MODIFICATION
//**	@MFUNC		Adds the specified settings to the specified file in this configuration
//**	@PARM		[in] The file name
//**	@PARM		[in] The settings
//**	@END
//***************************************************************************************************
//inline
void CIConfiguration::AddFileSettings( const CString& a_strFile, const CString& a_strSettings ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComBSTR	bszFile		( a_strFile		);
	CComBSTR	bszSettings	( a_strSettings );
	CComVariant	varReserved	( 0l			);

	DSWL_VERIFY( this->m_pIConfiguration->AddFileSettings( bszFile, bszSettings, varReserved ) );
}

//***************************************************************************************************
//**																				  AddToolSettings		
//***************************************************************************************************
//**	@DOC		MODIFICATION
//**	@MFUNC		Adds the specified tool settings to the configuration
//**	@PARM		[in] The tool name
//**	@PARM		[in] The settings
//**	@END
//***************************************************************************************************
//inline
void CIConfiguration::AddToolSettings( const CString& a_strTool, const CString& a_strSettings ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComBSTR	bszTool		( a_strTool		);
	CComBSTR	bszSettings	( a_strSettings );
	CComVariant	varReserved	( 0l			);

	DSWL_VERIFY( this->m_pIConfiguration->AddToolSettings( bszTool, bszSettings, varReserved ) );
}

//***************************************************************************************************
//**																			   AddCustomBuildStep			
//***************************************************************************************************
//**	@DOC		MODIFICATION
//**	@MFUNC		Adds the specified custom build step to the configuration
//**	@PARM		[in] The command
//**	@PARM		[in] The output
//**	@PARM		[in] The description
//**	@END
//***************************************************************************************************
//inline
void CIConfiguration::AddCustomBuildStep( const CString& a_strCommand, const CString& a_strOutput, const CString& a_strDescription ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComBSTR	bszCommand		( a_strCommand		);
	CComBSTR	bszOutput		( a_strOutput		);
	CComBSTR	bszDescription	( a_strDescription	);
	CComVariant	varReserved		( 0l				);

	DSWL_VERIFY( this->m_pIConfiguration->AddCustomBuildStep( bszCommand, bszOutput, bszDescription, varReserved ) );
}

//***************************************************************************************************
//**																		 AddCustomBuildStepToFile			
//***************************************************************************************************
//**	@DOC		MODIFICATION
//**	@MFUNC		Adds the specified custom build step to the specified file in this configuration
//**	@PARM		[in] The file's full path
//**	@PARM		[in] The command
//**	@PARM		[in] The output
//**	@PARM		[in] The description
//**	@END
//***************************************************************************************************
//inline
void CIConfiguration::AddCustomBuildStepToFile( const CString& a_strFile, const CString& a_strCommand, const CString& a_strOutput, const CString& a_strDescription ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComBSTR	bszFile		( a_strFile		);
	CComBSTR	bszCommand		( a_strCommand		);
	CComBSTR	bszOutput		( a_strOutput		);
	CComBSTR	bszDescription	( a_strDescription	);
	CComVariant	varReserved		( 0l				);

	DSWL_VERIFY( this->m_pIConfiguration->AddCustomBuildStepToFile( bszFile, bszCommand, bszOutput, bszDescription, varReserved ) );
}
 
//***************************************************************************************************
//**																			   RemoveFileSettings				
//***************************************************************************************************
//**	@DOC		MODIFICATION
//**	@MFUNC		Removes the specified settings from the specified file in this configuration
//**	@PARM		[in] The file
//**	@PARM		[in] The settings
//**	@END
//***************************************************************************************************
//inline
void CIConfiguration::RemoveFileSettings( const CString& a_strFile, const CString& a_strSettings ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComBSTR	bszFile		( a_strFile		);
	CComBSTR	bszSettings	( a_strSettings );
	CComVariant	varReserved	( 0l			);

	DSWL_VERIFY( this->m_pIConfiguration->RemoveFileSettings( bszFile, bszSettings, varReserved ) );
}

//***************************************************************************************************
//**																			   RemoveToolSettings				
//***************************************************************************************************
//**	@DOC		MODIFICATION
//**	@MFUNC		Removes the specified tool settings from the configuration
//**	@PARM		[in] The tool name
//**	@PARM		[in] The settings
//**	@END
//***************************************************************************************************
//inline
void CIConfiguration::RemoveToolSettings( const CString& a_strTool, const CString& a_strSettings ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComBSTR	bszTool		( a_strTool		);
	CComBSTR	bszSettings	( a_strSettings );
	CComVariant	varReserved	( 0l			);

	DSWL_VERIFY( this->m_pIConfiguration->RemoveToolSettings( bszTool, bszSettings, varReserved ) );
}
 
//***************************************************************************************************
//**																	   MakeCurrentSettingsDefault			
//***************************************************************************************************
//**	@DOC		MODIFICATION
//**	@MFUNC		Makes the current settings the default settings
//**	@PARM		[in] 
//**	@END
//***************************************************************************************************
//inline
void CIConfiguration::MakeCurrentSettingsDefault( void ) 
{
	ASSERT( TRUE == this->IsValid() );

	CComVariant	varReserved( 0l );

	DSWL_VERIFY( this->m_pIConfiguration->MakeCurrentSettingsDefault( varReserved ) );
}

//
//---------------------------------------------------------------------------------------------------
//******************************************     BUILD     ******************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																							Clean  
//***************************************************************************************************
//**	@DOC		BUILD
//**	@MFUNC		Cleans the configuration and all of its dependencies
//**	@END
//***************************************************************************************************
//inline
void CIConfiguration::Clean( void ) 
{
	ASSERT( TRUE == this->IsValid() );

	this->GetApplication().Clean( this->m_pIConfiguration.p );
}

//***************************************************************************************************
//**																							Build	  
//***************************************************************************************************
//**	@DOC		BUILD
//**	@MFUNC		Builds the configuration and all of its dependencies
//**	@END
//***************************************************************************************************
//inline
void CIConfiguration::Build( void ) 
{
	ASSERT( TRUE == this->IsValid() );

	this->GetApplication().Build( this->m_pIConfiguration.p );
}

//***************************************************************************************************
//**																					   RebuildAll		  
//***************************************************************************************************
//**	@DOC		BUILD
//**	@MFUNC		Rebuilds the configuration and all of its dependencies
//**	@END
//***************************************************************************************************
//inline
void CIConfiguration::RebuildAll( void ) 
{
	ASSERT( TRUE == this->IsValid() );

	this->GetApplication().RebuildAll( this->m_pIConfiguration.p );
}

//***************************************************************************************************
//**																						  Execute  
//***************************************************************************************************
//**	@DOC		BUILD
//**	@MFUNC		Executes the configuration
//**	@END
//***************************************************************************************************
//inline
void CIConfiguration::Execute( void ) 
{
	ASSERT( TRUE == this->IsValid() );

	this->GetApplication().Execute( this->m_pIConfiguration.p );
}
 
//***************************************************************************************************
//**																						GetErrors	  
//***************************************************************************************************
//**	@DOC		BUILD
//**	@MFUNC		Determines the number of errors that occured during the last build
//**	@RDESC		The number of errors
//**	@END
//***************************************************************************************************
//inline
long CIConfiguration::GetErrors( void ) const 
{
	ASSERT( TRUE == this->IsValid() );

	return this->GetApplication().GetErrors();
}

//***************************************************************************************************
//**																					  GetWarnings  
//***************************************************************************************************
//**	@DOC		BUILD
//**	@MFUNC		Determines the number of errors that occured during the last build
//**	@RDESC		The number of warnings
//**	@END
//***************************************************************************************************
//inline
long CIConfiguration::GetWarnings( void ) const 
{
	ASSERT( TRUE == this->IsValid() );

	return this->GetApplication().GetWarnings();
}
 
//
//---------------------------------------------------------------------------------------------------
//****************************************     OPERATORS     ****************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																					  operator ==
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Comparison operator
//**	@PARM		[in] The configuration to compare to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
bool CIConfiguration::operator == ( const CIConfiguration& a_Other ) const 
{
	return this->m_pIConfiguration == a_Other.m_pIConfiguration;
}

//***************************************************************************************************
//**																					  operator !=
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Comparison operator
//**	@PARM		[in] The configuration to compare to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
bool CIConfiguration::operator != ( const CIConfiguration& a_Other ) const 
{
	return this->m_pIConfiguration != a_Other.m_pIConfiguration;
}

//***************************************************************************************************
//**																					  operator <=
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Comparison operator
//**	@PARM		[in] The configuration to compare to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
bool CIConfiguration::operator <= ( const CIConfiguration& a_Other ) const 
{
	return this->m_pIConfiguration.p <= a_Other.m_pIConfiguration.p;
}

//***************************************************************************************************
//**																					  operator >=
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Comparison operator
//**	@PARM		[in] The configuration to compare to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
bool CIConfiguration::operator >= ( const CIConfiguration& a_Other ) const 
{
	return this->m_pIConfiguration.p >= a_Other.m_pIConfiguration.p;
}

//***************************************************************************************************
//**																					   operator <
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Comparison operator
//**	@PARM		[in] The configuration to compare to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
bool CIConfiguration::operator < ( const CIConfiguration& a_Other ) const 
{
	return this->m_pIConfiguration.p < a_Other.m_pIConfiguration.p;
}

//***************************************************************************************************
//**																					   operator >
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Comparison operator
//**	@PARM		[in] The configuration to compare to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
bool CIConfiguration::operator > ( const CIConfiguration& a_Other ) const 
{
	return this->m_pIConfiguration.p > a_Other.m_pIConfiguration.p;
}

//***************************************************************************************************
//**																					   operator =
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Copy operator
//**	@PARM		[in] The configuration to attach to
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
CIConfiguration& CIConfiguration::operator = ( IConfiguration* a_pIOther ) 
{
	this->m_pIConfiguration = a_pIOther;

	return (*this);
}

//***************************************************************************************************
//**																					   operator *
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Dereference operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
IConfiguration* CIConfiguration::operator * ( void ) 
{
	return this->m_pIConfiguration.p;
}

//***************************************************************************************************
//**																				 const operator *
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Dereference operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
const IConfiguration* CIConfiguration::operator * ( void ) const 
{
	return this->m_pIConfiguration.p;
}

//***************************************************************************************************
//**																					  operator ->
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Member access operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
IConfiguration* CIConfiguration::operator -> ( void ) 
{
	return * (*this);
}

//***************************************************************************************************
//**																				const operator ->
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Member access operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
const IConfiguration* CIConfiguration::operator -> ( void ) const 
{
	return * (*this);
}

//---------------------------------------------------------------------------------------------------
//***************************************************************************************************
//---------------------------------------------------------------------------------------------------

#ifdef _DSWL_SWITCH_USE_AUTOCAST
#ifdef _DSWL_SWITCH_USE_UNSAFE_AUTOCAST

//***************************************************************************************************
//**																				 const operator *
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		TypeCast operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
CIConfiguration::operator IConfiguration* ( void ) const 
{
	return this->m_pIConfiguration.p;
}

#else

//***************************************************************************************************
//**																					   operator *
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		TypeCast operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
CIConfiguration::operator IConfiguration* ( void ) 
{
	return this->m_pIConfiguration.p;
}

//***************************************************************************************************
//**																				 const operator *
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		TypeCast operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
CIConfiguration::operator const IConfiguration* ( void ) const 
{
	return this->m_pIConfiguration.p;
}

#endif
#endif


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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions