Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

stringstream.h

00001 #ifndef OW32_stringstream_h
00002 #define OW32_stringstream_h
00003 
00004 #include <iostream>
00005 #include <string>
00006 #include <OW32/auto_array_ptr.h>
00007 
00008 inline std::istream& operator>>(std::istream& is, std::wstring& str)
00009 {
00010     size_t count;
00011     is.read((char*)&count,sizeof(count));
00012     if (!is.good()) 
00013         return is;
00014 
00015     if (count > 0) {
00016         OW32::auto_array_ptr<wchar_t> buf(new wchar_t[count+1]);
00017         is.read((char*)buf.get(), count * sizeof(wchar_t));
00018         buf[count] = L'\0';
00019         str = buf.get();
00020     } else {
00021         str = L"";
00022     }
00023     return is;
00024 }
00025 
00026 inline std::ostream& operator<<(std::ostream& os, const std::wstring& str)
00027 {
00028     size_t count=str.length();
00029     os.write((char*)&count,sizeof(count));
00030     if (count > 0)
00031         os.write((char*)str.c_str(), count * sizeof(wchar_t));
00032     return os;
00033 }
00034 
00035 #endif // OW32_stringstream_h

Generated on Sun Jun 5 01:29:18 2005 for OW32 by  doxygen 1.3.9.1