From: stephan b. <sg...@us...> - 2004-12-25 18:08:22
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10782/src/System Modified Files: Mime.cpp Log Message: Moved the comparison ops into namespace-scope funcs, non-friends. i'm not sure why, but C++ gurus making them free funcs if possible, as opposed to members. Index: Mime.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Mime.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Mime.cpp 24 Dec 2004 16:23:24 -0000 1.7 +++ Mime.cpp 25 Dec 2004 18:08:03 -0000 1.8 @@ -94,39 +94,31 @@ { } -bool MimeType::operator<( const MimeType & rhs ) const +bool operator<( const MimeType &lhs, const MimeType & rhs ) { - if( &rhs == this ) return false; - return this->mimeType() < rhs.mimeType(); - if( m_mediaType < rhs.m_mediaType) - { - return true; - } - else if( m_mediaType == rhs.m_mediaType) - { - return (m_subType < rhs.m_subType); - } - return false; + if( &rhs == &lhs ) return false; + return lhs.mimeType() < rhs.mimeType(); } -bool MimeType::operator==( const MimeType & rhs ) const +bool operator==( const MimeType & lhs, const MimeType & rhs ) { - return (m_mediaType == rhs.m_mediaType) - && - (m_subType == rhs.m_subType) - ; + return (lhs.mimeType() == rhs.mimeType()); } +bool operator==( const MimeType & lhs, const std::string & rhs ) +{ + return lhs.mimeType() == rhs; +} + + MimeTypeDb::MimeTypeDb() { } MimeTypeDb::~MimeTypeDb() { - m_types.clear(); - m_exts.clear(); - m_rexts.clear(); + this->clear(); } @@ -175,7 +167,7 @@ this->insert(mtype); return true; } - + void MimeTypeDb::mapExtension(const MimeType& mimet, const std::string & file_ext ) { // CERR << "mapping extension ["<<file_ext<<"] \t==>\t[" << mimet.mimeType()<<"]\n"; |