Microsoft Foundation Classes (mfc.hlp) (Table of Contents; Topic list)
class CString
                                              Up Contents Index Back
──Microsoft Foundation Classes──────────────────────────────────────────────
 
  Description
 
  A CString object consists of a variable-length sequence of characters.
  The CString class provides a variety of functions and operators that
  manipulate CString objects using a syntax similar to that of Basic.
  Concatenation and comparison operators, together with simplified memory
  management, make CString objects easier to use than ordinary character
  arrays. The increased processing overhead is not significant. The
  following selections link to useful CString application notes:
 
  ■   CString Exception CleanupCString Argument Passing
 
  Comments
 
  The maximum size of a CString object is MAXINT (32,767) characters.
 
  The const char* operator gives direct access to the characters in a
  CString object, which makes it look like a C-language character array.
  Unlike a character array, however, the CString class has a built-in
  memory-allocation capability. This allows string objects to grow as a
  result of concatenation operations.
 
  No attempt is made to "fold" CString objects (if you make two CString
  objects containing Chicago, for example, the characters in Chicago are
  stored in two places).
 
  The CString class is not implemented as a Microsoft Foundation
  collection class, although CString objects can certainly be stored as
  elements in collections.
 
  The overloaded const char* conversion operator allows CString objects to
  be freely substituted for character pointers in function calls. The
  CString( const char* psz ) constructor allows character pointers to be
  substituted for CString objects.
 
  Use the GetBuffer and ReleaseBuffer member functions when you need to
  directly access a CString as a nonconstant pointer to char (char*
  instead of a const char*).
 
  CString objects follow "value semantics". A CString object represents a
  unique value. Think of a CString as an actual string not as a pointer to
  a string.
 
  Where possible, allocate CString objects on the frame rather than on the
  heap. This saves memory and simplifies parameter passing.
 
  #include <afx.h>
 
  Public Members
 
  Construction/Destruction
 
  CString   Constructs CString objects in various ways.
 
  ~CString   Destroys a CString object.
 
  The String as an Array
 
  GetLength     Returns the number of characters in a CString object.
 
  IsEmpty       Tests whether the length of a CString object is 0.
 
  Empty         Forces a string to have 0 length.
 
  GetAt         Returns the character at a given position.
 
  operator []   Returns the character at a given position.
 
  SetAt         Sets a character at a given position.
 
  operator const char* ()
                  Directly accesses characters stored in a CString
                  object.
 
  Assignment/Concatenation
 
  operator =    Assigns a new value to a CString object.
 
  operator +    Concatenates two strings and returns a new string.
 
  operator +=   Concatenates a new string to the end of an existing
                  string.
 
  Comparison
 
  operators ==, <, etc.   Comparison operators (ASCII, case sensitive).
 
  Compare                 Compares two strings (ASCII, case sensitive).
 
  CompareNoCase           Compares two strings (ASCII, case
                            insensitive).
 
  Collate                 Compares two strings with proper
                            language-dependent ordering.
 
  Extraction
 
  Mid             Extracts the middle part of a string (like the Basic
                    MID$ command).
 
  Left            Extracts the left part of a string (like the Basic
                    LEFT$ command).
 
  Right           Extracts the right part of a string (like the Basic
                    RIGHT$ command).
 
  SpanIncluding   Extracts a substring that contains only the characters
                    in a set.
 
  SpanExcluding   Extracts a substring that contains only the characters
                    not in a set.
 
  Other Conversions
 
  MakeUpper     Converts all the characters in this string to uppercase
                  characters.
 
  MakeLower     Converts all the characters in this string to lowercase
                  characters.
 
  MakeReverse   Reverses the characters in this string.
 
  Searching
 
  Find          Finds a character or substring inside a larger string.
 
  ReverseFind   Finds a character inside a larger string; starts from
                  the end.
 
  FindOneOf     Finds the first matching character from a set.
 
  Archive/Dump
 
  operator <<   Inserts a CString object to an archive or dump context.
 
  operator >>   Extracts a CString object from an archive.
 
  Buffer Access
 
  GetBuffer            Returns a pointer to the characters in the
                         CString.
 
  GetBufferSetLength   Returns a pointer to the characters in the
                         CString, truncating to the specified length.
 
  ReleaseBuffer        Yields control of the buffer returned by
                         GetBuffer.
 
  Windows-Specific
 
  LoadString   Loads an existing CString object from a Windows
                 resource.
 
  AnsiToOem    Makes an in-place conversion from the ANSI character set
                 to the OEM character set.
 
  OemToAnsi    Makes an in-place conversion from the OEM character set
                 to the ANSI character set.
 
 
                                     -♦-