Mac Developer Library

Developer

OSBoolean Class Reference

Options
Deployment Target:

On This Page

OSBoolean

OSBoolean wraps a boolean value in a C++ object for use in Libkern collections.

OSBoolean represents a boolean true/false value as a Libkern C++ object. There are only two instances of OSBoolean, kOSBooleanTrue and kOSBooleanFalse. These are shared globally and returned by the instance-creation function withBoolean. Thus, you can use pointer comparison to test whether two OSBoolean objects are equal.

  • Overridden to prevent deallocation of the shared global instances.

    Declaration

    virtual void free();

    Discussion

    This function should never be called.

  • Returns the C++ bool value for the OSBoolean object.

    Declaration

    virtual bool getValue() const;

    Return Value

    Returns the C++ bool value of the OSBoolean object.

  • Tests the equality of two OSBoolean objects.

    Declaration

    virtual bool isEqualTo( const OSBoolean *aBoolean) const;

    Parameters

    aBoolean

    The OSBoolean to be compared against the receiver.

    Return Value

    true if the OSBoolean objects are equal, false if not.

    Discussion

    Two OSBoolean objects are considered equal if they are the same exact object (pointer equality).

  • Tests the equality an OSBoolean to an arbitrary object.

    Declaration

    virtual bool isEqualTo( const OSMetaClassBase *anObject) const;

    Parameters

    anObject

    An object to be compared against the receiver.

    Return Value

    true if the objects are equal, false if not.

    Discussion

    An OSBoolean is considered equal to another object if that object is derived from OSBoolean and represents the same C++ bool value.

  • Checks whether the OSBoolean object represents a false bool value.

    Declaration

    virtual bool isFalse() const;

    Return Value

    true if the OSBoolean object is false, true otherwise.

    Discussion

    You can also use == against kOSBooleanFalse.

  • Checks whether the OSBoolean object represents a true bool value.

    Declaration

    virtual bool isTrue() const;

    Return Value

    true if the OSBoolean object is true, false otherwise.

    Discussion

    You can also use == against kOSBooleanTrue.

  • Archives the receiver into the provided OSSerialize object.

    Declaration

    virtual bool serialize( OSSerialize *serializer) const;

    Parameters

    serializer

    The OSSerialize object.

    Return Value

    true if serialization succeeds, false if not.

  • Overrides the reference counting mechanism for the shared global instances.

    Declaration

    virtual void taggedRelease( const void *tag, const int when) const;

    Parameters

    tag

    Unused.

    when

    Unused.

  • Overrides the reference counting mechanism for the shared global instances.

    Declaration

    virtual void taggedRetain( const void *tag) const;

    Parameters

    tag

    Unused.

  • Returns one of the global instances of OSBoolean.

    Declaration

    static OSBoolean * withBoolean( bool value);

    Parameters

    value

    A boolean value.

    Return Value

    The global instance of OSBoolean with the boolean value.

    Discussion

    This function actually returns either kOSBooleanTrue or kOSBooleanFalse, so that you can always use pointer comparison with OSBoolean objects.