nsStringBundleService.h 1.7 KB

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