From: stephan b. <sg...@us...> - 2004-12-24 03:25:04
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22067/src/System Modified Files: Mime.cpp Log Message: appears to work except for file ext map, maybe due to operator prob in MimeType. Too tired... Index: Mime.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Mime.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Mime.cpp 24 Dec 2004 03:01:09 -0000 1.2 +++ Mime.cpp 24 Dec 2004 03:24:55 -0000 1.3 @@ -40,6 +40,10 @@ { } +MimeType::MimeType() +{ +} + MimeType::~MimeType() { } @@ -183,15 +187,18 @@ std::string rest; std::string strMediaType; std::string strSubType; + MimeType mimet; while(!strm.eof()) { getline(strm, line); - if(line.empty() || line[0] != '#') + if(line.empty() || line[0] == '#') { continue; } p1 = line.find("/"); p2 = line.find_first_of( " \t", p1+1 ); + // line.find_first_not_of( "abcdefghijklmnopqrstuvqxyz-ABCDEFGHIJKLMNOPQRSTUVQXYZ0123456789", p1+1 ); + // ^^^ find_first_of( " \t", p1+1 ) is giving me until line.end()! if( std::string::npos == p1 || std::string::npos == p2 ) { @@ -199,19 +206,22 @@ } strMediaType = line.substr(0,p1); - strSubType = line.substr(p1+1,p2); - - db.typeMap().insert(make_pair(strMediaType, MimeType(strMediaType, strSubType) ) ); + strSubType = line.substr(p1+1,p2-(p1+1)); + rest = line.substr(p2+1,(line.size()-p2)); +// CERR << "media=["<<strMediaType<<"]\t p1="<<p1<<", p2="<<p2<<", subtype=["<<strSubType<<"]\t" +// << "rest=["<<rest<<"]\n"; + mimet = MimeType(strMediaType, strSubType); + db.typeMap().insert(make_pair(strMediaType, mimet ) ); - rest = line.substr(p2+1,line.size()-1); std::istringstream istr(rest.c_str()); - while( istr.good() ) + while( ! istr.eof() ) { istr >> ext; if( ! ext.empty() && ext[0] != '#' ) { - db.extensionsMap().insert(make_pair(MimeType(strMediaType, strSubType), ext ) ); + db.extensionsMap().insert(make_pair(mimet, ext ) ); } + ext = ""; } } } |