mozilla
Your Search Results

    nsDependentCString

    In This Article
    1. Method Overview
    2. Base Classes
    3. Data Members
    4. Methods
      1. Constructors
        1. Parameters
        2. Parameters
        3. Parameters
        4. Parameters
        5. Parameters
      2. AssertValid
      3. Rebind
        1. Parameters
        2. Parameters
        3. Parameters
      4. operator=
        1. Parameters
        2. Parameters
        3. Parameters
        4. Parameters
        5. Parameters
      5. get
      6. Find
        1. Parameters
        2. Parameters
      7. RFind
        1. Parameters
        2. Parameters
      8. RFindChar
        1. Parameters
      9. FindCharInSet
        1. Parameters
        2. Parameters
      10. RFindCharInSet
        1. Parameters
        2. Parameters
      11. Compare
        1. Parameters
      12. EqualsIgnoreCase
        1. Parameters
      13. ToFloat
        1. Parameters
      14. ToInteger
        1. Parameters
      15. Mid
        1. Parameters
      16. Left
        1. Parameters
      17. Right
        1. Parameters
      18. SetCharAt
        1. Parameters
      19. StripChars
        1. Parameters
      20. StripWhitespace
      21. ReplaceChar
        1. Parameters
        2. Parameters
      22. ReplaceSubstring
        1. Parameters
        2. Parameters
      23. Trim
        1. Parameters
      24. CompressWhitespace
        1. Parameters
      25. AssignWithConversion
        1. Parameters
        2. Parameters
      26. AppendWithConversion
        1. Parameters
        2. Parameters
      27. AppendInt
        1. Parameters
        2. Parameters
        3. Parameters
      28. AppendFloat
        1. Parameters
        2. Parameters
      29. BeginReading
        1. Parameters
        2. Parameters
      30. EndReading
        1. Parameters
        2. Parameters
      31. BeginWriting
        1. Parameters
        2. Parameters
      32. EndWriting
        1. Parameters
        2. Parameters
      33. Data
      34. Length
      35. IsEmpty
      36. IsVoid
      37. IsTerminated
      38. CharAt
        1. Parameters
      39. operator[]
        1. Parameters
      40. First
      41. Last
      42. CountChar
        1. Parameters
      43. FindChar
        1. Parameters
      44. Equals
        1. Parameters
        2. Parameters
        3. Parameters
        4. Parameters
      45. EqualsASCII
        1. Parameters
        2. Parameters
      46. EqualsLiteral(const char
      47. EqualsLiteral(char
      48. LowerCaseEqualsASCII
        1. Parameters
        2. Parameters
      49. LowerCaseEqualsLiteral(const char
      50. LowerCaseEqualsLiteral(char
      51. Assign
        1. Parameters
        2. Parameters
        3. Parameters
        4. Parameters
      52. AssignASCII
        1. Parameters
        2. Parameters
      53. AssignLiteral(const char
      54. AssignLiteral(char
      55. Adopt
        1. Parameters
      56. Replace
        1. Parameters
        2. Parameters
        3. Parameters
        4. Parameters
      57. ReplaceASCII
        1. Parameters
      58. Append
        1. Parameters
        2. Parameters
        3. Parameters
        4. Parameters
      59. AppendASCII
        1. Parameters
      60. AppendLiteral(const char
      61. AppendLiteral(char
      62. operator+=
        1. Parameters
        2. Parameters
        3. Parameters
        4. Parameters
      63. Insert
        1. Parameters
        2. Parameters
        3. Parameters
        4. Parameters
      64. Cut
        1. Parameters
      65. SetCapacity
        1. Parameters
      66. SetLength
        1. Parameters
      67. Truncate
        1. Parameters
      68. GetData
        1. Parameters
      69. GetMutableData
        1. Parameters
      70. SetIsVoid
        1. Parameters
      71. StripChar
        1. Parameters

    Class Declaration

    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.

    Method Overview

    Constructors
    AssertValid
    Rebind
    operator=
    get
    Find
    RFind
    RFindChar
    FindCharInSet
    RFindCharInSet
    Compare
    EqualsIgnoreCase
    ToFloat
    ToInteger
    Mid
    Left
    Right
    SetCharAt
    StripChars
    StripWhitespace
    ReplaceChar
    ReplaceSubstring
    Trim
    CompressWhitespace
    AssignWithConversion
    AppendWithConversion
    AppendInt
    AppendFloat
    BeginReading
    EndReading
    BeginWriting
    EndWriting
    Data
    Length
    IsEmpty
    IsVoid
    IsTerminated
    CharAt
    operator[]
    First
    Last
    CountChar
    FindChar
    Equals
    EqualsASCII
    EqualsLiteral(const char
    EqualsLiteral(char
    LowerCaseEqualsASCII
    LowerCaseEqualsLiteral(const char
    LowerCaseEqualsLiteral(char
    Assign
    AssignASCII
    AssignLiteral(const char
    AssignLiteral(char
    Adopt
    Replace
    ReplaceASCII
    Append
    AppendASCII
    AppendLiteral(const char
    AppendLiteral(char
    operator+=
    Insert
    Cut
    SetCapacity
    SetLength
    Truncate
    GetData
    GetMutableData
    SetIsVoid
    StripChar

    Base Classes

    Data Members

    No public members.

    Methods

    Constructors

    nsDependentCString(const char*, const char*) - source

    Parameters

    char* start
    A pointer to the start of the string. Must not be null.
    char* end
    A pointer to the string's null terminator. Must not be null.
    nsDependentCString(const char*, PRUint32) - source

    Parameters

    char* data
    A pointer to the string. Must not be null.
    PRUint32 length
    The length of the string.
    nsDependentCString(const char*) - source
    Constructs an nsDependentString when you don't know the length in advance. Instead NS_strlen is used to measure the length.

    Parameters

    char* data
    A pointer to the string. Must not be null.
    nsDependentCString(const nsCString_internal&, PRUint32)
    Constructs an nsDependentString from an existing flat string.

    Parameters

    nsCString_internal& str
    The existing flat string.
    PRUint32 startPos
    The position within the existing string at which the dependent string should start. This is similar to using Substring(str, startPos), except that the resulting string is flat.
    void nsDependentCString() - source
    Constructs an nsDependentString to be rebound later.
    nsDependentCString(const nsACString_internal&) - source
    Obsolete in Gecko 9. This constructor should not be used.

    Parameters

    nsACString_internal& str

    AssertValid

    void AssertValid() - source
    verify restrictions

    Rebind

    void Rebind(const char*) - source
    allow this class to be bound to a different string...

    Parameters

    • char* data
    void Rebind(const char*, PRUint32) - source

    Parameters

    • char* data
    • PRUint32 length
    void Rebind(const char*, const char*) - source

    Parameters

    • char* start
    • char* end

    operator=

    nsCString& operator=(const nsCString&) - source

    Parameters

    • nsCString& str
    nsACString_internal& operator=(char) - source

    Parameters

    • char c
    nsACString_internal& operator=(const char*) - source

    Parameters

    • char* data
    nsACString_internal& operator=(const nsACString_internal&) - source

    Parameters

    • nsACString_internal& str
    nsACString_internal& operator=(const nsCSubstringTuple&) - source

    Parameters

    • nsCSubstringTuple& tuple

    get

    char* get() const - source
    returns the null-terminated string

    Find

    PRInt32 Find(const nsCString&, PRBool, PRInt32, PRInt32) const - source
    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

    Parameters

    • nsCString& aString
    • PRBool aIgnoreCase
    • PRInt32 aOffset
    • PRInt32 aCount
    PRInt32 Find(const char*, PRBool, PRInt32, PRInt32) const - source

    Parameters

    • char* aString
    • PRBool aIgnoreCase
    • PRInt32 aOffset
    • PRInt32 aCount

    RFind

    PRInt32 RFind(const nsCString&, PRBool, PRInt32, PRInt32) const - source
    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

    Parameters

    • nsCString& aString
    • PRBool aIgnoreCase
    • PRInt32 aOffset
    • PRInt32 aCount
    PRInt32 RFind(const char*, PRBool, PRInt32, PRInt32) const - source

    Parameters

    • char* aCString
    • PRBool aIgnoreCase
    • PRInt32 aOffset
    • PRInt32 aCount

    RFindChar

    PRInt32 RFindChar(PRUnichar, PRInt32, PRInt32) const - source

    Parameters

    • PRUnichar aChar
    • PRInt32 aOffset
    • PRInt32 aCount

    FindCharInSet

    PRInt32 FindCharInSet(const char*, PRInt32) const - source
    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

    Parameters

    • char* aString
    • PRInt32 aOffset
    PRInt32 FindCharInSet(const nsCString&, PRInt32) const - source

    Parameters

    • nsCString& aString
    • PRInt32 aOffset

    RFindCharInSet

    PRInt32 RFindCharInSet(const char*, PRInt32) const - source
    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

    Parameters

    • char* aString
    • PRInt32 aOffset
    PRInt32 RFindCharInSet(const nsCString&, PRInt32) const - source

    Parameters

    • nsCString& aString
    • PRInt32 aOffset

    Compare

    PRInt32 Compare(const char*, PRBool, PRInt32) const - source
    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

    Parameters

    • char* aString
    • PRBool aIgnoreCase
    • PRInt32 aCount

    EqualsIgnoreCase

    PRBool EqualsIgnoreCase(const char*, PRInt32) const - source
    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

    Parameters

    • char* aString
    • PRInt32 aCount

    ToFloat

    float ToFloat(PRInt32*) const - source
    Perform string to float conversion.
    
    @param   aErrorCode will contain error if one occurs
    @return  float rep of string value

    Parameters

    • PRInt32* aErrorCode

    ToInteger

    PRInt32 ToInteger(PRInt32*, PRUint32) const - source

    Parameters

    • PRInt32* aErrorCode
    • PRUint32 aRadix

    Mid

    PRUint32 Mid(nsCString&, PRUint32, PRUint32) const - source

    Parameters

    • nsCString& aResult
    • PRUint32 aStartPos
    • PRUint32 aCount

    Left

    PRUint32 Left(nsCString&, PRUint32) const - source

    Parameters

    • nsCString& aResult
    • PRUint32 aCount
    PRUint32 Right(nsCString&, PRUint32) const - source

    Parameters

    • nsCString& aResult
    • PRUint32 aCount

    SetCharAt

    PRBool SetCharAt(PRUnichar, PRUint32) - source
    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

    Parameters

    • PRUnichar aChar
    • PRUint32 aIndex

    StripChars

    void StripChars(const char*) - source
    These methods are used to remove all occurrences of the
    characters found in aSet from this string.
    
    @param  aSet -- characters to be cut from this

    Parameters

    • char* aSet

    StripWhitespace

    void StripWhitespace() - source
    This method strips whitespace throughout the string.

    ReplaceChar

    void ReplaceChar(char, char) - source
    swaps occurence of 1 string for another

    Parameters

    • char aOldChar
    • char aNewChar
    void ReplaceChar(const char*, char) - source

    Parameters

    • char* aSet
    • char aNewChar

    ReplaceSubstring

    void ReplaceSubstring(const nsCString&, const nsCString&) - source

    Parameters

    • nsCString& aTarget
    • nsCString& aNewValue
    void ReplaceSubstring(const char*, const char*) - source

    Parameters

    • char* aTarget
    • char* aNewValue

    Trim

    void Trim(const char*, PRBool, PRBool, PRBool) - source
    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

    Parameters

    • char* aSet
    • PRBool aEliminateLeading
    • PRBool aEliminateTrailing
    • PRBool aIgnoreQuotes

    CompressWhitespace

    void CompressWhitespace(PRBool, PRBool) - source
    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

    Parameters

    • PRBool aEliminateLeading
    • PRBool aEliminateTrailing

    AssignWithConversion

    void AssignWithConversion(const nsAString_internal&) - source
    assign/append/insert with _LOSSY_ conversion

    Parameters

    • nsAString_internal& aString
    void AssignWithConversion(const PRUnichar*, PRInt32) - source

    Parameters

    • PRUnichar* aData
    • PRInt32 aLength

    AppendWithConversion

    void AppendWithConversion(const nsAString_internal&) - source

    Parameters

    • nsAString_internal& aString
    void AppendWithConversion(const PRUnichar*, PRInt32) - source

    Parameters

    • PRUnichar* aData
    • PRInt32 aLength

    AppendInt

    void AppendInt(PRInt32, PRInt32) - source
    Append the given integer to this string

    Parameters

    • PRInt32 aInteger
    • PRInt32 aRadix
    void AppendInt(PRUint32, PRInt32) - source
    Append the given unsigned integer to this string

    Parameters

    • PRUint32 aInteger
    • PRInt32 aRadix
    void AppendInt(PRInt64, PRInt32) - source

    Parameters

    • PRInt64 aInteger
    • PRInt32 aRadix

    AppendFloat

    void AppendFloat(float) - source
    Append the given float to this string

    Parameters

    • float aFloat
    void AppendFloat(double) - source

    Parameters

    • double aFloat

    BeginReading

    char* BeginReading() const - source
    reading iterators
    nsReadingIterator<char>& BeginReading(nsReadingIterator<char>&) const - source
    deprecated reading iterators

    Parameters

    • nsReadingIterator<char>& iter
    char*& BeginReading(const char*&) const - source

    Parameters

    • char*& iter

    EndReading

    char* EndReading() const - source
    nsReadingIterator<char>& EndReading(nsReadingIterator<char>&) const - source

    Parameters

    • nsReadingIterator<char>& iter
    char*& EndReading(const char*&) const - source

    Parameters

    • char*& iter

    BeginWriting

    char* BeginWriting() - source
    writing iterators
    nsWritingIterator<char>& BeginWriting(nsWritingIterator<char>&) - source
    deprecated writing iterators

    Parameters

    • nsWritingIterator<char>& iter
    char*& BeginWriting(char*&) - source

    Parameters

    • char*& iter

    EndWriting

    char* EndWriting() - source
    nsWritingIterator<char>& EndWriting(nsWritingIterator<char>&) - source

    Parameters

    • nsWritingIterator<char>& iter
    char*& EndWriting(char*&) - source

    Parameters

    • char*& iter

    Data

    char* Data() const - source
    accessors

    Length

    PRUint32 Length() const - source

    IsEmpty

    PRBool IsEmpty() const - source

    IsVoid

    PRBool IsVoid() const - source

    IsTerminated

    PRBool IsTerminated() const - source

    CharAt

    char CharAt(PRUint32) const - source

    Parameters

    • PRUint32 i

    operator[]

    char operator[](PRUint32) const - source

    Parameters

    • PRUint32 i

    First

    char First() const - source

    Last

    char Last() const - source

    CountChar

    PRUint32 CountChar(char) const - source

    Parameters

    • char <anonymous>

    FindChar

    PRInt32 FindChar(char, PRUint32) const - source

    Parameters

    • char <anonymous>
    • PRUint32 offset

    Equals

    PRBool Equals(const nsACString_internal&) const - source
    equality

    Parameters

    • nsACString_internal& <anonymous>
    PRBool Equals(const nsACString_internal&, const nsCStringComparator&) const - source

    Parameters

    • nsACString_internal& <anonymous>
    • nsCStringComparator& <anonymous>
    PRBool Equals(const char*) const - source

    Parameters

    • char* data
    PRBool Equals(const char*, const nsCStringComparator&) const - source

    Parameters

    • char* data
    • nsCStringComparator& comp

    EqualsASCII

    PRBool EqualsASCII(const char*, PRUint32) const - source
    An efficient comparison with ASCII that can be used even
    for wide strings. Call this version when you know the
    length of 'data'.

    Parameters

    • char* data
    • PRUint32 len
    PRBool EqualsASCII(const char*) const - source
    An efficient comparison with ASCII that can be used even
    for wide strings. Call this version when 'data' is
    null-terminated.

    Parameters

    • char* data

    EqualsLiteral(const char

    PRBool EqualsLiteral(const char (&)[N]) const - source

    EqualsLiteral(char

    PRBool EqualsLiteral(char (&)[N]) const - source

    LowerCaseEqualsASCII

    PRBool LowerCaseEqualsASCII(const char*, PRUint32) const - source

    Parameters

    • char* data
    • PRUint32 len
    PRBool LowerCaseEqualsASCII(const char*) const - source

    Parameters

    • char* data

    LowerCaseEqualsLiteral(const char

    PRBool LowerCaseEqualsLiteral(const char (&)[N]) const - source

    LowerCaseEqualsLiteral(char

    PRBool LowerCaseEqualsLiteral(char (&)[N]) const - source

    Assign

    void Assign(char) - source
    assignment

    Parameters

    • char c
    void Assign(const char*, PRUint32) - source

    Parameters

    • char* data
    • PRUint32 length
    void Assign(const nsACString_internal&) - source

    Parameters

    • nsACString_internal& <anonymous>
    void Assign(const nsCSubstringTuple&) - source

    Parameters

    • nsCSubstringTuple& <anonymous>

    AssignASCII

    void AssignASCII(const char*, PRUint32) - source

    Parameters

    • char* data
    • PRUint32 length
    void AssignASCII(const char*) - source

    Parameters

    • char* data

    AssignLiteral(const char

    void AssignLiteral(const char (&)[N]) - source

    AssignLiteral(char

    void AssignLiteral(char (&)[N]) - source

    Adopt

    void Adopt(char*, PRUint32) - source

    Parameters

    • char* data
    • PRUint32 length

    Replace

    void Replace(PRUint32, PRUint32, char) - source
    buffer manipulation

    Parameters

    • PRUint32 cutStart
    • PRUint32 cutLength
    • char c
    void Replace(PRUint32, PRUint32, const char*, PRUint32) - source

    Parameters

    • PRUint32 cutStart
    • PRUint32 cutLength
    • char* data
    • PRUint32 length
    void Replace(PRUint32, PRUint32, const nsACString_internal&) - source

    Parameters

    • PRUint32 cutStart
    • PRUint32 cutLength
    • nsACString_internal& str
    void Replace(PRUint32, PRUint32, const nsCSubstringTuple&) - source

    Parameters

    • PRUint32 cutStart
    • PRUint32 cutLength
    • nsCSubstringTuple& tuple

    ReplaceASCII

    void ReplaceASCII(PRUint32, PRUint32, const char*, PRUint32) - source

    Parameters

    • PRUint32 cutStart
    • PRUint32 cutLength
    • char* data
    • PRUint32 length

    Append

    void Append(char) - source

    Parameters

    • char c
    void Append(const char*, PRUint32) - source

    Parameters

    • char* data
    • PRUint32 length
    void Append(const nsACString_internal&) - source

    Parameters

    • nsACString_internal& str
    void Append(const nsCSubstringTuple&) - source

    Parameters

    • nsCSubstringTuple& tuple

    AppendASCII

    void AppendASCII(const char*, PRUint32) - source

    Parameters

    • char* data
    • PRUint32 length

    AppendLiteral(const char

    void AppendLiteral(const char (&)[N]) - source

    AppendLiteral(char

    void AppendLiteral(char (&)[N]) - source

    operator+=

    nsACString_internal& operator+=(char) - source

    Parameters

    • char c
    nsACString_internal& operator+=(const char*) - source

    Parameters

    • char* data
    nsACString_internal& operator+=(const nsACString_internal&) - source

    Parameters

    • nsACString_internal& str
    nsACString_internal& operator+=(const nsCSubstringTuple&) - source

    Parameters

    • nsCSubstringTuple& tuple

    Insert

    void Insert(char, PRUint32) - source

    Parameters

    • char c
    • PRUint32 pos
    void Insert(const char*, PRUint32, PRUint32) - source

    Parameters

    • char* data
    • PRUint32 pos
    • PRUint32 length
    void Insert(const nsACString_internal&, PRUint32) - source

    Parameters

    • nsACString_internal& str
    • PRUint32 pos
    void Insert(const nsCSubstringTuple&, PRUint32) - source

    Parameters

    • nsCSubstringTuple& tuple
    • PRUint32 pos

    Cut

    void Cut(PRUint32, PRUint32) - source

    Parameters

    • PRUint32 cutStart
    • PRUint32 cutLength

    SetCapacity

    void SetCapacity(PRUint32) - source
    buffer sizing

    Parameters

    • PRUint32 newCapacity

    SetLength

    void SetLength(PRUint32) - source

    Parameters

    • PRUint32 newLength

    Truncate

    void Truncate(PRUint32) - source

    Parameters

    • PRUint32 newLength

    GetData

    PRUint32 GetData(const char**) const - source
    Get a const pointer to the string's internal buffer.  The caller
    MUST NOT modify the characters at the returned address.
    
    @returns The length of the buffer in characters.

    Parameters

    • char** data

    GetMutableData

    PRUint32 GetMutableData(char**, PRUint32) - source
    Get a pointer to the string's internal buffer, optionally resizing
    the buffer first.  If size_type(-1) is passed for newLen, then the
    current length of the string is used.  The caller MAY modify the
    characters at the returned address (up to but not exceeding the
    length of the string).
    
    @returns The length of the buffer in characters or 0 if unable to
    satisfy the request due to low-memory conditions.

    Parameters

    • char** data
    • PRUint32 newLen

    SetIsVoid

    void SetIsVoid(PRBool) - source
    string data is never null, but can be marked void.  if true, the
    string will be truncated.  @see nsTSubstring::IsVoid

    Parameters

    • PRBool <anonymous>

    StripChar

    void StripChar(char, PRInt32) - source
    This method is used to remove all occurrences of aChar from this
    string.
    
    @param  aChar -- char to be stripped
    @param  aOffset -- where in this string to start stripping chars

    Parameters

    • char aChar
    • PRInt32 aOffset

    Document Tags and Contributors

    Contributors to this page: BenjaminSmedberg, Sheppy, Neil
    Last updated by: Sheppy,