gecko/xpcom/string/public/nsTDependentSubstring.h
Ehsan Akhgari 0fd9123eac Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg
This patch was generated by a script.  Here's the source of the script for
future reference:

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert PRInt8 int8_t
convert PRUint8 uint8_t
convert PRInt16 int16_t
convert PRUint16 uint16_t
convert PRInt32 int32_t
convert PRUint32 uint32_t
convert PRInt64 int64_t
convert PRUint64 uint64_t

convert PRIntn int
convert PRUintn unsigned

convert PRSize size_t

convert PROffset32 int32_t
convert PROffset64 int64_t

convert PRPtrdiff ptrdiff_t

convert PRFloat64 double
2012-08-22 11:56:38 -04:00

104 lines
3.3 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// IWYU pragma: private, include "nsDependentSubstring.h"
/**
* nsTDependentSubstring_CharT
*
* A string class which wraps an external array of string characters. It
* is the client code's responsibility to ensure that the external buffer
* remains valid for a long as the string is alive.
*
* NAMES:
* nsDependentSubstring for wide characters
* nsDependentCSubstring for narrow characters
*/
class nsTDependentSubstring_CharT : public nsTSubstring_CharT
{
public:
typedef nsTDependentSubstring_CharT self_type;
public:
void Rebind( const substring_type&, uint32_t startPos, uint32_t length = size_type(-1) );
void Rebind( const char_type* data, size_type length );
void Rebind( const char_type* start, const char_type* end )
{
Rebind(start, size_type(end - start));
}
nsTDependentSubstring_CharT( const substring_type& str, uint32_t startPos, uint32_t length = size_type(-1) )
: substring_type()
{
Rebind(str, startPos, length);
}
nsTDependentSubstring_CharT( const char_type* data, size_type length )
: substring_type(const_cast<char_type*>(data), length, F_NONE) {}
nsTDependentSubstring_CharT( const char_type* start, const char_type* end )
: substring_type(const_cast<char_type*>(start), uint32_t(end - start), F_NONE) {}
nsTDependentSubstring_CharT( const const_iterator& start, const const_iterator& end )
: substring_type(const_cast<char_type*>(start.get()), uint32_t(end.get() - start.get()), F_NONE) {}
// Create a nsTDependentSubstring to be bound later
nsTDependentSubstring_CharT()
: substring_type() {}
// 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 nsTSubstring_CharT& str, uint32_t startPos, uint32_t length = uint32_t(-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* data, uint32_t length )
{
return nsTDependentSubstring_CharT(data, length);
}
inline
const nsTDependentSubstring_CharT
Substring( const CharT* start, const CharT* end )
{
return nsTDependentSubstring_CharT(start, end);
}
inline
const nsTDependentSubstring_CharT
StringHead( const nsTSubstring_CharT& str, uint32_t count )
{
return nsTDependentSubstring_CharT(str, 0, count);
}
inline
const nsTDependentSubstring_CharT
StringTail( const nsTSubstring_CharT& str, uint32_t count )
{
return nsTDependentSubstring_CharT(str, str.Length() - count, count);
}