|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
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 nsEntityConverter_h__ |
|
7 #define nsEntityConverter_h__ |
|
8 |
|
9 #include "nsIEntityConverter.h" |
|
10 #include "nsIStringBundle.h" |
|
11 #include "nsCOMPtr.h" |
|
12 |
|
13 #define kVERSION_STRING_LEN 128 |
|
14 |
|
15 class nsEntityVersionList |
|
16 { |
|
17 public: |
|
18 nsEntityVersionList() {} |
|
19 |
|
20 uint32_t mVersion; |
|
21 char16_t mEntityListName[kVERSION_STRING_LEN+1]; |
|
22 nsCOMPtr<nsIStringBundle> mEntities; |
|
23 }; |
|
24 |
|
25 class nsEntityConverter: public nsIEntityConverter |
|
26 { |
|
27 public: |
|
28 |
|
29 // |
|
30 // implementation methods |
|
31 // |
|
32 nsEntityConverter(); |
|
33 virtual ~nsEntityConverter(); |
|
34 |
|
35 // |
|
36 // nsISupports |
|
37 // |
|
38 NS_DECL_ISUPPORTS |
|
39 |
|
40 // |
|
41 // nsIEntityConverter |
|
42 // |
|
43 NS_IMETHOD ConvertUTF32ToEntity(uint32_t character, uint32_t entityVersion, char **_retval); |
|
44 NS_IMETHOD ConvertToEntity(char16_t character, uint32_t entityVersion, char **_retval); |
|
45 |
|
46 NS_IMETHOD ConvertToEntities(const char16_t *inString, uint32_t entityVersion, char16_t **_retval); |
|
47 |
|
48 protected: |
|
49 |
|
50 // load a version property file and generate a version list (number/name pair) |
|
51 NS_IMETHOD LoadVersionPropertyFile(); |
|
52 |
|
53 // map version number to version string |
|
54 const char16_t* GetVersionName(uint32_t versionNumber); |
|
55 |
|
56 // map version number to a string bundle |
|
57 nsIStringBundle* GetVersionBundleInstance(uint32_t versionNumber); |
|
58 |
|
59 // load a string bundle file |
|
60 already_AddRefed<nsIStringBundle> LoadEntityBundle(uint32_t version); |
|
61 |
|
62 |
|
63 nsEntityVersionList *mVersionList; // array of version number/name pairs |
|
64 uint32_t mVersionListLength; // number of supported versions |
|
65 }; |
|
66 |
|
67 #endif |