Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef _nsUdetXPCOMWrapper_h__
7 : #define _nsUdetXPCOMWrapper_h__
8 : #include "nsISupports.h"
9 : #include "nsICharsetDetector.h"
10 : #include "nsIStringCharsetDetector.h"
11 : #include "nsICharsetDetectionObserver.h"
12 : #include "nsCOMPtr.h"
13 :
14 : #include "nsIFactory.h"
15 :
16 : // {12BB8F1B-2389-11d3-B3BF-00805F8A6670}
17 : #define NS_JA_PSMDETECTOR_CID \
18 : { 0x12bb8f1b, 0x2389, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
19 :
20 : // {12BB8F1C-2389-11d3-B3BF-00805F8A6670}
21 : #define NS_JA_STRING_PSMDETECTOR_CID \
22 : { 0x12bb8f1c, 0x2389, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
23 :
24 : //=====================================================================
25 : class nsXPCOMDetector :
26 : public nsUniversalDetector,
27 : public nsICharsetDetector
28 : {
29 : NS_DECL_ISUPPORTS
30 : public:
31 : nsXPCOMDetector();
32 : NS_IMETHOD Init(nsICharsetDetectionObserver* aObserver) override;
33 : NS_IMETHOD DoIt(const char* aBuf, uint32_t aLen, bool *oDontFeedMe) override;
34 : NS_IMETHOD Done() override;
35 : protected:
36 : virtual ~nsXPCOMDetector();
37 : virtual void Report(const char* aCharset) override;
38 : private:
39 : nsCOMPtr<nsICharsetDetectionObserver> mObserver;
40 : };
41 :
42 :
43 : //=====================================================================
44 : class nsXPCOMStringDetector :
45 : public nsUniversalDetector,
46 : public nsIStringCharsetDetector
47 : {
48 : NS_DECL_ISUPPORTS
49 : public:
50 : nsXPCOMStringDetector();
51 : NS_IMETHOD DoIt(const char* aBuf, uint32_t aLen,
52 : const char** oCharset, nsDetectionConfident &oConf) override;
53 : protected:
54 : virtual ~nsXPCOMStringDetector();
55 : virtual void Report(const char* aCharset) override;
56 : private:
57 : nsCOMPtr<nsICharsetDetectionObserver> mObserver;
58 : const char* mResult;
59 : };
60 :
61 : //=====================================================================
62 :
63 0 : class nsJAPSMDetector : public nsXPCOMDetector
64 : {
65 : public:
66 0 : nsJAPSMDetector()
67 0 : : nsXPCOMDetector() {}
68 : };
69 :
70 0 : class nsJAStringPSMDetector : public nsXPCOMStringDetector
71 : {
72 : public:
73 0 : nsJAStringPSMDetector()
74 0 : : nsXPCOMStringDetector() {}
75 : };
76 :
77 : #endif //_nsUdetXPCOMWrapper_h__
|