2002-10-14 23:06:27 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
2002-09-25 01:50:05 +04:00
|
|
|
|
|
|
|
#ifndef nsStringBundle_h__
|
|
|
|
#define nsStringBundle_h__
|
|
|
|
|
2011-04-29 23:21:57 +04:00
|
|
|
#include "mozilla/ReentrantMonitor.h"
|
2002-10-14 23:06:27 +04:00
|
|
|
#include "nsIStringBundle.h"
|
2002-09-25 01:50:05 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2002-10-14 23:06:27 +04:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsCOMArray.h"
|
2013-09-27 20:45:04 +04:00
|
|
|
|
|
|
|
class nsIPersistentProperties;
|
|
|
|
class nsIStringBundleOverride;
|
2002-09-25 01:50:05 +04:00
|
|
|
|
2002-10-14 23:06:27 +04:00
|
|
|
class nsStringBundle : public nsIStringBundle
|
2002-09-25 01:50:05 +04:00
|
|
|
{
|
|
|
|
public:
|
2002-10-14 23:06:27 +04:00
|
|
|
// init version
|
|
|
|
nsStringBundle(const char* aURLSpec, nsIStringBundleOverride*);
|
|
|
|
nsresult LoadProperties();
|
2014-04-21 20:41:56 +04:00
|
|
|
|
2013-07-19 06:23:32 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2002-10-14 23:06:27 +04:00
|
|
|
NS_DECL_NSISTRINGBUNDLE
|
2002-09-25 01:50:05 +04:00
|
|
|
|
2002-10-14 23:06:27 +04:00
|
|
|
nsCOMPtr<nsIPersistentProperties> mProps;
|
2002-09-25 01:50:05 +04:00
|
|
|
|
2002-10-14 23:06:27 +04:00
|
|
|
protected:
|
2014-06-24 02:40:02 +04:00
|
|
|
virtual ~nsStringBundle();
|
|
|
|
|
2002-10-14 23:06:27 +04:00
|
|
|
//
|
2014-04-21 20:41:56 +04:00
|
|
|
// functional decomposition of the funitions repeatively called
|
2002-10-14 23:06:27 +04:00
|
|
|
//
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult GetStringFromID(int32_t aID, nsAString& aResult);
|
2002-10-14 23:06:27 +04:00
|
|
|
nsresult GetStringFromName(const nsAString& aName, nsAString& aResult);
|
|
|
|
|
2002-11-05 10:02:07 +03:00
|
|
|
nsresult GetCombinedEnumeration(nsIStringBundleOverride* aOverrideString,
|
2002-10-14 23:06:27 +04:00
|
|
|
nsISimpleEnumerator** aResult);
|
2002-09-25 01:50:05 +04:00
|
|
|
private:
|
2002-10-14 23:06:27 +04:00
|
|
|
nsCString mPropertiesURL;
|
|
|
|
nsCOMPtr<nsIStringBundleOverride> mOverrideStrings;
|
2011-04-29 23:21:57 +04:00
|
|
|
mozilla::ReentrantMonitor mReentrantMonitor;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mAttemptedLoad;
|
|
|
|
bool mLoaded;
|
2014-04-21 20:41:56 +04:00
|
|
|
|
2002-10-14 23:06:27 +04:00
|
|
|
public:
|
2014-01-04 19:02:17 +04:00
|
|
|
static nsresult FormatString(const char16_t *formatStr,
|
|
|
|
const char16_t **aParams, uint32_t aLength,
|
|
|
|
char16_t **aResult);
|
2002-10-14 23:06:27 +04:00
|
|
|
};
|
2002-09-25 01:50:05 +04:00
|
|
|
|
2014-06-24 02:40:02 +04:00
|
|
|
class nsExtensibleStringBundle;
|
|
|
|
|
2002-10-14 23:06:27 +04:00
|
|
|
/**
|
2014-04-21 20:41:57 +04:00
|
|
|
* An extensible implementation of the StringBundle interface.
|
2002-10-14 23:06:27 +04:00
|
|
|
*
|
|
|
|
* @created 28/Dec/1999
|
|
|
|
* @author Catalin Rotaru [CATA]
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsExtensibleStringBundle final : public nsIStringBundle
|
2002-10-14 23:06:27 +04:00
|
|
|
{
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISTRINGBUNDLE
|
2002-09-25 01:50:05 +04:00
|
|
|
|
2002-10-14 23:06:27 +04:00
|
|
|
nsresult Init(const char * aCategory, nsIStringBundleService *);
|
2002-09-25 01:50:05 +04:00
|
|
|
|
2002-10-14 23:06:27 +04:00
|
|
|
public:
|
|
|
|
nsExtensibleStringBundle();
|
2014-07-09 00:46:24 +04:00
|
|
|
|
|
|
|
private:
|
2002-10-14 23:06:27 +04:00
|
|
|
virtual ~nsExtensibleStringBundle();
|
2014-07-09 00:46:24 +04:00
|
|
|
|
|
|
|
nsCOMArray<nsIStringBundle> mBundles;
|
|
|
|
bool mLoaded;
|
2002-09-25 01:50:05 +04:00
|
|
|
};
|
|
|
|
|
2002-10-14 23:06:27 +04:00
|
|
|
|
|
|
|
|
2002-09-25 01:50:05 +04:00
|
|
|
#endif
|