Back to index

lightning-sunbird  0.9+nobinonly
nsID Struct Reference

A "unique identifier". More...

#include <nsID.h>

List of all members.

Public Member Functions

PRBool Equals (const nsID &other) const
 Equivalency method.
NS_COM_GLUE PRBool Parse (const char *aIDStr)
 nsID Parsing method.
NS_COM_GLUE char * ToString () const
 nsID string encoder.

Public Attributes

Indentifier values
PRUint32 m0
PRUint16 m1
PRUint16 m2
PRUint8 m3 [8]

Detailed Description

A "unique identifier".

This is modeled after OSF DCE UUIDs. FROZEN

Definition at line 52 of file nsID.h.

Member Function Documentation

PRBool nsID::Equals ( const nsID other) const [inline]

Equivalency method.

Compares this nsID with another.

PR_TRUE if they are the same, PR_FALSE if not.

Definition at line 74 of file nsID.h.

    // One would think that this could be done faster with a really
    // efficient implementation of memcmp(), but evidently no
    // memcmp()'s out there are better than this code.
    // See bug for
    // details.

    return (PRBool)
      ((((PRUint32*) &m0)[0] == ((PRUint32*) &other.m0)[0]) &&
       (((PRUint32*) &m0)[1] == ((PRUint32*) &other.m0)[1]) &&
       (((PRUint32*) &m0)[2] == ((PRUint32*) &other.m0)[2]) &&
       (((PRUint32*) &m0)[3] == ((PRUint32*) &other.m0)[3]));
PRBool nsID::Parse ( const char *  aIDStr)

nsID Parsing method.

Turns a {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} string into an nsID

Definition at line 93 of file nsID.cpp.

  /* Optimized for speed */
  if(!aIDStr) {
    return PR_FALSE;

  PRBool expectFormat1 = (aIDStr[0] == '{');
  if(expectFormat1) aIDStr++;

  PARSE_CHARS_TO_NUM(aIDStr, m0, 8);
  PARSE_CHARS_TO_NUM(aIDStr, m1, 4);
  PARSE_CHARS_TO_NUM(aIDStr, m2, 4);
  int i;
  for(i=0; i<2; i++)
    PARSE_CHARS_TO_NUM(aIDStr, m3[i], 2);
  while(i < 8) {
    PARSE_CHARS_TO_NUM(aIDStr, m3[i], 2);
  return expectFormat1 ? *aIDStr == '}' : PR_TRUE;

Here is the caller graph for this function:

char * nsID::ToString ( ) const

nsID string encoder.

Returns an allocated string in {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} format. Caller should free string.

Definition at line 127 of file nsID.cpp.

  char *res = (char*)PR_Malloc(39);    // use PR_Malloc if this is to be freed with nsCRT::free

  if (res != NULL) {
    PR_snprintf(res, 39, gIDFormat,
                m0, (PRUint32) m1, (PRUint32) m2,
                (PRUint32) m3[0], (PRUint32) m3[1], (PRUint32) m3[2],
                (PRUint32) m3[3], (PRUint32) m3[4], (PRUint32) m3[5],
                (PRUint32) m3[6], (PRUint32) m3[7]);
  return res;

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

Definition at line 58 of file nsID.h.

Definition at line 59 of file nsID.h.

Definition at line 60 of file nsID.h.

Definition at line 61 of file nsID.h.

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