Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
nsUnicharUtils.cpp File Reference
#include "nsString.h"
#include "nsUnicharUtils.h"
#include "nsUnicharUtilCIID.h"
#include "nsICaseConversion.h"
#include "nsIServiceManager.h"
#include "nsCRT.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"

Go to the source code of this file.

Classes

class  nsShutdownObserver
class  ConvertToLowerCase
 A character sink for case conversion. More...
class  CopyToLowerCase
 A character sink for copying with case conversion. More...
class  ConvertToUpperCase
 A character sink for in-place case conversion. More...
class  CopyToUpperCase
 A character sink for copying with case conversion. More...

Functions

static nsresult NS_InitCaseConversion ()
void ToLowerCase (nsASingleFragmentString &aString)
void ToLowerCase (nsString &aString)
void ToLowerCase (const nsAString &aSource, nsAString &aDest)
void ToUpperCase (nsASingleFragmentString &aString)
void ToUpperCase (nsString &aString)
void ToUpperCase (const nsAString &aSource, nsAString &aDest)
PRUnichar ToLowerCase (PRUnichar aChar)
PRUnichar ToUpperCase (PRUnichar aChar)

Variables

static nsICaseConversiongCaseConv = nsnull

Function Documentation

static nsresult NS_InitCaseConversion ( ) [static]

Definition at line 73 of file nsUnicharUtils.cpp.

                                        {
    if (gCaseConv) return NS_OK;

    nsresult rv;
    
    rv = CallGetService(NS_UNICHARUTIL_CONTRACTID, &gCaseConv);

    if (NS_SUCCEEDED(rv)) {
        nsCOMPtr<nsIObserverService> obs =
            do_GetService("@mozilla.org/observer-service;1", &rv);
        if (NS_SUCCEEDED(rv)) {
            nsShutdownObserver *observer = new nsShutdownObserver();
            if (observer)
                obs->AddObserver(observer, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
        }
    }
    
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 125 of file nsUnicharUtils.cpp.

  {
    ConvertToLowerCase converter;
    PRUnichar* start;
    converter.write(aString.BeginWriting(start), aString.Length());
  }

Here is the call graph for this function:

void ToLowerCase ( nsString aString)

Definition at line 133 of file nsUnicharUtils.cpp.

  {
    ConvertToLowerCase converter;
    PRUnichar* start;
    converter.write(aString.BeginWriting(start), aString.Length());
  }

Here is the call graph for this function:

void ToLowerCase ( const nsAString &  aSource,
nsAString &  aDest 
)

Definition at line 170 of file nsUnicharUtils.cpp.

  {
    nsAString::const_iterator fromBegin, fromEnd;
    nsAString::iterator toBegin;
    // FIXME: need way to return error
    if (!EnsureStringLength(aDest, aSource.Length())) {
      aDest.Truncate();
      return; // out of memory
    }
    CopyToLowerCase converter(aDest.BeginWriting(toBegin));
    copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter);
  }

Here is the call graph for this function:

Definition at line 314 of file nsUnicharUtils.cpp.

{
    PRUnichar result;
    if (NS_FAILED(NS_InitCaseConversion()))
        return aChar;

    if (gCaseConv)
        gCaseConv->ToLower(aChar, &result);
    else {
        NS_WARNING("No case converter: no conversion done");
        if (aChar < 256)
            result = tolower(char(aChar));
        else
            result = aChar;
    }
    return result;
}

Here is the call graph for this function:

Definition at line 215 of file nsUnicharUtils.cpp.

  {
    ConvertToUpperCase converter;
    PRUnichar* start;
    converter.write(aString.BeginWriting(start), aString.Length());
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void ToUpperCase ( nsString aString)

Definition at line 223 of file nsUnicharUtils.cpp.

  {
    ConvertToUpperCase converter;
    PRUnichar* start;
    converter.write(aString.BeginWriting(start), aString.Length());
  }

Here is the call graph for this function:

void ToUpperCase ( const nsAString &  aSource,
nsAString &  aDest 
)

Definition at line 260 of file nsUnicharUtils.cpp.

  {
    nsAString::const_iterator fromBegin, fromEnd;
    nsAString::iterator toBegin;
    // FIXME: need way to return error
    if (!EnsureStringLength(aDest, aSource.Length())) {
      aDest.Truncate();
      return; // out of memory
    }
    CopyToUpperCase converter(aDest.BeginWriting(toBegin));
    copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter);
  }

Here is the call graph for this function:

Definition at line 333 of file nsUnicharUtils.cpp.

{
    PRUnichar result;
    if (NS_FAILED(NS_InitCaseConversion()))
        return aChar;

    if (gCaseConv)
        gCaseConv->ToUpper(aChar, &result);
    else {
        NS_WARNING("No case converter: no conversion done");
        if (aChar < 256)
            result = toupper(char(aChar));
        else
            result = aChar;
    }
    return result;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 50 of file nsUnicharUtils.cpp.