xref: /haiku/headers/private/storage/sniffer/Err.h (revision 4c8e85b316c35a9161f5a1c50ad70bc91c83a76f)
1 //----------------------------------------------------------------------
2 //  This software is part of the Haiku distribution and is covered
3 //  by the MIT License.
4 //---------------------------------------------------------------------
5 /*!
6 	\file sniffer/Err.h
7 	Mime Sniffer Error class declarations
8 */
9 #ifndef _SNIFFER_ERR_H
10 #define _SNIFFER_ERR_H
11 
12 #include <SupportDefs.h>
13 #include <string>
14 
15 namespace BPrivate {
16 namespace Storage {
17 namespace Sniffer {
18 
19 //! Exception class used by the MIME Sniffer
20 /*! Each exception contains an error message, and an byte offset into
21 	the original rule that generated the error, for the sake of
22 	providing spiffy error messages of the following sort:
23 
24 	<code>
25 	"1.0 ('abc' & 0xFFAAFFAA)"
26 	              ^    Sniffer pattern error: pattern and mask lengths do not match
27 	</code>
28 */
29 class Err {
30 public:
31 	Err(const char *msg, const ssize_t pos);
32 	Err(const std::string &msg, const ssize_t pos);
33 	Err(const Err &ref);
34 	virtual ~Err();
35 	Err& operator=(const Err &ref);
36 
37 	status_t SetTo(const char *msg, const ssize_t pos);
38 	status_t SetTo(const std::string &msg, const ssize_t pos);
39 	void Unset();
40 
41 	void SetMsg(const char *msg);
42 	void SetPos(ssize_t pos);
43 
44 	const char* Msg() const;
45 	ssize_t Pos() const;
46 
47 private:
48 	char *fMsg;
49 	ssize_t fPos;
50 };
51 
52 };	// namespace Sniffer
53 };	// namespace Storage
54 };	// namespace BPrivate
55 
56 #endif	// _SNIFFER_ERR_H
57 
58 
59