Back to index

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

#include <nsCharTraits.h>

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

List of all members.

Public Types

typedef char char_type
typedef unsigned char unsigned_char_type
typedef PRUnichar 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 c 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 = (const char*) &gNullChar

Detailed Description

Definition at line 395 of file nsCharTraits.h.


Member Typedef Documentation

typedef char nsCharTraits< char >::char_type

Definition at line 397 of file nsCharTraits.h.

Definition at line 399 of file nsCharTraits.h.

typedef int nsCharTraits< char >::int_type

Definition at line 413 of file nsCharTraits.h.

typedef unsigned char nsCharTraits< char >::unsigned_char_type

Definition at line 398 of file nsCharTraits.h.


Member Function Documentation

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

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

Definition at line 533 of file nsCharTraits.h.

      {
        return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c;
      }
static void nsCharTraits< char >::assign ( char_type lhs,
char_type  rhs 
) [inline, static]

Definition at line 405 of file nsCharTraits.h.

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

Definition at line 479 of file nsCharTraits.h.

Here is the call graph for this function:

static int nsCharTraits< char >::compare ( const char_type s1,
const char_type s2,
size_t  n 
) [inline, static]

Definition at line 486 of file nsCharTraits.h.

      {
        return memcmp(s1, s2, n);
      }

Here is the call graph for this function:

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

Definition at line 493 of file nsCharTraits.h.

      {
#ifdef DEBUG
        for (size_t i = 0; i < n; ++i)
          {
            NS_ASSERTION(!(s2[i] & ~0x7F), "Unexpected non-ASCII character");
          }
#endif
        return compare(s1, s2, n);
      }

Here is the call graph for this function:

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

Definition at line 509 of file nsCharTraits.h.

      {
        // can't use strcmp here because we don't want to stop when s1
        // contains a null
        for ( ; n--; ++s1, ++s2 )
          {
            if ( !*s2 )
              return 1;
            NS_ASSERTION(!(*s2 & ~0x7F), "Unexpected non-ASCII character");
            if ( *s1 != *s2 )
              return to_int_type(*s1) - to_int_type(*s2);
          }

        if ( *s2 )
          return -1;

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

Definition at line 540 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 != *s2 )
              return to_int_type(lower_s1) - to_int_type(*s2);
          }
        return 0;
      }
static int nsCharTraits< char >::compareLowerCaseToASCIINullTerminated ( const char_type s1,
size_t  n,
const char *  s2 
) [inline, static]

Definition at line 559 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 != *s2 )
              return to_int_type(lower_s1) - to_int_type(*s2);
          }

        if ( *s2 )
          return -1;

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

Definition at line 465 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< char >::copyASCII ( char_type s1,
const char *  s2,
size_t  n 
) [inline, static]

Definition at line 472 of file nsCharTraits.h.

      {
        return copy(s1, s2, n);
      }

Here is the call graph for this function:

static nsCharTraits_bool nsCharTraits< char >::eq ( char_type  lhs,
char_type  rhs 
) [inline, static]

Definition at line 441 of file nsCharTraits.h.

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

Definition at line 431 of file nsCharTraits.h.

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

Definition at line 588 of file nsCharTraits.h.

      {
        return NS_REINTERPRET_CAST(const char_type*, memchr(s, to_int_type(c), n));
      }
static size_t nsCharTraits< char >::length ( const char_type s) [inline, static]

Definition at line 581 of file nsCharTraits.h.

      {
        return strlen(s);
      }
static nsCharTraits_bool nsCharTraits< char >::lt ( char_type  lhs,
char_type  rhs 
) [inline, static]

Definition at line 448 of file nsCharTraits.h.

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

Definition at line 458 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< char >::to_char_type ( int_type  c) [inline, static]

Definition at line 417 of file nsCharTraits.h.

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

Definition at line 424 of file nsCharTraits.h.


Member Data Documentation

const char * nsCharTraits< char >::sEmptyBuffer = (const char*) &gNullChar [static]

Definition at line 401 of file nsCharTraits.h.


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