\file RPatternList.cpp
MIME sniffer rpattern list implementation
*/
#include <sniffer/Err.h>
#include <sniffer/RPattern.h>
#include <sniffer/RPatternList.h>
#include <DataIO.h>
#include <stdio.h>
using namespace BPrivate::Storage::Sniffer;
RPatternList::RPatternList()
: DisjList()
{
}
RPatternList::~RPatternList() {
std::vector<RPattern*>::iterator i;
for (i = fList.begin(); i != fList.end(); i++)
delete *i;
}
status_t
RPatternList::InitCheck() const {
return B_OK;
}
Err*
RPatternList::GetErr() const {
return NULL;
}
with any of the list's patterns. Each pattern is searched
over its own specified range.
*/
bool
RPatternList::Sniff(BPositionIO *data) const {
if (InitCheck() != B_OK)
return false;
else {
bool result = false;
std::vector<RPattern*>::const_iterator i;
for (i = fList.begin(); i != fList.end(); i++) {
if (*i)
result |= (*i)->Sniff(data, fCaseInsensitive);
}
return result;
}
}
code if something goes wrong.
*/
ssize_t
RPatternList::BytesNeeded() const
{
ssize_t result = InitCheck();
if (result == B_OK) {
result = 0;
std::vector<RPattern*>::const_iterator i;
for (i = fList.begin(); i != fList.end(); i++) {
if (*i) {
ssize_t bytes = (*i)->BytesNeeded();
if (bytes >= 0) {
if (bytes > result)
result = bytes;
} else {
result = bytes;
break;
}
}
}
}
return result;
}
void
RPatternList::Add(RPattern *rpattern) {
if (rpattern)
fList.push_back(rpattern);
}