Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions
NSString Class Reference

List of all members.

Public Member Functions

(void- assignTo_nsAString: [implementation]
(NSString *) - stringByRemovingCharactersInSet: [implementation]
(NSString *) - stringByReplacingCharactersInSet:withString: [implementation]
(NSString *) - stringByTruncatingTo:at: [implementation]

Static Public Member Functions

(id+ ellipsisString [implementation]
(id+ stringWith_nsAString: [implementation]

Private Member Functions

(PRUnichar *) - createNewUnicodeBuffer [implementation]

Static Private Member Functions

(id+ stringWithPRUnichars: [implementation]

Detailed Description

Definition at line 47 of file NSString+Utils.mm.


Member Function Documentation

- (void) assignTo_nsAString: (nsAString&)  ioString [implementation]

Definition at line 78 of file NSString+Utils.mm.

                          :(nsAString&)ioString
{
  PRUnichar     stackBuffer[ASSIGN_STACK_BUFFER_CHARACTERS];
  PRUnichar*    buffer = stackBuffer;
  
  // XXX maybe fix this to use SetLength(0), SetLength(len), and a writing iterator.
  unsigned int len = [self length];
  
  if (len + 1 > ASSIGN_STACK_BUFFER_CHARACTERS)
  {
    buffer = (PRUnichar *)malloc(sizeof(PRUnichar) * (len + 1));
    if (!buffer)
      return;
  }

  [self getCharacters: buffer];   // does not null terminate
  ioString.Assign(buffer, len);
  
  if (buffer != stackBuffer)
    free(buffer);
}
- (PRUnichar *) createNewUnicodeBuffer [implementation]

Definition at line 147 of file NSString+Utils.mm.

{
  PRUint32 length = [self length];
  PRUnichar* retStr = (PRUnichar*)nsMemory::Alloc((length + 1) * sizeof(PRUnichar));
  [self getCharacters:retStr];
  retStr[length] = PRUnichar(0);
  return retStr;
}

Here is the call graph for this function:

+ (id) ellipsisString [implementation]

Definition at line 50 of file NSString+Utils.mm.

{
  static NSString* sEllipsisString = nil;
  if (!sEllipsisString)
  {
    unichar ellipsisChar = 0x2026;
    sEllipsisString = [[NSString alloc] initWithCharacters:&ellipsisChar length:1];
  }
  
  return sEllipsisString;
}

Here is the caller graph for this function:

- (NSString *) stringByRemovingCharactersInSet: (NSCharacterSet*)  characterSet [implementation]

Definition at line 100 of file NSString+Utils.mm.

                                             :(NSCharacterSet*)characterSet
{
  NSScanner*       cleanerScanner = [NSScanner scannerWithString:self];
  NSMutableString* cleanString    = [NSMutableString stringWithCapacity:[self length]];
  
  while (![cleanerScanner isAtEnd])
  {
    NSString* stringFragment;
    if ([cleanerScanner scanUpToCharactersFromSet:characterSet intoString:&stringFragment])
      [cleanString appendString:stringFragment];

    [cleanerScanner scanCharactersFromSet:characterSet intoString:nil];
  }

  return cleanString;
}
- (NSString *) stringByReplacingCharactersInSet: (NSCharacterSet*)  characterSet
withString: (NSString*)  string 
[implementation]

Definition at line 117 of file NSString+Utils.mm.

                                              :(NSCharacterSet*)characterSet withString:(NSString*)string
{
  NSScanner*       cleanerScanner = [NSScanner scannerWithString:self];
  NSMutableString* cleanString    = [NSMutableString stringWithCapacity:[self length]];
  
  while (![cleanerScanner isAtEnd])
  {
    NSString* stringFragment;
    if ([cleanerScanner scanUpToCharactersFromSet:characterSet intoString:&stringFragment])
      [cleanString appendString:stringFragment];

    if ([cleanerScanner scanCharactersFromSet:characterSet intoString:nil])
      [cleanString appendString:string];
  }

  return cleanString;
}
- (NSString *) stringByTruncatingTo: (unsigned in maxCharacters
at: (ETruncationType truncationType 
[implementation]

Definition at line 135 of file NSString+Utils.mm.

                                 :(unsigned in)maxCharacters at:(ETruncationType)truncationType
{
  if ([self length] > maxCharacters)
  {
    NSMutableString *mutableCopy = [self mutableCopy];
    [mutableCopy truncateTo:maxCharacters at:truncationType];
    return [mutableCopy autorelease];
  }

  return [[self copy] autorelease];
}

Here is the call graph for this function:

+ (id) stringWith_nsAString: (const nsAString&)  inString [implementation]

Definition at line 70 of file NSString+Utils.mm.

                          :(const nsAString&)inString
{
  nsPromiseFlatString flatString = PromiseFlatString(inString);
  return [self stringWithCharacters:flatString.get() length:flatString.Length()];
}

Here is the caller graph for this function:

+ (id) stringWithPRUnichars: (const PRUnichar*)  inString [implementation]

Definition at line 62 of file NSString+Utils.mm.

                          :(const PRUnichar*)inString
{
  if (inString)
    return [self stringWithCharacters:inString length:nsCRT::strlen(inString)];
  else
    return [self string];
}

The documentation for this class was generated from the following file: