/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 "nsString.h"
#ifndef nsTString_h #define nsTString_h
#include"nsTSubstring.h"
/** * This is the canonical null-terminated string class. All subclasses * promise null-terminated storage. Instances of this class allocate * strings on the heap. * * NAMES: * nsString for wide characters * nsCString for narrow characters * * This class is also known as nsAFlat[C]String, where "flat" is used * to denote a null-terminated string.
*/ template <typename T> class nsTString : public nsTSubstring<T> { public: typedef nsTString<T> self_type;
using repr_type = mozilla::detail::nsTStringRepr<T>;
#ifdef __clang__ // bindgen w/ clang 3.9 at least chokes on a typedef, but using is okay. usingtypename nsTSubstring<T>::substring_type; #else // On the other hand msvc chokes on the using statement. It seems others // don't care either way so we lump them in here. typedeftypename nsTSubstring<T>::substring_type substring_type; #endif
// These are only for internal use within the string classes: typedeftypename substring_type::DataFlags DataFlags; typedeftypename substring_type::ClassFlags ClassFlags;
#ifdef XP_WIN /** * Returns the string as a wchar_t
*/ template <typename U = T> typename std::enable_if<std::is_same<U, char16_t>::value, constwchar_t*>::type
getW() const { returnreinterpret_cast<constwchar_t*>(this->mData);
} #endif
/** * returns character at specified index. * * NOTE: unlike nsTSubstring::CharAt, this function allows you to index * the null terminator character.
*/
/** * 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
*/ bool SetCharAt(char16_t aChar, index_type aIndex);
/** * Allow this string to be bound to a character buffer * until the string is rebound or mutated; the caller * must ensure that the buffer outlives the string.
*/ void Rebind(const char_type* aData, size_type aLength);
/** * verify restrictions for dependent strings
*/ void AssertValidDependentString() {
MOZ_ASSERT(this->mData, "nsTDependentString must wrap a non-NULL buffer");
MOZ_ASSERT(this->mData[substring_type::mLength] == 0, "nsTDependentString must wrap only null-terminated strings. " "You are probably looking for nsTDependentSubstring.");
}
/** * nsTAutoStringN * * Subclass of nsTString that adds support for stack-based string * allocation. It is normally not a good idea to use this class on the * heap, because it will allocate space which may be wasted if the string * it contains is significantly smaller or any larger than 64 characters. * * NAMES: * nsAutoStringN / nsTAutoString for wide characters * nsAutoCStringN / nsTAutoCString for narrow characters
*/ template <typename T, size_t N> class MOZ_NON_MEMMOVABLE nsTAutoStringN : public nsTString<T> { public: typedef nsTAutoStringN<T, N> self_type;
// These are only for internal use within the string classes: typedeftypename base_string_type::DataFlags DataFlags; typedeftypename base_string_type::ClassFlags ClassFlags; typedeftypename base_string_type::LengthStorage LengthStorage;
// Externs for the most common nsTAutoStringN variations. externtemplateclass nsTAutoStringN<char, 64>; externtemplateclass nsTAutoStringN<char16_t, 64>;
// // nsAutoString stores pointers into itself which are invalidated when an // nsTArray is resized, so nsTArray must not be instantiated with nsAutoString // elements! // template <class E> class nsTArrayElementTraits; template <typename T> class nsTArrayElementTraits<nsTAutoString<T>> { public: template <class A> struct Dont_Instantiate_nsTArray_of; template <class A> struct Instead_Use_nsTArray_of;
// See the comment above nsTGetterCopies_CharT for how to use this. template <typename T> inline nsTGetterCopies<T> getter_Copies(nsTSubstring<T>& aString) { return nsTGetterCopies<T>(aString);
}
#endif
¤ Dauer der Verarbeitung: 0.3 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.