|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionWhen writing ATL components, I have found that one of the hardest things for Windows programmers to overcome is the dependency on the MFC library. For dates and strings, MFC simplifies the programmer's job by handling memory allocations and type conversions within its class encapsulation. However, with that simplification comes the price of having to distribute the MFC DLL's with your component. This article focuses on the issues surrounding the use of strings in an ATL component.
If you don't include MFC support in your ATL component, you obviously won't have
the
CCOMStringWhile both of these articles are viable alternatives to the MFC The
Therefore, by using the The current version of the ConstructorsCCOMString() - Constructs an empty string.CCOMString(CCOMString&) - Constructs a string from another CCOMString.CCOMString(LPCTSTR) - Constructs a string from a LPCTSTR (i.e., const
TCHAR*).CCOMString(BSTR) - Constructs a string from a BSTR.CCOMString(TCHAR, int) - Constructs a string from a character repeated an
indicated number of times. Assignment Operationsoperator=(CCOMString&) - Copies another CCOMString object to the
CCOMString object.operator=(LPCTSTR) - Copies a LPCTSTR to the CCOMString object.operator=(BSTR) - Copies a BSTR to the CCOMString object.operator LPCTSTR() - Returns a const TCHAR* from the CCOMString object.TCHAR* GetString() - Obtains a pointer to the string contained in the
CCOMString object.BSTR AllocSysString() - Allocates a BSTR from the CCOMString object.Concatenation<code>operator+=(CCOMString&) - Concatenates a CCOMString object to the end
of the CCOMString object.operator+=(LPCTSTR) - Concatenates a const TCHAR* to the end of the
CCOMString object.operator+=(BSTR) - Concatenates a BSTR to the end of the CCOMString object.operator+=(TCHAR) - Concatenates a TCHAR to the end of the CCOMString
object.operator+(CCOMString&, CCOMString&) - Concatenates two CCOMString
objects together.operator+(CCOMString&, LPCTSTR) - Concatenates a CCOMString object and
a const TCHAR* together.operator+(LPCTSTR, CCOMString&) - Concatenates a const TCHAR* and
CCOMString object together.operator+(CCOMString&, BSTR) - Concatenates a CCOMString object and a
BSTR together.operator+(BSTR, CCOMString&) - Concatenates a BSTR and a CCOMString
object together.Accessors for the String as an ArrayGetLength() - Returns the length of the CCOMString string as an integer.IsEmpty() - Returns TRUE or FALSE depending on whether or not the
CCOMString string is empty.Empty() - Sets the CCOMString string to an empty string (i.e.,
_T("")).GetAt(int) - Returns a TCHAR character from the CCOMString string at the
specified location.operator[] (int) - Same functionality as GetAt(int).SetAt(int, TCHAR) - Sets the character at the specified location of the
CCOMString string to the specified character.ConversionsMakeUpper() - Converts the CCOMString string into all uppercase characters.MakeLower() - Converts the CCOMString string into all lowercase characters.MakeReverse() - Reverses the sequence of the characters contained in the
CCOMString string.TrimLeft() - Removes all spaces from the left-hand side of the CCOMString
string.TrimRight() - Removes all spaces from the right-hand side of the CCOMString
string.SearchingFind(TCHAR) - Returns the first position in the CCOMString string of the
specified character.Find(TCHAR, int nStart) - Returns the first position after the nStart
position in the CCOMString string of the specified character.Find(LPCTSTR lpszSub) - Returns the first position in the CCOMString string
of the specified character string.Find(LPCTSTR lpszSub, int nStart) - Returns the first position after the
nStart position in the CCOMString string of the specified character string.ExtractionMid(int) - Returns a CCOMString object containing the character starting at
the specified position to the end of the CCOMString string.Mid(int, int) - Returns a CCOMString object containing the character
starting at the specified position and extending for the specified length of the
CCOMString string.Left(int nCount) - Returns nCount characters starting at the left-hand side
of the CCOMString string.Right(int nCount) - Returns nCount characters starting at the right-hand
side of the CCOMString string.ReplacingReplace(TCHAR chOld, TCHAR chNew) - Replaces all the chOld characters in
the CCOMString string with the chNew character.Replace(LPCTSTR lpszOld, LPCTSTR lpszNew) - Replaces all the lpszOld
strings in the CCOMString string with the lpszNew string.ComparisonCompare(CCOMString&) - Compares the current CCOMString string with the
specified CCOMString string and returns zero if equal and non-zero if not equal.
This comparision is case sensitive.Compare(LPCTSTR) - Compares the current CCOMString string with the
specified const TCHAR* and returns zero if equal and non-zero if not equal. This
comparision is case sensitive.operator==(const CCOMString&, const CCOMString&) - Same
functionality as Compare(CCOMString&).operator==(const CCOMString&, LPCTSTR) - Same functionality as
Compare(LPCTSTR).operator==(LPCTSTR, const CCOMString&) - Same functionality as
Compare(LPCTSTR).operator!=(const CCOMString&, const CCOMString&) - Compares
the current CCOMString string with the specified CCOMString string and returns zero if not
equal and non-zero if equal. This comparision is case sensitive.operator!=(const CCOMString&, LPCTSTR) - Compares the current
CCOMString string with the specified const TCHAR* and returns zero if not equal and
non-zero if equal.This comparision is case sensitive.operator!=(LPCTSTR, const CCOMString&) - Same functionality as operator
!=(const CCOMString&, LPCTSTR).CompareNoCase(CCOMString&) - Compares the current CCOMString string
with the specified CCOMString string and returns zero if equal and non-zero if not equal.
This comparision is not case sensitive.CompareNoCase(LPCTSTR) - Compares the current CCOMString string with the
specified const TCHAR* and returns zero if equal and non-zero if not equal. This
comparision is not case sensitive.FormattingFormat(LPCTSTR, ...) - Formats the string similar to the C function
printf(). History28 June 2000 - memory leak fix in source 12 August 2000 - updated source ZIP file
|
||||||||||||||||||||||