Click here to Skip to main content
15,895,084 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.6K   2K   32  
Yet another replace dialog
//***************************************************************************
//*
//*	File:			dswl_configurations.cpp
//*	Description:	Wrapper for IConfigurations interface
//*
//***************************************************************************

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

#include "stdafx.h"

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

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

#include "../Inc/dswl_configurations.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
	IConfigurations* pITest;
	CIConfigurations test	 ( pITest );
	CIConfigurations test2 = pITest ;

	test = test2;
	test = pITest;

	#ifdef _DSWL_SWITCH_USE_AUTOCAST

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

	#endif
}
*/

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

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

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

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

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

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

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

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

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

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

//***************************************************************************************************
//**																						 GetCount 
//***************************************************************************************************
//**	@DOC		PROPERTIES
//**	@MFUNC		Returns the number of configurations in this collection
//**	@RDESC		The number of configurations in this collection
//**	@END
//***************************************************************************************************
//inline
long CIConfigurations::GetCount( void ) const 
{
	//
	//	CHECK VALIDITY
	//
	if ( FALSE == this->IsValid() )
	{
		return 0l;
	}

	//
	//	DELEGATE
	//
	long lCount = 0;

	DSWL_VERIFY( this->m_pIConfigurations->get_Count( &lCount ) );

	return lCount;
}

//
//---------------------------------------------------------------------------------------------------
//***************************************     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 CIConfigurations::IsNull( void ) const
{
	return ( NULL == this->m_pIConfigurations.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 CIConfigurations::IsValid( void ) const
{
	return ( NULL != this->m_pIConfigurations.p );
}

//
//---------------------------------------------------------------------------------------------------
//***********************************     ELEMENT MANAGEMENT     ************************************
//---------------------------------------------------------------------------------------------------
//

//***************************************************************************************************
//**																					   		GetAt
//***************************************************************************************************
//**	@DOC		ELEMENT MANAGEMENT
//**	@MFUNC		Determines the item at specified 0-based index. 
//**	@PARM		[in] The 0-based index of the item to return
//**	@RDESC		A pointer to the configuration's generic interface
//**	@END
//***************************************************************************************************
//inline
CIConfiguration CIConfigurations::GetAt( long a_lIndex ) const 
{
	ASSERT( TRUE == this->IsValid() );

	return this->GetItem( a_lIndex + 1 );
}

//***************************************************************************************************
//**																					   	  GetItem
//***************************************************************************************************
//**	@DOC		ELEMENT MANAGEMENT
//**	@MFUNC		Determines the item at specified 1-based index. 
//**	@PARM		[in] The 1-based index of the item to return
//**	@RDESC		A pointer to the configuration's generic interface
//**	@END
//***************************************************************************************************
//inline
CIConfiguration CIConfigurations::GetItem( long a_lItem ) const 
{
	ASSERT( TRUE == this->IsValid() );

	IConfiguration*		pIConfiguration = NULL;
	CComVariant			varCount		( a_lItem );

	DSWL_VERIFY( this->m_pIConfigurations->Item( varCount, &pIConfiguration ) );

	CComPtr< IConfiguration > pITemp = pIConfiguration;

	DSWL_RELEASE_EX( pIConfiguration, CIConfigurations::GetItem );

	return pITemp;
}

//
//---------------------------------------------------------------------------------------------------
//****************************************     OPERATORS     ****************************************
//---------------------------------------------------------------------------------------------------
//

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

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

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

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

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

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

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

	return (*this);
}

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

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

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

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

//***************************************************************************************************
//**																				const operator []
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		Subscription operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
CIConfiguration CIConfigurations::operator [] ( int a_iIndex ) const 
{
	return this->GetAt( a_iIndex );
}

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

#ifdef _DSWL_SWITCH_USE_AUTOCAST
#ifdef _DSWL_SWITCH_USE_UNSAFE_AUTOCAST

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

#else

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

//***************************************************************************************************
//**																				 const operator *
//***************************************************************************************************
//**	@DOC		OPERATORS
//**	@MFUNC		TypeCast operator
//**	@RDESC		
//**	@END
//***************************************************************************************************
//inline
CIConfigurations::operator const IConfigurations* ( void ) const 
{
	return this->m_pIConfigurations.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