nsStringBundle.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #ifndef nsStringBundle_h__
  6. #define nsStringBundle_h__
  7. #include "mozilla/ReentrantMonitor.h"
  8. #include "nsIStringBundle.h"
  9. #include "nsCOMPtr.h"
  10. #include "nsString.h"
  11. #include "nsCOMArray.h"
  12. class nsIPersistentProperties;
  13. class nsIStringBundleOverride;
  14. class nsStringBundle : public nsIStringBundle
  15. {
  16. public:
  17. // init version
  18. nsStringBundle(const char* aURLSpec, nsIStringBundleOverride*);
  19. nsresult LoadProperties();
  20. NS_DECL_THREADSAFE_ISUPPORTS
  21. NS_DECL_NSISTRINGBUNDLE
  22. nsCOMPtr<nsIPersistentProperties> mProps;
  23. protected:
  24. virtual ~nsStringBundle();
  25. //
  26. // functional decomposition of the funitions repeatively called
  27. //
  28. nsresult GetStringFromID(int32_t aID, nsAString& aResult);
  29. nsresult GetStringFromName(const nsAString& aName, nsAString& aResult);
  30. nsresult GetCombinedEnumeration(nsIStringBundleOverride* aOverrideString,
  31. nsISimpleEnumerator** aResult);
  32. private:
  33. nsCString mPropertiesURL;
  34. nsCOMPtr<nsIStringBundleOverride> mOverrideStrings;
  35. mozilla::ReentrantMonitor mReentrantMonitor;
  36. bool mAttemptedLoad;
  37. bool mLoaded;
  38. public:
  39. static nsresult FormatString(const char16_t *formatStr,
  40. const char16_t **aParams, uint32_t aLength,
  41. char16_t **aResult);
  42. };
  43. class nsExtensibleStringBundle;
  44. /**
  45. * An extensible implementation of the StringBundle interface.
  46. *
  47. * @created 28/Dec/1999
  48. * @author Catalin Rotaru [CATA]
  49. */
  50. class nsExtensibleStringBundle final : public nsIStringBundle
  51. {
  52. NS_DECL_ISUPPORTS
  53. NS_DECL_NSISTRINGBUNDLE
  54. nsresult Init(const char * aCategory, nsIStringBundleService *);
  55. public:
  56. nsExtensibleStringBundle();
  57. private:
  58. virtual ~nsExtensibleStringBundle();
  59. nsCOMArray<nsIStringBundle> mBundles;
  60. bool mLoaded;
  61. };
  62. #endif