extensions/universalchardet/src/xpcom/nsUdetXPCOMWrapper.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef _nsUdetXPCOMWrapper_h__
michael@0 7 #define _nsUdetXPCOMWrapper_h__
michael@0 8 #include "nsISupports.h"
michael@0 9 #include "nsICharsetDetector.h"
michael@0 10 #include "nsIStringCharsetDetector.h"
michael@0 11 #include "nsICharsetDetectionObserver.h"
michael@0 12 #include "nsCOMPtr.h"
michael@0 13
michael@0 14 #include "nsIFactory.h"
michael@0 15
michael@0 16 // {374E0CDE-F605-4259-8C92-E639C6C2EEEF}
michael@0 17 #define NS_UNIVERSAL_DETECTOR_CID \
michael@0 18 { 0x374e0cde, 0xf605, 0x4259, { 0x8c, 0x92, 0xe6, 0x39, 0xc6, 0xc2, 0xee, 0xef } }
michael@0 19
michael@0 20 // {6EE5301A-3981-49bd-85F8-1A2CC228CF3E}
michael@0 21 #define NS_UNIVERSAL_STRING_DETECTOR_CID \
michael@0 22 { 0x6ee5301a, 0x3981, 0x49bd, { 0x85, 0xf8, 0x1a, 0x2c, 0xc2, 0x28, 0xcf, 0x3e } }
michael@0 23
michael@0 24 // {12BB8F1B-2389-11d3-B3BF-00805F8A6670}
michael@0 25 #define NS_JA_PSMDETECTOR_CID \
michael@0 26 { 0x12bb8f1b, 0x2389, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
michael@0 27
michael@0 28 // {12BB8F1C-2389-11d3-B3BF-00805F8A6670}
michael@0 29 #define NS_JA_STRING_PSMDETECTOR_CID \
michael@0 30 { 0x12bb8f1c, 0x2389, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
michael@0 31
michael@0 32 // {EA06D4E1-2B3D-11d3-B3BF-00805F8A6670}
michael@0 33 #define NS_KO_PSMDETECTOR_CID \
michael@0 34 { 0xea06d4e1, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
michael@0 35
michael@0 36 // {EA06D4E2-2B3D-11d3-B3BF-00805F8A6670}
michael@0 37 #define NS_ZHCN_PSMDETECTOR_CID \
michael@0 38 { 0xea06d4e2, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
michael@0 39
michael@0 40 // {EA06D4E3-2B3D-11d3-B3BF-00805F8A6670}
michael@0 41 #define NS_ZHTW_PSMDETECTOR_CID \
michael@0 42 { 0xea06d4e3, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
michael@0 43
michael@0 44
michael@0 45 // {EA06D4E4-2B3D-11d3-B3BF-00805F8A6670}
michael@0 46 #define NS_KO_STRING_PSMDETECTOR_CID \
michael@0 47 { 0xea06d4e4, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
michael@0 48
michael@0 49 // {EA06D4E5-2B3D-11d3-B3BF-00805F8A6670}
michael@0 50 #define NS_ZHCN_STRING_PSMDETECTOR_CID \
michael@0 51 { 0xea06d4e5, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
michael@0 52
michael@0 53 // {EA06D4E6-2B3D-11d3-B3BF-00805F8A6670}
michael@0 54 #define NS_ZHTW_STRING_PSMDETECTOR_CID \
michael@0 55 { 0xea06d4e6, 0x2b3d, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
michael@0 56
michael@0 57
michael@0 58 // {FCACEF21-2B40-11d3-B3BF-00805F8A6670}
michael@0 59 #define NS_ZH_STRING_PSMDETECTOR_CID \
michael@0 60 { 0xfcacef21, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
michael@0 61
michael@0 62 // {FCACEF22-2B40-11d3-B3BF-00805F8A6670}
michael@0 63 #define NS_CJK_STRING_PSMDETECTOR_CID \
michael@0 64 { 0xfcacef22, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
michael@0 65
michael@0 66
michael@0 67 // {FCACEF23-2B40-11d3-B3BF-00805F8A6670}
michael@0 68 #define NS_ZH_PSMDETECTOR_CID \
michael@0 69 { 0xfcacef23, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
michael@0 70
michael@0 71 // {FCACEF24-2B40-11d3-B3BF-00805F8A6670}
michael@0 72 #define NS_CJK_PSMDETECTOR_CID \
michael@0 73 { 0xfcacef24, 0x2b40, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
michael@0 74
michael@0 75 //=====================================================================
michael@0 76 class nsXPCOMDetector :
michael@0 77 public nsUniversalDetector,
michael@0 78 public nsICharsetDetector
michael@0 79 {
michael@0 80 NS_DECL_ISUPPORTS
michael@0 81 public:
michael@0 82 nsXPCOMDetector(uint32_t aLanguageFilter);
michael@0 83 virtual ~nsXPCOMDetector();
michael@0 84 NS_IMETHOD Init(nsICharsetDetectionObserver* aObserver);
michael@0 85 NS_IMETHOD DoIt(const char* aBuf, uint32_t aLen, bool *oDontFeedMe);
michael@0 86 NS_IMETHOD Done();
michael@0 87 protected:
michael@0 88 virtual void Report(const char* aCharset);
michael@0 89 private:
michael@0 90 nsCOMPtr<nsICharsetDetectionObserver> mObserver;
michael@0 91 };
michael@0 92
michael@0 93
michael@0 94 //=====================================================================
michael@0 95 class nsXPCOMStringDetector :
michael@0 96 public nsUniversalDetector,
michael@0 97 public nsIStringCharsetDetector
michael@0 98 {
michael@0 99 NS_DECL_ISUPPORTS
michael@0 100 public:
michael@0 101 nsXPCOMStringDetector(uint32_t aLanguageFilter);
michael@0 102 virtual ~nsXPCOMStringDetector();
michael@0 103 NS_IMETHOD DoIt(const char* aBuf, uint32_t aLen,
michael@0 104 const char** oCharset, nsDetectionConfident &oConf);
michael@0 105 protected:
michael@0 106 virtual void Report(const char* aCharset);
michael@0 107 private:
michael@0 108 nsCOMPtr<nsICharsetDetectionObserver> mObserver;
michael@0 109 const char* mResult;
michael@0 110 };
michael@0 111
michael@0 112 //=====================================================================
michael@0 113 class nsUniversalXPCOMDetector : public nsXPCOMDetector
michael@0 114 {
michael@0 115 public:
michael@0 116 nsUniversalXPCOMDetector()
michael@0 117 : nsXPCOMDetector(NS_FILTER_ALL) {}
michael@0 118 };
michael@0 119
michael@0 120 class nsUniversalXPCOMStringDetector : public nsXPCOMStringDetector
michael@0 121 {
michael@0 122 public:
michael@0 123 nsUniversalXPCOMStringDetector()
michael@0 124 : nsXPCOMStringDetector(NS_FILTER_ALL) {}
michael@0 125 };
michael@0 126
michael@0 127 class nsJAPSMDetector : public nsXPCOMDetector
michael@0 128 {
michael@0 129 public:
michael@0 130 nsJAPSMDetector()
michael@0 131 : nsXPCOMDetector(NS_FILTER_JAPANESE) {}
michael@0 132 };
michael@0 133
michael@0 134 class nsJAStringPSMDetector : public nsXPCOMStringDetector
michael@0 135 {
michael@0 136 public:
michael@0 137 nsJAStringPSMDetector()
michael@0 138 : nsXPCOMStringDetector(NS_FILTER_JAPANESE) {}
michael@0 139 };
michael@0 140
michael@0 141 class nsKOPSMDetector : public nsXPCOMDetector
michael@0 142 {
michael@0 143 public:
michael@0 144 nsKOPSMDetector()
michael@0 145 : nsXPCOMDetector(NS_FILTER_KOREAN) {}
michael@0 146 };
michael@0 147
michael@0 148 class nsKOStringPSMDetector : public nsXPCOMStringDetector
michael@0 149 {
michael@0 150 public:
michael@0 151 nsKOStringPSMDetector()
michael@0 152 : nsXPCOMStringDetector(NS_FILTER_KOREAN) {}
michael@0 153 };
michael@0 154
michael@0 155 class nsZHTWPSMDetector : public nsXPCOMDetector
michael@0 156 {
michael@0 157 public:
michael@0 158 nsZHTWPSMDetector()
michael@0 159 : nsXPCOMDetector(NS_FILTER_CHINESE_TRADITIONAL) {}
michael@0 160 };
michael@0 161
michael@0 162 class nsZHTWStringPSMDetector : public nsXPCOMStringDetector
michael@0 163 {
michael@0 164 public:
michael@0 165 nsZHTWStringPSMDetector()
michael@0 166 : nsXPCOMStringDetector(NS_FILTER_CHINESE_TRADITIONAL) {}
michael@0 167 };
michael@0 168
michael@0 169 class nsZHCNPSMDetector : public nsXPCOMDetector
michael@0 170 {
michael@0 171 public:
michael@0 172 nsZHCNPSMDetector()
michael@0 173 : nsXPCOMDetector(NS_FILTER_CHINESE_SIMPLIFIED) {}
michael@0 174 };
michael@0 175
michael@0 176 class nsZHCNStringPSMDetector : public nsXPCOMStringDetector
michael@0 177 {
michael@0 178 public:
michael@0 179 nsZHCNStringPSMDetector()
michael@0 180 : nsXPCOMStringDetector(NS_FILTER_CHINESE_SIMPLIFIED) {}
michael@0 181 };
michael@0 182
michael@0 183 class nsZHPSMDetector : public nsXPCOMDetector
michael@0 184 {
michael@0 185 public:
michael@0 186 nsZHPSMDetector()
michael@0 187 : nsXPCOMDetector(NS_FILTER_CHINESE) {}
michael@0 188 };
michael@0 189
michael@0 190 class nsZHStringPSMDetector : public nsXPCOMStringDetector
michael@0 191 {
michael@0 192 public:
michael@0 193 nsZHStringPSMDetector()
michael@0 194 : nsXPCOMStringDetector(NS_FILTER_CHINESE) {}
michael@0 195 };
michael@0 196
michael@0 197 class nsCJKPSMDetector : public nsXPCOMDetector
michael@0 198 {
michael@0 199 public:
michael@0 200 nsCJKPSMDetector()
michael@0 201 : nsXPCOMDetector(NS_FILTER_CJK) {}
michael@0 202 };
michael@0 203
michael@0 204 class nsCJKStringPSMDetector : public nsXPCOMStringDetector
michael@0 205 {
michael@0 206 public:
michael@0 207 nsCJKStringPSMDetector()
michael@0 208 : nsXPCOMStringDetector(NS_FILTER_CJK) {}
michael@0 209 };
michael@0 210
michael@0 211 #endif //_nsUdetXPCOMWrapper_h__

mercurial