]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/c++/OSNumber.h
5eb6fa7ed554af25b239ef67cdb5d04ade02b127
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 /* IOOffset.h created by rsulack on Wed 17-Sep-1997 */
26 /* IOOffset.h converted to C++ by gvdl on Fri 1998-10-30 */
28 #ifndef _OS_OSNUMBER_H
29 #define _OS_OSNUMBER_H
31 #include <libkern/c++/OSObject.h>
35 @abstract A container class for numeric values.
37 class OSNumber
: public OSObject
39 OSDeclareDefaultStructors(OSNumber
)
42 unsigned long long value
;
45 struct ExpansionData
{ };
48 Reserved for future use. (Internal use only) */
49 ExpansionData
*reserved
;
54 @abstract A static constructor function to create and initialize an instance of OSNumber with a given value.
55 @param value The numeric integer value.
56 @param numberOfBits The number of bit required to represent the value.
57 @result Returns an instance of OSNumber or 0 if an error occurred.
59 static OSNumber
*withNumber(unsigned long long value
,
60 unsigned int numberOfBits
);
63 @abstract A static constructor function to create and initialize an instance of OSNumber with a given value represented as a simple c-string.
64 @param value A c-string representing a numeric value.
65 @param numberOfBits The number of bit required to represent the value.
66 @result Returns an instance of OSNumber or 0 if an error occurred.
68 static OSNumber
*withNumber(const char *value
, unsigned int numberOfBits
);
72 @abstract A member function to initialize an instance of OSNumber.
73 @param value An integer value.
74 @param numberOfBits The number of bit required to represent the value.
75 @result Returns true if instance was successfully initialized, false otherwise.
77 virtual bool init(unsigned long long value
, unsigned int numberOfBits
);
80 @abstract A member function to initialize an instance of OSNumber.
81 @param value A c-string representation of a numeric value.
82 @param numberOfBits The number of bit required to represent the value.
83 @result Returns true if instance was successfully initialized, false otherwise.
85 virtual bool init(const char *value
, unsigned int numberOfBits
);
88 @abstract Releases and deallocates resources created by the OSNumber instances.
89 @discussion This function should not be called directly, use release() instead.
94 @function numberOfBits
95 @abstract A member function which returns the number of bits used to represent the value.
96 @result Returns the number of bits required to represent the value.
98 virtual unsigned int numberOfBits() const;
100 @function numberOfBytes
101 @abstract A member function which returns the number of bytes used to represent the value.
102 @result Returns the number of bytes required to represent the value.
104 virtual unsigned int numberOfBytes() const;
107 @function unsigned8BitValue
108 @abstract A member function which returns its internal value as an 8-bit value.
109 @result Returns the internal value as an 8-bit value.
111 virtual unsigned char unsigned8BitValue() const;
113 @function unsigned16BitValue
114 @abstract A member function which returns its internal value as an 16-bit value.
115 @result Returns the internal value as an 16-bit value.
117 virtual unsigned short unsigned16BitValue() const;
119 @function unsigned32BitValue
120 @abstract A member function which returns its internal value as an 32-bit value.
121 @result Returns the internal value as an 32-bit value.
123 virtual unsigned int unsigned32BitValue() const;
125 @function unsigned64BitValue
126 @abstract A member function which returns its internal value as an 64-bit value.
127 @result Returns the internal value as an 64-bit value.
129 virtual unsigned long long unsigned64BitValue() const;
133 @abstract A member function which adds an integer value to the internal numeric value of the OSNumber object.
134 @param value The value to be added.
136 virtual void addValue(signed long long value
);
139 @abstract Replaces the current internal numeric value of the OSNumber object by the value given.
140 @param value The new value for the OSNumber object.
142 virtual void setValue(unsigned long long value
);
146 @abstract A member function to test the equality of two OSNumber objects.
147 @param integer The OSNumber object to be compared against the receiver.
148 @result Returns true if the two objects are equivalent, false otherwise.
150 virtual bool isEqualTo(const OSNumber
*integer
) const;
153 @abstract A member function to test the equality of an arbitrary OSObject derived object and an OSNumber object.
154 @param obj The OSObject derived object to be compared to the receiver.
155 @result Returns true if the two objects are equivalent, false otherwise.
157 virtual bool isEqualTo(const OSMetaClassBase
*obj
) const;
161 @abstract A member function which archives the receiver.
162 @param s The OSSerialize object.
163 @result Returns true if serialization was successful, false if not.
165 virtual bool serialize(OSSerialize
*s
) const;
168 OSMetaClassDeclareReservedUnused(OSNumber
, 0);
169 OSMetaClassDeclareReservedUnused(OSNumber
, 1);
170 OSMetaClassDeclareReservedUnused(OSNumber
, 2);
171 OSMetaClassDeclareReservedUnused(OSNumber
, 3);
172 OSMetaClassDeclareReservedUnused(OSNumber
, 4);
173 OSMetaClassDeclareReservedUnused(OSNumber
, 5);
174 OSMetaClassDeclareReservedUnused(OSNumber
, 6);
175 OSMetaClassDeclareReservedUnused(OSNumber
, 7);
178 #endif /* !_OS_OSNUMBER_H */