I end up resolving this issue by using just unicode version of CStringArray after all. I liked the CStringArrayUtils namespace approach to extend the function but I am still not sure if I would prefer this over deriving from the class for any particular reason!? Your approach gives me a good insight but at the same time is more complex even if we remove the templates. For example my difference function look like this and I like the fact it is invoked just by - operator so the main code looks clean.
Code:CStringArrayEx CStringArrayEx::operator - (const CStringArrayEx & rhs) { CStringArrayEx diffList; // difference list // number of items in reference array (right hand side) int rhsItemCount = rhs.GetCount(); CString strItem; for (int i = 0; i < rhsItemCount; i++) { strItem = rhs.GetAt(i); // if rhs string item is not in the source array, add it to the difference list if ( !FindNoCase( strItem ) ) diffList.Add( strItem ); } return diffList; }




Reply With Quote