New mime sniffer support classes
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@601 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file sniffer/Err.h
|
||||
Mime Sniffer Error class declarations
|
||||
*/
|
||||
#ifndef _sk_sniffer_err_h_
|
||||
#define _sk_sniffer_err_h_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <string>
|
||||
|
||||
namespace Sniffer {
|
||||
|
||||
//! Exception class used by the MIME Sniffer
|
||||
class Err {
|
||||
public:
|
||||
Err(const char *msg, const ssize_t pos);
|
||||
Err(const std::string &msg, const ssize_t pos);
|
||||
Err(const Err &ref);
|
||||
virtual ~Err();
|
||||
Err& operator=(const Err &ref);
|
||||
|
||||
status_t SetTo(const char *msg, const ssize_t pos);
|
||||
status_t SetTo(const std::string &msg, const ssize_t pos);
|
||||
void Unset();
|
||||
|
||||
const char* Msg() const;
|
||||
ssize_t Pos() const;
|
||||
|
||||
private:
|
||||
friend class Parser; // So it can update the pos of its out of mem object
|
||||
void SetMsg(const char *msg);
|
||||
void SetPos(ssize_t pos);
|
||||
char *fMsg;
|
||||
ssize_t fPos;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // _sk_sniffer_err_h_
|
||||
@@ -0,0 +1,49 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file sniffer/Pattern.h
|
||||
Mime Sniffer Pattern declarations
|
||||
*/
|
||||
#ifndef _sk_sniffer_pattern_h_
|
||||
#define _sk_sniffer_pattern_h_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <string>
|
||||
#include <sniffer/Range.h>
|
||||
|
||||
class BPositionIO;
|
||||
|
||||
namespace Sniffer {
|
||||
|
||||
class Err;
|
||||
|
||||
//! Abstract class definining an interface for sniffing BPositionIO objects
|
||||
class Pattern {
|
||||
public:
|
||||
Pattern(const char *string, const char *mask = NULL);
|
||||
~Pattern();
|
||||
|
||||
status_t InitCheck() const;
|
||||
Err* GetErr() const;
|
||||
|
||||
bool Sniff(Range range, BPositionIO *data) const;
|
||||
|
||||
status_t SetTo(const char *string, const char *mask = NULL);
|
||||
private:
|
||||
bool Sniff(off_t start, off_t size, BPositionIO *data) const;
|
||||
|
||||
void SetStatus(status_t status, const char *msg = NULL);
|
||||
void SetErrorMessage(const char *msg);
|
||||
|
||||
std::string fString;
|
||||
std::string fMask;
|
||||
|
||||
status_t fCStatus;
|
||||
Err *fErrorMessage;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // _sk_sniffer_pattern_h_
|
||||
@@ -0,0 +1,40 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file sniffer/PatternList.h
|
||||
MIME sniffer pattern list declarations
|
||||
*/
|
||||
#ifndef _sk_sniffer_pattern_list_h_
|
||||
#define _sk_sniffer_pattern_list_h_
|
||||
|
||||
#include <sniffer/Expr.h>
|
||||
#include <sniffer/Range.h>
|
||||
#include <vector>
|
||||
|
||||
class BPositionIO;
|
||||
|
||||
namespace Sniffer {
|
||||
|
||||
class Err;
|
||||
class Pattern;
|
||||
|
||||
class PatternList : public Expr {
|
||||
public:
|
||||
PatternList(Range range);
|
||||
virtual ~PatternList();
|
||||
|
||||
status_t InitCheck() const;
|
||||
Err* GetErr() const;
|
||||
|
||||
virtual bool Sniff(BPositionIO *data) const;
|
||||
void Add(Pattern *pattern);
|
||||
private:
|
||||
std::vector<Pattern*> fList;
|
||||
Range fRange;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // _sk_sniffer_pattern_list_h_
|
||||
@@ -0,0 +1,38 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file sniffer/RPattern.h
|
||||
Mime Sniffer RPattern declarations
|
||||
*/
|
||||
#ifndef _sk_sniffer_r_pattern_h_
|
||||
#define _sk_sniffer_r_pattern_h_
|
||||
|
||||
#include <sniffer/Range.h>
|
||||
|
||||
class BPositionIO;
|
||||
|
||||
namespace Sniffer {
|
||||
|
||||
class Err;
|
||||
class Pattern;
|
||||
|
||||
//! Abstract class definining an interface for sniffing BFile objects
|
||||
class RPattern {
|
||||
public:
|
||||
RPattern(Range range, Pattern *pattern);
|
||||
~RPattern();
|
||||
|
||||
status_t InitCheck() const;
|
||||
Err* GetErr() const;
|
||||
|
||||
bool Sniff(BPositionIO *data) const;
|
||||
private:
|
||||
Range fRange;
|
||||
Pattern *fPattern;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // _sk_sniffer_r_pattern_h_
|
||||
@@ -0,0 +1,38 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file sniffer/RPatternList.h
|
||||
MIME sniffer rpattern list declarations
|
||||
*/
|
||||
#ifndef _sk_sniffer_r_pattern_list_h_
|
||||
#define _sk_sniffer_r_pattern_list_h_
|
||||
|
||||
#include <sniffer/Expr.h>
|
||||
#include <vector>
|
||||
|
||||
class BPositionIO;
|
||||
|
||||
namespace Sniffer {
|
||||
|
||||
class Err;
|
||||
class RPattern;
|
||||
|
||||
class RPatternList : public Expr {
|
||||
public:
|
||||
RPatternList();
|
||||
virtual ~RPatternList();
|
||||
|
||||
status_t InitCheck() const;
|
||||
Err* GetErr() const;
|
||||
|
||||
virtual bool Sniff(BPositionIO *data) const;
|
||||
void Add(RPattern *rpattern);
|
||||
private:
|
||||
std::vector<RPattern*> fList;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // _sk_sniffer_r_pattern_list_h_
|
||||
Reference in New Issue
Block a user