Share via


CArchive::operator <<

Stores the indicated object or primitive type to the archive.

friend CArchive& operator <<( 
   CArchive& ar, 
   const CObject* pOb  
); 
throw( 
   CArchiveException*, 
   CFileException*  
); 
CArchive& AFXAPI operator <<( 
   CArchive& ar, 
   const RECT& rect 
); 
CArchive& AFXAPI operator <<( 
   CArchive& ar, 
   POINT point 
); 
CArchive& AFXAPI operator <<( 
  CArchive& ar, 
   SIZE size 
); 
template<  
   typename BaseType,  
   class StringTraits  
> 
CArchive& operator<<( 
   const ATL::CStringT< 
      BaseType,  
      StringTraits 
   >& str 
); 
CArchive& operator <<( 
   BYTE by  
); 
CArchive& operator <<( 
   WORD w  
); 
CArchive& operator <<( 
   LONG l  
); 
CArchive& operator <<( 
   DWORD dw  
); 
CArchive& operator <<( 
   float f  
); 
CArchive& operator <<( 
   double d  
); 
CArchive& operator <<( 
   int i  
); 
CArchive& operator <<( 
   short w  
); 
CArchive& operator <<( 
   char ch  
); 
CArchive& operator<<( 
   wchar_t ch  
); 
CArchive& operator <<( 
   unsigned u  
); 
CArchive& operator <<( 
   bool b  
); 
CArchive& operator<<( 
   ULONGLONG dwdw  
); 
CArchive& operator<<( 
   LONGLONG dwdw  
);

Return Value

A CArchive reference that enables multiple insertion operators on a single line.

Remarks

The last two versions above are specifically for storing 64-bit integers.

If you used the IMPLEMENT_SERIAL macro in your class implementation, then the insertion operator overloaded for CObject calls the protected WriteObject. This function, in turn, calls the Serialize function of the class.

The CStringT insertion operator (<<) supports diagnostic dumping and storing to an archive.

Example

This example demonstrates the use of the CArchive insertion operator << with the int and long types.

long l = 5;
int i = 10;
if(ar.IsStoring())
   ar << l << i;                            

This example 2 demonstrates the use of the CArchive insertion operator << with the CStringT type.

CString s("abc");
ar << s;  // Prints the value (abc)

Requirements

Header: afx.h

See Also

Reference

CArchive Class

Hierarchy Chart

CArchive::WriteObject

CObject::Serialize

CStringT Class

CDumpContext Class