michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsStringBundle_h__ michael@0: #define nsStringBundle_h__ michael@0: michael@0: #include "mozilla/ReentrantMonitor.h" michael@0: #include "nsIStringBundle.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsString.h" michael@0: #include "nsCOMArray.h" michael@0: michael@0: class nsIPersistentProperties; michael@0: class nsIStringBundleOverride; michael@0: michael@0: class nsStringBundle : public nsIStringBundle michael@0: { michael@0: public: michael@0: // init version michael@0: nsStringBundle(const char* aURLSpec, nsIStringBundleOverride*); michael@0: nsresult LoadProperties(); michael@0: virtual ~nsStringBundle(); michael@0: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSISTRINGBUNDLE michael@0: michael@0: nsCOMPtr mProps; michael@0: michael@0: protected: michael@0: // michael@0: // functional decomposition of the funitions repeatively called michael@0: // michael@0: nsresult GetStringFromID(int32_t aID, nsAString& aResult); michael@0: nsresult GetStringFromName(const nsAString& aName, nsAString& aResult); michael@0: michael@0: nsresult GetCombinedEnumeration(nsIStringBundleOverride* aOverrideString, michael@0: nsISimpleEnumerator** aResult); michael@0: private: michael@0: nsCString mPropertiesURL; michael@0: nsCOMPtr mOverrideStrings; michael@0: mozilla::ReentrantMonitor mReentrantMonitor; michael@0: bool mAttemptedLoad; michael@0: bool mLoaded; michael@0: michael@0: public: michael@0: static nsresult FormatString(const char16_t *formatStr, michael@0: const char16_t **aParams, uint32_t aLength, michael@0: char16_t **aResult); michael@0: }; michael@0: michael@0: /** michael@0: * An extensible implementation of the StringBundle interface. michael@0: * michael@0: * @created 28/Dec/1999 michael@0: * @author Catalin Rotaru [CATA] michael@0: */ michael@0: class nsExtensibleStringBundle : public nsIStringBundle michael@0: { michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSISTRINGBUNDLE michael@0: michael@0: nsresult Init(const char * aCategory, nsIStringBundleService *); michael@0: private: michael@0: michael@0: nsCOMArray mBundles; michael@0: bool mLoaded; michael@0: michael@0: public: michael@0: michael@0: nsExtensibleStringBundle(); michael@0: virtual ~nsExtensibleStringBundle(); michael@0: }; michael@0: michael@0: michael@0: michael@0: #endif