2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsStringBundle_h__
|
|
|
|
#define nsStringBundle_h__
|
|
|
|
|
2011-04-29 12:21:57 -07:00
|
|
|
#include "mozilla/ReentrantMonitor.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIStringBundle.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsCOMArray.h"
|
2013-09-27 09:45:04 -07:00
|
|
|
|
|
|
|
class nsIPersistentProperties;
|
|
|
|
class nsIStringBundleOverride;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsStringBundle : public nsIStringBundle
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// init version
|
|
|
|
nsStringBundle(const char* aURLSpec, nsIStringBundleOverride*);
|
|
|
|
nsresult LoadProperties();
|
2014-04-21 09:41:56 -07:00
|
|
|
|
2013-07-18 19:23:32 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSISTRINGBUNDLE
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPersistentProperties> mProps;
|
|
|
|
|
|
|
|
protected:
|
2014-06-23 15:40:02 -07:00
|
|
|
virtual ~nsStringBundle();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//
|
2014-04-21 09:41:56 -07:00
|
|
|
// functional decomposition of the funitions repeatively called
|
2007-03-22 10:30:00 -07:00
|
|
|
//
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult GetStringFromID(int32_t aID, nsAString& aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult GetStringFromName(const nsAString& aName, nsAString& aResult);
|
|
|
|
|
|
|
|
nsresult GetCombinedEnumeration(nsIStringBundleOverride* aOverrideString,
|
|
|
|
nsISimpleEnumerator** aResult);
|
|
|
|
private:
|
|
|
|
nsCString mPropertiesURL;
|
|
|
|
nsCOMPtr<nsIStringBundleOverride> mOverrideStrings;
|
2011-04-29 12:21:57 -07:00
|
|
|
mozilla::ReentrantMonitor mReentrantMonitor;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mAttemptedLoad;
|
|
|
|
bool mLoaded;
|
2014-04-21 09:41:56 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2014-01-04 07:02:17 -08:00
|
|
|
static nsresult FormatString(const char16_t *formatStr,
|
|
|
|
const char16_t **aParams, uint32_t aLength,
|
|
|
|
char16_t **aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2014-06-23 15:40:02 -07:00
|
|
|
class nsExtensibleStringBundle;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2014-04-21 09:41:57 -07:00
|
|
|
* An extensible implementation of the StringBundle interface.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* @created 28/Dec/1999
|
|
|
|
* @author Catalin Rotaru [CATA]
|
|
|
|
*/
|
2014-07-08 13:46:24 -07:00
|
|
|
class nsExtensibleStringBundle MOZ_FINAL : public nsIStringBundle
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISTRINGBUNDLE
|
|
|
|
|
|
|
|
nsresult Init(const char * aCategory, nsIStringBundleService *);
|
|
|
|
|
|
|
|
public:
|
|
|
|
nsExtensibleStringBundle();
|
2014-07-08 13:46:24 -07:00
|
|
|
|
|
|
|
private:
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~nsExtensibleStringBundle();
|
2014-07-08 13:46:24 -07:00
|
|
|
|
|
|
|
nsCOMArray<nsIStringBundle> mBundles;
|
|
|
|
bool mLoaded;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|