From: stephan b. <sg...@us...> - 2004-12-25 18:58:41
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17734/include/pclasses/System Modified Files: Mime.h Log Message: Added i/ostream operators for MimeType. Fixed mimeType() to return an empty string on an invalid (empty) type. Index: Mime.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/Mime.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Mime.h 25 Dec 2004 18:08:03 -0000 1.8 +++ Mime.h 25 Dec 2004 18:58:32 -0000 1.9 @@ -57,9 +57,14 @@ ~MimeType(); - //! Return the full MIME type + /** + Return the full MIME type string, in the format mediatype/subtype. + + If called on a default-constructed object it returns an + empty string. + */ inline const std::string mimeType() const - { return m_mediaType + "/" + m_subType; } + { return m_mediaType.empty() ? "" : (m_mediaType + "/" + m_subType); } //! Returns the MIME media type inline const std::string& mediaType() const @@ -91,7 +96,25 @@ Returns the equivalent of (lhs.mimeType() == rhs). */ bool operator==( const MimeType & lhs, const std::string & rhs ); - + +/** + Writes m.mimeType() to os. +*/ +std::ostream & operator<<( std::ostream &, const MimeType & m ); +/** + Reads one token from the stream, assuming it is + in the format media/subtype. The mimetype object + is then reconstructed with that data. + + On error (token not in correct format or IO error) m is not + modified. If parsing of the token fails then the stream's failbit + flag is set, though this behaviour is arguable and may be removed + after discussing it with other coders. + + This function reads char-by-char from the stream to avoid + depending on the stream's skipws flag. +*/ +std::istream & operator>>( std::istream &, MimeType & m ); //! MIME type database /*! |