|
a/src/internfile/internfile.cpp |
|
b/src/internfile/internfile.cpp |
|
... |
|
... |
545 |
}
|
545 |
}
|
546 |
out += "\n";
|
546 |
out += "\n";
|
547 |
}
|
547 |
}
|
548 |
}
|
548 |
}
|
549 |
|
549 |
|
|
|
550 |
void FileInterner::getMissingFromDescription(FIMissingStore *st, const string& in)
|
|
|
551 |
{
|
|
|
552 |
if (st == 0)
|
|
|
553 |
return;
|
|
|
554 |
|
|
|
555 |
// The "missing" file is text. Each line defines a missing filter
|
|
|
556 |
// and the list of mime types actually encountered that needed it (see method
|
|
|
557 |
// getMissingDescription())
|
|
|
558 |
|
|
|
559 |
vector<string> lines;
|
|
|
560 |
stringToTokens(in, lines, "\n");
|
|
|
561 |
|
|
|
562 |
for (vector<string>::const_iterator it = lines.begin();
|
|
|
563 |
it != lines.end(); it++) {
|
|
|
564 |
// Lines from the file are like:
|
|
|
565 |
//
|
|
|
566 |
// filter name string (mime1 mime2)
|
|
|
567 |
//
|
|
|
568 |
// We can't be too sure that there will never be a parenthesis
|
|
|
569 |
// inside the filter string as this comes from the filter
|
|
|
570 |
// itself. The list part is safer, so we start from the end.
|
|
|
571 |
const string& line = *it;
|
|
|
572 |
string::size_type lastopen = line.find_last_of("(");
|
|
|
573 |
if (lastopen == string::npos)
|
|
|
574 |
continue;
|
|
|
575 |
string::size_type lastclose = line.find_last_of(")");
|
|
|
576 |
if (lastclose == string::npos || lastclose <= lastopen + 1)
|
|
|
577 |
continue;
|
|
|
578 |
string smtypes = line.substr(lastopen+1, lastclose - lastopen - 1);
|
|
|
579 |
vector<string> mtypes;
|
|
|
580 |
stringToTokens(smtypes, mtypes);
|
|
|
581 |
string filter = line.substr(0, lastopen);
|
|
|
582 |
trimstring(filter);
|
|
|
583 |
if (filter.empty())
|
|
|
584 |
continue;
|
|
|
585 |
|
|
|
586 |
st->m_missingExternal.insert(filter);
|
|
|
587 |
for (vector<string>::const_iterator itt = mtypes.begin();
|
|
|
588 |
itt != mtypes.end(); itt++) {
|
|
|
589 |
st->m_typesForMissing[filter].insert(*itt);
|
|
|
590 |
}
|
|
|
591 |
}
|
|
|
592 |
}
|
|
|
593 |
|
550 |
// Helper for extracting a value from a map.
|
594 |
// Helper for extracting a value from a map.
|
551 |
static inline bool getKeyValue(const map<string, string>& docdata,
|
595 |
static inline bool getKeyValue(const map<string, string>& docdata,
|
552 |
const string& key, string& value)
|
596 |
const string& key, string& value)
|
553 |
{
|
597 |
{
|
554 |
map<string,string>::const_iterator it;
|
598 |
map<string,string>::const_iterator it;
|