Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Static Public Member Functions | Static Public Attributes
nsCharTraits< PRUnichar > Struct Reference

#include <nsCharTraits.h>

Collaboration diagram for nsCharTraits< PRUnichar >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef PRUnichar char_type
typedef PRUint16 unsigned_char_type
typedef char incompatible_char_type
typedef int int_type

Static Public Member Functions

static void assign (char_type &lhs, char_type rhs)
static char_type to_char_type (int_type c)
static int_type to_int_type (char_type c)
static nsCharTraits_bool eq_int_type (int_type lhs, int_type rhs)
static nsCharTraits_bool eq (char_type lhs, char_type rhs)
static nsCharTraits_bool lt (char_type lhs, char_type rhs)
static char_typemove (char_type *s1, const char_type *s2, size_t n)
static char_typecopy (char_type *s1, const char_type *s2, size_t n)
static char_typecopyASCII (char_type *s1, const char *s2, size_t n)
static char_typeassign (char_type *s, size_t n, char_type c)
static int compare (const char_type *s1, const char_type *s2, size_t n)
static int compareASCII (const char_type *s1, const char *s2, size_t n)
static int compareASCIINullTerminated (const char_type *s1, size_t n, const char *s2)
static char_type ASCIIToLower (char_type c)
 Convert c to its lower-case form, but only if the lower-case form is ASCII.
static int compareLowerCaseToASCII (const char_type *s1, const char *s2, size_t n)
static int compareLowerCaseToASCIINullTerminated (const char_type *s1, size_t n, const char *s2)
static size_t length (const char_type *s)
static const char_typefind (const char_type *s, size_t n, char_type c)

Static Public Attributes

static NS_COM const char_typesEmptyBuffer = &gNullChar

Detailed Description

Definition at line 110 of file nsCharTraits.h.


Member Typedef Documentation

Definition at line 112 of file nsCharTraits.h.

Definition at line 114 of file nsCharTraits.h.

Definition at line 131 of file nsCharTraits.h.

Definition at line 113 of file nsCharTraits.h.


Member Function Documentation

static char_type nsCharTraits< PRUnichar >::ASCIIToLower ( char_type  c) [inline, static]

Convert c to its lower-case form, but only if the lower-case form is ASCII.

Otherwise leave it alone.

There are only two non-ASCII Unicode characters whose lowercase equivalents are ASCII: KELVIN SIGN and LATIN CAPITAL LETTER I WITH DOT ABOVE. So it's a simple matter to handle those explicitly.

Definition at line 277 of file nsCharTraits.h.

      {
        if (c < 0x100)
          return (c >= 'A' && c <= 'Z') ? c + ('a' - 'A') : c;
        else
          {
            if (c == 0x212A) // KELVIN SIGN
              return 'k';
            if (c == 0x0130) // LATIN CAPITAL LETTER I WITH DOT ABOVE
              return 'i';
            return c;
          }
      }
static void nsCharTraits< PRUnichar >::assign ( char_type lhs,
char_type  rhs 
) [inline, static]

Definition at line 120 of file nsCharTraits.h.

      {
        lhs = rhs;
      }
static char_type* nsCharTraits< PRUnichar >::assign ( char_type s,
size_t  n,
char_type  c 
) [inline, static]

Definition at line 202 of file nsCharTraits.h.

      {
#ifdef USE_CPP_WCHAR_FUNCS
        return NS_STATIC_CAST(char_type*, wmemset(s, to_int_type(c), n));
#else
        char_type* result = s;
        while ( n-- )
          assign(*s++, c);
        return result;
#endif
      }
static int nsCharTraits< PRUnichar >::compare ( const char_type s1,
const char_type s2,
size_t  n 
) [inline, static]

Definition at line 216 of file nsCharTraits.h.

      {
#ifdef USE_CPP_WCHAR_FUNCS
        return wmemcmp(s1, s2, n);
#else
        for ( ; n--; ++s1, ++s2 )
          {
            if ( !eq(*s1, *s2) )
              return to_int_type(*s1) - to_int_type(*s2);
          }

        return 0;
#endif
      }
static int nsCharTraits< PRUnichar >::compareASCII ( const char_type s1,
const char *  s2,
size_t  n 
) [inline, static]

Definition at line 233 of file nsCharTraits.h.

      {
        for ( ; n--; ++s1, ++s2 )
          {
            NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
            if ( !eq_int_type(to_int_type(*s1), to_int_type(*s2)) )
              return to_int_type(*s1) - to_int_type(*s2);
          }

        return 0;
      }
static int nsCharTraits< PRUnichar >::compareASCIINullTerminated ( const char_type s1,
size_t  n,
const char *  s2 
) [inline, static]

Definition at line 250 of file nsCharTraits.h.

      {
        for ( ; n--; ++s1, ++s2 )
          {
            if ( !*s2 )
              return 1;
            NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
            if ( !eq_int_type(to_int_type(*s1), to_int_type(*s2)) )
              return to_int_type(*s1) - to_int_type(*s2);
          }

        if ( *s2 )
          return -1;

        return 0;
      }
static int nsCharTraits< PRUnichar >::compareLowerCaseToASCII ( const char_type s1,
const char *  s2,
size_t  n 
) [inline, static]

Definition at line 293 of file nsCharTraits.h.

      {
        for ( ; n--; ++s1, ++s2 )
          {
            NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
            NS_ASSERTION(!(*s2 >= 'A' && *s2 <= 'Z'),
                         "Unexpected uppercase character");
            char_type lower_s1 = ASCIIToLower(*s1);
            if ( lower_s1 != to_char_type(*s2) )
              return to_int_type(lower_s1) - to_int_type(*s2);
          }

        return 0;
      }
static int nsCharTraits< PRUnichar >::compareLowerCaseToASCIINullTerminated ( const char_type s1,
size_t  n,
const char *  s2 
) [inline, static]

Definition at line 313 of file nsCharTraits.h.

      {
        for ( ; n--; ++s1, ++s2 )
          {
            if ( !*s2 )
              return 1;
            NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
            NS_ASSERTION(!(*s2 >= 'A' && *s2 <= 'Z'),
                         "Unexpected uppercase character");
            char_type lower_s1 = ASCIIToLower(*s1);
            if ( lower_s1 != to_char_type(*s2) )
              return to_int_type(lower_s1) - to_int_type(*s2);
          }

        if ( *s2 )
          return -1;

        return 0;
      }
static char_type* nsCharTraits< PRUnichar >::copy ( char_type s1,
const char_type s2,
size_t  n 
) [inline, static]

Definition at line 184 of file nsCharTraits.h.

      {
        return NS_STATIC_CAST(char_type*, memcpy(s1, s2, n * sizeof(char_type)));
      }

Here is the call graph for this function:

static char_type* nsCharTraits< PRUnichar >::copyASCII ( char_type s1,
const char *  s2,
size_t  n 
) [inline, static]

Definition at line 191 of file nsCharTraits.h.

      {
        for (char_type* s = s1; n--; ++s, ++s2) {
          NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
          *s = *s2;
        }
        return s1;
      }
static nsCharTraits_bool nsCharTraits< PRUnichar >::eq ( char_type  lhs,
char_type  rhs 
) [inline, static]

Definition at line 160 of file nsCharTraits.h.

      {
        return lhs == rhs;
      }
static nsCharTraits_bool nsCharTraits< PRUnichar >::eq_int_type ( int_type  lhs,
int_type  rhs 
) [inline, static]

Definition at line 150 of file nsCharTraits.h.

      {
        return lhs == rhs;
      }
static const char_type* nsCharTraits< PRUnichar >::find ( const char_type s,
size_t  n,
char_type  c 
) [inline, static]

Definition at line 349 of file nsCharTraits.h.

      {
#ifdef USE_CPP_WCHAR_FUNCS
        return NS_REINTERPRET_CAST(const char_type*, wmemchr(s, to_int_type(c), n));
#else
        while ( n-- )
          {
            if ( eq(*s, c) )
              return s;
            ++s;
          }

        return 0;
#endif
      }
static size_t nsCharTraits< PRUnichar >::length ( const char_type s) [inline, static]

Definition at line 335 of file nsCharTraits.h.

      {
#ifdef USE_CPP_WCHAR_FUNCS
        return wcslen(s);
#else
        size_t result = 0;
        while ( !eq(*s++, char_type(0)) )
          ++result;
        return result;
#endif
      }
static nsCharTraits_bool nsCharTraits< PRUnichar >::lt ( char_type  lhs,
char_type  rhs 
) [inline, static]

Definition at line 167 of file nsCharTraits.h.

      {
        return lhs < rhs;
      }
static char_type* nsCharTraits< PRUnichar >::move ( char_type s1,
const char_type s2,
size_t  n 
) [inline, static]

Definition at line 177 of file nsCharTraits.h.

      {
        return NS_STATIC_CAST(char_type*, memmove(s1, s2, n * sizeof(char_type)));
      }

Here is the call graph for this function:

static char_type nsCharTraits< PRUnichar >::to_char_type ( int_type  c) [inline, static]

Definition at line 136 of file nsCharTraits.h.

      {
        return char_type(c);
      }
static int_type nsCharTraits< PRUnichar >::to_int_type ( char_type  c) [inline, static]

Definition at line 143 of file nsCharTraits.h.


Member Data Documentation

Definition at line 116 of file nsCharTraits.h.


The documentation for this struct was generated from the following files: