summaryrefslogtreecommitdiffstats
path: root/src/libs/xpcom18a4/xpcom/string/public
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 03:01:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 03:01:46 +0000
commitf8fe689a81f906d1b91bb3220acde2a4ecb14c5b (patch)
tree26484e9d7e2c67806c2d1760196ff01aaa858e8c /src/libs/xpcom18a4/xpcom/string/public
parentInitial commit. (diff)
downloadvirtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.tar.xz
virtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.zip
Adding upstream version 6.0.4-dfsg.upstream/6.0.4-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libs/xpcom18a4/xpcom/string/public')
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/.cvsignore1
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/Makefile.in86
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsAString.h96
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsAlgorithm.h131
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsCharTraits.h784
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsDependentString.h60
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsDependentSubstring.h56
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsEmbedString.h158
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsLiteralString.h116
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsObsoleteAString.h102
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsPrintfCString.h87
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsPromiseFlatString.h56
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsReadableUtils.h370
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsString.h237
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsStringAPI.h853
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsStringFwd.h96
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsStringIterator.h373
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsSubstring.h74
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsSubstringTuple.h56
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsTAString.h618
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsTDependentString.h137
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsTDependentSubstring.h142
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsTObsoleteAString.h165
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsTPromiseFlatString.h158
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsTString.h721
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsTSubstring.h575
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsTSubstringTuple.h113
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsUTF8Utils.h462
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/nsXPIDLString.h46
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/string-template-def-char.h58
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/string-template-def-unichar.h58
-rw-r--r--src/libs/xpcom18a4/xpcom/string/public/string-template-undef.h59
32 files changed, 7104 insertions, 0 deletions
diff --git a/src/libs/xpcom18a4/xpcom/string/public/.cvsignore b/src/libs/xpcom18a4/xpcom/string/public/.cvsignore
new file mode 100644
index 00000000..f3c7a7c5
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/src/libs/xpcom18a4/xpcom/string/public/Makefile.in b/src/libs/xpcom18a4/xpcom/string/public/Makefile.in
new file mode 100644
index 00000000..d3582bcc
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/Makefile.in
@@ -0,0 +1,86 @@
+# vim:set ts=8 sw=8 sts=8 noet:
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications.
+# Portions created by the Initial Developer are Copyright (C) 2001
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Johnny Stenback <jst@netscape.com> (original author)
+# Scott Collins <scc@mozilla.org>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH = ../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = string
+
+EXPORTS = \
+ nsAString.h \
+ nsAlgorithm.h \
+ nsCharTraits.h \
+ nsDependentString.h \
+ nsDependentSubstring.h \
+ nsLiteralString.h \
+ nsObsoleteAString.h \
+ nsPrintfCString.h \
+ nsPromiseFlatString.h \
+ nsReadableUtils.h \
+ nsString.h \
+ nsStringFwd.h \
+ nsStringIterator.h \
+ nsSubstring.h \
+ nsSubstringTuple.h \
+ nsTAString.h \
+ nsTDependentString.h \
+ nsTDependentSubstring.h \
+ nsTObsoleteAString.h \
+ nsTPromiseFlatString.h \
+ nsTString.h \
+ nsTSubstring.h \
+ nsTSubstringTuple.h \
+ nsUTF8Utils.h \
+ nsXPIDLString.h \
+ string-template-def-unichar.h \
+ string-template-def-char.h \
+ string-template-undef.h \
+ $(NULL)
+
+SDK_HEADERS = \
+ nsStringAPI.h \
+ nsEmbedString.h \
+ $(NULL)
+
+include $(topsrcdir)/config/rules.mk
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsAString.h b/src/libs/xpcom18a4/xpcom/string/public/nsAString.h
new file mode 100644
index 00000000..3675989c
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsAString.h
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsAString_h___
+#define nsAString_h___
+
+#ifndef nsStringFwd_h___
+#include "nsStringFwd.h"
+#endif
+
+#ifndef nsStringIterator_h___
+#include "nsStringIterator.h"
+#endif
+
+#ifndef nsObsoleteAString_h___
+#include "nsObsoleteAString.h"
+#endif
+
+// If some platform(s) can't handle our template that matches literal strings,
+// then we'll disable it on those platforms.
+#ifndef NS_DISABLE_LITERAL_TEMPLATE
+# if (defined(_MSC_VER) && (_MSC_VER < 1310)) || (defined(__SUNPRO_CC) & (__SUNPRO_CC < 0x560)) || (defined(__HP_aCC) && (__HP_aCC <= 012100))
+# define NS_DISABLE_LITERAL_TEMPLATE
+# endif
+#endif /* !NS_DISABLE_LITERAL_TEMPLATE */
+
+#include <string.h>
+
+ // declare nsAString
+#include "string-template-def-unichar.h"
+#include "nsTAString.h"
+#include "string-template-undef.h"
+
+
+ // declare nsACString
+#include "string-template-def-char.h"
+#include "nsTAString.h"
+#include "string-template-undef.h"
+
+
+ /**
+ * ASCII case-insensitive comparator. (for Unicode case-insensitive
+ * comparision, see nsUnicharUtils.h)
+ */
+class NS_COM nsCaseInsensitiveCStringComparator
+ : public nsCStringComparator
+ {
+ public:
+ typedef char char_type;
+
+ virtual int operator()( const char_type*, const char_type*, PRUint32 length ) const;
+ virtual int operator()( char_type, char_type ) const;
+ };
+
+
+ // included here for backwards compatibility
+#ifndef nsSubstringTuple_h___
+#include "nsSubstringTuple.h"
+#endif
+
+#endif // !defined(nsAString_h___)
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsAlgorithm.h b/src/libs/xpcom18a4/xpcom/string/public/nsAlgorithm.h
new file mode 100644
index 00000000..e81e6f57
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsAlgorithm.h
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Scott Collins <scc@mozilla.org> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsAlgorithm_h___
+#define nsAlgorithm_h___
+
+#ifndef nsCharTraits_h___
+#include "nsCharTraits.h"
+ // for |nsCharSourceTraits|, |nsCharSinkTraits|
+#endif
+
+#ifndef prtypes_h___
+#include "prtypes.h"
+ // for |PRUint32|...
+#endif
+
+#ifndef nsDebug_h___
+#include "nsDebug.h"
+ // for NS_ASSERTION
+#endif
+
+template <class T>
+inline
+const T&
+NS_MIN( const T& a, const T& b )
+ {
+ return b < a ? b : a;
+ }
+
+template <class T>
+inline
+const T&
+NS_MAX( const T& a, const T& b )
+ {
+ return a > b ? a : b;
+ }
+
+template <class InputIterator, class T>
+inline
+PRUint32
+NS_COUNT( InputIterator& first, const InputIterator& last, const T& value )
+ {
+ PRUint32 result = 0;
+ for ( ; first != last; ++first )
+ if ( *first == value )
+ ++result;
+ return result;
+ }
+
+template <class InputIterator, class OutputIterator>
+inline
+OutputIterator&
+copy_string( InputIterator& first, const InputIterator& last, OutputIterator& result )
+ {
+ typedef nsCharSourceTraits<InputIterator> source_traits;
+ typedef nsCharSinkTraits<OutputIterator> sink_traits;
+
+ while ( first != last )
+ {
+ PRInt32 count_copied = PRInt32(sink_traits::write(result, source_traits::read(first), source_traits::readable_distance(first, last)));
+ NS_ASSERTION(count_copied > 0, "|copy_string| will never terminate");
+ source_traits::advance(first, count_copied);
+ }
+
+ return result;
+ }
+
+template <class InputIterator, class OutputIterator>
+OutputIterator&
+copy_string_backward( const InputIterator& first, InputIterator& last, OutputIterator& result )
+ {
+ while ( first != last )
+ {
+ last.normalize_backward();
+ result.normalize_backward();
+ PRUint32 lengthToCopy = PRUint32( NS_MIN(last.size_backward(), result.size_backward()) );
+ if ( first.fragment().mStart == last.fragment().mStart )
+ lengthToCopy = NS_MIN(lengthToCopy, PRUint32(last.get() - first.get()));
+
+ NS_ASSERTION(lengthToCopy, "|copy_string_backward| will never terminate");
+
+#ifdef _MSC_VER
+ // XXX Visual C++ can't stomach 'typename' where it rightfully should
+ nsCharTraits<OutputIterator::value_type>::move(result.get()-lengthToCopy, last.get()-lengthToCopy, lengthToCopy);
+#else
+ nsCharTraits<typename OutputIterator::value_type>::move(result.get()-lengthToCopy, last.get()-lengthToCopy, lengthToCopy);
+#endif
+
+ last.advance( -PRInt32(lengthToCopy) );
+ result.advance( -PRInt32(lengthToCopy) );
+ }
+
+ return result;
+ }
+
+#endif // !defined(nsAlgorithm_h___)
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsCharTraits.h b/src/libs/xpcom18a4/xpcom/string/public/nsCharTraits.h
new file mode 100644
index 00000000..e7713c95
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsCharTraits.h
@@ -0,0 +1,784 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2000
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Scott Collins <scc@mozilla.org> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsCharTraits_h___
+#define nsCharTraits_h___
+
+#include <ctype.h>
+ // for |EOF|, |WEOF|
+
+#define FORCED_CPP_2BYTE_WCHAR_T
+ // disable special optimizations for now through this hack
+
+#if defined(HAVE_CPP_2BYTE_WCHAR_T) && !defined(FORCED_CPP_2BYTE_WCHAR_T)
+#define USE_CPP_WCHAR_FUNCS
+#endif
+
+#ifdef USE_CPP_WCHAR_FUNCS
+#include <wchar.h>
+ // for |wmemset|, et al
+#endif
+
+#include <string.h>
+ // for |memcpy|, et al
+
+#ifndef nscore_h___
+#include "nscore.h"
+ // for |PRUnichar|
+#endif
+
+#ifndef nsDebug_h__
+#include "nsDebug.h"
+ // for NS_ASSERTION
+#endif
+
+#ifdef HAVE_CPP_BOOL
+ typedef bool nsCharTraits_bool;
+#else
+ typedef PRBool nsCharTraits_bool;
+#endif
+
+template <class CharT> struct nsCharTraits {};
+
+NS_SPECIALIZE_TEMPLATE
+struct nsCharTraits<PRUnichar>
+ {
+ typedef PRUnichar char_type;
+ typedef PRUint16 unsigned_char_type;
+ typedef char incompatible_char_type;
+
+ NS_COM static const char_type *sEmptyBuffer;
+
+ static
+ void
+ assign( char_type& lhs, char_type rhs )
+ {
+ lhs = rhs;
+ }
+
+
+ // integer representation of characters:
+
+#ifdef USE_CPP_WCHAR_FUNCS
+ typedef wint_t int_type;
+#else
+ typedef int int_type;
+#endif
+
+ static
+ char_type
+ to_char_type( int_type c )
+ {
+ return char_type(c);
+ }
+
+ static
+ int_type
+ to_int_type( char_type c )
+ {
+ return int_type( NS_STATIC_CAST(unsigned_char_type, c) );
+ }
+
+ static
+ nsCharTraits_bool
+ eq_int_type( int_type lhs, int_type rhs )
+ {
+ return lhs == rhs;
+ }
+
+
+ // |char_type| comparisons:
+
+ static
+ nsCharTraits_bool
+ eq( char_type lhs, char_type rhs )
+ {
+ return lhs == rhs;
+ }
+
+ static
+ nsCharTraits_bool
+ lt( char_type lhs, char_type rhs )
+ {
+ return lhs < rhs;
+ }
+
+
+ // operations on s[n] arrays:
+
+ static
+ char_type*
+ move( char_type* s1, const char_type* s2, size_t n )
+ {
+ return NS_STATIC_CAST(char_type*, memmove(s1, s2, n * sizeof(char_type)));
+ }
+
+ static
+ char_type*
+ copy( char_type* s1, const char_type* s2, size_t n )
+ {
+ return NS_STATIC_CAST(char_type*, memcpy(s1, s2, n * sizeof(char_type)));
+ }
+
+ static
+ char_type*
+ copyASCII( char_type* s1, const char* s2, size_t n )
+ {
+ for (char_type* s = s1; n--; ++s, ++s2) {
+ NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
+ *s = *s2;
+ }
+ return s1;
+ }
+
+ static
+ char_type*
+ assign( char_type* s, size_t n, char_type c )
+ {
+#ifdef USE_CPP_WCHAR_FUNCS
+ return NS_STATIC_CAST(char_type*, wmemset(s, to_int_type(c), n));
+#else
+ char_type* result = s;
+ while ( n-- )
+ assign(*s++, c);
+ return result;
+#endif
+ }
+
+ static
+ int
+ compare( const char_type* s1, const char_type* s2, size_t n )
+ {
+#ifdef USE_CPP_WCHAR_FUNCS
+ return wmemcmp(s1, s2, n);
+#else
+ for ( ; n--; ++s1, ++s2 )
+ {
+ if ( !eq(*s1, *s2) )
+ return to_int_type(*s1) - to_int_type(*s2);
+ }
+
+ return 0;
+#endif
+ }
+
+ static
+ int
+ compareASCII( const char_type* s1, const char* s2, size_t n )
+ {
+ for ( ; n--; ++s1, ++s2 )
+ {
+ NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
+ if ( !eq_int_type(to_int_type(*s1), to_int_type(*s2)) )
+ return to_int_type(*s1) - to_int_type(*s2);
+ }
+
+ return 0;
+ }
+
+ // this version assumes that s2 is null-terminated and s1 has length n.
+ // if s1 is shorter than s2 then we return -1; if s1 is longer than s2,
+ // we return 1.
+ static
+ int
+ compareASCIINullTerminated( const char_type* s1, size_t n, const char* s2 )
+ {
+ for ( ; n--; ++s1, ++s2 )
+ {
+ if ( !*s2 )
+ return 1;
+ NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
+ if ( !eq_int_type(to_int_type(*s1), to_int_type(*s2)) )
+ return to_int_type(*s1) - to_int_type(*s2);
+ }
+
+ if ( *s2 )
+ return -1;
+
+ return 0;
+ }
+
+ /**
+ * Convert c to its lower-case form, but only if the lower-case form is
+ * ASCII. Otherwise leave it alone.
+ *
+ * There are only two non-ASCII Unicode characters whose lowercase
+ * equivalents are ASCII: KELVIN SIGN and LATIN CAPITAL LETTER I WITH
+ * DOT ABOVE. So it's a simple matter to handle those explicitly.
+ */
+ static
+ char_type
+ ASCIIToLower( char_type c )
+ {
+ if (c < 0x100)
+ return (c >= 'A' && c <= 'Z') ? c + ('a' - 'A') : c;
+ else
+ {
+ if (c == 0x212A) // KELVIN SIGN
+ return 'k';
+ if (c == 0x0130) // LATIN CAPITAL LETTER I WITH DOT ABOVE
+ return 'i';
+ return c;
+ }
+ }
+
+ static
+ int
+ compareLowerCaseToASCII( const char_type* s1, const char* s2, size_t n )
+ {
+ for ( ; n--; ++s1, ++s2 )
+ {
+ NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
+ NS_ASSERTION(!(*s2 >= 'A' && *s2 <= 'Z'),
+ "Unexpected uppercase character");
+ char_type lower_s1 = ASCIIToLower(*s1);
+ if ( lower_s1 != to_char_type(*s2) )
+ return to_int_type(lower_s1) - to_int_type(*s2);
+ }
+
+ return 0;
+ }
+
+ // this version assumes that s2 is null-terminated and s1 has length n.
+ // if s1 is shorter than s2 then we return -1; if s1 is longer than s2,
+ // we return 1.
+ static
+ int
+ compareLowerCaseToASCIINullTerminated( const char_type* s1, size_t n, const char* s2 )
+ {
+ for ( ; n--; ++s1, ++s2 )
+ {
+ if ( !*s2 )
+ return 1;
+ NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
+ NS_ASSERTION(!(*s2 >= 'A' && *s2 <= 'Z'),
+ "Unexpected uppercase character");
+ char_type lower_s1 = ASCIIToLower(*s1);
+ if ( lower_s1 != to_char_type(*s2) )
+ return to_int_type(lower_s1) - to_int_type(*s2);
+ }
+
+ if ( *s2 )
+ return -1;
+
+ return 0;
+ }
+
+ static
+ size_t
+ length( const char_type* s )
+ {
+#ifdef USE_CPP_WCHAR_FUNCS
+ return wcslen(s);
+#else
+ size_t result = 0;
+ while ( !eq(*s++, char_type(0)) )
+ ++result;
+ return result;
+#endif
+ }
+
+ static
+ const char_type*
+ find( const char_type* s, size_t n, char_type c )
+ {
+#ifdef USE_CPP_WCHAR_FUNCS
+ return NS_REINTERPRET_CAST(const char_type*, wmemchr(s, to_int_type(c), n));
+#else
+ while ( n-- )
+ {
+ if ( eq(*s, c) )
+ return s;
+ ++s;
+ }
+
+ return 0;
+#endif
+ }
+
+#if 0
+ // I/O related:
+
+ typedef streamoff off_type;
+ typedef streampos pos_type;
+ typedef mbstate_t state_type;
+
+ static
+ int_type
+ eof()
+ {
+#ifdef USE_CPP_WCHAR_FUNCS
+ return WEOF;
+#else
+ return EOF;
+#endif
+ }
+
+ static
+ int_type
+ not_eof( int_type c )
+ {
+ return eq_int_type(c, eof()) ? ~eof() : c;
+ }
+
+ // static state_type get_state( pos_type );
+#endif
+ };
+
+NS_SPECIALIZE_TEMPLATE
+struct nsCharTraits<char>
+ {
+ typedef char char_type;
+ typedef unsigned char unsigned_char_type;
+ typedef PRUnichar incompatible_char_type;
+
+ NS_COM static const char_type *sEmptyBuffer;
+
+ static
+ void
+ assign( char_type& lhs, char_type rhs )
+ {
+ lhs = rhs;
+ }
+
+
+ // integer representation of characters:
+
+ typedef int int_type;
+
+ static
+ char_type
+ to_char_type( int_type c )
+ {
+ return char_type(c);
+ }
+
+ static
+ int_type
+ to_int_type( char_type c )
+ {
+ return int_type( NS_STATIC_CAST(unsigned_char_type, c) );
+ }
+
+ static
+ nsCharTraits_bool
+ eq_int_type( int_type lhs, int_type rhs )
+ {
+ return lhs == rhs;
+ }
+
+
+ // |char_type| comparisons:
+
+ static
+ nsCharTraits_bool
+ eq( char_type lhs, char_type rhs )
+ {
+ return lhs == rhs;
+ }
+
+ static
+ nsCharTraits_bool
+ lt( char_type lhs, char_type rhs )
+ {
+ return lhs < rhs;
+ }
+
+
+ // operations on s[n] arrays:
+
+ static
+ char_type*
+ move( char_type* s1, const char_type* s2, size_t n )
+ {
+ return NS_STATIC_CAST(char_type*, memmove(s1, s2, n * sizeof(char_type)));
+ }
+
+ static
+ char_type*
+ copy( char_type* s1, const char_type* s2, size_t n )
+ {
+ return NS_STATIC_CAST(char_type*, memcpy(s1, s2, n * sizeof(char_type)));
+ }
+
+ static
+ char_type*
+ copyASCII( char_type* s1, const char* s2, size_t n )
+ {
+ return copy(s1, s2, n);
+ }
+
+ static
+ char_type*
+ assign( char_type* s, size_t n, char_type c )
+ {
+ return NS_STATIC_CAST(char_type*, memset(s, to_int_type(c), n));
+ }
+
+ static
+ int
+ compare( const char_type* s1, const char_type* s2, size_t n )
+ {
+ return memcmp(s1, s2, n);
+ }
+
+ static
+ int
+ compareASCII( const char_type* s1, const char* s2, size_t n )
+ {
+#ifdef DEBUG
+ for (size_t i = 0; i < n; ++i)
+ {
+ NS_ASSERTION(!(s2[i] & ~0x7F), "Unexpected non-ASCII character");
+ }
+#endif
+ return compare(s1, s2, n);
+ }
+
+ // this version assumes that s2 is null-terminated and s1 has length n.
+ // if s1 is shorter than s2 then we return -1; if s1 is longer than s2,
+ // we return 1.
+ static
+ int
+ compareASCIINullTerminated( const char_type* s1, size_t n, const char* s2 )
+ {
+ // can't use strcmp here because we don't want to stop when s1
+ // contains a null
+ for ( ; n--; ++s1, ++s2 )
+ {
+ if ( !*s2 )
+ return 1;
+ NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
+ if ( *s1 != *s2 )
+ return to_int_type(*s1) - to_int_type(*s2);
+ }
+
+ if ( *s2 )
+ return -1;
+
+ return 0;
+ }
+
+ /**
+ * Convert c to its lower-case form, but only if c is ASCII.
+ */
+ static
+ char_type
+ ASCIIToLower( char_type c )
+ {
+ return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c;
+ }
+
+ static
+ int
+ compareLowerCaseToASCII( const char_type* s1, const char* s2, size_t n )
+ {
+ for ( ; n--; ++s1, ++s2 )
+ {
+ NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
+ NS_ASSERTION(!(*s2 >= 'A' && *s2 <= 'Z'),
+ "Unexpected uppercase character");
+ char_type lower_s1 = ASCIIToLower(*s1);
+ if ( lower_s1 != *s2 )
+ return to_int_type(lower_s1) - to_int_type(*s2);
+ }
+ return 0;
+ }
+
+ // this version assumes that s2 is null-terminated and s1 has length n.
+ // if s1 is shorter than s2 then we return -1; if s1 is longer than s2,
+ // we return 1.
+ static
+ int
+ compareLowerCaseToASCIINullTerminated( const char_type* s1, size_t n, const char* s2 )
+ {
+ for ( ; n--; ++s1, ++s2 )
+ {
+ if ( !*s2 )
+ return 1;
+ NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
+ NS_ASSERTION(!(*s2 >= 'A' && *s2 <= 'Z'),
+ "Unexpected uppercase character");
+ char_type lower_s1 = ASCIIToLower(*s1);
+ if ( lower_s1 != *s2 )
+ return to_int_type(lower_s1) - to_int_type(*s2);
+ }
+
+ if ( *s2 )
+ return -1;
+
+ return 0;
+ }
+
+ static
+ size_t
+ length( const char_type* s )
+ {
+ return strlen(s);
+ }
+
+ static
+ const char_type*
+ find( const char_type* s, size_t n, char_type c )
+ {
+ return NS_REINTERPRET_CAST(const char_type*, memchr(s, to_int_type(c), n));
+ }
+
+#if 0
+ // I/O related:
+
+ typedef streamoff off_type;
+ typedef streampos pos_type;
+ typedef mbstate_t state_type;
+
+ static
+ int_type
+ eof()
+ {
+ return EOF;
+ }
+
+ static
+ int_type
+ not_eof( int_type c )
+ {
+ return eq_int_type(c, eof()) ? ~eof() : c;
+ }
+
+ // static state_type get_state( pos_type );
+#endif
+ };
+
+template <class InputIterator>
+struct nsCharSourceTraits
+ {
+ typedef typename InputIterator::difference_type difference_type;
+
+ static
+ PRUint32
+ readable_distance( const InputIterator& first, const InputIterator& last )
+ {
+ // assumes single fragment
+ return last.get() - first.get();
+ }
+
+ static
+ const typename InputIterator::value_type*
+ read( const InputIterator& iter )
+ {
+ return iter.get();
+ }
+
+ static
+ void
+ advance( InputIterator& s, difference_type n )
+ {
+ s.advance(n);
+ }
+ };
+
+#ifdef HAVE_CPP_PARTIAL_SPECIALIZATION
+
+template <class CharT>
+struct nsCharSourceTraits<CharT*>
+ {
+ typedef ptrdiff_t difference_type;
+
+ static
+ PRUint32
+ readable_distance( CharT* s )
+ {
+ return PRUint32(nsCharTraits<CharT>::length(s));
+// return numeric_limits<PRUint32>::max();
+ }
+
+ static
+ PRUint32
+ readable_distance( CharT* first, CharT* last )
+ {
+ return PRUint32(last-first);
+ }
+
+ static
+ const CharT*
+ read( CharT* s )
+ {
+ return s;
+ }
+
+ static
+ void
+ advance( CharT*& s, difference_type n )
+ {
+ s += n;
+ }
+ };
+
+#else
+
+NS_SPECIALIZE_TEMPLATE
+struct nsCharSourceTraits<const char*>
+ {
+ typedef ptrdiff_t difference_type;
+
+ static
+ PRUint32
+ readable_distance( const char* s )
+ {
+ return PRUint32(nsCharTraits<char>::length(s));
+// return numeric_limits<PRUint32>::max();
+ }
+
+ static
+ PRUint32
+ readable_distance( const char* first, const char* last )
+ {
+ return PRUint32(last-first);
+ }
+
+ static
+ const char*
+ read( const char* s )
+ {
+ return s;
+ }
+
+ static
+ void
+ advance( const char*& s, difference_type n )
+ {
+ s += n;
+ }
+ };
+
+
+NS_SPECIALIZE_TEMPLATE
+struct nsCharSourceTraits<const PRUnichar*>
+ {
+ typedef ptrdiff_t difference_type;
+
+ static
+ PRUint32
+ readable_distance( const PRUnichar* s )
+ {
+ return PRUint32(nsCharTraits<PRUnichar>::length(s));
+// return numeric_limits<PRUint32>::max();
+ }
+
+ static
+ PRUint32
+ readable_distance( const PRUnichar* first, const PRUnichar* last )
+ {
+ return PRUint32(last-first);
+ }
+
+ static
+ const PRUnichar*
+ read( const PRUnichar* s )
+ {
+ return s;
+ }
+
+ static
+ void
+ advance( const PRUnichar*& s, difference_type n )
+ {
+ s += n;
+ }
+ };
+
+#endif
+
+
+template <class OutputIterator>
+struct nsCharSinkTraits
+ {
+ static
+ PRUint32
+ write( OutputIterator& iter, const typename OutputIterator::value_type* s, PRUint32 n )
+ {
+ return iter.write(s, n);
+ }
+ };
+
+#ifdef HAVE_CPP_PARTIAL_SPECIALIZATION
+
+template <class CharT>
+struct nsCharSinkTraits<CharT*>
+ {
+ static
+ PRUint32
+ write( CharT*& iter, const CharT* s, PRUint32 n )
+ {
+ nsCharTraits<CharT>::move(iter, s, n);
+ iter += n;
+ return n;
+ }
+ };
+
+#else
+
+NS_SPECIALIZE_TEMPLATE
+struct nsCharSinkTraits<char*>
+ {
+ static
+ PRUint32
+ write( char*& iter, const char* s, PRUint32 n )
+ {
+ nsCharTraits<char>::move(iter, s, n);
+ iter += n;
+ return n;
+ }
+ };
+
+NS_SPECIALIZE_TEMPLATE
+struct nsCharSinkTraits<PRUnichar*>
+ {
+ static
+ PRUint32
+ write( PRUnichar*& iter, const PRUnichar* s, PRUint32 n )
+ {
+ nsCharTraits<PRUnichar>::move(iter, s, n);
+ iter += n;
+ return n;
+ }
+ };
+
+#endif
+
+#endif // !defined(nsCharTraits_h___)
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsDependentString.h b/src/libs/xpcom18a4/xpcom/string/public/nsDependentString.h
new file mode 100644
index 00000000..22e05b31
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsDependentString.h
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsDependentString_h___
+#define nsDependentString_h___
+
+#ifndef nsString_h___
+#include "nsString.h"
+#endif
+
+#ifndef nsDebug_h___
+#include "nsDebug.h"
+#endif
+
+ // declare nsDependentString
+#include "string-template-def-unichar.h"
+#include "nsTDependentString.h"
+#include "string-template-undef.h"
+
+ // declare nsDependentCString
+#include "string-template-def-char.h"
+#include "nsTDependentString.h"
+#include "string-template-undef.h"
+
+#endif /* !defined(nsDependentString_h___) */
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsDependentSubstring.h b/src/libs/xpcom18a4/xpcom/string/public/nsDependentSubstring.h
new file mode 100644
index 00000000..c6459436
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsDependentSubstring.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsDependentSubstring_h___
+#define nsDependentSubstring_h___
+
+#ifndef nsSubstring_h___
+#include "nsSubstring.h"
+#endif
+
+ // declare nsDependentSubstring
+#include "string-template-def-unichar.h"
+#include "nsTDependentSubstring.h"
+#include "string-template-undef.h"
+
+ // declare nsDependentCSubstring
+#include "string-template-def-char.h"
+#include "nsTDependentSubstring.h"
+#include "string-template-undef.h"
+
+#endif /* !defined(nsDependentSubstring_h___) */
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsEmbedString.h b/src/libs/xpcom18a4/xpcom/string/public/nsEmbedString.h
new file mode 100644
index 00000000..7af03ee3
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsEmbedString.h
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is a small implementation of the nsAString and nsACString.
+ *
+ * The Initial Developer of the Original Code is
+ * Peter Annema <jaggernaut@netscape.com>.
+ *
+ * Portions created by the Initial Developer are Copyright (C) 2002
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsEmbedString_h___
+#define nsEmbedString_h___
+
+#include "nsStringAPI.h"
+
+class nsEmbedString : public nsStringContainer
+ {
+ public:
+ typedef nsEmbedString self_type;
+ typedef nsAString abstract_string_type;
+
+ nsEmbedString()
+ {
+ NS_StringContainerInit(*this);
+ }
+
+ nsEmbedString(const self_type& aString)
+#ifdef VBOX
+ : nsStringContainer()
+#endif
+ {
+ NS_StringContainerInit(*this);
+ NS_StringCopy(*this, aString);
+ }
+
+ explicit
+ nsEmbedString(const abstract_string_type& aReadable)
+ {
+ NS_StringContainerInit(*this);
+ NS_StringCopy(*this, aReadable);
+ }
+
+ explicit
+ nsEmbedString(const char_type* aData, size_type aLength = PR_UINT32_MAX)
+ {
+ NS_StringContainerInit(*this);
+ NS_StringSetData(*this, aData, aLength);
+ }
+
+ ~nsEmbedString()
+ {
+ NS_StringContainerFinish(*this);
+ }
+
+ const char_type* get() const
+ {
+ const char_type* data;
+ NS_StringGetData(*this, &data);
+ return data;
+ }
+
+ self_type& operator=(const self_type& aString) { Assign(aString); return *this; }
+ self_type& operator=(const abstract_string_type& aReadable) { Assign(aReadable); return *this; }
+ self_type& operator=(const char_type* aPtr) { Assign(aPtr); return *this; }
+ self_type& operator=(char_type aChar) { Assign(aChar); return *this; }
+ };
+
+class nsEmbedCString : public nsCStringContainer
+ {
+ public:
+ typedef nsEmbedCString self_type;
+ typedef nsACString abstract_string_type;
+
+ nsEmbedCString()
+#ifdef VBOX
+ : nsCStringContainer()
+#endif
+ {
+ NS_CStringContainerInit(*this);
+ }
+
+ nsEmbedCString(const self_type& aString)
+#ifdef VBOX
+ : nsCStringContainer()
+#endif
+ {
+ NS_CStringContainerInit(*this);
+ NS_CStringCopy(*this, aString);
+ }
+
+ explicit
+ nsEmbedCString(const abstract_string_type& aReadable)
+#ifdef VBOX
+ : nsCStringContainer()
+#endif
+ {
+ NS_CStringContainerInit(*this);
+ NS_CStringCopy(*this, aReadable);
+ }
+
+ explicit
+ nsEmbedCString(const char_type* aData, size_type aLength = PR_UINT32_MAX)
+#ifdef VBOX
+ : nsCStringContainer()
+#endif
+ {
+ NS_CStringContainerInit(*this);
+ NS_CStringSetData(*this, aData, aLength);
+ }
+
+ ~nsEmbedCString()
+ {
+ NS_CStringContainerFinish(*this);
+ }
+
+ const char_type* get() const
+ {
+ const char_type* data;
+ NS_CStringGetData(*this, &data);
+ return data;
+ }
+
+ self_type& operator=(const self_type& aString) { Assign(aString); return *this; }
+ self_type& operator=(const abstract_string_type& aReadable) { Assign(aReadable); return *this; }
+ self_type& operator=(const char_type* aPtr) { Assign(aPtr); return *this; }
+ self_type& operator=(char_type aChar) { Assign(aChar); return *this; }
+ };
+
+#endif // !defined(nsEmbedString_h___)
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsLiteralString.h b/src/libs/xpcom18a4/xpcom/string/public/nsLiteralString.h
new file mode 100644
index 00000000..ba536297
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsLiteralString.h
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications.
+ * Portions created by the Initial Developer are Copyright (C) 2001
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Scott Collins <scc@mozilla.org> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsLiteralString_h___
+#define nsLiteralString_h___
+
+#ifndef nscore_h___
+#include "nscore.h"
+#endif
+
+#ifndef nsDependentString_h___
+#include "nsDependentString.h"
+#endif
+
+
+#if 0
+inline
+const nsDependentString
+literal_string( const nsAString::char_type* aPtr )
+ {
+ return nsDependentString(aPtr);
+ }
+
+inline
+const nsDependentString
+literal_string( const nsAString::char_type* aPtr, PRUint32 aLength )
+ {
+ return nsDependentString(aPtr, aLength);
+ }
+
+inline
+const nsDependentCString
+literal_string( const nsACString::char_type* aPtr )
+ {
+ return nsDependentCString(aPtr);
+ }
+
+inline
+const nsDependentCString
+literal_string( const nsACString::char_type* aPtr, PRUint32 aLength )
+ {
+ return nsDependentCString(aPtr, aLength);
+ }
+#endif
+
+#ifdef HAVE_CPP_2BYTE_WCHAR_T
+ #define NS_LL(s) L##s
+ #define NS_MULTILINE_LITERAL_STRING(s) nsDependentString(NS_REINTERPRET_CAST(const nsAString::char_type*, s), PRUint32((sizeof(s)/sizeof(wchar_t))-1))
+ #define NS_MULTILINE_LITERAL_STRING_INIT(n,s) n(NS_REINTERPRET_CAST(const nsAString::char_type*, s), PRUint32((sizeof(s)/sizeof(wchar_t))-1))
+ #define NS_NAMED_MULTILINE_LITERAL_STRING(n,s) const nsDependentString n(NS_REINTERPRET_CAST(const nsAString::char_type*, s), PRUint32((sizeof(s)/sizeof(wchar_t))-1))
+ typedef nsDependentString nsLiteralString;
+#else
+ #define NS_LL(s) s
+ #define NS_MULTILINE_LITERAL_STRING(s) NS_ConvertASCIItoUTF16(s, PRUint32(sizeof(s)-1))
+ #define NS_MULTILINE_LITERAL_STRING_INIT(n,s) n(s, PRUint32(sizeof(s)-1))
+ #define NS_NAMED_MULTILINE_LITERAL_STRING(n,s) const NS_ConvertASCIItoUTF16 n(s, PRUint32(sizeof(s)-1))
+ typedef NS_ConvertASCIItoUTF16 nsLiteralString;
+#endif
+
+/*
+ * Macro arguments used in concatenation or stringification won't be expanded.
+ * Therefore, in order for |NS_L(FOO)| to work as expected (which is to expand
+ * |FOO| before doing whatever |NS_L| needs to do to it) a helper macro needs
+ * to be inserted in between to allow the macro argument to expand.
+ * See "3.10.6 Separate Expansion of Macro Arguments" of the CPP manual for a
+ * more accurate and precise explanation.
+ */
+
+#define NS_L(s) NS_LL(s)
+
+#define NS_LITERAL_STRING(s) NS_STATIC_CAST(const nsAFlatString&, NS_MULTILINE_LITERAL_STRING(NS_LL(s)))
+#define NS_LITERAL_STRING_INIT(n,s) NS_MULTILINE_LITERAL_STRING_INIT(n, NS_LL(s))
+#define NS_NAMED_LITERAL_STRING(n,s) NS_NAMED_MULTILINE_LITERAL_STRING(n, NS_LL(s))
+
+#define NS_LITERAL_CSTRING(s) NS_STATIC_CAST(const nsDependentCString&, nsDependentCString(s, PRUint32(sizeof(s)-1)))
+#define NS_LITERAL_CSTRING_INIT(n,s) n(s, PRUint32(sizeof(s)-1))
+#define NS_NAMED_LITERAL_CSTRING(n,s) const nsDependentCString n(s, PRUint32(sizeof(s)-1))
+
+typedef nsDependentCString nsLiteralCString;
+
+#endif /* !defined(nsLiteralString_h___) */
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsObsoleteAString.h b/src/libs/xpcom18a4/xpcom/string/public/nsObsoleteAString.h
new file mode 100644
index 00000000..00d5892e
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsObsoleteAString.h
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsObsoleteAString_h___
+#define nsObsoleteAString_h___
+
+/*
+ STRING INTERNALS
+
+ This file defines nsObsoleteAString and nsObsoleteACString. These are
+ abstract classes (interfaces), containing only virtual functions
+ corresponding to the FROZEN nsA[C]String classes. They exist to provide
+ the new non-abstract nsA[C]String classes with a mechanism to maintain
+ backwards binary compatability.
+
+ From a binary point-of-view, the new nsA[C]String classes appear to have a
+ vtable pointer to the vtable of nsObsoleteA[C]StringThunk.
+ nsObsoleteA[C]StringThunk is a subclass of nsObsoleteA[C]String that serves
+ as a simple bridge between the virtual functions that make up the FROZEN
+ nsA[C]String contract and the new ns[C]Substring, which is now our only
+ subclass of nsA[C]String.
+
+ The methods on the new nsA[C]String are now all non-virtual. This reduces
+ codesize at the callsite, and reduces the number of memory dereferences and
+ jumps required to invoke a method on nsA[C]String. The result is improved
+ performance and reduced codesize. However, to maintain binary
+ compatibility, each method on nsA[C]String must check the value of its
+ vtable to determine if it corresponds to the built-in implementation of
+ nsObsoleteA[C]String (i.e., the address of the canonical vtable). If it
+ does, then the vtable can be ignored, and the nsA[C]String object (i.e.,
+ |this|) can be cast to ns[C]Substring directly. In which case, the
+ nsA[C]String methods can be satisfied by invoking the corresponding methods
+ directly on ns[C]Substring. If the vtable address does not correspond to
+ the built-in implementation, then the virtual functions on
+ nsObsoleteA[C]String must be invoked instead.
+
+ So, if a nsA[C]String reference corresponds to an external implementation
+ (such as the old nsEmbed[C]String that shipped with previous versions of
+ Mozilla), then methods invoked on that nsA[C]String will still act like
+ virtual function calls. This ensures binary compatibility while avoiding
+ virtual function calls in most cases.
+
+ Finally, nsObsoleteA[C]String (i.e., the FROZEN nsA[C]String vtable) is
+ now a DEPRECATED interface. See nsStringAPI.h and nsEmbedString.h for
+ the new preferred way to access nsA[C]String references in an external
+ component or Gecko embedding application.
+ */
+
+#ifndef nsStringFwd_h___
+#include "nsStringFwd.h"
+#endif
+
+#ifndef nscore_h___
+#include "nscore.h"
+#endif
+
+ // declare nsObsoleteAString
+#include "string-template-def-unichar.h"
+#include "nsTObsoleteAString.h"
+#include "string-template-undef.h"
+
+ // declare nsObsoleteACString
+#include "string-template-def-char.h"
+#include "nsTObsoleteAString.h"
+#include "string-template-undef.h"
+
+#endif // !defined(nsObsoleteAString_h___)
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsPrintfCString.h b/src/libs/xpcom18a4/xpcom/string/public/nsPrintfCString.h
new file mode 100644
index 00000000..3f3d04d3
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsPrintfCString.h
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1994-2000
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsPrintfCString_h___
+#define nsPrintfCString_h___
+
+#ifndef nsString_h___
+#include "nsString.h"
+#endif
+
+
+ /**
+ * |nsPrintfCString| lets you use a formated |printf| string as an |const nsACString|.
+ *
+ * myCStr += nsPrintfCString("%f", 13.917);
+ * // ...a general purpose substitute for |AppendFloat|
+ *
+ * For longer patterns, you'll want to use the constructor that takes a length
+ *
+ * nsPrintfCString(128, "%f, %f, %f, %f, %f, %f, %f, %i, %f", x, y, z, 3.2, j, k, l, 3, 3.1);
+ *
+ * Exceding the default size (which you must specify in the constructor, it is not determined)
+ * causes an allocation, so avoid that. If your formatted string exceeds the allocated space, it is
+ * cut off at the size of the buffer, no error is reported (and no out-of-bounds writing occurs).
+ * This class is intended to be useful for numbers and short
+ * strings, not arbitrary formatting of other strings (e.g., with %s). There is currently no
+ * wide version of this class, since wide |printf| is not generally available. That means
+ * to get a wide version of your formatted data, you must, e.g.,
+ *
+ * CopyASCIItoUTF16(nsPrintfCString("%f", 13.917"), myStr);
+ *
+ * That's another good reason to avoid this class for anything but numbers ... as strings can be
+ * much more efficiently handled with |NS_LITERAL_[C]STRING| and |nsLiteral[C]String|.
+ */
+
+class NS_COM nsPrintfCString : public nsCString
+ {
+ typedef nsCString string_type;
+
+ enum { kLocalBufferSize=15 };
+ // ought to be large enough for most things ... a |long long| needs at most 20 (so you'd better ask)
+ // pinkerton suggests 7. We should measure and decide what's appropriate
+
+ public:
+ // XXX don't these need to be declared CDECL ??
+ explicit nsPrintfCString( const char_type* format, ... );
+ nsPrintfCString( size_type n, const char_type* format, ...);
+
+ private:
+ char_type mLocalBuffer[ kLocalBufferSize + 1 ];
+ };
+
+#endif // !defined(nsPrintfCString_h___)
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsPromiseFlatString.h b/src/libs/xpcom18a4/xpcom/string/public/nsPromiseFlatString.h
new file mode 100644
index 00000000..b98aa1a2
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsPromiseFlatString.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsPromiseFlatString_h___
+#define nsPromiseFlatString_h___
+
+#ifndef nsString_h___
+#include "nsString.h"
+#endif
+
+ // declare nsPromiseFlatString
+#include "string-template-def-unichar.h"
+#include "nsTPromiseFlatString.h"
+#include "string-template-undef.h"
+
+ // declare nsPromiseFlatCString
+#include "string-template-def-char.h"
+#include "nsTPromiseFlatString.h"
+#include "string-template-undef.h"
+
+#endif /* !defined(nsPromiseFlatString_h___) */
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsReadableUtils.h b/src/libs/xpcom18a4/xpcom/string/public/nsReadableUtils.h
new file mode 100644
index 00000000..13f94c09
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsReadableUtils.h
@@ -0,0 +1,370 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2000
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Scott Collins <scc@mozilla.org> (original author)
+ * Johnny Stenbeck <jst@netscape.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsReadableUtils_h___
+#define nsReadableUtils_h___
+
+ /**
+ * I guess all the routines in this file are all mis-named.
+ * According to our conventions, they should be |NS_xxx|.
+ */
+
+#ifndef nsAString_h___
+#include "nsAString.h"
+#endif
+
+inline size_t Distance( const nsReadingIterator<PRUnichar>& start, const nsReadingIterator<PRUnichar>& end )
+ {
+ return end.get() - start.get();
+ }
+inline size_t Distance( const nsReadingIterator<char>& start, const nsReadingIterator<char>& end )
+ {
+ return end.get() - start.get();
+ }
+
+NS_COM void LossyCopyUTF16toASCII( const nsAString& aSource, nsACString& aDest );
+NS_COM void CopyASCIItoUTF16( const nsACString& aSource, nsAString& aDest );
+
+NS_COM void LossyCopyUTF16toASCII( const PRUnichar* aSource, nsACString& aDest );
+NS_COM void CopyASCIItoUTF16( const char* aSource, nsAString& aDest );
+
+NS_COM void CopyUTF16toUTF8( const nsAString& aSource, nsACString& aDest );
+NS_COM void CopyUTF8toUTF16( const nsACString& aSource, nsAString& aDest );
+
+NS_COM void CopyUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest );
+NS_COM void CopyUTF8toUTF16( const char* aSource, nsAString& aDest );
+
+NS_COM void LossyAppendUTF16toASCII( const nsAString& aSource, nsACString& aDest );
+NS_COM void AppendASCIItoUTF16( const nsACString& aSource, nsAString& aDest );
+
+NS_COM void LossyAppendUTF16toASCII( const PRUnichar* aSource, nsACString& aDest );
+NS_COM void AppendASCIItoUTF16( const char* aSource, nsAString& aDest );
+
+NS_COM void AppendUTF16toUTF8( const nsAString& aSource, nsACString& aDest );
+NS_COM void AppendUTF8toUTF16( const nsACString& aSource, nsAString& aDest );
+
+NS_COM void AppendUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest );
+NS_COM void AppendUTF8toUTF16( const char* aSource, nsAString& aDest );
+
+// Backward compatibility
+inline
+NS_COM void CopyUCS2toASCII( const nsAString& aSource, nsACString& aDest )
+{ LossyCopyUTF16toASCII(aSource, aDest); }
+inline
+NS_COM void CopyASCIItoUCS2( const nsACString& aSource, nsAString& aDest )
+{ CopyASCIItoUTF16(aSource, aDest); }
+
+ /**
+ * Returns a new |char| buffer containing a zero-terminated copy of |aSource|.
+ *
+ * Allocates and returns a new |char| buffer which you must free with |nsMemory::Free|.
+ * Performs a lossy encoding conversion by chopping 16-bit wide characters down to 8-bits wide while copying |aSource| to your new buffer.
+ * This conversion is not well defined; but it reproduces legacy string behavior.
+ * The new buffer is zero-terminated, but that may not help you if |aSource| contains embedded nulls.
+ *
+ * @param aSource a 16-bit wide string
+ * @return a new |char| buffer you must free with |nsMemory::Free|.
+ */
+NS_COM char* ToNewCString( const nsAString& aSource );
+
+
+ /**
+ * Returns a new |char| buffer containing a zero-terminated copy of |aSource|.
+ *
+ * Allocates and returns a new |char| buffer which you must free with |nsMemory::Free|.
+ * The new buffer is zero-terminated, but that may not help you if |aSource| contains embedded nulls.
+ *
+ * @param aSource an 8-bit wide string
+ * @return a new |char| buffer you must free with |nsMemory::Free|.
+ */
+NS_COM char* ToNewCString( const nsACString& aSource );
+
+ /**
+ * Returns a new |char| buffer containing a zero-terminated copy of |aSource|.
+ *
+ * Allocates and returns a new |char| buffer which you must free with
+ * |nsMemory::Free|.
+ * Performs an encoding conversion from a UTF-16 string to a UTF-8 string
+ * copying |aSource| to your new buffer.
+ * The new buffer is zero-terminated, but that may not help you if |aSource|
+ * contains embedded nulls.
+ *
+ * @param aSource a UTF-16 string (made of PRUnichar's)
+ * @param aUTF8Count the number of 8-bit units that was returned
+ * @return a new |char| buffer you must free with |nsMemory::Free|.
+ */
+
+NS_COM char* ToNewUTF8String( const nsAString& aSource, PRUint32 *aUTF8Count = nsnull );
+
+
+ /**
+ * Returns a new |PRUnichar| buffer containing a zero-terminated copy of
+ * |aSource|.
+ *
+ * Allocates and returns a new |PRUnichar| buffer which you must free with
+ * |nsMemory::Free|.
+ * The new buffer is zero-terminated, but that may not help you if |aSource|
+ * contains embedded nulls.
+ *
+ * @param aSource a UTF-16 string
+ * @return a new |PRUnichar| buffer you must free with |nsMemory::Free|.
+ */
+NS_COM PRUnichar* ToNewUnicode( const nsAString& aSource );
+
+
+ /**
+ * Returns a new |PRUnichar| buffer containing a zero-terminated copy of |aSource|.
+ *
+ * Allocates and returns a new |PRUnichar| buffer which you must free with |nsMemory::Free|.
+ * Performs an encoding conversion by 0-padding 8-bit wide characters up to 16-bits wide while copying |aSource| to your new buffer.
+ * This conversion is not well defined; but it reproduces legacy string behavior.
+ * The new buffer is zero-terminated, but that may not help you if |aSource| contains embedded nulls.
+ *
+ * @param aSource an 8-bit wide string (a C-string, NOT UTF-8)
+ * @return a new |PRUnichar| buffer you must free with |nsMemory::Free|.
+ */
+NS_COM PRUnichar* ToNewUnicode( const nsACString& aSource );
+
+ /**
+ * Returns a new |PRUnichar| buffer containing a zero-terminated copy
+ * of |aSource|.
+ *
+ * Allocates and returns a new |char| buffer which you must free with
+ * |nsMemory::Free|. Performs an encoding conversion from UTF-8 to UTF-16
+ * while copying |aSource| to your new buffer. This conversion is well defined
+ * for a valid UTF-8 string. The new buffer is zero-terminated, but that
+ * may not help you if |aSource| contains embedded nulls.
+ *
+ * @param aSource an 8-bit wide string, UTF-8 encoded
+ * @param aUTF16Count the number of 16-bit units that was returned
+ * @return a new |PRUnichar| buffer you must free with |nsMemory::Free|.
+ * (UTF-16 encoded)
+ */
+NS_COM PRUnichar* UTF8ToNewUnicode( const nsACString& aSource, PRUint32 *aUTF16Count = nsnull );
+
+ /**
+ * Copies |aLength| 16-bit code units from the start of |aSource| to the
+ * |PRUnichar| buffer |aDest|.
+ *
+ * After this operation |aDest| is not null terminated.
+ *
+ * @param aSource a UTF-16 string
+ * @param aSrcOffset start offset in the source string
+ * @param aDest a |PRUnichar| buffer
+ * @param aLength the number of 16-bit code units to copy
+ * @return pointer to destination buffer - identical to |aDest|
+ */
+NS_COM PRUnichar* CopyUnicodeTo( const nsAString& aSource,
+ PRUint32 aSrcOffset,
+ PRUnichar* aDest,
+ PRUint32 aLength );
+
+
+ /**
+ * Copies 16-bit characters between iterators |aSrcStart| and
+ * |aSrcEnd| to the writable string |aDest|. Similar to the
+ * |nsString::Mid| method.
+ *
+ * After this operation |aDest| is not null terminated.
+ *
+ * @param aSrcStart start source iterator
+ * @param aSrcEnd end source iterator
+ * @param aDest destination for the copy
+ */
+NS_COM void CopyUnicodeTo( const nsAString::const_iterator& aSrcStart,
+ const nsAString::const_iterator& aSrcEnd,
+ nsAString& aDest );
+
+ /**
+ * Appends 16-bit characters between iterators |aSrcStart| and
+ * |aSrcEnd| to the writable string |aDest|.
+ *
+ * After this operation |aDest| is not null terminated.
+ *
+ * @param aSrcStart start source iterator
+ * @param aSrcEnd end source iterator
+ * @param aDest destination for the copy
+ */
+NS_COM void AppendUnicodeTo( const nsAString::const_iterator& aSrcStart,
+ const nsAString::const_iterator& aSrcEnd,
+ nsAString& aDest );
+
+ /**
+ * Returns |PR_TRUE| if |aString| contains only ASCII characters, that is, characters in the range (0x00, 0x7F).
+ *
+ * @param aString a 16-bit wide string to scan
+ */
+NS_COM PRBool IsASCII( const nsAString& aString );
+
+ /**
+ * Returns |PR_TRUE| if |aString| contains only ASCII characters, that is, characters in the range (0x00, 0x7F).
+ *
+ * @param aString a 8-bit wide string to scan
+ */
+NS_COM PRBool IsASCII( const nsACString& aString );
+
+
+ /**
+ * Returns |PR_TRUE| if |aString| is a valid UTF-8 string.
+ * XXX This is not bullet-proof and nor an all-purpose UTF-8 validator.
+ * It is mainly written to replace and roughly equivalent to
+ *
+ * str.Equals(NS_ConvertUTF16toUTF8(NS_ConvertUTF8toUTF16(str)))
+ *
+ * (see bug 191541)
+ * As such, it does not check for non-UTF-8 7bit encodings such as
+ * ISO-2022-JP and HZ. However, it filters out UTF-8 representation
+ * of surrogate codepoints and non-characters ( 0xFFFE and 0xFFFF
+ * in planes 0 through 16.) as well as overlong UTF-8 sequences.
+ * Also note that it regards UTF-8 sequences corresponding to
+ * codepoints above 0x10FFFF as invalid in accordance with
+ * http://www.ietf.org/internet-drafts/draft-yergeau-rfc2279bis-04.txt
+ *
+ * @param aString an 8-bit wide string to scan
+ */
+NS_COM PRBool IsUTF8( const nsACString& aString );
+
+
+ /**
+ * Converts case in place in the argument string.
+ */
+NS_COM void ToUpperCase( nsACString& );
+
+NS_COM void ToLowerCase( nsACString& );
+
+NS_COM void ToUpperCase( nsCSubstring& );
+
+NS_COM void ToLowerCase( nsCSubstring& );
+
+ /**
+ * Converts case from string aSource to aDest.
+ */
+NS_COM void ToUpperCase( const nsACString& aSource, nsACString& aDest );
+
+NS_COM void ToLowerCase( const nsACString& aSource, nsACString& aDest );
+
+ /**
+ * Finds the leftmost occurance of |aPattern|, if any in the range |aSearchStart|..|aSearchEnd|.
+ *
+ * Returns |PR_TRUE| if a match was found, and adjusts |aSearchStart| and |aSearchEnd| to
+ * point to the match. If no match was found, returns |PR_FALSE| and makes |aSearchStart == aSearchEnd|.
+ *
+ * Currently, this is equivalent to the O(m*n) implementation previously on |ns[C]String|.
+ * If we need something faster, then we can implement that later.
+ */
+
+NS_COM PRBool FindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() );
+NS_COM PRBool FindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() );
+
+/* sometimes we don't care about where the string was, just that we
+ * found it or not */
+inline PRBool FindInReadable( const nsAString& aPattern, const nsAString& aSource, const nsStringComparator& compare = nsDefaultStringComparator() )
+{
+ nsAString::const_iterator start, end;
+ aSource.BeginReading(start);
+ aSource.EndReading(end);
+ return FindInReadable(aPattern, start, end, compare);
+}
+
+inline PRBool FindInReadable( const nsACString& aPattern, const nsACString& aSource, const nsCStringComparator& compare = nsDefaultCStringComparator() )
+{
+ nsACString::const_iterator start, end;
+ aSource.BeginReading(start);
+ aSource.EndReading(end);
+ return FindInReadable(aPattern, start, end, compare);
+}
+
+
+NS_COM PRBool CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator& );
+
+ /**
+ * Finds the rightmost occurance of |aPattern|
+ * Returns |PR_TRUE| if a match was found, and adjusts |aSearchStart| and |aSearchEnd| to
+ * point to the match. If no match was found, returns |PR_FALSE| and makes |aSearchStart == aSearchEnd|.
+ *
+ * Currently, this is equivalent to the O(m*n) implementation previously on |ns[C]String|.
+ * If we need something faster, then we can implement that later.
+ */
+NS_COM PRBool RFindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() );
+NS_COM PRBool RFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() );
+
+ /**
+ * Finds the leftmost occurance of |aChar|, if any in the range
+ * |aSearchStart|..|aSearchEnd|.
+ *
+ * Returns |PR_TRUE| if a match was found, and adjusts |aSearchStart| to
+ * point to the match. If no match was found, returns |PR_FALSE| and
+ * makes |aSearchStart == aSearchEnd|.
+ */
+NS_COM PRBool FindCharInReadable( PRUnichar aChar, nsAString::const_iterator& aSearchStart, const nsAString::const_iterator& aSearchEnd );
+NS_COM PRBool FindCharInReadable( char aChar, nsACString::const_iterator& aSearchStart, const nsACString::const_iterator& aSearchEnd );
+
+ /**
+ * Finds the number of occurences of |aChar| in the string |aStr|
+ */
+NS_COM PRUint32 CountCharInReadable( const nsAString& aStr,
+ PRUnichar aChar );
+NS_COM PRUint32 CountCharInReadable( const nsACString& aStr,
+ char aChar );
+
+NS_COM PRBool
+StringBeginsWith( const nsAString& aSource, const nsAString& aSubstring,
+ const nsStringComparator& aComparator =
+ nsDefaultStringComparator() );
+NS_COM PRBool
+StringBeginsWith( const nsACString& aSource, const nsACString& aSubstring,
+ const nsCStringComparator& aComparator =
+ nsDefaultCStringComparator() );
+NS_COM PRBool
+StringEndsWith( const nsAString& aSource, const nsAString& aSubstring,
+ const nsStringComparator& aComparator =
+ nsDefaultStringComparator() );
+NS_COM PRBool
+StringEndsWith( const nsACString& aSource, const nsACString& aSubstring,
+ const nsCStringComparator& aComparator =
+ nsDefaultCStringComparator() );
+
+NS_COM PRUint32 HashString( const nsAString& aStr );
+NS_COM PRUint32 HashString( const nsACString& aStr );
+
+NS_COM const nsAFlatString& EmptyString();
+NS_COM const nsAFlatCString& EmptyCString();
+
+
+#endif // !defined(nsReadableUtils_h___)
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsString.h b/src/libs/xpcom18a4/xpcom/string/public/nsString.h
new file mode 100644
index 00000000..67376d19
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsString.h
@@ -0,0 +1,237 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsString_h___
+#define nsString_h___
+
+
+#ifndef nsSubstring_h___
+#include "nsSubstring.h"
+#endif
+
+#ifndef nsDependentSubstring_h___
+#include "nsDependentSubstring.h"
+#endif
+
+#ifndef nsReadableUtils_h___
+#include "nsReadableUtils.h"
+#endif
+
+#include NEW_H
+
+ // enable support for the obsolete string API if not explicitly disabled
+#ifndef MOZ_STRING_WITH_OBSOLETE_API
+#define MOZ_STRING_WITH_OBSOLETE_API 1
+#endif
+
+#if MOZ_STRING_WITH_OBSOLETE_API
+ // radix values for ToInteger/AppendInt
+#define kRadix10 (10)
+#define kRadix16 (16)
+#define kAutoDetect (100)
+#define kRadixUnknown (kAutoDetect+1)
+#define IGNORE_CASE (PR_TRUE)
+#endif
+
+
+ // declare nsString, et. al.
+#include "string-template-def-unichar.h"
+#include "nsTString.h"
+#include "string-template-undef.h"
+
+ // declare nsCString, et. al.
+#include "string-template-def-char.h"
+#include "nsTString.h"
+#include "string-template-undef.h"
+
+
+ /**
+ * A helper class that converts a UTF-16 string to ASCII in a lossy manner
+ */
+class NS_LossyConvertUTF16toASCII : public nsCAutoString
+ {
+ public:
+ explicit
+ NS_LossyConvertUTF16toASCII( const PRUnichar* aString )
+ {
+ LossyAppendUTF16toASCII(aString, *this);
+ }
+
+ NS_LossyConvertUTF16toASCII( const PRUnichar* aString, PRUint32 aLength )
+ {
+ LossyAppendUTF16toASCII(Substring(aString, aString + aLength), *this);
+ }
+
+ explicit
+ NS_LossyConvertUTF16toASCII( const nsAString& aString )
+ {
+ LossyAppendUTF16toASCII(aString, *this);
+ }
+
+ private:
+ // NOT TO BE IMPLEMENTED
+ NS_LossyConvertUTF16toASCII( char );
+ };
+
+
+class NS_ConvertASCIItoUTF16 : public nsAutoString
+ {
+ public:
+ explicit
+ NS_ConvertASCIItoUTF16( const char* aCString )
+ {
+ AppendASCIItoUTF16(aCString, *this);
+ }
+
+ NS_ConvertASCIItoUTF16( const char* aCString, PRUint32 aLength )
+ {
+ AppendASCIItoUTF16(Substring(aCString, aCString + aLength), *this);
+ }
+
+ explicit
+ NS_ConvertASCIItoUTF16( const nsACString& aCString )
+ {
+ AppendASCIItoUTF16(aCString, *this);
+ }
+
+ private:
+ // NOT TO BE IMPLEMENTED
+ NS_ConvertASCIItoUTF16( PRUnichar );
+ };
+
+
+ /**
+ * A helper class that converts a UTF-16 string to UTF-8
+ */
+class NS_ConvertUTF16toUTF8 : public nsCAutoString
+ {
+ public:
+ explicit
+ NS_ConvertUTF16toUTF8( const PRUnichar* aString )
+ {
+ AppendUTF16toUTF8(aString, *this);
+ }
+
+ NS_ConvertUTF16toUTF8( const PRUnichar* aString, PRUint32 aLength )
+ {
+ AppendUTF16toUTF8(Substring(aString, aString + aLength), *this);
+ }
+
+ explicit
+ NS_ConvertUTF16toUTF8( const nsAString& aString )
+ {
+ AppendUTF16toUTF8(aString, *this);
+ }
+
+ private:
+ // NOT TO BE IMPLEMENTED
+ NS_ConvertUTF16toUTF8( char );
+ };
+
+
+class NS_ConvertUTF8toUTF16 : public nsAutoString
+ {
+ public:
+ explicit
+ NS_ConvertUTF8toUTF16( const char* aCString )
+ {
+ AppendUTF8toUTF16(aCString, *this);
+ }
+
+ NS_ConvertUTF8toUTF16( const char* aCString, PRUint32 aLength )
+ {
+ AppendUTF8toUTF16(Substring(aCString, aCString + aLength), *this);
+ }
+
+ explicit
+ NS_ConvertUTF8toUTF16( const nsACString& aCString )
+ {
+ AppendUTF8toUTF16(aCString, *this);
+ }
+
+ private:
+ // NOT TO BE IMPLEMENTED
+ NS_ConvertUTF8toUTF16( PRUnichar );
+ };
+
+
+// the following are included/declared for backwards compatibility
+
+typedef NS_ConvertUTF16toUTF8 NS_ConvertUCS2toUTF8;
+typedef NS_LossyConvertUTF16toASCII NS_LossyConvertUCS2toASCII;
+typedef NS_ConvertASCIItoUTF16 NS_ConvertASCIItoUCS2;
+typedef NS_ConvertUTF8toUTF16 NS_ConvertUTF8toUCS2;
+typedef nsAutoString nsVoidableString;
+
+#ifndef nsDependentString_h___
+#include "nsDependentString.h"
+#endif
+
+#ifndef nsLiteralString_h___
+#include "nsLiteralString.h"
+#endif
+
+#ifndef nsPromiseFlatString_h___
+#include "nsPromiseFlatString.h"
+#endif
+
+// need to include these for backwards compatibility
+#include "nsMemory.h"
+#include <string.h>
+#include <stdio.h>
+#include "plhash.h"
+
+inline PRInt32 MinInt(PRInt32 x, PRInt32 y)
+ {
+ return NS_MIN(x, y);
+ }
+
+inline PRInt32 MaxInt(PRInt32 x, PRInt32 y)
+ {
+ return NS_MAX(x, y);
+ }
+
+/**
+ * Deprecated: don't use |Recycle|, just call |nsMemory::Free| directly
+ *
+ * Return the given buffer to the heap manager. Calls allocator::Free()
+ */
+inline void Recycle( char* aBuffer) { nsMemory::Free(aBuffer); }
+inline void Recycle( PRUnichar* aBuffer) { nsMemory::Free(aBuffer); }
+
+#endif // !defined(nsString_h___)
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsStringAPI.h b/src/libs/xpcom18a4/xpcom/string/public/nsStringAPI.h
new file mode 100644
index 00000000..cc0818b6
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsStringAPI.h
@@ -0,0 +1,853 @@
+/* vim:set ts=2 sw=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsStringAPI_h__
+#define nsStringAPI_h__
+
+/**
+ * nsStringAPI.h
+ *
+ * This file describes a minimal API for working with XPCOM's abstract
+ * string classes. It divorces the consumer from having any run-time
+ * dependency on the implementation details of the abstract string types.
+ */
+
+#include "nscore.h"
+
+#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
+#define NS_CStringContainerInit VBoxNsxpNS_CStringContainerInit
+#define NS_CStringContainerFinish VBoxNsxpNS_CStringContainerFinish
+#define NS_CStringCloneData VBoxNsxpNS_CStringCloneData
+#define NS_CStringCopy VBoxNsxpNS_CStringCopy
+#define NS_CStringGetData VBoxNsxpNS_CStringGetData
+#define NS_CStringSetData VBoxNsxpNS_CStringSetData
+#define NS_CStringSetDataRange VBoxNsxpNS_CStringSetDataRange
+#define NS_UTF16ToCString VBoxNsxpNS_UTF16ToCString
+#define NS_CStringToUTF16 VBoxNsxpNS_CStringToUTF16
+#define NS_StringContainerInit VBoxNsxpNS_StringContainerInit
+#define NS_StringContainerFinish VBoxNsxpNS_StringContainerFinish
+#define NS_StringCloneData VBoxNsxpNS_StringCloneData
+#define NS_StringCopy VBoxNsxpNS_StringCopy
+#define NS_StringGetData VBoxNsxpNS_StringGetData
+#define NS_StringSetData VBoxNsxpNS_StringSetData
+#define NS_StringSetDataRange VBoxNsxpNS_StringSetDataRange
+#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
+
+#define NS_STRINGAPI(x) extern "C" NS_COM x
+
+/* The base string types */
+class nsAString;
+class nsACString;
+
+/* ------------------------------------------------------------------------- */
+
+/**
+ * nsStringContainer
+ *
+ * This is an opaque data type that is large enough to hold the canonical
+ * implementation of nsAString. The binary structure of this class is an
+ * implementation detail.
+ *
+ * The string data stored in a string container is always single fragment
+ * and null-terminated.
+ *
+ * Typically, string containers are allocated on the stack for temporary
+ * use. However, they can also be malloc'd if necessary. In either case,
+ * a string container is not useful until it has been initialized with a
+ * call to NS_StringContainerInit. The following example shows how to use
+ * a string container to call a function that takes a |nsAString &| out-param.
+ *
+ * NS_METHOD GetBlah(nsAString &aBlah);
+ *
+ * nsresult MyCode()
+ * {
+ * nsresult rv;
+ *
+ * nsStringContainer sc;
+ * rv = NS_StringContainerInit(sc);
+ * if (NS_FAILED(rv))
+ * return rv;
+ *
+ * rv = GetBlah(sc);
+ * if (NS_SUCCEEDED(rv))
+ * {
+ * const PRUnichar *data;
+ * NS_StringGetData(sc, &data);
+ * //
+ * // |data| now points to the result of the GetBlah function
+ * //
+ * }
+ *
+ * NS_StringContainerFinish(sc);
+ * return rv;
+ * }
+ *
+ * The following example show how to use a string container to pass a string
+ * parameter to a function taking a |const nsAString &| in-param.
+ *
+ * NS_METHOD SetBlah(const nsAString &aBlah);
+ *
+ * nsresult MyCode()
+ * {
+ * nsresult rv;
+ *
+ * nsStringContainer sc;
+ * rv = NS_StringContainerInit(sc);
+ * if (NS_FAILED(rv))
+ * return rv;
+ *
+ * const PRUnichar kData[] = {'x','y','z','\0'};
+ * rv = NS_StringSetData(sc, kData, sizeof(kData)/2 - 1);
+ * if (NS_SUCCEEDED(rv))
+ * rv = SetBlah(sc);
+ *
+ * NS_StringContainerFinish(sc);
+ * return rv;
+ * }
+ */
+class nsStringContainer;
+
+/**
+ * NS_StringContainerInit
+ *
+ * @param aContainer string container reference
+ * @return NS_OK if string container successfully initialized
+ *
+ * This function may allocate additional memory for aContainer. When
+ * aContainer is no longer needed, NS_StringContainerFinish should be called.
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(nsresult)
+NS_StringContainerInit(nsStringContainer &aContainer);
+
+/**
+ * NS_StringContainerFinish
+ *
+ * @param aContainer string container reference
+ *
+ * This function frees any memory owned by aContainer.
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(void)
+NS_StringContainerFinish(nsStringContainer &aContainer);
+
+/* ------------------------------------------------------------------------- */
+
+/**
+ * NS_StringGetData
+ *
+ * This function returns a const character pointer to the string's internal
+ * buffer, the length of the string, and a boolean value indicating whether
+ * or not the buffer is null-terminated.
+ *
+ * @param aStr abstract string reference
+ * @param aData out param that will hold the address of aStr's
+ * internal buffer
+ * @param aTerminated if non-null, this out param will be set to indicate
+ * whether or not aStr's internal buffer is null-
+ * terminated
+ * @return length of aStr's internal buffer
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(PRUint32)
+NS_StringGetData
+ (const nsAString &aStr, const PRUnichar **aData,
+ PRBool *aTerminated = nsnull);
+
+/**
+ * NS_StringCloneData
+ *
+ * This function returns a null-terminated copy of the string's
+ * internal buffer.
+ *
+ * @param aStr abstract string reference
+ * @return null-terminated copy of the string's internal buffer
+ * (it must be free'd using using nsMemory::Free)
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(PRUnichar *)
+NS_StringCloneData
+ (const nsAString &aStr);
+
+/**
+ * NS_StringSetData
+ *
+ * This function copies aData into aStr.
+ *
+ * @param aStr abstract string reference
+ * @param aData character buffer
+ * @param aDataLength number of characters to copy from source string (pass
+ * PR_UINT32_MAX to copy until end of aData, designated by
+ * a null character)
+ * @return NS_OK if function succeeded
+ *
+ * This function does not necessarily null-terminate aStr after copying data
+ * from aData. The behavior depends on the implementation of the abstract
+ * string, aStr. If aStr is a reference to a nsStringContainer, then its data
+ * will be null-terminated by this function.
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(nsresult)
+NS_StringSetData
+ (nsAString &aStr, const PRUnichar *aData,
+ PRUint32 aDataLength = PR_UINT32_MAX);
+
+/**
+ * NS_StringSetDataRange
+ *
+ * This function copies aData into a section of aStr. As a result it can be
+ * used to insert new characters into the string.
+ *
+ * @param aStr abstract string reference
+ * @param aCutOffset starting index where the string's existing data
+ * is to be overwritten (pass PR_UINT32_MAX to cause
+ * aData to be appended to the end of aStr, in which
+ * case the value of aCutLength is ignored).
+ * @param aCutLength number of characters to overwrite starting at
+ * aCutOffset (pass PR_UINT32_MAX to overwrite until the
+ * end of aStr).
+ * @param aData character buffer (pass null to cause this function
+ * to simply remove the "cut" range)
+ * @param aDataLength number of characters to copy from source string (pass
+ * PR_UINT32_MAX to copy until end of aData, designated by
+ * a null character)
+ * @return NS_OK if function succeeded
+ *
+ * This function does not necessarily null-terminate aStr after copying data
+ * from aData. The behavior depends on the implementation of the abstract
+ * string, aStr. If aStr is a reference to a nsStringContainer, then its data
+ * will be null-terminated by this function.
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(nsresult)
+NS_StringSetDataRange
+ (nsAString &aStr, PRUint32 aCutOffset, PRUint32 aCutLength,
+ const PRUnichar *aData, PRUint32 aDataLength = PR_UINT32_MAX);
+
+/**
+ * NS_StringCopy
+ *
+ * This function makes aDestStr have the same value as aSrcStr. It is
+ * provided as an optimization.
+ *
+ * @param aDestStr abstract string reference to be modified
+ * @param aSrcStr abstract string reference containing source string
+ * @return NS_OK if function succeeded
+ *
+ * This function does not necessarily null-terminate aDestStr after copying
+ * data from aSrcStr. The behavior depends on the implementation of the
+ * abstract string, aDestStr. If aDestStr is a reference to a
+ * nsStringContainer, then its data will be null-terminated by this function.
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(nsresult)
+NS_StringCopy
+ (nsAString &aDestStr, const nsAString &aSrcStr);
+
+/**
+ * NS_StringAppendData
+ *
+ * This function appends data to the existing value of aStr.
+ *
+ * @param aStr abstract string reference to be modified
+ * @param aData character buffer
+ * @param aDataLength number of characters to append (pass PR_UINT32_MAX to
+ * append until a null-character is encountered)
+ * @return NS_OK if function succeeded
+ *
+ * This function does not necessarily null-terminate aStr upon completion.
+ * The behavior depends on the implementation of the abstract string, aStr.
+ * If aStr is a reference to a nsStringContainer, then its data will be null-
+ * terminated by this function.
+ */
+inline NS_HIDDEN_(nsresult)
+NS_StringAppendData(nsAString &aStr, const PRUnichar *aData,
+ PRUint32 aDataLength = PR_UINT32_MAX)
+{
+ return NS_StringSetDataRange(aStr, PR_UINT32_MAX, 0, aData, aDataLength);
+}
+
+/**
+ * NS_StringInsertData
+ *
+ * This function inserts data into the existing value of aStr at the specified
+ * offset.
+ *
+ * @param aStr abstract string reference to be modified
+ * @param aOffset specifies where in the string to insert aData
+ * @param aData character buffer
+ * @param aDataLength number of characters to append (pass PR_UINT32_MAX to
+ * append until a null-character is encountered)
+ * @return NS_OK if function succeeded
+ *
+ * This function does not necessarily null-terminate aStr upon completion.
+ * The behavior depends on the implementation of the abstract string, aStr.
+ * If aStr is a reference to a nsStringContainer, then its data will be null-
+ * terminated by this function.
+ */
+inline NS_HIDDEN_(nsresult)
+NS_StringInsertData(nsAString &aStr, PRUint32 aOffset, const PRUnichar *aData,
+ PRUint32 aDataLength = PR_UINT32_MAX)
+{
+ return NS_StringSetDataRange(aStr, aOffset, 0, aData, aDataLength);
+}
+
+/**
+ * NS_StringCutData
+ *
+ * This function shortens the existing value of aStr, by removing characters
+ * at the specified offset.
+ *
+ * @param aStr abstract string reference to be modified
+ * @param aCutOffset specifies where in the string to insert aData
+ * @param aCutLength number of characters to remove
+ * @return NS_OK if function succeeded
+ */
+inline NS_HIDDEN_(nsresult)
+NS_StringCutData(nsAString &aStr, PRUint32 aCutOffset, PRUint32 aCutLength)
+{
+ return NS_StringSetDataRange(aStr, aCutOffset, aCutLength, nsnull, 0);
+}
+
+/* ------------------------------------------------------------------------- */
+
+/**
+ * nsCStringContainer
+ *
+ * This is an opaque data type that is large enough to hold the canonical
+ * implementation of nsACString. The binary structure of this class is an
+ * implementation detail.
+ *
+ * The string data stored in a string container is always single fragment
+ * and null-terminated.
+ *
+ * @see nsStringContainer for use cases and further documentation.
+ */
+class nsCStringContainer;
+
+/**
+ * NS_CStringContainerInit
+ *
+ * @param aContainer string container reference
+ * @return NS_OK if string container successfully initialized
+ *
+ * This function may allocate additional memory for aContainer. When
+ * aContainer is no longer needed, NS_CStringContainerFinish should be called.
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(nsresult)
+NS_CStringContainerInit(nsCStringContainer &aContainer);
+
+/**
+ * NS_CStringContainerFinish
+ *
+ * @param aContainer string container reference
+ *
+ * This function frees any memory owned by aContainer.
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(void)
+NS_CStringContainerFinish(nsCStringContainer &aContainer);
+
+/* ------------------------------------------------------------------------- */
+
+/**
+ * NS_CStringGetData
+ *
+ * This function returns a const character pointer to the string's internal
+ * buffer, the length of the string, and a boolean value indicating whether
+ * or not the buffer is null-terminated.
+ *
+ * @param aStr abstract string reference
+ * @param aData out param that will hold the address of aStr's
+ * internal buffer
+ * @param aTerminated if non-null, this out param will be set to indicate
+ * whether or not aStr's internal buffer is null-
+ * terminated
+ * @return length of aStr's internal buffer
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(PRUint32)
+NS_CStringGetData
+ (const nsACString &aStr, const char **aData,
+ PRBool *aTerminated = nsnull);
+
+/**
+ * NS_CStringCloneData
+ *
+ * This function returns a null-terminated copy of the string's
+ * internal buffer.
+ *
+ * @param aStr abstract string reference
+ * @return null-terminated copy of the string's internal buffer
+ * (it must be free'd using using nsMemory::Free)
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(char *)
+NS_CStringCloneData
+ (const nsACString &aStr);
+
+/**
+ * NS_CStringSetData
+ *
+ * This function copies aData into aStr.
+ *
+ * @param aStr abstract string reference
+ * @param aData character buffer
+ * @param aDataLength number of characters to copy from source string (pass
+ * PR_UINT32_MAX to copy until end of aData, designated by
+ * a null character)
+ * @return NS_OK if function succeeded
+ *
+ * This function does not necessarily null-terminate aStr after copying data
+ * from aData. The behavior depends on the implementation of the abstract
+ * string, aStr. If aStr is a reference to a nsStringContainer, then its data
+ * will be null-terminated by this function.
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(nsresult)
+NS_CStringSetData
+ (nsACString &aStr, const char *aData,
+ PRUint32 aDataLength = PR_UINT32_MAX);
+
+/**
+ * NS_CStringSetDataRange
+ *
+ * This function copies aData into a section of aStr. As a result it can be
+ * used to insert new characters into the string.
+ *
+ * @param aStr abstract string reference
+ * @param aCutOffset starting index where the string's existing data
+ * is to be overwritten (pass PR_UINT32_MAX to cause
+ * aData to be appended to the end of aStr, in which
+ * case the value of aCutLength is ignored).
+ * @param aCutLength number of characters to overwrite starting at
+ * aCutOffset (pass PR_UINT32_MAX to overwrite until the
+ * end of aStr).
+ * @param aData character buffer (pass null to cause this function
+ * to simply remove the "cut" range)
+ * @param aDataLength number of characters to copy from source string (pass
+ * PR_UINT32_MAX to copy until end of aData, designated by
+ * a null character)
+ * @return NS_OK if function succeeded
+ *
+ * This function does not necessarily null-terminate aStr after copying data
+ * from aData. The behavior depends on the implementation of the abstract
+ * string, aStr. If aStr is a reference to a nsStringContainer, then its data
+ * will be null-terminated by this function.
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(nsresult)
+NS_CStringSetDataRange
+ (nsACString &aStr, PRUint32 aCutOffset, PRUint32 aCutLength,
+ const char *aData, PRUint32 aDataLength = PR_UINT32_MAX);
+
+/**
+ * NS_CStringCopy
+ *
+ * This function makes aDestStr have the same value as aSrcStr. It is
+ * provided as an optimization.
+ *
+ * @param aDestStr abstract string reference to be modified
+ * @param aSrcStr abstract string reference containing source string
+ * @return NS_OK if function succeeded
+ *
+ * This function does not necessarily null-terminate aDestStr after copying
+ * data from aSrcStr. The behavior depends on the implementation of the
+ * abstract string, aDestStr. If aDestStr is a reference to a
+ * nsStringContainer, then its data will be null-terminated by this function.
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(nsresult)
+NS_CStringCopy
+ (nsACString &aDestStr, const nsACString &aSrcStr);
+
+/**
+ * NS_CStringAppendData
+ *
+ * This function appends data to the existing value of aStr.
+ *
+ * @param aStr abstract string reference to be modified
+ * @param aData character buffer
+ * @param aDataLength number of characters to append (pass PR_UINT32_MAX to
+ * append until a null-character is encountered)
+ * @return NS_OK if function succeeded
+ *
+ * This function does not necessarily null-terminate aStr upon completion.
+ * The behavior depends on the implementation of the abstract string, aStr.
+ * If aStr is a reference to a nsStringContainer, then its data will be null-
+ * terminated by this function.
+ */
+inline NS_HIDDEN_(nsresult)
+NS_CStringAppendData(nsACString &aStr, const char *aData,
+ PRUint32 aDataLength = PR_UINT32_MAX)
+{
+ return NS_CStringSetDataRange(aStr, PR_UINT32_MAX, 0, aData, aDataLength);
+}
+
+/**
+ * NS_CStringInsertData
+ *
+ * This function inserts data into the existing value of aStr at the specified
+ * offset.
+ *
+ * @param aStr abstract string reference to be modified
+ * @param aOffset specifies where in the string to insert aData
+ * @param aData character buffer
+ * @param aDataLength number of characters to append (pass PR_UINT32_MAX to
+ * append until a null-character is encountered)
+ * @return NS_OK if function succeeded
+ *
+ * This function does not necessarily null-terminate aStr upon completion.
+ * The behavior depends on the implementation of the abstract string, aStr.
+ * If aStr is a reference to a nsStringContainer, then its data will be null-
+ * terminated by this function.
+ */
+inline NS_HIDDEN_(nsresult)
+NS_CStringInsertData(nsACString &aStr, PRUint32 aOffset, const char *aData,
+ PRUint32 aDataLength = PR_UINT32_MAX)
+{
+ return NS_CStringSetDataRange(aStr, aOffset, 0, aData, aDataLength);
+}
+
+/**
+ * NS_CStringCutData
+ *
+ * This function shortens the existing value of aStr, by removing characters
+ * at the specified offset.
+ *
+ * @param aStr abstract string reference to be modified
+ * @param aCutOffset specifies where in the string to insert aData
+ * @param aCutLength number of characters to remove
+ * @return NS_OK if function succeeded
+ */
+inline NS_HIDDEN_(nsresult)
+NS_CStringCutData(nsACString &aStr, PRUint32 aCutOffset, PRUint32 aCutLength)
+{
+ return NS_CStringSetDataRange(aStr, aCutOffset, aCutLength, nsnull, 0);
+}
+
+/* ------------------------------------------------------------------------- */
+
+/**
+ * Encodings that can be used with the following conversion routines.
+ */
+enum nsCStringEncoding {
+ /* Conversion between ASCII and UTF-16 assumes that all bytes in the source
+ * string are 7-bit ASCII and can be inflated to UTF-16 by inserting null
+ * bytes. Reverse conversion is done by truncating every other byte. The
+ * conversion may result in loss and/or corruption of information if the
+ * strings do not strictly contain ASCII data. */
+ NS_CSTRING_ENCODING_ASCII = 0,
+
+ /* Conversion between UTF-8 and UTF-16 is non-lossy. */
+ NS_CSTRING_ENCODING_UTF8 = 1,
+
+ /* Conversion from UTF-16 to the native filesystem charset may result in a
+ * loss of information. No attempt is made to protect against data loss in
+ * this case. The native filesystem charset applies to strings passed to
+ * the "Native" method variants on nsIFile and nsILocalFile. */
+ NS_CSTRING_ENCODING_NATIVE_FILESYSTEM = 2
+};
+
+/**
+ * NS_CStringToUTF16
+ *
+ * This function converts the characters in a nsACString to an array of UTF-16
+ * characters, in the platform endianness. The result is stored in a nsAString
+ * object.
+ *
+ * @param aSource abstract string reference containing source string
+ * @param aSrcEncoding character encoding of the source string
+ * @param aDest abstract string reference to hold the result
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(nsresult)
+NS_CStringToUTF16(const nsACString &aSource, nsCStringEncoding aSrcEncoding,
+ nsAString &aDest);
+
+/**
+ * NS_UTF16ToCString
+ *
+ * This function converts the UTF-16 characters in a nsAString to a single-byte
+ * encoding. The result is stored in a nsACString object. In some cases this
+ * conversion may be lossy. In such cases, the conversion may succeed with a
+ * return code indicating loss of information. The exact behavior is not
+ * specified at this time.
+ *
+ * @param aSource abstract string reference containing source string
+ * @param aDestEncoding character encoding of the resulting string
+ * @param aDest abstract string reference to hold the result
+ *
+ * @status FROZEN
+ */
+NS_STRINGAPI(nsresult)
+NS_UTF16ToCString(const nsAString &aSource, nsCStringEncoding aDestEncoding,
+ nsACString &aDest);
+
+/* ------------------------------------------------------------------------- */
+
+/**
+ * Below we define nsAString and nsACString. The "_external" suffix is an
+ * implementation detail. nsAString_external is the name of the external
+ * representation of nsAString from the point of view of the Mozilla codebase.
+ * To a user of this API, nsAString_external is exactly nsAString.
+ *
+ * These classes should be treated as abstract classes with unspecified
+ * structure. The inline methods are provided as helper functions around the
+ * C-style API provided above.
+ *
+ * Do not try to mix these definitions of nsAString and nsACString with the
+ * internal definition of these classes from nsAString.h in the Mozilla tree.
+ */
+
+#ifndef NS_STRINGAPI_IMPL
+#define nsAString_external nsAString
+#define nsACString_external nsACString
+#endif
+
+class nsAString_external
+{
+#ifndef NS_STRINGAPI_IMPL
+
+public:
+ typedef PRUnichar char_type;
+ typedef nsAString_external self_type;
+ typedef PRUint32 size_type;
+ typedef PRUint32 index_type;
+
+ NS_HIDDEN_(const char_type*) BeginReading() const
+ {
+ const char_type *data;
+ NS_StringGetData(*this, &data);
+ return data;
+ }
+
+ NS_HIDDEN_(const char_type*) EndReading() const
+ {
+ const char_type *data;
+ PRUint32 len = NS_StringGetData(*this, &data);
+ return data + len;
+ }
+
+ NS_HIDDEN_(size_type) Length() const
+ {
+ const char_type* data;
+ return NS_StringGetData(*this, &data);
+ }
+
+ NS_HIDDEN_(void) Assign(const self_type& aString)
+ {
+ NS_StringCopy(*this, aString);
+ }
+ NS_HIDDEN_(void) Assign(const char_type* aData, size_type aLength = PR_UINT32_MAX)
+ {
+ NS_StringSetData(*this, aData, aLength);
+ }
+ NS_HIDDEN_(void) Assign(char_type aChar)
+ {
+ NS_StringSetData(*this, &aChar, 1);
+ }
+
+ NS_HIDDEN_(self_type&) operator=(const self_type& aString) { Assign(aString); return *this; }
+ NS_HIDDEN_(self_type&) operator=(const char_type* aPtr) { Assign(aPtr); return *this; }
+ NS_HIDDEN_(self_type&) operator=(char_type aChar) { Assign(aChar); return *this; }
+
+ NS_HIDDEN_(void) Replace( index_type cutStart, size_type cutLength, const char_type* data, size_type length = size_type(-1) )
+ {
+ NS_StringSetDataRange(*this, cutStart, cutLength, data, length);
+ }
+ NS_HIDDEN_(void) Replace( index_type cutStart, size_type cutLength, char_type c )
+ {
+ Replace(cutStart, cutLength, &c, 1);
+ }
+ NS_HIDDEN_(void) Replace( index_type cutStart, size_type cutLength, const self_type& readable )
+ {
+ const char_type* data;
+ PRUint32 dataLen = NS_StringGetData(readable, &data);
+ NS_StringSetDataRange(*this, cutStart, cutLength, data, dataLen);
+ }
+
+ NS_HIDDEN_(void) Append( char_type c ) { Replace(size_type(-1), 0, c); }
+ NS_HIDDEN_(void) Append( const char_type* data, size_type length = size_type(-1) ) { Replace(size_type(-1), 0, data, length); }
+ NS_HIDDEN_(void) Append( const self_type& readable ) { Replace(size_type(-1), 0, readable); }
+
+ NS_HIDDEN_(self_type&) operator+=( char_type c ) { Append(c); return *this; }
+ NS_HIDDEN_(self_type&) operator+=( const char_type* data ) { Append(data); return *this; }
+ NS_HIDDEN_(self_type&) operator+=( const self_type& readable ) { Append(readable); return *this; }
+
+ NS_HIDDEN_(void) Insert( char_type c, index_type pos ) { Replace(pos, 0, c); }
+ NS_HIDDEN_(void) Insert( const char_type* data, index_type pos, size_type length = size_type(-1) ) { Replace(pos, 0, data, length); }
+ NS_HIDDEN_(void) Insert( const self_type& readable, index_type pos ) { Replace(pos, 0, readable); }
+
+ NS_HIDDEN_(void) Cut( index_type cutStart, size_type cutLength ) { Replace(cutStart, cutLength, nsnull, 0); }
+
+#endif // NS_STRINGAPI_IMPL
+
+private:
+ void *v;
+};
+
+class nsACString_external
+{
+#ifndef NS_STRINGAPI_IMPL
+
+public:
+ typedef char char_type;
+ typedef nsACString_external self_type;
+ typedef PRUint32 size_type;
+ typedef PRUint32 index_type;
+
+ NS_HIDDEN_(const char_type*) BeginReading() const
+ {
+ const char_type *data;
+ NS_CStringGetData(*this, &data);
+ return data;
+ }
+
+ NS_HIDDEN_(const char_type*) EndReading() const
+ {
+ const char_type *data;
+ PRUint32 len = NS_CStringGetData(*this, &data);
+ return data + len;
+ }
+
+ NS_HIDDEN_(size_type) Length() const
+ {
+ const char_type* data;
+ return NS_CStringGetData(*this, &data);
+ }
+
+ NS_HIDDEN_(void) Assign(const self_type& aString)
+ {
+ NS_CStringCopy(*this, aString);
+ }
+ NS_HIDDEN_(void) Assign(const char_type* aData, size_type aLength = PR_UINT32_MAX)
+ {
+ NS_CStringSetData(*this, aData, aLength);
+ }
+ NS_HIDDEN_(void) Assign(char_type aChar)
+ {
+ NS_CStringSetData(*this, &aChar, 1);
+ }
+
+ NS_HIDDEN_(self_type&) operator=(const self_type& aString) { Assign(aString); return *this; }
+ NS_HIDDEN_(self_type&) operator=(const char_type* aPtr) { Assign(aPtr); return *this; }
+ NS_HIDDEN_(self_type&) operator=(char_type aChar) { Assign(aChar); return *this; }
+
+ NS_HIDDEN_(void) Replace( index_type cutStart, size_type cutLength, const char_type* data, size_type length = size_type(-1) )
+ {
+ NS_CStringSetDataRange(*this, cutStart, cutLength, data, length);
+ }
+ NS_HIDDEN_(void) Replace( index_type cutStart, size_type cutLength, char_type c )
+ {
+ Replace(cutStart, cutLength, &c, 1);
+ }
+ NS_HIDDEN_(void) Replace( index_type cutStart, size_type cutLength, const self_type& readable )
+ {
+ const char_type* data;
+ PRUint32 dataLen = NS_CStringGetData(readable, &data);
+ NS_CStringSetDataRange(*this, cutStart, cutLength, data, dataLen);
+ }
+
+ NS_HIDDEN_(void) Append( char_type c ) { Replace(size_type(-1), 0, c); }
+ NS_HIDDEN_(void) Append( const char_type* data, size_type length = size_type(-1) ) { Replace(size_type(-1), 0, data, length); }
+ NS_HIDDEN_(void) Append( const self_type& readable ) { Replace(size_type(-1), 0, readable); }
+
+ NS_HIDDEN_(self_type&) operator+=( char_type c ) { Append(c); return *this; }
+ NS_HIDDEN_(self_type&) operator+=( const char_type* data ) { Append(data); return *this; }
+ NS_HIDDEN_(self_type&) operator+=( const self_type& readable ) { Append(readable); return *this; }
+
+ NS_HIDDEN_(void) Insert( char_type c, index_type pos ) { Replace(pos, 0, c); }
+ NS_HIDDEN_(void) Insert( const char_type* data, index_type pos, size_type length = size_type(-1) ) { Replace(pos, 0, data, length); }
+ NS_HIDDEN_(void) Insert( const self_type& readable, index_type pos ) { Replace(pos, 0, readable); }
+
+ NS_HIDDEN_(void) Cut( index_type cutStart, size_type cutLength ) { Replace(cutStart, cutLength, nsnull, 0); }
+
+#endif // NS_STRINGAPI_IMPL
+
+private:
+ void *v;
+};
+
+/* ------------------------------------------------------------------------- */
+
+/**
+ * Below we define nsStringContainer and nsCStringContainer. These classes
+ * have unspecified structure. In most cases, your code should use
+ * nsEmbedString instead of these classes; however, if you prefer C-style
+ * programming, then look no further...
+ */
+
+class nsStringContainer : public nsAString_external
+{
+private:
+ void *d1;
+ PRUint32 d2;
+ void *d3;
+
+public:
+ nsStringContainer() {} // MSVC6 needs this
+};
+
+class nsCStringContainer : public nsACString_external
+{
+private:
+ void *d1;
+ PRUint32 d2;
+ void *d3;
+
+public:
+ nsCStringContainer() {} // MSVC6 needs this
+};
+
+#endif // nsStringAPI_h__
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsStringFwd.h b/src/libs/xpcom18a4/xpcom/string/public/nsStringFwd.h
new file mode 100644
index 00000000..4c664011
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsStringFwd.h
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications.
+ * Portions created by the Initial Developer are Copyright (C) 2001
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Scott Collins <scc@mozilla.org> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/* nsStringFwd.h --- forward declarations for string classes */
+
+#ifndef nsStringFwd_h___
+#define nsStringFwd_h___
+
+#ifndef nscore_h___
+#include "nscore.h"
+#endif
+
+
+ /**
+ * double-byte (PRUnichar) string types
+ */
+
+class nsAString;
+class nsObsoleteAString;
+class nsSubstring;
+class nsSubstringTuple;
+class nsString;
+class nsAutoString;
+class nsDependentString;
+class nsDependentSubstring;
+class nsPromiseFlatString;
+class nsStringComparator;
+class nsDefaultStringComparator;
+class nsXPIDLString;
+
+
+ /**
+ * single-byte (char) string types
+ */
+
+class nsACString;
+class nsObsoleteACString;
+class nsCSubstring;
+class nsCSubstringTuple;
+class nsCString;
+class nsCAutoString;
+class nsDependentCString;
+class nsDependentCSubstring;
+class nsPromiseFlatCString;
+class nsCStringComparator;
+class nsDefaultCStringComparator;
+class nsXPIDLCString;
+
+
+ /**
+ * typedefs for backwards compatibility
+ */
+
+typedef nsString nsAFlatString;
+typedef nsSubstring nsASingleFragmentString;
+
+typedef nsCString nsAFlatCString;
+typedef nsCSubstring nsASingleFragmentCString;
+
+
+#endif /* !defined(nsStringFwd_h___) */
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsStringIterator.h b/src/libs/xpcom18a4/xpcom/string/public/nsStringIterator.h
new file mode 100644
index 00000000..1848594c
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsStringIterator.h
@@ -0,0 +1,373 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications.
+ * Portions created by the Initial Developer are Copyright (C) 2001
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Scott Collins <scc@mozilla.org> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsStringIterator_h___
+#define nsStringIterator_h___
+
+#ifndef nsCharTraits_h___
+#include "nsCharTraits.h"
+#endif
+
+#ifndef nsAlgorithm_h___
+#include "nsAlgorithm.h"
+#endif
+
+#ifndef nsDebug_h___
+#include "nsDebug.h"
+#endif
+
+ /**
+ * @see nsTAString
+ */
+
+template <class CharT>
+class nsReadingIterator
+ {
+ public:
+ typedef nsReadingIterator<CharT> self_type;
+ typedef ptrdiff_t difference_type;
+ typedef CharT value_type;
+ typedef const CharT* pointer;
+ typedef const CharT& reference;
+
+ private:
+ friend class nsAString;
+ friend class nsACString;
+ friend class nsSubstring;
+ friend class nsCSubstring;
+
+ // unfortunately, the API for nsReadingIterator requires that the
+ // iterator know its start and end positions. this was needed when
+ // we supported multi-fragment strings, but now it is really just
+ // extra baggage. we should remove mStart and mEnd at some point.
+
+ const CharT* mStart;
+ const CharT* mEnd;
+ const CharT* mPosition;
+
+ public:
+ nsReadingIterator() { }
+ // nsReadingIterator( const nsReadingIterator<CharT>& ); // auto-generated copy-constructor OK
+ // nsReadingIterator<CharT>& operator=( const nsReadingIterator<CharT>& ); // auto-generated copy-assignment operator OK
+
+ inline void normalize_forward() {}
+ inline void normalize_backward() {}
+
+ pointer
+ start() const
+ {
+ return mStart;
+ }
+
+ pointer
+ end() const
+ {
+ return mEnd;
+ }
+
+ pointer
+ get() const
+ {
+ return mPosition;
+ }
+
+ CharT
+ operator*() const
+ {
+ return *get();
+ }
+
+#if 0
+ // An iterator really deserves this, but some compilers (notably IBM VisualAge for OS/2)
+ // don't like this when |CharT| is a type without members.
+ pointer
+ operator->() const
+ {
+ return get();
+ }
+#endif
+
+ self_type&
+ operator++()
+ {
+ ++mPosition;
+ return *this;
+ }
+
+ self_type
+ operator++( int )
+ {
+ self_type result(*this);
+ ++mPosition;
+ return result;
+ }
+
+ self_type&
+ operator--()
+ {
+ --mPosition;
+ return *this;
+ }
+
+ self_type
+ operator--( int )
+ {
+ self_type result(*this);
+ --mPosition;
+ return result;
+ }
+
+ difference_type
+ size_forward() const
+ {
+ return mEnd - mPosition;
+ }
+
+ difference_type
+ size_backward() const
+ {
+ return mPosition - mStart;
+ }
+
+ self_type&
+ advance( difference_type n )
+ {
+ if (n > 0)
+ {
+ difference_type step = NS_MIN(n, size_forward());
+
+ NS_ASSERTION(step>0, "can't advance a reading iterator beyond the end of a string");
+
+ mPosition += step;
+ }
+ else if (n < 0)
+ {
+ difference_type step = NS_MAX(n, -size_backward());
+
+ NS_ASSERTION(step<0, "can't advance (backward) a reading iterator beyond the end of a string");
+
+ mPosition += step;
+ }
+ return *this;
+ }
+ };
+
+ /**
+ * @see nsTAString
+ */
+
+template <class CharT>
+class nsWritingIterator
+ {
+ public:
+ typedef nsWritingIterator<CharT> self_type;
+ typedef ptrdiff_t difference_type;
+ typedef CharT value_type;
+ typedef CharT* pointer;
+ typedef CharT& reference;
+
+ private:
+ friend class nsAString;
+ friend class nsACString;
+ friend class nsSubstring;
+ friend class nsCSubstring;
+
+ // unfortunately, the API for nsWritingIterator requires that the
+ // iterator know its start and end positions. this was needed when
+ // we supported multi-fragment strings, but now it is really just
+ // extra baggage. we should remove mStart and mEnd at some point.
+
+ CharT* mStart;
+ CharT* mEnd;
+ CharT* mPosition;
+
+ public:
+ nsWritingIterator() { }
+ // nsWritingIterator( const nsWritingIterator<CharT>& ); // auto-generated copy-constructor OK
+ // nsWritingIterator<CharT>& operator=( const nsWritingIterator<CharT>& ); // auto-generated copy-assignment operator OK
+
+ inline void normalize_forward() {}
+ inline void normalize_backward() {}
+
+ pointer
+ start() const
+ {
+ return mStart;
+ }
+
+ pointer
+ end() const
+ {
+ return mEnd;
+ }
+
+ pointer
+ get() const
+ {
+ return mPosition;
+ }
+
+ reference
+ operator*() const
+ {
+ return *get();
+ }
+
+#if 0
+ // An iterator really deserves this, but some compilers (notably IBM VisualAge for OS/2)
+ // don't like this when |CharT| is a type without members.
+ pointer
+ operator->() const
+ {
+ return get();
+ }
+#endif
+
+ self_type&
+ operator++()
+ {
+ ++mPosition;
+ return *this;
+ }
+
+ self_type
+ operator++( int )
+ {
+ self_type result(*this);
+ ++mPosition;
+ return result;
+ }
+
+ self_type&
+ operator--()
+ {
+ --mPosition;
+ return *this;
+ }
+
+ self_type
+ operator--( int )
+ {
+ self_type result(*this);
+ --mPosition;
+ return result;
+ }
+
+ difference_type
+ size_forward() const
+ {
+ return mEnd - mPosition;
+ }
+
+ difference_type
+ size_backward() const
+ {
+ return mPosition - mStart;
+ }
+
+ self_type&
+ advance( difference_type n )
+ {
+ if (n > 0)
+ {
+ difference_type step = NS_MIN(n, size_forward());
+
+ NS_ASSERTION(step>0, "can't advance a writing iterator beyond the end of a string");
+
+ mPosition += step;
+ }
+ else if (n < 0)
+ {
+ difference_type step = NS_MAX(n, -size_backward());
+
+ NS_ASSERTION(step<0, "can't advance (backward) a writing iterator beyond the end of a string");
+
+ mPosition += step;
+ }
+ return *this;
+ }
+
+ PRUint32
+ write( const value_type* s, PRUint32 n )
+ {
+ NS_ASSERTION(size_forward() > 0, "You can't |write| into an |nsWritingIterator| with no space!");
+
+ nsCharTraits<value_type>::move(mPosition, s, n);
+ advance( difference_type(n) );
+ return n;
+ }
+ };
+
+template <class CharT>
+inline
+PRBool
+operator==( const nsReadingIterator<CharT>& lhs, const nsReadingIterator<CharT>& rhs )
+ {
+ return lhs.get() == rhs.get();
+ }
+
+template <class CharT>
+inline
+PRBool
+operator!=( const nsReadingIterator<CharT>& lhs, const nsReadingIterator<CharT>& rhs )
+ {
+ return lhs.get() != rhs.get();
+ }
+
+
+ //
+ // |nsWritingIterator|s
+ //
+
+template <class CharT>
+inline
+PRBool
+operator==( const nsWritingIterator<CharT>& lhs, const nsWritingIterator<CharT>& rhs )
+ {
+ return lhs.get() == rhs.get();
+ }
+
+template <class CharT>
+inline
+PRBool
+operator!=( const nsWritingIterator<CharT>& lhs, const nsWritingIterator<CharT>& rhs )
+ {
+ return lhs.get() != rhs.get();
+ }
+
+#endif /* !defined(nsStringIterator_h___) */
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsSubstring.h b/src/libs/xpcom18a4/xpcom/string/public/nsSubstring.h
new file mode 100644
index 00000000..35a1a568
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsSubstring.h
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsSubstring_h___
+#define nsSubstring_h___
+
+#ifndef nsAString_h___
+#include "nsAString.h"
+#endif
+
+#define kNotFound -1
+
+// If some platform(s) can't handle our template that matches literal strings,
+// then we'll disable it on those platforms.
+#ifndef NS_DISABLE_LITERAL_TEMPLATE
+# if (defined(_MSC_VER) && (_MSC_VER < 1310)) || (defined(__SUNPRO_CC) & (__SUNPRO_CC < 0x560)) || (defined(__HP_aCC) && (__HP_aCC <= 012100))
+# define NS_DISABLE_LITERAL_TEMPLATE
+# endif
+#endif /* !NS_DISABLE_LITERAL_TEMPLATE */
+
+#include <string.h>
+
+ // declare nsSubstring
+#include "string-template-def-unichar.h"
+#include "nsTSubstring.h"
+#include "string-template-undef.h"
+
+
+ // declare nsCSubstring
+#include "string-template-def-char.h"
+#include "nsTSubstring.h"
+#include "string-template-undef.h"
+
+
+#ifndef nsSubstringTuple_h___
+#include "nsSubstringTuple.h"
+#endif
+
+#endif // !defined(nsSubstring_h___)
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsSubstringTuple.h b/src/libs/xpcom18a4/xpcom/string/public/nsSubstringTuple.h
new file mode 100644
index 00000000..8cf6f803
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsSubstringTuple.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsSubstringTuple_h___
+#define nsSubstringTuple_h___
+
+#ifndef nsSubstring_h___
+#include "nsSubstring.h"
+#endif
+
+ // declare nsSubstringTuple
+#include "string-template-def-unichar.h"
+#include "nsTSubstringTuple.h"
+#include "string-template-undef.h"
+
+ // declare nsCSubstringTuple
+#include "string-template-def-char.h"
+#include "nsTSubstringTuple.h"
+#include "string-template-undef.h"
+
+#endif // !defined(nsSubstringTuple_h___)
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsTAString.h b/src/libs/xpcom18a4/xpcom/string/public/nsTAString.h
new file mode 100644
index 00000000..93b88443
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsTAString.h
@@ -0,0 +1,618 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Scott Collins <scc@mozilla.org> (original author)
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+ /**
+ * The base for string comparators
+ */
+class NS_COM nsTStringComparator_CharT
+ {
+ public:
+ typedef CharT char_type;
+
+ nsTStringComparator_CharT() {}
+
+ virtual int operator()( const char_type*, const char_type*, PRUint32 length ) const = 0;
+ virtual int operator()( char_type, char_type ) const = 0;
+ };
+
+
+ /**
+ * The default string comparator (case-sensitive comparision)
+ */
+class NS_COM nsTDefaultStringComparator_CharT
+ : public nsTStringComparator_CharT
+ {
+ public:
+ typedef CharT char_type;
+
+ nsTDefaultStringComparator_CharT() {}
+
+ virtual int operator()( const char_type*, const char_type*, PRUint32 length ) const;
+ virtual int operator()( char_type, char_type ) const;
+ };
+
+
+ /**
+ * nsTAString is the most abstract class in the string hierarchy.
+ *
+ * In its original inception, nsTAString was designed to allow the data
+ * storage for a string to be separated into multiple fragments. This was
+ * intended to enable lazy string flattening or avoid string flattening
+ * altogether in some cases. This abstraction, however, meant that every
+ * single string operation (including simple operations such as IsEmpty() and
+ * BeginReading()) required virtual function calls. A virtual destructor was
+ * also required. This not only meant additional overhead for invoking
+ * string methods but also added to additional codesize at every callsite (to
+ * load the virtual function address).
+ *
+ * Today nsTAString exists mainly for backwards compatibility of the string
+ * API. It is restricted to representing a contiguous array of characters,
+ * where the character array is not necessarily null-terminated. Moreover,
+ * since nsTAString's virtual function table was frozen for Mozilla 1.0,
+ * nsTAString necessarily maintains ABI compatibility with older versions of
+ * Gecko. (nsTObsoleteAString provides that frozen ABI. See
+ * nsObsoleteAString.h for a description of how we solve the ABI
+ * compatibility requirement while eliminating virtual function calls on
+ * nsTAString.)
+ *
+ * XPIDL still generates C++ header files with references to nsTAStrings, so
+ * nsTAString will still be heavily used in real code.
+ *
+ * If the opportunity to break ABI compatibility with Mozilla 1.0 were to
+ * ever arise, our first move should be to make nsTAString equate to
+ * nsTSubstring. This may in fact be an option today for some Gecko-based
+ * products.
+ */
+class nsTAString_CharT
+ {
+ public:
+
+ typedef CharT char_type;
+ typedef nsCharTraits<char_type> char_traits;
+
+ typedef char_traits::incompatible_char_type incompatible_char_type;
+
+ typedef nsTAString_CharT self_type;
+ typedef nsTAString_CharT abstract_string_type;
+ typedef nsTObsoleteAString_CharT obsolete_string_type;
+ typedef nsTSubstring_CharT substring_type;
+ typedef nsTSubstringTuple_CharT substring_tuple_type;
+
+ typedef nsReadingIterator<char_type> const_iterator;
+ typedef nsWritingIterator<char_type> iterator;
+
+ typedef nsTStringComparator_CharT comparator_type;
+
+ typedef PRUint32 size_type;
+ typedef PRUint32 index_type;
+
+ public:
+
+ // this acts like a virtual destructor
+ NS_COM NS_FASTCALL ~nsTAString_CharT();
+
+
+ /**
+ * BeginReading/EndReading can be used to get immutable access to the
+ * string's underlying buffer. EndReading returns a pointer to the
+ * end of the string's buffer. nsReadableUtils.h provides a collection
+ * of utility functions that work with these iterators.
+ */
+
+ inline const_iterator& BeginReading( const_iterator& iter ) const
+ {
+ size_type len = GetReadableBuffer(&iter.mStart);
+ iter.mEnd = iter.mStart + len;
+ iter.mPosition = iter.mStart;
+ return iter;
+ }
+
+ inline const_iterator& EndReading( const_iterator& iter ) const
+ {
+ size_type len = GetReadableBuffer(&iter.mStart);
+ iter.mEnd = iter.mStart + len;
+ iter.mPosition = iter.mEnd;
+ return iter;
+ }
+
+
+ /**
+ * BeginWriting/EndWriting can be used to get mutable access to the
+ * string's underlying buffer. EndWriting returns a pointer to the
+ * end of the string's buffer. This iterator API cannot be used to
+ * grow a buffer. Use SetLength to resize the string's buffer.
+ */
+
+ inline iterator& BeginWriting( iterator& iter )
+ {
+ size_type len = GetWritableBuffer(&iter.mStart);
+ iter.mEnd = iter.mStart + len;
+ iter.mPosition = iter.mStart;
+ return iter;
+ }
+
+ inline iterator& EndWriting( iterator& iter )
+ {
+ size_type len = GetWritableBuffer(&iter.mStart);
+ iter.mEnd = iter.mStart + len;
+ iter.mPosition = iter.mEnd;
+ return iter;
+ }
+
+
+ /**
+ * Length checking functions. IsEmpty is a helper function to avoid
+ * writing code like: |if (str.Length() == 0)|
+ */
+
+ NS_COM size_type NS_FASTCALL Length() const;
+ PRBool IsEmpty() const { return Length() == 0; }
+
+
+ /**
+ * String equality tests. Pass a string comparator if you want to
+ * control how the strings are compared. By default, a binary
+ * "case-sensitive" comparision is performed.
+ */
+
+ NS_COM PRBool NS_FASTCALL Equals( const self_type& ) const;
+ NS_COM PRBool NS_FASTCALL Equals( const self_type&, const comparator_type& ) const;
+ NS_COM PRBool NS_FASTCALL Equals( const char_type* ) const;
+ NS_COM PRBool NS_FASTCALL Equals( const char_type*, const comparator_type& ) const;
+
+ /**
+ * An efficient comparison with ASCII that can be used even
+ * for wide strings. Call this version when you know the
+ * length of 'data'.
+ */
+ NS_COM PRBool NS_FASTCALL EqualsASCII( const char* data, size_type len ) const;
+ /**
+ * An efficient comparison with ASCII that can be used even
+ * for wide strings. Call this version when 'data' is
+ * null-terminated.
+ */
+ NS_COM PRBool NS_FASTCALL EqualsASCII( const char* data ) const;
+
+ // EqualsLiteral must ONLY be applied to an actual literal string.
+ // Do not attempt to use it with a regular char* pointer, or with a char
+ // array variable.
+ // The template trick to acquire the array length at compile time without
+ // using a macro is due to Corey Kosak, with much thanks.
+#ifdef NS_DISABLE_LITERAL_TEMPLATE
+ inline PRBool EqualsLiteral( const char* str ) const
+ {
+ return EqualsASCII(str);
+ }
+#else
+ template<int N>
+ inline PRBool EqualsLiteral( const char (&str)[N] ) const
+ {
+ return EqualsASCII(str, N-1);
+ }
+ template<int N>
+ inline PRBool EqualsLiteral( char (&str)[N] ) const
+ {
+ const char* s = str;
+ return EqualsASCII(s, N-1);
+ }
+#endif
+
+ // The LowerCaseEquals methods compare the lower case version of
+ // this string to some ASCII/Literal string. The ASCII string is
+ // *not* lowercased for you. If you compare to an ASCII or literal
+ // string that contains an uppercase character, it is guaranteed to
+ // return false. We will throw assertions too.
+ NS_COM PRBool NS_FASTCALL LowerCaseEqualsASCII( const char* data, size_type len ) const;
+ NS_COM PRBool NS_FASTCALL LowerCaseEqualsASCII( const char* data ) const;
+
+ // LowerCaseEqualsLiteral must ONLY be applied to an actual
+ // literal string. Do not attempt to use it with a regular char*
+ // pointer, or with a char array variable. Use
+ // LowerCaseEqualsASCII for them.
+#ifdef NS_DISABLE_LITERAL_TEMPLATE
+ inline PRBool LowerCaseEqualsLiteral( const char* str ) const
+ {
+ return LowerCaseEqualsASCII(str);
+ }
+#else
+ template<int N>
+ inline PRBool LowerCaseEqualsLiteral( const char (&str)[N] ) const
+ {
+ return LowerCaseEqualsASCII(str, N-1);
+ }
+ template<int N>
+ inline PRBool LowerCaseEqualsLiteral( char (&str)[N] ) const
+ {
+ const char* s = str;
+ return LowerCaseEqualsASCII(s, N-1);
+ }
+#endif
+
+ /**
+ * A string always references a non-null data pointer. In some
+ * applications (e.g., the DOM) it is necessary for a string class
+ * to have some way to distinguish an empty string from a null (or
+ * void) string. These methods enable support for the concept of
+ * a void string.
+ */
+
+ NS_COM PRBool NS_FASTCALL IsVoid() const;
+ NS_COM void NS_FASTCALL SetIsVoid( PRBool );
+
+
+ /**
+ * This method returns true if the string's underlying buffer is
+ * null-terminated. This should rarely be needed by applications.
+ * The PromiseFlatTString method should be used to ensure that a
+ * string's underlying buffer is null-terminated.
+ */
+
+ NS_COM PRBool NS_FASTCALL IsTerminated() const;
+
+
+ /**
+ * These are contant time since nsTAString uses flat storage
+ */
+ NS_COM char_type NS_FASTCALL First() const;
+ NS_COM char_type NS_FASTCALL Last() const;
+
+
+ /**
+ * Returns the number of occurances of the given character.
+ */
+ NS_COM size_type NS_FASTCALL CountChar( char_type ) const;
+
+
+ /**
+ * Locates the offset of the first occurance of the character. Pass a
+ * non-zero offset to control where the search begins.
+ */
+
+ NS_COM PRInt32 NS_FASTCALL FindChar( char_type, index_type offset = 0 ) const;
+
+
+ /**
+ * SetCapacity is not required to do anything; however, it can be used
+ * as a hint to the implementation to reduce allocations.
+ *
+ * SetCapacity(0) is a suggestion to discard all associated storage.
+ */
+ NS_COM void NS_FASTCALL SetCapacity( size_type );
+
+
+ /**
+ * XXX talk to dbaron about this comment. we do need a method that
+ * XXX allows someone to resize a string's buffer so that it can be
+ * XXX populated using writing iterators. SetLength seems to be the
+ * XXX right method for the job, and we do use it in this capacity
+ * XXX in certain places.
+ *
+ * SetLength is used in two ways:
+ * 1) to |Cut| a suffix of the string;
+ * 2) to prepare to |Append| or move characters around.
+ *
+ * External callers are not allowed to use |SetLength| in this
+ * latter capacity, and should prefer |Truncate| for the former.
+ * In other words, |SetLength| is deprecated for all use outside
+ * of the string library and the internal use may at some point
+ * be replaced as well.
+ *
+ * This distinction makes me think the two different uses should
+ * be split into two distinct functions.
+ */
+ NS_COM void NS_FASTCALL SetLength( size_type );
+
+
+ /**
+ * Can't use |Truncate| to make a string longer!
+ */
+ void Truncate( size_type aNewLength=0 )
+ {
+ NS_ASSERTION(aNewLength <= Length(), "Truncate cannot make string longer");
+ SetLength(aNewLength);
+ }
+
+
+ /**
+ * |Assign| and |operator=| make |this| equivalent to the string or
+ * buffer given as an argument. If possible, they do this by sharing
+ * a reference counted buffer (see |nsTSubstring|). If not, they copy
+ * the buffer into their own buffer.
+ */
+
+ NS_COM void NS_FASTCALL Assign( const self_type& readable );
+ NS_COM void NS_FASTCALL Assign( const substring_tuple_type& tuple );
+ NS_COM void NS_FASTCALL Assign( const char_type* data );
+ NS_COM void NS_FASTCALL Assign( const char_type* data, size_type length );
+ NS_COM void NS_FASTCALL Assign( char_type c );
+
+ NS_COM void NS_FASTCALL AssignASCII( const char* data, size_type length );
+ NS_COM void NS_FASTCALL AssignASCII( const char* data );
+
+ // AssignLiteral must ONLY be applied to an actual literal string.
+ // Do not attempt to use it with a regular char* pointer, or with a char
+ // array variable. Use AssignASCII for those.
+#ifdef NS_DISABLE_LITERAL_TEMPLATE
+ void AssignLiteral( const char* str )
+ { AssignASCII(str); }
+#else
+ template<int N>
+ void AssignLiteral( const char (&str)[N] )
+ { AssignASCII(str, N-1); }
+ template<int N>
+ void AssignLiteral( char (&str)[N] )
+ { AssignASCII(str, N-1); }
+#endif
+
+ // copy-assignment operator. I must define my own if I don't want the compiler to make me one
+ self_type& operator=( const self_type& readable ) { Assign(readable); return *this; }
+ self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
+ self_type& operator=( const char_type* data ) { Assign(data); return *this; }
+ self_type& operator=( char_type c ) { Assign(c); return *this; }
+
+
+
+ /**
+ * |Append|, |operator+=| are used to add characters to the end of this string.
+ */
+
+ NS_COM void NS_FASTCALL Append( const self_type& readable );
+ NS_COM void NS_FASTCALL Append( const substring_tuple_type& tuple );
+ NS_COM void NS_FASTCALL Append( const char_type* data );
+ NS_COM void NS_FASTCALL Append( const char_type* data, size_type length );
+ NS_COM void NS_FASTCALL Append( char_type c );
+
+ NS_COM void NS_FASTCALL AppendASCII( const char* data, size_type length );
+ NS_COM void NS_FASTCALL AppendASCII( const char* data );
+
+ // AppendLiteral must ONLY be applied to an actual literal string.
+ // Do not attempt to use it with a regular char* pointer, or with a char
+ // array variable. Use AppendASCII for those.
+#ifdef NS_DISABLE_LITERAL_TEMPLATE
+ void AppendLiteral( const char* str )
+ { AppendASCII(str); }
+#else
+ template<int N>
+ void AppendLiteral( const char (&str)[N] )
+ { AppendASCII(str, N-1); }
+ template<int N>
+ void AppendLiteral( char (&str)[N] )
+ { AppendASCII(str, N-1); }
+#endif
+
+ self_type& operator+=( const self_type& readable ) { Append(readable); return *this; }
+ self_type& operator+=( const substring_tuple_type& tuple ) { Append(tuple); return *this; }
+ self_type& operator+=( const char_type* data ) { Append(data); return *this; }
+ self_type& operator+=( char_type c ) { Append(c); return *this; }
+
+
+ /**
+ * |Insert| is used to add characters into this string at a given position.
+ * NOTE: It's a shame the |pos| parameter isn't at the front of the arg list.
+ */
+
+ NS_COM void NS_FASTCALL Insert( const self_type& readable, index_type pos );
+ NS_COM void NS_FASTCALL Insert( const substring_tuple_type& tuple, index_type pos );
+ NS_COM void NS_FASTCALL Insert( const char_type* data, index_type pos );
+ NS_COM void NS_FASTCALL Insert( const char_type* data, index_type pos, size_type length );
+ NS_COM void NS_FASTCALL Insert( char_type c, index_type pos );
+
+
+ /**
+ * |Cut| is used to remove a range of characters from this string.
+ */
+
+ NS_COM void NS_FASTCALL Cut( index_type cutStart, size_type cutLength );
+
+
+ /**
+ * |Replace| is used overwrite a range of characters from this string.
+ */
+
+ NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const self_type& readable );
+ NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const substring_tuple_type& readable );
+
+
+ /**
+ * this is public to support automatic conversion of tuple to abstract
+ * string, which is necessary to support our API.
+ */
+ nsTAString_CharT(const substring_tuple_type& tuple)
+ : mVTable(obsolete_string_type::sCanonicalVTable)
+ , mData(nsnull)
+ , mLength(0)
+ , mFlags(0)
+ {
+ Assign(tuple);
+ }
+
+ protected:
+
+ friend class nsTSubstringTuple_CharT;
+
+ // GCC 3.2 erroneously needs these (even though they are subclasses!)
+ friend class nsTSubstring_CharT;
+ friend class nsTDependentSubstring_CharT;
+ friend class nsTPromiseFlatString_CharT;
+
+ /**
+ * the address of our virtual function table. required for backwards
+ * compatibility with Mozilla 1.0 frozen nsAC?String interface.
+ */
+ const void* mVTable;
+
+ /**
+ * these fields are "here" only when mVTable == sCanonicalVTable.
+ *
+ * they exist to support automatic construction of a nsTAString
+ * from a nsTSubstringTuple.
+ */
+ char_type* mData;
+ size_type mLength;
+ PRUint32 mFlags;
+
+ /**
+ * nsTAString must be subclassed before it can be instantiated.
+ */
+ nsTAString_CharT(char_type* data, size_type length, PRUint32 flags)
+ : mVTable(obsolete_string_type::sCanonicalVTable)
+ , mData(data)
+ , mLength(length)
+ , mFlags(flags)
+ {}
+
+ /**
+ * optional ctor for use by subclasses.
+ *
+ * NOTE: mData and mLength are intentionally left uninitialized.
+ */
+ explicit
+ nsTAString_CharT(PRUint32 flags)
+ : mVTable(obsolete_string_type::sCanonicalVTable)
+ , mFlags(flags)
+ {}
+
+ /**
+ * get pointer to internal string buffer (may not be null terminated).
+ * return length of buffer.
+ */
+ NS_COM size_type NS_FASTCALL GetReadableBuffer( const char_type **data ) const;
+ NS_COM size_type NS_FASTCALL GetWritableBuffer( char_type **data );
+
+ /**
+ * returns true if this tuple is dependent on (i.e., overlapping with)
+ * the given char sequence.
+ */
+ PRBool NS_FASTCALL IsDependentOn(const char_type *start, const char_type *end) const;
+
+ /**
+ * we can be converted to a const nsTSubstring (dependent on this)
+ */
+ const substring_type NS_FASTCALL ToSubstring() const;
+
+ /**
+ * type cast helpers
+ */
+
+ const obsolete_string_type* AsObsoleteString() const
+ {
+ return NS_REINTERPRET_CAST(const obsolete_string_type*, this);
+ }
+
+ obsolete_string_type* AsObsoleteString()
+ {
+ return NS_REINTERPRET_CAST(obsolete_string_type*, this);
+ }
+
+ const substring_type* AsSubstring() const
+ {
+ return NS_REINTERPRET_CAST(const substring_type*, this);
+ }
+
+ substring_type* AsSubstring()
+ {
+ return NS_REINTERPRET_CAST(substring_type*, this);
+ }
+
+ private:
+
+ // GCC 2.95.3, EGCS-2.91.66, Sun Workshop/Forte, and IBM VisualAge C++
+ // require a public copy-constructor in order to support automatic
+ // construction of a nsTAString from a nsTSubstringTuple. I believe
+ // enabling the default copy-constructor is harmless, but I do not want
+ // it to be enabled by default because that might tempt people into
+ // using it (where it would be invalid).
+#if !defined(__SUNPRO_CC) && \
+ !(defined(_AIX) && defined(__IBMCPP__)) && \
+ (!defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ > 95)
+
+ // NOT TO BE IMPLEMENTED
+ nsTAString_CharT( const self_type& );
+
+#endif
+
+ // NOT TO BE IMPLEMENTED
+ void operator= ( incompatible_char_type );
+ void Assign ( incompatible_char_type );
+ void operator+= ( incompatible_char_type );
+ void Append ( incompatible_char_type );
+ void Insert ( incompatible_char_type, index_type );
+ };
+
+
+NS_COM
+int NS_FASTCALL Compare( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs, const nsTStringComparator_CharT& = nsTDefaultStringComparator_CharT() );
+
+
+inline
+PRBool operator!=( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs )
+ {
+ return !lhs.Equals(rhs);
+ }
+
+inline
+PRBool operator< ( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs )
+ {
+ return Compare(lhs, rhs)< 0;
+ }
+
+inline
+PRBool operator<=( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs )
+ {
+ return Compare(lhs, rhs)<=0;
+ }
+
+inline
+PRBool operator==( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs )
+ {
+ return lhs.Equals(rhs);
+ }
+
+inline
+PRBool operator>=( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs )
+ {
+ return Compare(lhs, rhs)>=0;
+ }
+
+inline
+PRBool operator> ( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs )
+ {
+ return Compare(lhs, rhs)> 0;
+ }
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsTDependentString.h b/src/libs/xpcom18a4/xpcom/string/public/nsTDependentString.h
new file mode 100644
index 00000000..91a2b53e
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsTDependentString.h
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Scott Collins <scc@mozilla.org> (original author)
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+ /**
+ * nsTDependentString_CharT
+ *
+ * Stores a null-terminated, immutable sequence of characters.
+ *
+ * Subclass of nsTString that restricts string value to an immutable
+ * character sequence. This class does not own its data, so the creator
+ * of objects of this type must take care to ensure that a
+ * nsTDependentString continues to reference valid memory for the
+ * duration of its use.
+ */
+class nsTDependentString_CharT : public nsTString_CharT
+ {
+ public:
+
+ typedef nsTDependentString_CharT self_type;
+
+ public:
+
+ /**
+ * verify restrictions
+ */
+ void AssertValid()
+ {
+ NS_ASSERTION(mData, "nsTDependentString must wrap a non-NULL buffer");
+ NS_ASSERTION(mLength != size_type(-1), "nsTDependentString has bogus length");
+ NS_ASSERTION(mData[mLength] == 0, "nsTDependentString must wrap only null-terminated strings");
+ }
+
+
+ /**
+ * constructors
+ */
+
+ nsTDependentString_CharT( const char_type* start, const char_type* end )
+ : string_type(NS_CONST_CAST(char_type*, start), end - start, F_TERMINATED)
+ {
+ AssertValid();
+ }
+
+ nsTDependentString_CharT( const char_type* data, PRUint32 length )
+ : string_type(NS_CONST_CAST(char_type*, data), length, F_TERMINATED)
+ {
+ AssertValid();
+ }
+
+ explicit
+ nsTDependentString_CharT( const char_type* data )
+ : string_type(NS_CONST_CAST(char_type*, data), char_traits::length(data), F_TERMINATED)
+ {
+ AssertValid();
+ }
+
+ explicit
+ nsTDependentString_CharT( const substring_type& str )
+ : string_type(NS_CONST_CAST(char_type*, str.Data()), str.Length(), F_TERMINATED)
+ {
+ AssertValid();
+ }
+
+ // XXX are you sure??
+ // auto-generated copy-constructor OK
+ // auto-generated copy-assignment operator OK
+ // auto-generated destructor OK
+
+
+ /**
+ * allow this class to be bound to a different string...
+ */
+
+ void Rebind( const char_type* data )
+ {
+ mData = NS_CONST_CAST(char_type*, data);
+ mLength = char_traits::length(data);
+ SetDataFlags(F_TERMINATED);
+ AssertValid();
+ }
+
+ void Rebind( const char_type* data, size_type length )
+ {
+ mData = NS_CONST_CAST(char_type*, data);
+ mLength = length;
+ SetDataFlags(F_TERMINATED);
+ AssertValid();
+ }
+
+ void Rebind( const char_type* start, const char_type* end )
+ {
+ Rebind(start, end - start);
+ }
+
+ private:
+
+ // NOT USED
+ nsTDependentString_CharT( const substring_tuple_type& );
+ nsTDependentString_CharT( const abstract_string_type& );
+ };
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsTDependentSubstring.h b/src/libs/xpcom18a4/xpcom/string/public/nsTDependentSubstring.h
new file mode 100644
index 00000000..89d96e13
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsTDependentSubstring.h
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Scott Collins <scc@mozilla.org> (original author)
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+ /**
+ * nsTDependentSubstring_CharT
+ */
+class nsTDependentSubstring_CharT : public nsTSubstring_CharT
+ {
+ public:
+
+ typedef nsTDependentSubstring_CharT self_type;
+
+ public:
+
+ NS_COM void Rebind( const abstract_string_type&, PRUint32 startPos, PRUint32 length = size_type(-1) );
+ NS_COM void Rebind( const substring_type&, PRUint32 startPos, PRUint32 length = size_type(-1) );
+
+ void Rebind( const char_type* start, const char_type* end )
+ {
+ NS_ASSERTION(start && end, "nsTDependentSubstring must wrap a non-NULL buffer");
+ mData = NS_CONST_CAST(char_type*, start);
+ mLength = end - start;
+ SetDataFlags(F_NONE);
+ }
+
+ nsTDependentSubstring_CharT( const abstract_string_type& str, PRUint32 startPos, PRUint32 length = size_type(-1) )
+ : substring_type(F_NONE)
+ {
+ Rebind(str, startPos, length);
+ }
+
+ nsTDependentSubstring_CharT( const substring_type& str, PRUint32 startPos, PRUint32 length = size_type(-1) )
+ : substring_type(F_NONE)
+ {
+ Rebind(str, startPos, length);
+ }
+
+ nsTDependentSubstring_CharT( const char_type* start, const char_type* end )
+ : substring_type(NS_CONST_CAST(char_type*, start), end - start, F_NONE) {}
+
+ nsTDependentSubstring_CharT( const const_iterator& start, const const_iterator& end )
+ : substring_type(NS_CONST_CAST(char_type*, start.get()), end.get() - start.get(), F_NONE) {}
+
+ // auto-generated copy-constructor OK (XXX really?? what about base class copy-ctor?)
+
+ private:
+ // NOT USED
+ void operator=( const self_type& ); // we're immutable, you can't assign into a substring
+ };
+
+inline
+const nsTDependentSubstring_CharT
+Substring( const nsTAString_CharT& str, PRUint32 startPos, PRUint32 length = PRUint32(-1) )
+ {
+ return nsTDependentSubstring_CharT(str, startPos, length);
+ }
+
+inline
+const nsTDependentSubstring_CharT
+Substring( const nsTSubstring_CharT& str, PRUint32 startPos, PRUint32 length = PRUint32(-1) )
+ {
+ return nsTDependentSubstring_CharT(str, startPos, length);
+ }
+
+inline
+const nsTDependentSubstring_CharT
+Substring( const nsReadingIterator<CharT>& start, const nsReadingIterator<CharT>& end )
+ {
+ return nsTDependentSubstring_CharT(start.get(), end.get());
+ }
+
+inline
+const nsTDependentSubstring_CharT
+Substring( const CharT* start, const CharT* end )
+ {
+ return nsTDependentSubstring_CharT(start, end);
+ }
+
+inline
+const nsTDependentSubstring_CharT
+StringHead( const nsTAString_CharT& str, PRUint32 count )
+ {
+ return nsTDependentSubstring_CharT(str, 0, count);
+ }
+
+inline
+const nsTDependentSubstring_CharT
+StringHead( const nsTSubstring_CharT& str, PRUint32 count )
+ {
+ return nsTDependentSubstring_CharT(str, 0, count);
+ }
+
+inline
+const nsTDependentSubstring_CharT
+StringTail( const nsTAString_CharT& str, PRUint32 count )
+ {
+ return nsTDependentSubstring_CharT(str, str.Length() - count, count);
+ }
+
+inline
+const nsTDependentSubstring_CharT
+StringTail( const nsTSubstring_CharT& str, PRUint32 count )
+ {
+ return nsTDependentSubstring_CharT(str, str.Length() - count, count);
+ }
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsTObsoleteAString.h b/src/libs/xpcom18a4/xpcom/string/public/nsTObsoleteAString.h
new file mode 100644
index 00000000..82d5f56c
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsTObsoleteAString.h
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+ /**
+ * nsTObsoleteAString_CharT : binary compatible with old nsAC?String vtable
+ *
+ * @status FROZEN
+ */
+class nsTObsoleteAString_CharT
+ {
+ public:
+ /**
+ * This is holds the address of the vtable for the canonical string
+ * implementation (i.e., nsTString).
+ */
+ NS_COM static const void *sCanonicalVTable;
+
+ /**
+ * An |nsFragmentRequest| is used to tell |GetReadableFragment| and
+ * |GetWritableFragment| what to do.
+ *
+ * @see GetReadableFragment
+ */
+ enum nsFragmentRequest { kPrevFragment, kFirstFragment, kLastFragment, kNextFragment, kFragmentAt };
+
+ /**
+ * A |nsReadableFragment| provides |const| access to a contiguous hunk of
+ * string of homogenous units, e.g., bytes (|char|). This doesn't mean it
+ * represents a flat hunk. It could be a variable length encoding, for
+ * instance UTF-8. And the fragment itself need not be zero-terminated.
+ *
+ * An |nsReadableFragment| is the underlying machinery that lets
+ * |nsReadingIterator|s work.
+ *
+ * @see nsReadingIterator
+ * @status FROZEN
+ */
+ struct nsReadableFragment
+ {
+ const CharT* mStart;
+ const CharT* mEnd;
+ const void* mFragmentIdentifier;
+
+ nsReadableFragment() : mStart(0), mEnd(0), mFragmentIdentifier(0) {}
+ };
+
+
+ /**
+ * A |nsWritableFragment| provides non-|const| access to a contiguous hunk of
+ * string of homogenous units, e.g., bytes (|char|). This doesn't mean it
+ * represents a flat hunk. It could be a variable length encoding, for
+ * instance UTF-8. And the fragment itself need not be zero-terminated.
+ *
+ * An |nsWritableFragment| is the underlying machinery that lets
+ * |nsWritingIterator|s work.
+ *
+ * @see nsWritingIterator
+ * @status FROZEN
+ */
+ struct nsWritableFragment
+ {
+ CharT* mStart;
+ CharT* mEnd;
+ void* mFragmentIdentifier;
+
+ nsWritableFragment() : mStart(0), mEnd(0), mFragmentIdentifier(0) {}
+ };
+
+ protected:
+
+ typedef CharT char_type;
+
+ typedef void buffer_handle_type;
+ typedef void shared_buffer_handle_type;
+ typedef nsReadableFragment const_fragment_type;
+ typedef nsWritableFragment fragment_type;
+
+ typedef nsTAString_CharT abstract_string_type;
+
+ typedef PRUint32 size_type;
+ typedef PRUint32 index_type;
+
+ protected:
+
+ friend class nsTAString_CharT;
+ friend class nsTSubstring_CharT;
+
+ /** here's the old nsAC?String vtable **/
+
+ virtual ~nsTObsoleteAString_CharT() { }
+
+ virtual PRUint32 GetImplementationFlags() const = 0;
+ virtual const buffer_handle_type* GetFlatBufferHandle() const = 0;
+ virtual const buffer_handle_type* GetBufferHandle() const = 0;
+ virtual const shared_buffer_handle_type* GetSharedBufferHandle() const = 0;
+
+ virtual size_type Length() const = 0;
+
+ virtual PRBool IsVoid() const = 0;
+ virtual void SetIsVoid( PRBool ) = 0;
+
+ virtual void SetCapacity( size_type ) = 0;
+ virtual void SetLength( size_type ) = 0;
+
+ virtual void Cut( index_type cutStart, size_type cutLength ) = 0;
+
+ virtual void do_AssignFromReadable( const abstract_string_type& ) = 0;
+ virtual void do_AssignFromElementPtr( const char_type* ) = 0;
+ virtual void do_AssignFromElementPtrLength( const char_type*, size_type ) = 0;
+ virtual void do_AssignFromElement( char_type ) = 0;
+
+ virtual void do_AppendFromReadable( const abstract_string_type& ) = 0;
+ virtual void do_AppendFromElementPtr( const char_type* ) = 0;
+ virtual void do_AppendFromElementPtrLength( const char_type*, size_type ) = 0;
+ virtual void do_AppendFromElement( char_type ) = 0;
+
+ virtual void do_InsertFromReadable( const abstract_string_type&, index_type ) = 0;
+ virtual void do_InsertFromElementPtr( const char_type*, index_type ) = 0;
+ virtual void do_InsertFromElementPtrLength( const char_type*, index_type, size_type ) = 0;
+ virtual void do_InsertFromElement( char_type, index_type ) = 0;
+
+ virtual void do_ReplaceFromReadable( index_type, size_type, const abstract_string_type& ) = 0;
+
+ virtual const char_type* GetReadableFragment( const_fragment_type&, nsFragmentRequest, PRUint32 = 0 ) const = 0;
+ virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 = 0 ) = 0;
+ };
+
+ // forward declare implementation
+class nsTObsoleteAStringThunk_CharT;
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsTPromiseFlatString.h b/src/libs/xpcom18a4/xpcom/string/public/nsTPromiseFlatString.h
new file mode 100644
index 00000000..6cf82f60
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsTPromiseFlatString.h
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Scott Collins <scc@mozilla.org> (original author)
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+ /**
+ * NOTE:
+ *
+ * Try to avoid flat strings. |PromiseFlat[C]String| will help you as a last
+ * resort, and this may be necessary when dealing with legacy or OS calls,
+ * but in general, requiring a null-terminated array of characters kills many
+ * of the performance wins the string classes offer. Write your own code to
+ * use |nsA[C]String&|s for parameters. Write your string proccessing
+ * algorithms to exploit iterators. If you do this, you will benefit from
+ * being able to chain operations without copying or allocating and your code
+ * will be significantly more efficient. Remember, a function that takes an
+ * |const nsA[C]String&| can always be passed a raw character pointer by
+ * wrapping it (for free) in a |nsDependent[C]String|. But a function that
+ * takes a character pointer always has the potential to force allocation and
+ * copying.
+ *
+ *
+ * How to use it:
+ *
+ * A |nsPromiseFlat[C]String| doesn't necessarily own the characters it
+ * promises. You must never use it to promise characters out of a string
+ * with a shorter lifespan. The typical use will be something like this:
+ *
+ * SomeOSFunction( PromiseFlatCString(aCString).get() ); // GOOD
+ *
+ * Here's a BAD use:
+ *
+ * const char* buffer = PromiseFlatCString(aCString).get();
+ * SomeOSFunction(buffer); // BAD!! |buffer| is a dangling pointer
+ *
+ * The only way to make one is with the function |PromiseFlat[C]String|,
+ * which produce a |const| instance. ``What if I need to keep a promise
+ * around for a little while?'' you might ask. In that case, you can keep a
+ * reference, like so
+ *
+ * const nsPromiseFlatString& flat = PromiseFlatString(aString);
+ * // this reference holds the anonymous temporary alive, but remember,
+ * // it must _still_ have a lifetime shorter than that of |aString|
+ *
+ * SomeOSFunction(flat.get());
+ * SomeOtherOSFunction(flat.get());
+ *
+ *
+ * How does it work?
+ *
+ * A |nsPromiseFlat[C]String| is just a wrapper for another string. If you
+ * apply it to a string that happens to be flat, your promise is just a
+ * dependent reference to the string's data. If you apply it to a non-flat
+ * string, then a temporary flat string is created for you, by allocating and
+ * copying. In the event that you end up assigning the result into a sharing
+ * string (e.g., |nsTString|), the right thing happens.
+ */
+
+class nsTPromiseFlatString_CharT : public nsTString_CharT
+ {
+ public:
+
+ typedef nsTPromiseFlatString_CharT self_type;
+
+ private:
+
+ NS_COM void Init( const substring_type& );
+ NS_COM void Init( const abstract_string_type& );
+
+ // NOT TO BE IMPLEMENTED
+ void operator=( const self_type& );
+
+ // NOT TO BE IMPLEMENTED
+ nsTPromiseFlatString_CharT();
+
+ public:
+
+ explicit
+ nsTPromiseFlatString_CharT( const substring_type& str )
+ : string_type()
+ {
+ Init(str);
+ }
+
+ explicit
+ nsTPromiseFlatString_CharT( const abstract_string_type& readable )
+ : string_type()
+ {
+ Init(readable);
+ }
+
+ explicit
+ nsTPromiseFlatString_CharT( const substring_tuple_type& tuple )
+ : string_type()
+ {
+ // nothing else to do here except assign the value of the tuple
+ // into ourselves.
+ Assign(tuple);
+ }
+ };
+
+inline
+const nsTPromiseFlatString_CharT
+TPromiseFlatString_CharT( const nsTAString_CharT& str )
+ {
+ return nsTPromiseFlatString_CharT(str);
+ }
+
+ // e.g., PromiseFlatCString(Substring(s))
+inline
+const nsTPromiseFlatString_CharT
+TPromiseFlatString_CharT( const nsTSubstring_CharT& frag )
+ {
+ return nsTPromiseFlatString_CharT(frag);
+ }
+
+ // e.g., PromiseFlatCString(a + b)
+inline
+const nsTPromiseFlatString_CharT
+TPromiseFlatString_CharT( const nsTSubstringTuple_CharT& tuple )
+ {
+ return nsTPromiseFlatString_CharT(tuple);
+ }
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsTString.h b/src/libs/xpcom18a4/xpcom/string/public/nsTString.h
new file mode 100644
index 00000000..2ef241b2
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsTString.h
@@ -0,0 +1,721 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Rick Gessner <rickg@netscape.com> (original author)
+ * Scott Collins <scc@mozilla.org>
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+ /**
+ * This is the canonical null-terminated string class. All subclasses
+ * promise null-terminated storage. Instances of this class allocate
+ * strings on the heap.
+ *
+ * This class is also known as nsAFlat[C]String, where "flat" is used
+ * to denote a null-terminated string.
+ */
+class nsTString_CharT : public nsTSubstring_CharT
+ {
+ public:
+
+ typedef nsTString_CharT self_type;
+
+ public:
+
+ /**
+ * constructors
+ */
+
+ nsTString_CharT()
+ : substring_type() {}
+
+ explicit
+ nsTString_CharT( char_type c )
+ : substring_type()
+ {
+ Assign(c);
+ }
+
+ explicit
+ nsTString_CharT( const char_type* data, size_type length = size_type(-1) )
+ : substring_type()
+ {
+ Assign(data, length);
+ }
+
+ nsTString_CharT( const self_type& str )
+ : substring_type()
+ {
+ Assign(str);
+ }
+
+ nsTString_CharT( const substring_tuple_type& tuple )
+ : substring_type()
+ {
+ Assign(tuple);
+ }
+
+ explicit
+ nsTString_CharT( const abstract_string_type& readable )
+ : substring_type()
+ {
+ Assign(readable);
+ }
+
+
+ // |operator=| does not inherit, so we must define our own
+ self_type& operator=( char_type c ) { Assign(c); return *this; }
+ self_type& operator=( const char_type* data ) { Assign(data); return *this; }
+ self_type& operator=( const self_type& str ) { Assign(str); return *this; }
+ self_type& operator=( const substring_type& str ) { Assign(str); return *this; }
+ self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
+ self_type& operator=( const abstract_string_type& readable ) { Assign(readable); return *this; }
+
+
+ /**
+ * returns the null-terminated string
+ */
+
+ const char_type* get() const
+ {
+ return mData;
+ }
+
+
+ /**
+ * returns character at specified index.
+ *
+ * NOTE: unlike nsTSubstring::CharAt, this function allows you to index
+ * the null terminator character.
+ */
+
+ char_type CharAt( index_type i ) const
+ {
+ NS_ASSERTION(i <= mLength, "index exceeds allowable range");
+ return mData[i];
+ }
+
+ char_type operator[]( index_type i ) const
+ {
+ return CharAt(i);
+ }
+
+
+#if MOZ_STRING_WITH_OBSOLETE_API
+
+
+ /**
+ * Search for the given substring within this string.
+ *
+ * @param aString is substring to be sought in this
+ * @param aIgnoreCase selects case sensitivity
+ * @param aOffset tells us where in this string to start searching
+ * @param aCount tells us how far from the offset we are to search. Use
+ * -1 to search the whole string.
+ * @return offset in string, or kNotFound
+ */
+
+ NS_COM PRInt32 Find( const nsCString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
+ NS_COM PRInt32 Find( const char* aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
+
+#ifdef CharT_is_PRUnichar
+ NS_COM PRInt32 Find( const nsAFlatString& aString, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
+ NS_COM PRInt32 Find( const PRUnichar* aString, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
+#endif
+
+
+ /**
+ * This methods scans the string backwards, looking for the given string
+ *
+ * @param aString is substring to be sought in this
+ * @param aIgnoreCase tells us whether or not to do caseless compare
+ * @param aOffset tells us where in this string to start searching.
+ * Use -1 to search from the end of the string.
+ * @param aCount tells us how many iterations to make starting at the
+ * given offset.
+ * @return offset in string, or kNotFound
+ */
+
+ NS_COM PRInt32 RFind( const nsCString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
+ NS_COM PRInt32 RFind( const char* aCString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
+
+#ifdef CharT_is_PRUnichar
+ NS_COM PRInt32 RFind( const nsAFlatString& aString, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
+ NS_COM PRInt32 RFind( const PRUnichar* aString, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
+#endif
+
+
+ /**
+ * Search for given char within this string
+ *
+ * @param aChar is the character to search for
+ * @param aOffset tells us where in this strig to start searching
+ * @param aCount tells us how far from the offset we are to search.
+ * Use -1 to search the whole string.
+ * @return offset in string, or kNotFound
+ */
+
+ // PRInt32 FindChar( PRUnichar aChar, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
+ NS_COM PRInt32 RFindChar( PRUnichar aChar, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
+
+
+ /**
+ * This method searches this string for the first character found in
+ * the given string.
+ *
+ * @param aString contains set of chars to be found
+ * @param aOffset tells us where in this string to start searching
+ * (counting from left)
+ * @return offset in string, or kNotFound
+ */
+
+ NS_COM PRInt32 FindCharInSet( const char* aString, PRInt32 aOffset=0 ) const;
+ PRInt32 FindCharInSet( const self_type& aString, PRInt32 aOffset=0 ) const
+ {
+ return FindCharInSet(aString.get(), aOffset);
+ }
+
+#ifdef CharT_is_PRUnichar
+ NS_COM PRInt32 FindCharInSet( const PRUnichar* aString, PRInt32 aOffset=0 ) const;
+#endif
+
+
+ /**
+ * This method searches this string for the last character found in
+ * the given string.
+ *
+ * @param aString contains set of chars to be found
+ * @param aOffset tells us where in this string to start searching
+ * (counting from left)
+ * @return offset in string, or kNotFound
+ */
+
+ NS_COM PRInt32 RFindCharInSet( const char_type* aString, PRInt32 aOffset=-1 ) const;
+ PRInt32 RFindCharInSet( const self_type& aString, PRInt32 aOffset=-1 ) const
+ {
+ return RFindCharInSet(aString.get(), aOffset);
+ }
+
+
+ /**
+ * Compares a given string to this string.
+ *
+ * @param aString is the string to be compared
+ * @param aIgnoreCase tells us how to treat case
+ * @param aCount tells us how many chars to compare
+ * @return -1,0,1
+ */
+
+#ifdef CharT_is_char
+ NS_COM PRInt32 Compare( const char* aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aCount=-1 ) const;
+#endif
+
+
+ /**
+ * Equality check between given string and this string.
+ *
+ * @param aString is the string to check
+ * @param aIgnoreCase tells us how to treat case
+ * @param aCount tells us how many chars to compare
+ * @return boolean
+ */
+#ifdef CharT_is_char
+ PRBool EqualsIgnoreCase( const char* aString, PRInt32 aCount=-1 ) const {
+ return Compare(aString, PR_TRUE, aCount) == 0;
+ }
+#else
+ NS_COM PRBool EqualsIgnoreCase( const char* aString, PRInt32 aCount=-1 ) const;
+
+
+ /**
+ * Copies data from internal buffer onto given char* buffer
+ *
+ * NOTE: This only copies as many chars as will fit in given buffer (clips)
+ * @param aBuf is the buffer where data is stored
+ * @param aBuflength is the max # of chars to move to buffer
+ * @param aOffset is the offset to copy from
+ * @return ptr to given buffer
+ */
+
+ NS_COM char* ToCString( char* aBuf, PRUint32 aBufLength, PRUint32 aOffset=0 ) const;
+
+#endif // !CharT_is_PRUnichar
+
+ /**
+ * Perform string to float conversion.
+ *
+ * @param aErrorCode will contain error if one occurs
+ * @return float rep of string value
+ */
+ NS_COM float ToFloat( PRInt32* aErrorCode ) const;
+
+
+ /**
+ * Perform string to int conversion.
+ * @param aErrorCode will contain error if one occurs
+ * @param aRadix tells us which radix to assume; kAutoDetect tells us to determine the radix for you.
+ * @return int rep of string value, and possible (out) error code
+ */
+ NS_COM PRInt32 ToInteger( PRInt32* aErrorCode, PRUint32 aRadix=kRadix10 ) const;
+
+
+ /**
+ * |Left|, |Mid|, and |Right| are annoying signatures that seem better almost
+ * any _other_ way than they are now. Consider these alternatives
+ *
+ * aWritable = aReadable.Left(17); // ...a member function that returns a |Substring|
+ * aWritable = Left(aReadable, 17); // ...a global function that returns a |Substring|
+ * Left(aReadable, 17, aWritable); // ...a global function that does the assignment
+ *
+ * as opposed to the current signature
+ *
+ * aReadable.Left(aWritable, 17); // ...a member function that does the assignment
+ *
+ * or maybe just stamping them out in favor of |Substring|, they are just duplicate functionality
+ *
+ * aWritable = Substring(aReadable, 0, 17);
+ */
+
+ NS_COM size_type Mid( self_type& aResult, PRUint32 aStartPos, PRUint32 aCount ) const;
+
+ size_type Left( self_type& aResult, size_type aCount ) const
+ {
+ return Mid(aResult, 0, aCount);
+ }
+
+ size_type Right( self_type& aResult, size_type aCount ) const
+ {
+ aCount = NS_MIN(mLength, aCount);
+ return Mid(aResult, mLength - aCount, aCount);
+ }
+
+
+ /**
+ * Set a char inside this string at given index
+ *
+ * @param aChar is the char you want to write into this string
+ * @param anIndex is the ofs where you want to write the given char
+ * @return TRUE if successful
+ */
+
+ NS_COM PRBool SetCharAt( PRUnichar aChar, PRUint32 aIndex );
+
+
+ /**
+ * These methods are used to remove all occurances of the
+ * characters found in aSet from this string.
+ *
+ * @param aSet -- characters to be cut from this
+ */
+ NS_COM void StripChars( const char* aSet );
+
+
+ /**
+ * This method is used to remove all occurances of aChar from this
+ * string.
+ *
+ * @param aChar -- char to be stripped
+ * @param aOffset -- where in this string to start stripping chars
+ */
+
+ NS_COM void StripChar( char_type aChar, PRInt32 aOffset=0 );
+
+
+ /**
+ * This method strips whitespace throughout the string.
+ */
+ NS_COM void StripWhitespace();
+
+
+ /**
+ * swaps occurence of 1 string for another
+ */
+
+ NS_COM void ReplaceChar( char_type aOldChar, char_type aNewChar );
+ NS_COM void ReplaceChar( const char* aSet, char_type aNewChar );
+ NS_COM void ReplaceSubstring( const self_type& aTarget, const self_type& aNewValue);
+ NS_COM void ReplaceSubstring( const char_type* aTarget, const char_type* aNewValue);
+
+
+ /**
+ * This method trims characters found in aTrimSet from
+ * either end of the underlying string.
+ *
+ * @param aSet -- contains chars to be trimmed from both ends
+ * @param aEliminateLeading
+ * @param aEliminateTrailing
+ * @param aIgnoreQuotes -- if true, causes surrounding quotes to be ignored
+ * @return this
+ */
+ NS_COM void Trim( const char* aSet, PRBool aEliminateLeading=PR_TRUE, PRBool aEliminateTrailing=PR_TRUE, PRBool aIgnoreQuotes=PR_FALSE );
+
+ /**
+ * This method strips whitespace from string.
+ * You can control whether whitespace is yanked from start and end of
+ * string as well.
+ *
+ * @param aEliminateLeading controls stripping of leading ws
+ * @param aEliminateTrailing controls stripping of trailing ws
+ */
+ NS_COM void CompressWhitespace( PRBool aEliminateLeading=PR_TRUE, PRBool aEliminateTrailing=PR_TRUE );
+
+
+ /**
+ * assign/append/insert with _LOSSY_ conversion
+ */
+
+ NS_COM void AssignWithConversion( const nsTAString_IncompatibleCharT& aString );
+ NS_COM void AssignWithConversion( const incompatible_char_type* aData, PRInt32 aLength=-1 );
+
+ NS_COM void AppendWithConversion( const nsTAString_IncompatibleCharT& aString );
+ NS_COM void AppendWithConversion( const incompatible_char_type* aData, PRInt32 aLength=-1 );
+
+ /**
+ * Append the given integer to this string
+ */
+ NS_COM void AppendInt( PRInt32 aInteger, PRInt32 aRadix=kRadix10 ); //radix=8,10 or 16
+
+ /**
+ * Append the given unsigned integer to this string
+ */
+ inline void AppendInt( PRUint32 aInteger, PRInt32 aRadix = kRadix10 )
+ {
+ AppendInt(PRInt32(aInteger), aRadix);
+ }
+
+ /**
+ * Append the given 64-bit integer to this string.
+ * @param aInteger The integer to append
+ * @param aRadix The radix to use; can be 8, 10 or 16.
+ */
+ NS_COM void AppendInt( PRInt64 aInteger, PRInt32 aRadix=kRadix10 );
+
+ /**
+ * Append the given float to this string
+ */
+
+ NS_COM void AppendFloat( double aFloat );
+
+#endif // !MOZ_STRING_WITH_OBSOLETE_API
+
+
+ protected:
+
+ explicit
+ nsTString_CharT( PRUint32 flags )
+ : substring_type(flags) {}
+
+ // allow subclasses to initialize fields directly
+ nsTString_CharT( char_type* data, size_type length, PRUint32 flags )
+ : substring_type(data, length, flags) {}
+ };
+
+
+class nsTFixedString_CharT : public nsTString_CharT
+ {
+ public:
+
+ typedef nsTFixedString_CharT self_type;
+ typedef nsTFixedString_CharT fixed_string_type;
+
+ public:
+
+ /**
+ * @param data
+ * fixed-size buffer to be used by the string (the contents of
+ * this buffer may be modified by the string)
+ * @param storageSize
+ * the size of the fixed buffer
+ * @param length (optional)
+ * the length of the string already contained in the buffer
+ */
+
+ nsTFixedString_CharT( char_type* data, size_type storageSize )
+ : string_type(data, char_traits::length(data), F_TERMINATED | F_FIXED | F_CLASS_FIXED)
+ , mFixedCapacity(storageSize - 1)
+ , mFixedBuf(data)
+ {}
+
+ nsTFixedString_CharT( char_type* data, size_type storageSize, size_type length )
+ : string_type(data, length, F_TERMINATED | F_FIXED | F_CLASS_FIXED)
+ , mFixedCapacity(storageSize - 1)
+ , mFixedBuf(data)
+ {
+ // null-terminate
+ mFixedBuf[length] = char_type(0);
+ }
+
+ // |operator=| does not inherit, so we must define our own
+ self_type& operator=( char_type c ) { Assign(c); return *this; }
+ self_type& operator=( const char_type* data ) { Assign(data); return *this; }
+ self_type& operator=( const substring_type& str ) { Assign(str); return *this; }
+ self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
+ self_type& operator=( const abstract_string_type& readable ) { Assign(readable); return *this; }
+
+ protected:
+
+ friend class nsTSubstring_CharT;
+
+ size_type mFixedCapacity;
+ char_type *mFixedBuf;
+ };
+
+
+ /**
+ * nsTAutoString_CharT
+ *
+ * Subclass of nsTString_CharT that adds support for stack-based string
+ * allocation. Do not allocate this class on the heap! ;-)
+ */
+class nsTAutoString_CharT : public nsTFixedString_CharT
+ {
+ public:
+
+ typedef nsTAutoString_CharT self_type;
+
+ public:
+
+ /**
+ * constructors
+ */
+
+ nsTAutoString_CharT()
+ : fixed_string_type(mStorage, kDefaultStorageSize, 0)
+ {}
+
+ explicit
+ nsTAutoString_CharT( char_type c )
+ : fixed_string_type(mStorage, kDefaultStorageSize, 0)
+ {
+ Assign(c);
+ }
+
+ explicit
+ nsTAutoString_CharT( const char_type* data, size_type length = size_type(-1) )
+ : fixed_string_type(mStorage, kDefaultStorageSize, 0)
+ {
+ Assign(data, length);
+ }
+
+ nsTAutoString_CharT( const self_type& str )
+ : fixed_string_type(mStorage, kDefaultStorageSize, 0)
+ {
+ Assign(str);
+ }
+
+ explicit
+ nsTAutoString_CharT( const substring_type& str )
+ : fixed_string_type(mStorage, kDefaultStorageSize, 0)
+ {
+ Assign(str);
+ }
+
+ nsTAutoString_CharT( const substring_tuple_type& tuple )
+ : fixed_string_type(mStorage, kDefaultStorageSize, 0)
+ {
+ Assign(tuple);
+ }
+
+ explicit
+ nsTAutoString_CharT( const abstract_string_type& readable )
+ : fixed_string_type(mStorage, kDefaultStorageSize, 0)
+ {
+ Assign(readable);
+ }
+
+ // |operator=| does not inherit, so we must define our own
+ self_type& operator=( char_type c ) { Assign(c); return *this; }
+ self_type& operator=( const char_type* data ) { Assign(data); return *this; }
+ self_type& operator=( const self_type& str ) { Assign(str); return *this; }
+ self_type& operator=( const substring_type& str ) { Assign(str); return *this; }
+ self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
+ self_type& operator=( const abstract_string_type& readable ) { Assign(readable); return *this; }
+
+ enum { kDefaultStorageSize = 64 };
+
+ private:
+
+ char_type mStorage[kDefaultStorageSize];
+ };
+
+
+ /**
+ * nsTXPIDLString extends nsTString such that:
+ *
+ * (1) mData can be null
+ * (2) objects of this type can be automatically cast to |const CharT*|
+ * (3) getter_Copies method is supported to adopt data
+ */
+class nsTXPIDLString_CharT : public nsTString_CharT
+ {
+ public:
+
+ typedef nsTXPIDLString_CharT self_type;
+
+ public:
+
+ nsTXPIDLString_CharT()
+ : string_type(NS_CONST_CAST(char_type*, char_traits::sEmptyBuffer), 0, F_TERMINATED | F_VOIDED) {}
+
+ // copy-constructor required to avoid default
+ nsTXPIDLString_CharT( const self_type& str )
+ : string_type(NS_CONST_CAST(char_type*, char_traits::sEmptyBuffer), 0, F_TERMINATED | F_VOIDED)
+ {
+ Assign(str);
+ }
+
+ // return nsnull if we are voided
+ const char_type* get() const
+ {
+ return (mFlags & F_VOIDED) ? nsnull : mData;
+ }
+
+ // this case operator is the reason why this class cannot just be a
+ // typedef for nsTString
+ operator const char_type*() const
+ {
+ return get();
+ }
+
+ // need this to diambiguous operator[int]
+ char_type operator[]( PRInt32 i ) const
+ {
+ return CharAt(index_type(i));
+ }
+
+ // |operator=| does not inherit, so we must define our own
+ self_type& operator=( char_type c ) { Assign(c); return *this; }
+ self_type& operator=( const char_type* data ) { Assign(data); return *this; }
+ self_type& operator=( const self_type& str ) { Assign(str); return *this; }
+ self_type& operator=( const substring_type& str ) { Assign(str); return *this; }
+ self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
+ self_type& operator=( const abstract_string_type& readable ) { Assign(readable); return *this; }
+ };
+
+
+ /**
+ * getter_Copies support for use with raw string out params:
+ *
+ * NS_IMETHOD GetBlah(char**);
+ *
+ * void some_function()
+ * {
+ * nsXPIDLCString blah;
+ * GetBlah(getter_Copies(blah));
+ * // ...
+ * }
+ */
+class nsTGetterCopies_CharT
+ {
+ public:
+ typedef CharT char_type;
+
+ nsTGetterCopies_CharT(nsTXPIDLString_CharT& str)
+ : mString(str), mData(nsnull) {}
+
+ ~nsTGetterCopies_CharT()
+ {
+ mString.Adopt(mData); // OK if mData is null
+ }
+
+ operator char_type**()
+ {
+ return &mData;
+ }
+
+ private:
+ nsTXPIDLString_CharT& mString;
+ char_type* mData;
+ };
+
+inline
+nsTGetterCopies_CharT
+getter_Copies( nsTXPIDLString_CharT& aString )
+ {
+ return nsTGetterCopies_CharT(aString);
+ }
+
+
+ /**
+ * nsTAdoptingString extends nsTXPIDLString such that:
+ *
+ * (1) Adopt given string on construction or assignment, i.e. take
+ * the value of what's given, and make what's given forget its
+ * value. Note that this class violates constness in a few
+ * places. Be careful!
+ */
+class nsTAdoptingString_CharT : public nsTXPIDLString_CharT
+ {
+ public:
+
+ typedef nsTAdoptingString_CharT self_type;
+
+ public:
+
+ explicit nsTAdoptingString_CharT() {}
+ explicit nsTAdoptingString_CharT(char_type* str, size_type length = size_type(-1))
+ {
+ Adopt(str, length);
+ }
+
+ // copy-constructor required to adopt on copy. Note that this
+ // will violate the constness of |str| in the operator=()
+ // call. |str| will be truncated as a side-effect of this
+ // constructor.
+ nsTAdoptingString_CharT( const self_type& str )
+#ifdef VBOX /* bird: shut up annoying warnings */
+ : nsTXPIDLString_CharT()
+#endif
+ {
+ *this = str;
+ }
+
+ // |operator=| does not inherit, so we must define our own
+ self_type& operator=( const substring_type& str ) { Assign(str); return *this; }
+ self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
+ self_type& operator=( const abstract_string_type& readable ) { Assign(readable); return *this; }
+
+ // Adopt(), if possible, when assigning to a self_type&. Note
+ // that this violates the constness of str, str is always
+ // truncated when this operator is called.
+ NS_COM self_type& operator=( const self_type& str );
+
+ private:
+ // NOT TO BE IMPLEMENTED.
+ self_type& operator=( const char_type* data );
+ self_type& operator=( char_type* data );
+ };
+
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsTSubstring.h b/src/libs/xpcom18a4/xpcom/string/public/nsTSubstring.h
new file mode 100644
index 00000000..aaaf5a64
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsTSubstring.h
@@ -0,0 +1,575 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+ /**
+ * nsTSubstring
+ *
+ * The base string type. This type is not instantiated directly. A sub-
+ * class is instantiated instead. For example, see nsTString.
+ *
+ * This type works like nsTAString except that it does not have the ABI
+ * requirements of that interface. Like nsTAString, nsTSubstring
+ * represents a single contiguous array of characters that may or may not
+ * be null-terminated.
+ *
+ * Many of the accessors on nsTSubstring are inlined as an optimization.
+ *
+ * This class is also known as "nsASingleFragmentC?String".
+ */
+class nsTSubstring_CharT : public nsTAString_CharT
+ {
+ public:
+
+ typedef nsTSubstring_CharT self_type;
+ typedef nsTString_CharT string_type;
+
+ typedef char_type* char_iterator;
+ typedef const char_type* const_char_iterator;
+
+ public:
+
+ /**
+ * reading iterators
+ */
+
+ const_char_iterator BeginReading() const { return mData; }
+ const_char_iterator EndReading() const { return mData + mLength; }
+
+ /**
+ * deprecated reading iterators
+ */
+
+ const_iterator& BeginReading( const_iterator& iter ) const
+ {
+ iter.mStart = mData;
+ iter.mEnd = mData + mLength;
+ iter.mPosition = iter.mStart;
+ return iter;
+ }
+
+ const_iterator& EndReading( const_iterator& iter ) const
+ {
+ iter.mStart = mData;
+ iter.mEnd = mData + mLength;
+ iter.mPosition = iter.mEnd;
+ return iter;
+ }
+
+ const_char_iterator& BeginReading( const_char_iterator& iter ) const
+ {
+ return iter = mData;
+ }
+
+ const_char_iterator& EndReading( const_char_iterator& iter ) const
+ {
+ return iter = mData + mLength;
+ }
+
+
+ /**
+ * writing iterators
+ */
+
+ char_iterator BeginWriting() { EnsureMutable(); return mData; }
+ char_iterator EndWriting() { EnsureMutable(); return mData + mLength; }
+
+ /**
+ * deprecated writing iterators
+ */
+
+ iterator& BeginWriting( iterator& iter )
+ {
+ EnsureMutable();
+ iter.mStart = mData;
+ iter.mEnd = mData + mLength;
+ iter.mPosition = iter.mStart;
+ return iter;
+ }
+
+ iterator& EndWriting( iterator& iter )
+ {
+ EnsureMutable();
+ iter.mStart = mData;
+ iter.mEnd = mData + mLength;
+ iter.mPosition = iter.mEnd;
+ return iter;
+ }
+
+ char_iterator& BeginWriting( char_iterator& iter )
+ {
+ EnsureMutable();
+ return iter = mData;
+ }
+
+ char_iterator& EndWriting( char_iterator& iter )
+ {
+ EnsureMutable();
+ return iter = mData + mLength;
+ }
+
+
+ /**
+ * accessors
+ */
+
+ // returns pointer to string data (not necessarily null-terminated)
+ const char_type *Data() const
+ {
+ return mData;
+ }
+
+ size_type Length() const
+ {
+ return mLength;
+ }
+
+ PRBool IsEmpty() const
+ {
+ return mLength == 0;
+ }
+
+ PRBool IsVoid() const
+ {
+ return mFlags & F_VOIDED;
+ }
+
+ PRBool IsTerminated() const
+ {
+ return mFlags & F_TERMINATED;
+ }
+
+ char_type CharAt( index_type i ) const
+ {
+ NS_ASSERTION(i < mLength, "index exceeds allowable range");
+ return mData[i];
+ }
+
+ char_type operator[]( index_type i ) const
+ {
+ return CharAt(i);
+ }
+
+ char_type First() const
+ {
+ NS_ASSERTION(mLength > 0, "|First()| called on an empty string");
+ return mData[0];
+ }
+
+ inline
+ char_type Last() const
+ {
+ NS_ASSERTION(mLength > 0, "|Last()| called on an empty string");
+ return mData[mLength - 1];
+ }
+
+ NS_COM size_type NS_FASTCALL CountChar( char_type ) const;
+ NS_COM PRInt32 NS_FASTCALL FindChar( char_type, index_type offset = 0 ) const;
+
+
+ /**
+ * equality
+ */
+
+ NS_COM PRBool NS_FASTCALL Equals( const self_type& ) const;
+ NS_COM PRBool NS_FASTCALL Equals( const self_type&, const comparator_type& ) const;
+
+ NS_COM PRBool NS_FASTCALL Equals( const abstract_string_type& readable ) const;
+ NS_COM PRBool NS_FASTCALL Equals( const abstract_string_type& readable, const comparator_type& comp ) const;
+
+ NS_COM PRBool NS_FASTCALL Equals( const char_type* data ) const;
+ NS_COM PRBool NS_FASTCALL Equals( const char_type* data, const comparator_type& comp ) const;
+
+ /**
+ * An efficient comparison with ASCII that can be used even
+ * for wide strings. Call this version when you know the
+ * length of 'data'.
+ */
+ NS_COM PRBool NS_FASTCALL EqualsASCII( const char* data, size_type len ) const;
+ /**
+ * An efficient comparison with ASCII that can be used even
+ * for wide strings. Call this version when 'data' is
+ * null-terminated.
+ */
+ NS_COM PRBool NS_FASTCALL EqualsASCII( const char* data ) const;
+
+ // EqualsLiteral must ONLY be applied to an actual literal string.
+ // Do not attempt to use it with a regular char* pointer, or with a char
+ // array variable.
+ // The template trick to acquire the array length at compile time without
+ // using a macro is due to Corey Kosak, with much thanks.
+#ifdef NS_DISABLE_LITERAL_TEMPLATE
+ inline PRBool EqualsLiteral( const char* str ) const
+ {
+ return EqualsASCII(str);
+ }
+#else
+ template<int N>
+ inline PRBool EqualsLiteral( const char (&str)[N] ) const
+ {
+ return EqualsASCII(str, N-1);
+ }
+ template<int N>
+ inline PRBool EqualsLiteral( char (&str)[N] ) const
+ {
+ const char* s = str;
+ return EqualsASCII(s, N-1);
+ }
+#endif
+
+ // The LowerCaseEquals methods compare the lower case version of
+ // this string to some ASCII/Literal string. The ASCII string is
+ // *not* lowercased for you. If you compare to an ASCII or literal
+ // string that contains an uppercase character, it is guaranteed to
+ // return false. We will throw assertions too.
+ NS_COM PRBool NS_FASTCALL LowerCaseEqualsASCII( const char* data, size_type len ) const;
+ NS_COM PRBool NS_FASTCALL LowerCaseEqualsASCII( const char* data ) const;
+
+ // LowerCaseEqualsLiteral must ONLY be applied to an actual
+ // literal string. Do not attempt to use it with a regular char*
+ // pointer, or with a char array variable. Use
+ // LowerCaseEqualsASCII for them.
+#ifdef NS_DISABLE_LITERAL_TEMPLATE
+ inline PRBool LowerCaseEqualsLiteral( const char* str ) const
+ {
+ return LowerCaseEqualsASCII(str);
+ }
+#else
+ template<int N>
+ inline PRBool LowerCaseEqualsLiteral( const char (&str)[N] ) const
+ {
+ return LowerCaseEqualsASCII(str, N-1);
+ }
+ template<int N>
+ inline PRBool LowerCaseEqualsLiteral( char (&str)[N] ) const
+ {
+ const char* s = str;
+ return LowerCaseEqualsASCII(s, N-1);
+ }
+#endif
+
+ /**
+ * assignment
+ */
+
+ void Assign( char_type c ) { Assign(&c, 1); }
+ NS_COM void NS_FASTCALL Assign( const char_type* data, size_type length = size_type(-1) );
+ NS_COM void NS_FASTCALL Assign( const self_type& );
+ NS_COM void NS_FASTCALL Assign( const substring_tuple_type& );
+ NS_COM void NS_FASTCALL Assign( const abstract_string_type& );
+
+ NS_COM void NS_FASTCALL AssignASCII( const char* data, size_type length );
+ NS_COM void NS_FASTCALL AssignASCII( const char* data );
+
+ // AssignLiteral must ONLY be applied to an actual literal string.
+ // Do not attempt to use it with a regular char* pointer, or with a char
+ // array variable. Use AssignASCII for those.
+#ifdef NS_DISABLE_LITERAL_TEMPLATE
+ void AssignLiteral( const char* str )
+ { AssignASCII(str); }
+#else
+ template<int N>
+ void AssignLiteral( const char (&str)[N] )
+ { AssignASCII(str, N-1); }
+ template<int N>
+ void AssignLiteral( char (&str)[N] )
+ { AssignASCII(str, N-1); }
+#endif
+
+ self_type& operator=( char_type c ) { Assign(c); return *this; }
+ self_type& operator=( const char_type* data ) { Assign(data); return *this; }
+ self_type& operator=( const self_type& str ) { Assign(str); return *this; }
+ self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
+ self_type& operator=( const abstract_string_type& readable ) { Assign(readable); return *this; }
+
+ NS_COM void NS_FASTCALL Adopt( char_type* data, size_type length = size_type(-1) );
+
+
+ /**
+ * buffer manipulation
+ */
+
+ void Replace( index_type cutStart, size_type cutLength, char_type c ) { Replace(cutStart, cutLength, &c, 1); }
+ NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const char_type* data, size_type length = size_type(-1) );
+ void Replace( index_type cutStart, size_type cutLength, const self_type& str ) { Replace(cutStart, cutLength, str.Data(), str.Length()); }
+ NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const substring_tuple_type& tuple );
+ NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const abstract_string_type& readable );
+
+ NS_COM void NS_FASTCALL ReplaceASCII( index_type cutStart, size_type cutLength, const char* data, size_type length = size_type(-1) );
+
+ void Append( char_type c ) { Replace(mLength, 0, c); }
+ void Append( const char_type* data, size_type length = size_type(-1) ) { Replace(mLength, 0, data, length); }
+ void Append( const self_type& str ) { Replace(mLength, 0, str); }
+ void Append( const substring_tuple_type& tuple ) { Replace(mLength, 0, tuple); }
+ void Append( const abstract_string_type& readable ) { Replace(mLength, 0, readable); }
+
+ void AppendASCII( const char* data, size_type length = size_type(-1) ) { ReplaceASCII(mLength, 0, data, length); }
+
+ // AppendLiteral must ONLY be applied to an actual literal string.
+ // Do not attempt to use it with a regular char* pointer, or with a char
+ // array variable. Use AppendASCII for those.
+#ifdef NS_DISABLE_LITERAL_TEMPLATE
+ void AppendLiteral( const char* str )
+ { AppendASCII(str); }
+#else
+ template<int N>
+ void AppendLiteral( const char (&str)[N] )
+ { AppendASCII(str, N-1); }
+ template<int N>
+ void AppendLiteral( char (&str)[N] )
+ { AppendASCII(str, N-1); }
+#endif
+
+ self_type& operator+=( char_type c ) { Append(c); return *this; }
+ self_type& operator+=( const char_type* data ) { Append(data); return *this; }
+ self_type& operator+=( const self_type& str ) { Append(str); return *this; }
+ self_type& operator+=( const substring_tuple_type& tuple ) { Append(tuple); return *this; }
+ self_type& operator+=( const abstract_string_type& readable ) { Append(readable); return *this; }
+
+ void Insert( char_type c, index_type pos ) { Replace(pos, 0, c); }
+ void Insert( const char_type* data, index_type pos, size_type length = size_type(-1) ) { Replace(pos, 0, data, length); }
+ void Insert( const self_type& str, index_type pos ) { Replace(pos, 0, str); }
+ void Insert( const substring_tuple_type& tuple, index_type pos ) { Replace(pos, 0, tuple); }
+ void Insert( const abstract_string_type& readable, index_type pos ) { Replace(pos, 0, readable); }
+
+ void Cut( index_type cutStart, size_type cutLength ) { Replace(cutStart, cutLength, char_traits::sEmptyBuffer, 0); }
+
+
+ /**
+ * buffer sizing
+ */
+
+ NS_COM void NS_FASTCALL SetCapacity( size_type capacity );
+
+ NS_COM void NS_FASTCALL SetLength( size_type );
+
+ void Truncate( size_type newLength = 0 )
+ {
+ NS_ASSERTION(newLength <= mLength, "Truncate cannot make string longer");
+ SetLength(newLength);
+ }
+
+
+ /**
+ * string data is never null, but can be marked void. if true, the
+ * string will be truncated. @see nsTSubstring::IsVoid
+ */
+
+ NS_COM void NS_FASTCALL SetIsVoid( PRBool );
+
+
+ public:
+
+ /**
+ * this is public to support automatic conversion of tuple to string
+ * base type, which helps avoid converting to nsTAString.
+ */
+ nsTSubstring_CharT(const substring_tuple_type& tuple)
+ : abstract_string_type(nsnull, 0, F_NONE)
+ {
+ Assign(tuple);
+ }
+
+ protected:
+
+ friend class nsTObsoleteAStringThunk_CharT;
+ friend class nsTAString_CharT;
+ friend class nsTSubstringTuple_CharT;
+
+ // XXX GCC 3.4 needs this :-(
+ friend class nsTPromiseFlatString_CharT;
+
+ // default initialization
+ nsTSubstring_CharT()
+ : abstract_string_type(
+ NS_CONST_CAST(char_type*, char_traits::sEmptyBuffer), 0, F_TERMINATED) {}
+
+ // allow subclasses to initialize fields directly
+ nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags )
+ : abstract_string_type(data, length, flags) {}
+
+ // version of constructor that leaves mData and mLength uninitialized
+ explicit
+ nsTSubstring_CharT( PRUint32 flags )
+ : abstract_string_type(flags) {}
+
+ // copy-constructor, constructs as dependent on given object
+ // (NOTE: this is for internal use only)
+ nsTSubstring_CharT( const self_type& str )
+ : abstract_string_type(
+ str.mData, str.mLength, str.mFlags & (F_TERMINATED | F_VOIDED)) {}
+
+ /**
+ * this function releases mData and does not change the value of
+ * any of its member variables. inotherwords, this function acts
+ * like a destructor.
+ */
+ void NS_FASTCALL Finalize();
+
+ /**
+ * this function prepares mData to be mutated.
+ *
+ * @param capacity specifies the required capacity of mData
+ * @param old_data returns null or the old value of mData
+ * @param old_flags returns 0 or the old value of mFlags
+ *
+ * if mData is already mutable and of sufficient capacity, then this
+ * function will return immediately. otherwise, it will either resize
+ * mData or allocate a new shared buffer. if it needs to allocate a
+ * new buffer, then it will return the old buffer and the corresponding
+ * flags. this allows the caller to decide when to free the old data.
+ *
+ * XXX we should expose a way for subclasses to free old_data.
+ */
+ PRBool NS_FASTCALL MutatePrep( size_type capacity, char_type** old_data, PRUint32* old_flags );
+
+ /**
+ * this function prepares a section of mData to be modified. if
+ * necessary, this function will reallocate mData and possibly move
+ * existing data to open up the specified section.
+ *
+ * @param cutStart specifies the starting offset of the section
+ * @param cutLength specifies the length of the section to be replaced
+ * @param newLength specifies the length of the new section
+ *
+ * for example, suppose mData contains the string "abcdef" then
+ *
+ * ReplacePrep(2, 3, 4);
+ *
+ * would cause mData to look like "ab____f" where the characters
+ * indicated by '_' have an unspecified value and can be freely
+ * modified. this function will null-terminate mData upon return.
+ */
+ void NS_FASTCALL ReplacePrep( index_type cutStart, size_type cutLength, size_type newLength );
+
+ /**
+ * returns the number of writable storage units starting at mData.
+ * the value does not include space for the null-terminator character.
+ *
+ * NOTE: this function returns size_type(-1) if mData is immutable.
+ */
+ size_type NS_FASTCALL Capacity() const;
+
+ /**
+ * this helper function can be called prior to directly manipulating
+ * the contents of mData. see, for example, BeginWriting.
+ */
+ NS_COM void NS_FASTCALL EnsureMutable();
+
+ /**
+ * returns true if this string overlaps with the given string fragment.
+ */
+ PRBool IsDependentOn( const char_type *start, const char_type *end ) const
+ {
+ /**
+ * if it _isn't_ the case that one fragment starts after the other ends,
+ * or ends before the other starts, then, they conflict:
+ *
+ * !(f2.begin >= f1.end || f2.end <= f1.begin)
+ *
+ * Simplified, that gives us:
+ */
+ return ( start < (mData + mLength) && end > mData );
+ }
+
+ /**
+ * this helper function stores the specified dataFlags in mFlags
+ */
+ void SetDataFlags(PRUint32 dataFlags)
+ {
+ NS_ASSERTION((dataFlags & 0xFFFF0000) == 0, "bad flags");
+ mFlags = dataFlags | (mFlags & 0xFFFF0000);
+ }
+
+ public:
+
+ // mFlags is a bitwise combination of the following flags. the meaning
+ // and interpretation of these flags is an implementation detail.
+ //
+ // NOTE: these flags are declared public _only_ for convenience inside
+ // the string implementation.
+
+ enum
+ {
+ F_NONE = 0, // no flags
+
+ // data flags are in the lower 16-bits
+ F_TERMINATED = 1 << 0, // IsTerminated returns true
+ F_VOIDED = 1 << 1, // IsVoid returns true
+ F_SHARED = 1 << 2, // mData points to a heap-allocated, shared buffer
+ F_OWNED = 1 << 3, // mData points to a heap-allocated, raw buffer
+ F_FIXED = 1 << 4, // mData points to a fixed-size writable, dependent buffer
+
+ // class flags are in the upper 16-bits
+ F_CLASS_FIXED = 1 << 16 // indicates that |this| is of type nsTFixedString
+ };
+
+ //
+ // Some terminology:
+ //
+ // "dependent buffer" A dependent buffer is one that the string class
+ // does not own. The string class relies on some
+ // external code to ensure the lifetime of the
+ // dependent buffer.
+ //
+ // "shared buffer" A shared buffer is one that the string class
+ // allocates. When it allocates a shared string
+ // buffer, it allocates some additional space at
+ // the beginning of the buffer for additional
+ // fields, including a reference count and a
+ // buffer length. See nsStringHeader.
+ //
+ // "adopted buffer" An adopted buffer is a raw string buffer
+ // allocated on the heap (using nsMemory::Alloc)
+ // of which the string class subsumes ownership.
+ //
+ // Some comments about the string flags:
+ //
+ // F_SHARED, F_OWNED, and F_FIXED are all mutually exlusive. They
+ // indicate the allocation type of mData. If none of these flags
+ // are set, then the string buffer is dependent.
+ //
+ // F_SHARED, F_OWNED, or F_FIXED imply F_TERMINATED. This is because
+ // the string classes always allocate null-terminated buffers, and
+ // non-terminated substrings are always dependent.
+ //
+ // F_VOIDED implies F_TERMINATED, and moreover it implies that mData
+ // points to char_traits::sEmptyBuffer. Therefore, F_VOIDED is
+ // mutually exclusive with F_SHARED, F_OWNED, and F_FIXED.
+ //
+ };
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsTSubstringTuple.h b/src/libs/xpcom18a4/xpcom/string/public/nsTSubstringTuple.h
new file mode 100644
index 00000000..2ded17d5
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsTSubstringTuple.h
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+ /**
+ * nsTSubstringTuple_CharT
+ *
+ * Represents a tuple of string fragments. Built as a recursive binary tree.
+ * It is used to implement the concatenation of two or more string objects.
+ *
+ * NOTE: This class is a private implementation detail and should never be
+ * referenced outside the string code.
+ */
+class nsTSubstringTuple_CharT
+ {
+ public:
+
+ typedef CharT char_type;
+ typedef nsCharTraits<char_type> char_traits;
+
+ typedef nsTSubstringTuple_CharT self_type;
+ typedef nsTSubstring_CharT substring_type;
+ typedef nsTString_CharT string_type;
+ typedef nsTAString_CharT abstract_string_type;
+ typedef nsTObsoleteAString_CharT obsolete_string_type;
+
+ typedef PRUint32 size_type;
+
+ public:
+
+ nsTSubstringTuple_CharT(const abstract_string_type* a, const abstract_string_type* b)
+ : mHead(nsnull)
+ , mFragA(a)
+ , mFragB(b) {}
+
+ nsTSubstringTuple_CharT(const self_type& head, const abstract_string_type* b)
+ : mHead(&head)
+ , mFragA(nsnull) // this fragment is ignored when head != nsnull
+ , mFragB(b) {}
+
+ /**
+ * computes the aggregate string length
+ */
+ NS_COM size_type Length() const;
+
+ /**
+ * writes the aggregate string to the given buffer. bufLen is assumed
+ * to be equal to or greater than the value returned by the Length()
+ * method. the string written to |buf| is not null-terminated.
+ */
+ NS_COM void WriteTo(char_type *buf, PRUint32 bufLen) const;
+
+ /**
+ * returns true if this tuple is dependent on (i.e., overlapping with)
+ * the given char sequence.
+ */
+ NS_COM PRBool IsDependentOn(const char_type *start, const char_type *end) const;
+
+ private:
+
+ const self_type* mHead;
+ const abstract_string_type* mFragA;
+ const abstract_string_type* mFragB;
+ };
+
+inline
+const nsTSubstringTuple_CharT
+operator+(const nsTAString_CharT& a, const nsTAString_CharT& b)
+ {
+ return nsTSubstringTuple_CharT(&a, &b);
+ }
+
+inline
+const nsTSubstringTuple_CharT
+operator+(const nsTSubstringTuple_CharT& head, const nsTAString_CharT& b)
+ {
+ return nsTSubstringTuple_CharT(head, &b);
+ }
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsUTF8Utils.h b/src/libs/xpcom18a4/xpcom/string/public/nsUTF8Utils.h
new file mode 100644
index 00000000..c91079c2
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsUTF8Utils.h
@@ -0,0 +1,462 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2001
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Peter Annema <jaggernaut@netscape.com> (original author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsUTF8Utils_h_
+#define nsUTF8Utils_h_
+
+class UTF8traits
+ {
+ public:
+ static PRBool isASCII(char c) { return (c & 0x80) == 0x00; }
+ static PRBool isInSeq(char c) { return (c & 0xC0) == 0x80; }
+ static PRBool is2byte(char c) { return (c & 0xE0) == 0xC0; }
+ static PRBool is3byte(char c) { return (c & 0xF0) == 0xE0; }
+ static PRBool is4byte(char c) { return (c & 0xF8) == 0xF0; }
+ static PRBool is5byte(char c) { return (c & 0xFC) == 0xF8; }
+ static PRBool is6byte(char c) { return (c & 0xFE) == 0xFC; }
+ };
+
+#define PLANE1_BASE 0x00010000
+#define UCS2_REPLACEMENT_CHAR 0xfffd
+
+#ifdef __GNUC__
+#define NS_ALWAYS_INLINE __attribute__((always_inline))
+#else
+#define NS_ALWAYS_INLINE
+#endif
+
+/**
+ * A character sink (see |copy_string| in nsAlgorithm.h) for converting
+ * UTF-8 to UTF-16
+ */
+class ConvertUTF8toUTF16
+ {
+ public:
+ typedef nsACString::char_type value_type;
+ typedef nsAString::char_type buffer_type;
+
+ ConvertUTF8toUTF16( buffer_type* aBuffer )
+ : mStart(aBuffer), mBuffer(aBuffer), mErrorEncountered(PR_FALSE) {}
+
+ size_t Length() const { return mBuffer - mStart; }
+
+ PRUint32 NS_ALWAYS_INLINE write( const value_type* start, PRUint32 N )
+ {
+ if ( mErrorEncountered )
+ return N;
+
+ // algorithm assumes utf8 units won't
+ // be spread across fragments
+ const value_type* p = start;
+ const value_type* end = start + N;
+ buffer_type* out = mBuffer;
+ for ( ; p != end /* && *p */; )
+ {
+ char c = *p++;
+
+ if ( UTF8traits::isASCII(c) )
+ {
+ *out++ = buffer_type(c);
+ continue;
+ }
+
+ PRUint32 ucs4;
+ PRUint32 minUcs4;
+ PRInt32 state = 0;
+
+ if ( UTF8traits::is2byte(c) )
+ {
+ ucs4 = (PRUint32(c) << 6) & 0x000007C0L;
+ state = 1;
+ minUcs4 = 0x00000080;
+ }
+ else if ( UTF8traits::is3byte(c) )
+ {
+ ucs4 = (PRUint32(c) << 12) & 0x0000F000L;
+ state = 2;
+ minUcs4 = 0x00000800;
+ }
+ else if ( UTF8traits::is4byte(c) )
+ {
+ ucs4 = (PRUint32(c) << 18) & 0x001F0000L;
+ state = 3;
+ minUcs4 = 0x00010000;
+ }
+ else if ( UTF8traits::is5byte(c) )
+ {
+ ucs4 = (PRUint32(c) << 24) & 0x03000000L;
+ state = 4;
+ minUcs4 = 0x00200000;
+ }
+ else if ( UTF8traits::is6byte(c) )
+ {
+ ucs4 = (PRUint32(c) << 30) & 0x40000000L;
+ state = 5;
+ minUcs4 = 0x04000000;
+ }
+ else
+ {
+ NS_ERROR("Not a UTF-8 string. This code should only be used for converting from known UTF-8 strings.");
+ mErrorEncountered = PR_TRUE;
+ mBuffer = out;
+ return N;
+ }
+
+ while ( state-- )
+ {
+ c = *p++;
+
+ if ( UTF8traits::isInSeq(c) )
+ {
+ PRInt32 shift = state * 6;
+ ucs4 |= (PRUint32(c) & 0x3F) << shift;
+ }
+ else
+ {
+ NS_ERROR("not a UTF8 string");
+ mErrorEncountered = PR_TRUE;
+ mBuffer = out;
+ return N;
+ }
+ }
+
+ if ( ucs4 < minUcs4 )
+ {
+ // Overlong sequence
+ *out++ = UCS2_REPLACEMENT_CHAR;
+ }
+ else if ( ucs4 <= 0xD7FF )
+ {
+ *out++ = ucs4;
+ }
+ else if ( /* ucs4 >= 0xD800 && */ ucs4 <= 0xDFFF )
+ {
+ // Surrogates
+ *out++ = UCS2_REPLACEMENT_CHAR;
+ }
+ else if ( ucs4 == 0xFFFE || ucs4 == 0xFFFF )
+ {
+ // Prohibited characters
+ *out++ = UCS2_REPLACEMENT_CHAR;
+ }
+ else if ( ucs4 >= PLANE1_BASE )
+ {
+ if ( ucs4 >= 0x00110000 )
+ *out++ = UCS2_REPLACEMENT_CHAR;
+ else {
+ // surrogate, see unicode specification 3.7 for following math.
+ ucs4 -= PLANE1_BASE;
+ *out++ = (PRUnichar)(ucs4 >> 10) | 0xd800u;
+ *out++ = (PRUnichar)(ucs4 & 0x3ff) | 0xdc00u;
+ }
+ }
+ else
+ {
+ *out++ = ucs4;
+ }
+ }
+ mBuffer = out;
+ return p - start;
+ }
+
+ void write_terminator()
+ {
+ *mBuffer = buffer_type(0);
+ }
+
+ private:
+ buffer_type* const mStart;
+ buffer_type* mBuffer;
+ PRBool mErrorEncountered;
+ };
+
+/**
+ * A character sink (see |copy_string| in nsAlgorithm.h) for computing
+ * the length of the UTF-16 string equivalent to a UTF-8 string.
+ */
+class CalculateUTF8Length
+ {
+ public:
+ typedef nsACString::char_type value_type;
+
+ CalculateUTF8Length() : mLength(0), mErrorEncountered(PR_FALSE) { }
+
+ size_t Length() const { return mLength; }
+
+ PRUint32 NS_ALWAYS_INLINE write( const value_type* start, PRUint32 N )
+ {
+ // ignore any further requests
+ if ( mErrorEncountered )
+ return N;
+
+ // algorithm assumes utf8 units won't
+ // be spread across fragments
+ const value_type* p = start;
+ const value_type* end = start + N;
+ for ( ; p < end /* && *p */; ++mLength )
+ {
+ if ( UTF8traits::isASCII(*p) )
+ p += 1;
+ else if ( UTF8traits::is2byte(*p) )
+ p += 2;
+ else if ( UTF8traits::is3byte(*p) )
+ p += 3;
+ else if ( UTF8traits::is4byte(*p) ) {
+ p += 4;
+ // Because a UTF-8 sequence of 4 bytes represents a codepoint
+ // greater than 0xFFFF, it will become a surrogate pair in the
+ // UTF-16 string, so add 1 more to mLength.
+ // This doesn't happen with is5byte and is6byte because they
+ // are illegal UTF-8 sequences (greater than 0x10FFFF) so get
+ // converted to a single replacement character.
+ //
+ // XXX: if the 4-byte sequence is an illegal non-shortest form,
+ // it also gets converted to a replacement character, so
+ // mLength will be off by one in this case.
+ ++mLength;
+ }
+ else if ( UTF8traits::is5byte(*p) )
+ p += 5;
+ else if ( UTF8traits::is6byte(*p) )
+ p += 6;
+ else
+ {
+ break;
+ }
+ }
+ if ( p != end )
+ {
+ NS_ERROR("Not a UTF-8 string. This code should only be used for converting from known UTF-8 strings.");
+ mErrorEncountered = PR_TRUE;
+ mLength = 0;
+ return N;
+ }
+ return p - start;
+ }
+
+ private:
+ size_t mLength;
+ PRBool mErrorEncountered;
+ };
+
+/**
+ * A character sink (see |copy_string| in nsAlgorithm.h) for converting
+ * UTF-16 to UTF-8.
+ */
+class ConvertUTF16toUTF8
+ {
+ public:
+ typedef nsAString::char_type value_type;
+ typedef nsACString::char_type buffer_type;
+
+ // The error handling here is more lenient than that in
+ // |ConvertUTF8toUTF16|, but it's that way for backwards
+ // compatibility.
+
+ ConvertUTF16toUTF8( buffer_type* aBuffer )
+ : mStart(aBuffer), mBuffer(aBuffer) {}
+
+ size_t Size() const { return mBuffer - mStart; }
+
+ PRUint32 NS_ALWAYS_INLINE write( const value_type* start, PRUint32 N )
+ {
+ buffer_type *out = mBuffer; // gcc isn't smart enough to do this!
+
+ for (const value_type *p = start, *end = start + N; p < end; ++p )
+ {
+ value_type c = *p;
+ if (! (c & 0xFF80)) // U+0000 - U+007F
+ {
+ *out++ = (char)c;
+ }
+ else if (! (c & 0xF800)) // U+0100 - U+07FF
+ {
+ *out++ = 0xC0 | (char)(c >> 6);
+ *out++ = 0x80 | (char)(0x003F & c);
+ }
+ else if (0xD800 != (0xF800 & c)) // U+0800 - U+D7FF,U+E000 - U+FFFF
+ {
+ *out++ = 0xE0 | (char)(c >> 12);
+ *out++ = 0x80 | (char)(0x003F & (c >> 6));
+ *out++ = 0x80 | (char)(0x003F & c );
+ }
+ else if (0xD800 == (0xFC00 & c)) // U+D800 - U+DBFF
+ {
+ // D800- DBFF - High Surrogate
+ // N = (H- D800) *400 + 10000 + ...
+ PRUint32 ucs4 = 0x10000 + ((0x03FF & c) << 10);
+
+ ++p;
+ if (p == end)
+ {
+ NS_ERROR("Surrogate pair split between fragments");
+ mBuffer = out;
+ return N;
+ }
+ c = *p;
+
+ if (0xDC00 == (0xFC00 & c))
+ {
+ // DC00- DFFF - Low Surrogate
+ // N += ( L - DC00 )
+ ucs4 |= (0x03FF & c);
+
+ // 0001 0000-001F FFFF
+ *out++ = 0xF0 | (char)(ucs4 >> 18);
+ *out++ = 0x80 | (char)(0x003F & (ucs4 >> 12));
+ *out++ = 0x80 | (char)(0x003F & (ucs4 >> 6));
+ *out++ = 0x80 | (char)(0x003F & ucs4);
+ }
+ else
+ {
+ NS_ERROR("got a High Surrogate but no low surrogate");
+ // output nothing.
+ }
+ }
+ else // U+DC00 - U+DFFF
+ {
+ // DC00- DFFF - Low Surrogate
+ NS_ERROR("got a low Surrogate but no high surrogate");
+ // output nothing.
+ }
+ }
+
+ mBuffer = out;
+ return N;
+ }
+
+ void write_terminator()
+ {
+ *mBuffer = buffer_type(0);
+ }
+
+ private:
+ buffer_type* const mStart;
+ buffer_type* mBuffer;
+ };
+
+/**
+ * A character sink (see |copy_string| in nsAlgorithm.h) for computing
+ * the number of bytes a UTF-16 would occupy in UTF-8.
+ */
+class CalculateUTF8Size
+ {
+ public:
+ typedef nsAString::char_type value_type;
+
+ CalculateUTF8Size()
+ : mSize(0) { }
+
+ size_t Size() const { return mSize; }
+
+ PRUint32 NS_ALWAYS_INLINE write( const value_type* start, PRUint32 N )
+ {
+ // Assume UCS2 surrogate pairs won't be spread across fragments.
+ for (const value_type *p = start, *end = start + N; p < end; ++p )
+ {
+ value_type c = *p;
+ if (! (c & 0xFF80)) // U+0000 - U+007F
+ mSize += 1;
+ else if (! (c & 0xF800)) // U+0100 - U+07FF
+ mSize += 2;
+ else if (0xD800 != (0xF800 & c)) // U+0800 - U+D7FF,U+E000 - U+FFFF
+ mSize += 3;
+ else if (0xD800 == (0xFC00 & c)) // U+D800 - U+DBFF
+ {
+ ++p;
+ if (p == end)
+ {
+ NS_ERROR("Surrogate pair split between fragments");
+ return N;
+ }
+ c = *p;
+
+ if (0xDC00 == (0xFC00 & c))
+ mSize += 4;
+ else
+ NS_ERROR("got a high Surrogate but no low surrogate");
+ }
+ else // U+DC00 - U+DFFF
+ NS_ERROR("got a low Surrogate but no high surrogate");
+ }
+
+ return N;
+ }
+
+ private:
+ size_t mSize;
+ };
+
+/**
+ * A character sink that performs a |reinterpret_cast| style conversion
+ * between character types.
+ */
+template <class FromCharT, class ToCharT>
+class LossyConvertEncoding
+ {
+ public:
+ typedef FromCharT value_type;
+
+ typedef FromCharT input_type;
+ typedef ToCharT output_type;
+
+ typedef typename nsCharTraits<FromCharT>::unsigned_char_type unsigned_input_type;
+
+ public:
+ LossyConvertEncoding( output_type* aDestination ) : mDestination(aDestination) { }
+
+ PRUint32
+ write( const input_type* aSource, PRUint32 aSourceLength )
+ {
+ const input_type* done_writing = aSource + aSourceLength;
+ while ( aSource < done_writing )
+ *mDestination++ = (output_type)(unsigned_input_type)(*aSource++); // use old-style cast to mimic old |ns[C]String| behavior
+ return aSourceLength;
+ }
+
+ void
+ write_terminator()
+ {
+ *mDestination = output_type(0);
+ }
+
+ private:
+ output_type* mDestination;
+ };
+
+#endif /* !defined(nsUTF8Utils_h_) */
diff --git a/src/libs/xpcom18a4/xpcom/string/public/nsXPIDLString.h b/src/libs/xpcom18a4/xpcom/string/public/nsXPIDLString.h
new file mode 100644
index 00000000..c66a2d7a
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/nsXPIDLString.h
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsXPIDLString_h___
+#define nsXPIDLString_h___
+
+#ifndef nsString_h___
+#include "nsString.h"
+#endif
+
+#endif /* !defined(nsXPIDLString_h___) */
diff --git a/src/libs/xpcom18a4/xpcom/string/public/string-template-def-char.h b/src/libs/xpcom18a4/xpcom/string/public/string-template-def-char.h
new file mode 100644
index 00000000..d0f3a907
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/string-template-def-char.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#define CharT char
+#define CharT_is_char 1
+#define nsTObsoleteAString_CharT nsObsoleteACString
+#define nsTObsoleteAStringThunk_CharT nsObsoleteACStringThunk
+#define nsTAString_CharT nsACString
+#define nsTAString_IncompatibleCharT nsAString
+#define nsTString_CharT nsCString
+#define nsTFixedString_CharT nsFixedCString
+#define nsTAutoString_CharT nsCAutoString
+#define nsTSubstring_CharT nsCSubstring
+#define nsTSubstringTuple_CharT nsCSubstringTuple
+#define nsTStringComparator_CharT nsCStringComparator
+#define nsTDefaultStringComparator_CharT nsDefaultCStringComparator
+#define nsTDependentString_CharT nsDependentCString
+#define nsTDependentSubstring_CharT nsDependentCSubstring
+#define nsTXPIDLString_CharT nsXPIDLCString
+#define nsTGetterCopies_CharT nsCGetterCopies
+#define nsTAdoptingString_CharT nsAdoptingCString
+#define nsTPromiseFlatString_CharT nsPromiseFlatCString
+#define TPromiseFlatString_CharT PromiseFlatCString
diff --git a/src/libs/xpcom18a4/xpcom/string/public/string-template-def-unichar.h b/src/libs/xpcom18a4/xpcom/string/public/string-template-def-unichar.h
new file mode 100644
index 00000000..c966dfbe
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/string-template-def-unichar.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#define CharT PRUnichar
+#define CharT_is_PRUnichar 1
+#define nsTObsoleteAString_CharT nsObsoleteAString
+#define nsTObsoleteAStringThunk_CharT nsObsoleteAStringThunk
+#define nsTAString_CharT nsAString
+#define nsTAString_IncompatibleCharT nsACString
+#define nsTString_CharT nsString
+#define nsTFixedString_CharT nsFixedString
+#define nsTAutoString_CharT nsAutoString
+#define nsTSubstring_CharT nsSubstring
+#define nsTSubstringTuple_CharT nsSubstringTuple
+#define nsTStringComparator_CharT nsStringComparator
+#define nsTDefaultStringComparator_CharT nsDefaultStringComparator
+#define nsTDependentString_CharT nsDependentString
+#define nsTDependentSubstring_CharT nsDependentSubstring
+#define nsTXPIDLString_CharT nsXPIDLString
+#define nsTGetterCopies_CharT nsGetterCopies
+#define nsTAdoptingString_CharT nsAdoptingString
+#define nsTPromiseFlatString_CharT nsPromiseFlatString
+#define TPromiseFlatString_CharT PromiseFlatString
diff --git a/src/libs/xpcom18a4/xpcom/string/public/string-template-undef.h b/src/libs/xpcom18a4/xpcom/string/public/string-template-undef.h
new file mode 100644
index 00000000..45344370
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/string/public/string-template-undef.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla.
+ *
+ * The Initial Developer of the Original Code is IBM Corporation.
+ * Portions created by IBM Corporation are Copyright (C) 2003
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Darin Fisher <darin@meer.net>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#undef CharT
+#undef CharT_is_PRUnichar
+#undef CharT_is_char
+#undef nsTObsoleteAString_CharT
+#undef nsTObsoleteAStringThunk_CharT
+#undef nsTAString_CharT
+#undef nsTAString_IncompatibleCharT
+#undef nsTString_CharT
+#undef nsTFixedString_CharT
+#undef nsTAutoString_CharT
+#undef nsTSubstring_CharT
+#undef nsTSubstringTuple_CharT
+#undef nsTStringComparator_CharT
+#undef nsTDefaultStringComparator_CharT
+#undef nsTDependentString_CharT
+#undef nsTDependentSubstring_CharT
+#undef nsTXPIDLString_CharT
+#undef nsTGetterCopies_CharT
+#undef nsTAdoptingString_CharT
+#undef nsTPromiseFlatString_CharT
+#undef TPromiseFlatString_CharT