|
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 nsStringBundleService_h__ |
|
7 #define nsStringBundleService_h__ |
|
8 |
|
9 #include "nsCOMPtr.h" |
|
10 #include "nsDataHashtable.h" |
|
11 #include "nsHashKeys.h" |
|
12 #include "nsIPersistentProperties2.h" |
|
13 #include "nsIStringBundle.h" |
|
14 #include "nsIObserver.h" |
|
15 #include "nsWeakReference.h" |
|
16 #include "nsIErrorService.h" |
|
17 #include "nsIStringBundleOverride.h" |
|
18 |
|
19 #include "mozilla/LinkedList.h" |
|
20 |
|
21 struct bundleCacheEntry_t; |
|
22 |
|
23 class nsStringBundleService : public nsIStringBundleService, |
|
24 public nsIObserver, |
|
25 public nsSupportsWeakReference |
|
26 { |
|
27 public: |
|
28 nsStringBundleService(); |
|
29 virtual ~nsStringBundleService(); |
|
30 |
|
31 nsresult Init(); |
|
32 |
|
33 NS_DECL_ISUPPORTS |
|
34 NS_DECL_NSISTRINGBUNDLESERVICE |
|
35 NS_DECL_NSIOBSERVER |
|
36 |
|
37 private: |
|
38 nsresult getStringBundle(const char *aUrl, nsIStringBundle** aResult); |
|
39 nsresult FormatWithBundle(nsIStringBundle* bundle, nsresult aStatus, |
|
40 uint32_t argCount, char16_t** argArray, |
|
41 char16_t* *result); |
|
42 |
|
43 void flushBundleCache(); |
|
44 |
|
45 bundleCacheEntry_t *insertIntoCache(already_AddRefed<nsIStringBundle> aBundle, |
|
46 nsCString &aHashKey); |
|
47 |
|
48 nsDataHashtable<nsCStringHashKey, bundleCacheEntry_t*> mBundleMap; |
|
49 mozilla::LinkedList<bundleCacheEntry_t> mBundleCache; |
|
50 |
|
51 nsCOMPtr<nsIErrorService> mErrorService; |
|
52 nsCOMPtr<nsIStringBundleOverride> mOverrideStrings; |
|
53 }; |
|
54 |
|
55 #endif |