1 /* -*- Mode: IDL; 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/. */
6 #include
"nsISupports.idl"
7 #include
"nsISimpleEnumerator.idl"
10 #include
"mozilla/MemoryReporting.h"
21 // Define Contractid and CID
22 // {D85A17C1-AA7C-11d2-9B8C-00805F8A16D9}
23 #define NS_STRINGBUNDLESERVICE_CID \
24 { 0xd85a17c1, 0xaa7c, 0x11d2, \
25 { 0x9b, 0x8c, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9 } }
27 #define NS_STRINGBUNDLE_CONTRACTID
"@mozilla.org/intl/stringbundle;1"
31 [scriptable
, uuid(D85A17C2
-AA7C
-11d2
-9B8C
-00805F8A16D9
)]
32 interface nsIStringBundle
: nsISupports
34 AString GetStringFromID
(in long aID
);
36 // This method is mostly used from JS, where AUTF8String is appropriate.
37 [binaryname
(GetStringFromAUTF8Name
)]
38 AString GetStringFromName
(in AUTF8String aName
);
40 // This method is mostly used from C++, where |string| is appropriate because
41 // the names are most often 8-bit string literals (normally ASCII, though
42 // u8"foo" literals will also work).
43 [noscript
, binaryname
(GetStringFromName
)]
44 AString GetStringFromNameCpp
(in string aName
);
46 // this is kind of like ssprintf - except that you can
47 // only pass it unicode strings, using the %S formatting character.
48 // the id or name should refer to a string in the bundle that
49 // uses %S.. do NOT try to use any other types.
50 // this uses nsTextFormatter::ssprintf to do the dirty work.
51 AString formatStringFromID
(in long aID
, in Array
<AString
> params
);
53 // This method is mostly used from JS, where AUTF8String is appropriate.
54 [binaryname
(FormatStringFromAUTF8Name
)]
55 AString formatStringFromName
(in AUTF8String aName
, in Array
<AString
> params
);
57 // This method is mostly used from C++, where |string| is appropriate because
58 // the names are most often 8-bit string literals (normally ASCII, though
59 // u8"foo" literals will also work).
60 [noscript
, binaryname
(FormatStringFromName
)]
61 AString formatStringFromNameCpp
(in string aName
, in Array
<AString
> params
);
64 Implements nsISimpleEnumerator, replaces nsIEnumerator
66 nsISimpleEnumerator getSimpleEnumeration
();
67 // Preloads string bundle data asynchronously
71 virtual size_t SizeOfIncludingThis
(mozilla
::MallocSizeOf aMallocSizeOf
) const = 0;
72 virtual size_t SizeOfIncludingThisIfUnshared
(mozilla
::MallocSizeOf aMallocSizeOf
) const = 0;
76 [scriptable
, uuid(D85A17C0
-AA7C
-11d2
-9B8C
-00805F8A16D9
)]
77 interface nsIStringBundleService
: nsISupports
79 nsIStringBundle createBundle
(in string aURLSpec
);
82 * Formats a message string from a status code and status arguments.
83 * @param aStatus - The status code. This is mapped into a string ID and
84 * and used in the string lookup process (see nsIErrorService).
85 * @param aStatusArg - The status message argument(s). Multiple arguments
86 * can be separated by newline ('\n') characters.
87 * @return the formatted message
89 AString formatStatusMessage
(in nsresult aStatus
, in wstring aStatusArg
);
92 * flushes the string bundle cache - useful when the locale changes or
93 * when we need to get some extra memory back
95 * at some point, we might want to make this flush all the bundles,
96 * because any bundles that are floating around when the locale changes
97 * will suddenly contain bad data
103 virtual size_t SizeOfIncludingThis
(mozilla
::MallocSizeOf aMallocSizeOf
) const = 0;
105 virtual
void SendContentBundles
(mozilla
::dom
::ContentParent
* aContentParent
) const = 0;
107 virtual
void RegisterContentBundle
(const nsCString
& aBundleURL
,
108 const mozilla
::ipc
::FileDescriptor
& aMapFile
,
109 size_t aMapSize
) = 0;