2 suggestions on CAtlRegExp class

Nov 22, 2008 at 8:08 AM
Edited Nov 22, 2008 at 8:09 AM

I have 2 suggestions on the CAtlRegExp template class.

1. Change the label "Error" to some other label name.
The label is referenced by the "goto" statement in CAtlRegExp::Match( ). It will conflict with "ADODB::Error" if you use CAtlRegExp and ADODB in the same project and result in compilation failure.

2. Change  CAtlRegExp::Match( ) to a const function.
Actually  CAtlRegExp::Match( ) never modify any member variable, so it should be defined as a const member function and no synchronization mechanism such as critical section or mutex is needed for Match( ) operation.
This can be done easily by adding a const member function GetInstructionConst( ) as the following, and change all the GetInstruction( ) in Match( ) to GetInstructionConst( ).

 const INSTRUCTION & GetInstructionConst(size_t nIndex) const throw()
        return m_Instructions[nIndex];

Thanks for your reading.