1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim:set ts=2 sw=2 sts=2 et cindent: */
3
/* ***** BEGIN LICENSE BLOCK *****
4
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
* The contents of this file are subject to the Mozilla Public License Version
7
* 1.1 (the "License"); you may not use this file except in compliance with
8
* the License. You may obtain a copy of the License at
9
* http://www.mozilla.org/MPL/
11
* Software distributed under the License is distributed on an "AS IS" basis,
12
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
* for the specific language governing rights and limitations under the
16
* The Original Code is Mozilla.
18
* The Initial Developer of the Original Code is IBM Corporation.
19
* Portions created by IBM Corporation are Copyright (C) 2003
20
* IBM Corporation. All Rights Reserved.
23
* Darin Fisher <darin@meer.net>
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the MPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the MPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
43
#ifndef nsSubstring_h___
44
#include "nsSubstring.h"
47
#ifndef nsDependentSubstring_h___
48
#include "nsDependentSubstring.h"
51
#ifndef nsReadableUtils_h___
52
#include "nsReadableUtils.h"
57
// enable support for the obsolete string API if not explicitly disabled
58
#ifndef MOZ_STRING_WITH_OBSOLETE_API
59
#define MOZ_STRING_WITH_OBSOLETE_API 1
62
#if MOZ_STRING_WITH_OBSOLETE_API
63
// radix values for ToInteger/AppendInt
66
#define kAutoDetect (100)
67
#define kRadixUnknown (kAutoDetect+1)
68
#define IGNORE_CASE (PR_TRUE)
72
// declare nsString, et. al.
73
#include "string-template-def-unichar.h"
74
#include "nsTString.h"
75
#include "string-template-undef.h"
77
// declare nsCString, et. al.
78
#include "string-template-def-char.h"
79
#include "nsTString.h"
80
#include "string-template-undef.h"
84
* A helper class that converts a UTF-16 string to ASCII in a lossy manner
86
class NS_LossyConvertUTF16toASCII : public nsCAutoString
90
NS_LossyConvertUTF16toASCII( const PRUnichar* aString )
92
LossyAppendUTF16toASCII(aString, *this);
95
NS_LossyConvertUTF16toASCII( const PRUnichar* aString, PRUint32 aLength )
97
LossyAppendUTF16toASCII(Substring(aString, aString + aLength), *this);
101
NS_LossyConvertUTF16toASCII( const nsAString& aString )
103
LossyAppendUTF16toASCII(aString, *this);
107
// NOT TO BE IMPLEMENTED
108
NS_LossyConvertUTF16toASCII( char );
112
class NS_ConvertASCIItoUTF16 : public nsAutoString
116
NS_ConvertASCIItoUTF16( const char* aCString )
118
AppendASCIItoUTF16(aCString, *this);
121
NS_ConvertASCIItoUTF16( const char* aCString, PRUint32 aLength )
123
AppendASCIItoUTF16(Substring(aCString, aCString + aLength), *this);
127
NS_ConvertASCIItoUTF16( const nsACString& aCString )
129
AppendASCIItoUTF16(aCString, *this);
133
// NOT TO BE IMPLEMENTED
134
NS_ConvertASCIItoUTF16( PRUnichar );
139
* A helper class that converts a UTF-16 string to UTF-8
141
class NS_ConvertUTF16toUTF8 : public nsCAutoString
145
NS_ConvertUTF16toUTF8( const PRUnichar* aString )
147
AppendUTF16toUTF8(aString, *this);
150
NS_ConvertUTF16toUTF8( const PRUnichar* aString, PRUint32 aLength )
152
AppendUTF16toUTF8(Substring(aString, aString + aLength), *this);
156
NS_ConvertUTF16toUTF8( const nsAString& aString )
158
AppendUTF16toUTF8(aString, *this);
162
// NOT TO BE IMPLEMENTED
163
NS_ConvertUTF16toUTF8( char );
167
class NS_ConvertUTF8toUTF16 : public nsAutoString
171
NS_ConvertUTF8toUTF16( const char* aCString )
173
AppendUTF8toUTF16(aCString, *this);
176
NS_ConvertUTF8toUTF16( const char* aCString, PRUint32 aLength )
178
AppendUTF8toUTF16(Substring(aCString, aCString + aLength), *this);
182
NS_ConvertUTF8toUTF16( const nsACString& aCString )
184
AppendUTF8toUTF16(aCString, *this);
188
// NOT TO BE IMPLEMENTED
189
NS_ConvertUTF8toUTF16( PRUnichar );
193
// the following are included/declared for backwards compatibility
195
typedef NS_ConvertUTF16toUTF8 NS_ConvertUCS2toUTF8;
196
typedef NS_LossyConvertUTF16toASCII NS_LossyConvertUCS2toASCII;
197
typedef NS_ConvertASCIItoUTF16 NS_ConvertASCIItoUCS2;
198
typedef NS_ConvertUTF8toUTF16 NS_ConvertUTF8toUCS2;
199
typedef nsAutoString nsVoidableString;
201
#ifndef nsDependentString_h___
202
#include "nsDependentString.h"
205
#ifndef nsLiteralString_h___
206
#include "nsLiteralString.h"
209
#ifndef nsPromiseFlatString_h___
210
#include "nsPromiseFlatString.h"
213
// need to include these for backwards compatibility
214
#include "nsMemory.h"
219
inline PRInt32 MinInt(PRInt32 x, PRInt32 y)
224
inline PRInt32 MaxInt(PRInt32 x, PRInt32 y)
230
* Deprecated: don't use |Recycle|, just call |nsMemory::Free| directly
232
* Return the given buffer to the heap manager. Calls allocator::Free()
234
inline void Recycle( char* aBuffer) { nsMemory::Free(aBuffer); }
235
inline void Recycle( PRUnichar* aBuffer) { nsMemory::Free(aBuffer); }
237
#endif // !defined(nsString_h___)