sbStringBundle.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 :miv */
3 /*
4 //
5 // BEGIN SONGBIRD GPL
6 //
7 // This file is part of the Songbird web player.
8 //
9 // Copyright(c) 2005-2008 POTI, Inc.
10 // http://songbirdnest.com
11 //
12 // This file may be licensed under the terms of of the
13 // GNU General Public License Version 2 (the "GPL").
14 //
15 // Software distributed under the License is distributed
16 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
17 // express or implied. See the GPL for the specific language
18 // governing rights and limitations.
19 //
20 // You should have received a copy of the GPL along with this
21 // program. If not, go to http://www.gnu.org/licenses/gpl.html
22 // or write to the Free Software Foundation, Inc.,
23 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 // END SONGBIRD GPL
26 //
27 */
28 
29 #ifndef __SB_STRINGBUNDLE_H__
30 #define __SB_STRINGBUNDLE_H__
31 
32 //------------------------------------------------------------------------------
33 //------------------------------------------------------------------------------
34 //
35 // Songbird string bundle services.
36 //
37 //------------------------------------------------------------------------------
38 //------------------------------------------------------------------------------
39 
45 // Songbird imports.
46 #include <sbIStringBundleService.h>
47 #include <sbStringUtils.h>
48 
49 // Mozilla imports.
50 #include <nsCOMArray.h>
51 #include <nsCOMPtr.h>
52 #include <nsIStringBundle.h>
53 
54 
77 class sbStringBundle
78 {
79  //----------------------------------------------------------------------------
80  //
81  // Public interface.
82  //
83  //----------------------------------------------------------------------------
84 
85 public:
86 
87  //
88  // Constructors/destructors.
89  //
90 
99  sbStringBundle(const char* aURI = nsnull);
100 
101 
107  sbStringBundle(nsIStringBundle* aBundle);
108 
109 
110  //
111  // Public services.
112  //
113 
126  nsString Get(const nsAString& aKey,
127  const nsAString& aDefault = SBVoidString());
128 
129  nsString Get(const char* aKey,
130  const char* aDefault = nsnull);
131 
132 
146  nsString Format(const nsAString& aKey,
147  nsTArray<nsString>& aParams,
148  const nsAString& aDefault = SBVoidString());
149 
150  nsString Format(const char* aKey,
151  nsTArray<nsString>& aParams,
152  const char* aDefault = nsnull);
153 
154  nsString Format(const nsAString& aKey,
155  const nsAString& aParam,
156  const nsAString& aDefault = SBVoidString());
157 
158  nsString Format(const char* aKey,
159  const nsAString& aParam,
160  const char* aDefault = nsnull);
161 
162 
163  //----------------------------------------------------------------------------
164  //
165  // Private interface.
166  //
167  //----------------------------------------------------------------------------
168 
169 private:
170 
171  //
172  // mStringBundleService Songbird string bundle service.
173  // mBundleList List of string bundles.
174  //
175 
176  nsCOMPtr<sbIStringBundleService>
177  mStringBundleService;
178  nsCOMArray<nsIStringBundle> mBundleList;
179 
180 
181  //
182  // Internal services.
183  //
184 
185  nsresult LoadBundle(const char* aURI);
186 
187  nsresult LoadBundle(nsIStringBundle* aBundle);
188 
189  nsresult ApplySubstitutions(nsAString& aString);
190 };
191 
192 
193 #endif // __SB_STRINGBUNDLE_H__
194 
nsString Get(const nsAString &aKey, const nsAString &aDefault=SBVoidString())
nsString Format(const nsAString &aKey, nsTArray< nsString > &aParams, const nsAString &aDefault=SBVoidString())