Annotation of XNU/libkern/c++/OSBoolean.cpp, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * The contents of this file constitute Original Code as defined in and
                      7:  * are subject to the Apple Public Source License Version 1.1 (the
                      8:  * "License").  You may not use this file except in compliance with the
                      9:  * License.  Please obtain a copy of the License at
                     10:  * http://www.apple.com/publicsource and read it before using this file.
                     11:  * 
                     12:  * This Original Code and all software distributed under the License are
                     13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     17:  * License for the specific language governing rights and limitations
                     18:  * under the License.
                     19:  * 
                     20:  * @APPLE_LICENSE_HEADER_END@
                     21:  */
                     22: /* OSBoolean.cpp created by rsulack on Tue Oct 12 1999 */
                     23: 
                     24: #include <libkern/c++/OSBoolean.h>
                     25: #include <libkern/c++/OSString.h>
                     26: #include <libkern/c++/OSSerialize.h>
                     27: #include <libkern/c++/OSLib.h>
                     28: 
                     29: #define super OSObject
                     30: 
                     31: OSDefineMetaClassAndStructors(OSBoolean, OSObject)
                     32: 
                     33: bool OSBoolean::init(bool inValue)
                     34: {
                     35:     if (!super::init())
                     36:         return false;
                     37: 
                     38:     value = inValue;
                     39: 
                     40:     return true;
                     41: }
                     42: 
                     43: void OSBoolean::free() { super::free(); }
                     44: 
                     45: OSBoolean *OSBoolean::withBoolean(bool inValue)
                     46: {
                     47:     OSBoolean *me = new OSBoolean;
                     48: 
                     49:     if (me && !me->init(inValue)) {
                     50:         me->free();
                     51:         return 0;
                     52:     }
                     53: 
                     54:     return me;
                     55: }
                     56: 
                     57: bool OSBoolean::isTrue() const { return value; }
                     58: bool OSBoolean::isFalse() const { return !value; }
                     59: 
                     60: bool OSBoolean::isEqualTo(const OSBoolean *boolean) const
                     61: {
                     62:     return (value == boolean->value);
                     63: }
                     64: 
                     65: bool OSBoolean::isEqualTo(const OSObject *obj) const
                     66: {
                     67:     OSBoolean *        boolean;
                     68:     if ((boolean = OSDynamicCast(OSBoolean, (OSObject *)obj )))
                     69:        return isEqualTo(boolean);
                     70:     else
                     71:        return false;
                     72: }
                     73: 
                     74: bool OSBoolean::serialize(OSSerialize *s) const
                     75: {
                     76:     if (s->previouslySerialized(this)) return true;
                     77: 
                     78:     return s->addString(value ? "<true/>" : "<false/>");
                     79: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.