OSBoolean

Inherits from
OSObject
Availability
Available in OS X v10.0 and later.
Declared in
OSBoolean.h

Overview

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.

Tasks

Miscellaneous

Instance Methods

free

Overridden to prevent deallocation of the shared global instances.

virtual void free();
Discussion

This function should never be called.

getValue

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

virtual bool getValue() const;
Return Value

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

isEqualTo(const OSBoolean *)

Tests the equality of two OSBoolean objects.

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).

isEqualTo(const OSMetaClassBase *)

Tests the equality an OSBoolean to an arbitrary object.

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.

isFalse

Checks whether the OSBoolean object represents a false bool value.

virtual bool isFalse() const;
Return Value

true if the OSBoolean object is false, true otherwise.

Discussion

You can also use == against kOSBooleanFalse.

isTrue

Checks whether the OSBoolean object represents a true bool value.

virtual bool isTrue() const;
Return Value

true if the OSBoolean object is true, false otherwise.

Discussion

You can also use == against kOSBooleanTrue.

serialize

Archives the receiver into the provided OSSerialize object.

virtual bool serialize( OSSerialize *serializer) const;
Parameters
serializer

The OSSerialize object.

Return Value

true if serialization succeeds, false if not.

taggedRelease

Overrides the reference counting mechanism for the shared global instances.

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

Unused.

when

Unused.

taggedRetain

Overrides the reference counting mechanism for the shared global instances.

virtual void taggedRetain( const void *tag) const;
Parameters
tag

Unused.

withBoolean

Returns one of the global instances of OSBoolean.

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.