Mac Developer Library

Developer

OSSymbol Class Reference

Options
Deployment Target:

On This Page
Language:

OSSymbol

OSSymbol wraps a C string in a unique C++ object for use as keys in Libkern collections. More...

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Not Applicable @import Kernel;

Availability


Available in OS X v10.0 and later.
  • Overrides OSObject::free to synchronize with the symbol pool.

    Declaration

    C++

    virtual void free();

    Discussion

    Because OSSymbol shares instances, the reference-counting functions must synchronize access to the class-internal tables used to track those instances.

    Import Statement

  • Overridden to prevent creation of duplicate symbols.

    Declaration

    C++

    virtual bool initWithCString( const char *cString);

    Parameters

    cString

    Unused.

    Return Value

    false.

    Discussion

    Overrides OSString's implementation to prevent creation of distinct OSSymbols with the same string value.

    Import Statement

  • Overridden to prevent creation of duplicate symbols.

    Declaration

    C++

    virtual bool initWithCStringNoCopy( const char *cString);

    Parameters

    cString

    Unused.

    Return Value

    false.

    Discussion

    Overrides OSString's implementation to prevent creation of distinct OSSymbols with the same string value.

    Import Statement

  • Overridden to prevent creation of duplicate symbols.

    Declaration

    C++

    virtual bool initWithString( const OSString *aString);

    Parameters

    aString

    Unused.

    Return Value

    false.

    Discussion

    Overrides OSString's implementation to prevent creation of distinct OSSymbols with the same string value.

    Import Statement

  • Tests the equality of an OSSymbol object to an arbitrary object.

    Declaration

    C++

    virtual bool isEqualTo( const OSMetaClassBase *anObject) const;

    Parameters

    anObject

    The object to be compared against the receiver.

    Return Value

    Returns true if the two objects are equivalent, false otherwise.

    Discussion

    An OSSymbol is considered equal to another object if that object is derived from OSString and contains the equivalent bytes of the same length.

    Import Statement

  • Tests the equality of an OSSymbol object with a C string.

    Declaration

    C++

    virtual bool isEqualTo( const char *cString) const;

    Parameters

    cString

    The C string to compare against the receiver.

    Return Value

    true if the OSSymbol's characters are equivalent to the C string's, false otherwise.

    Import Statement

  • Tests the equality of two OSSymbol objects.

    Declaration

    C++

    virtual bool isEqualTo( const OSSymbol *aSymbol) const;

    Parameters

    aSymbol

    The OSSymbol object being compared against the receiver.

    Return Value

    true if the two OSSymbol objects are equivalent, false otherwise.

    Discussion

    Two OSSymbol objects are considered equal if they have the same address; that is, this function is equivalent to the == operator.

    Import Statement

  • Overrides OSObject::taggedRelease(const void *) to synchronize with the symbol pool.

    Declaration

    C++

    virtual void taggedRelease( const void *tag) const;

    Parameters

    tag

    Used for tracking collection references.

    Discussion

    Because OSSymbol shares instances, the reference-counting functions must synchronize access to the class-internal tables used to track those instances.

    Import Statement

  • Overrides OSObject::taggedRelease(const void *, const int) to synchronize with the symbol pool.

    Declaration

    C++

    virtual void taggedRelease( const void *tag, const intfreeWhen) const;

    Parameters

    tag

    Used for tracking collection references.

    freeWhen

    If decrementing the reference count makes it >= freeWhen, the object is immediately freed.

    Discussion

    Because OSSymbol shares instances, the reference-counting functions must synchronize access to the class-internal tables used to track those instances.

    Import Statement

  • Returns an OSSymbol created from a C string, or the existing unique instance of the same value.

    Declaration

    C++

    static const OSSymbol * withCString( const char *cString);

    Parameters

    cString

    The C string to look up or copy.

    Return Value

    An instance of OSSymbol representing the same characters as cString; NULL on failure.

    Discussion

    This function returns the unique OSSymbol instance representing the string value of cString. You can compare it with other OSSymbols using the == operator.

    OSSymbols are reference-counted normally. This function either returns a new OSSymbol with a retain count of 1, or increments the retain count of the existing instance.

    Import Statement

  • Returns an OSSymbol created from a C string, without copying that string, or the existing unique instance of the same value.

    Declaration

    C++

    static const OSSymbol * withCStringNoCopy( const char *cString);

    Parameters

    cString

    The C string to look up or use.

    Return Value

    An instance of OSSymbol representing the same characters as cString; NULL.

    Discussion

    Avoid using this function; OSSymbols should own their internal string buffers.

    This function returns the unique OSSymbol instance representing the string value of cString. You can compare it with other OSSymbols using the == operator.

    OSSymbols are reference-counted normally. This function either returns a new OSSymbol with a retain count of 1, or increments the retain count of the existing instance.

    Import Statement

  • Returns an OSSymbol created from an OSString, or the existing unique instance of the same value.

    Declaration

    C++

    static const OSSymbol * withString( const OSString *aString);

    Parameters

    aString

    The OSString object to look up or copy.

    Return Value

    An instance of OSSymbol representing the same characters as aString; NULL on failure.

    Discussion

    This function creates or returns the unique OSSymbol instance representing the string value of aString. You can compare it with other OSSymbols using the == operator.

    OSSymbols are reference-counted normally. This function either returns a new OSSymbol with a retain count of 1, or increments the retain count of the existing instance.

    Import Statement