]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/c++/OSNumber.h
3dd54a69a9ffab5ddb6fc8ae6924aa7e977c8566
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 /* IOOffset.h created by rsulack on Wed 17-Sep-1997 */
24 /* IOOffset.h converted to C++ by gvdl on Fri 1998-10-30 */
26 #ifndef _OS_OSNUMBER_H
27 #define _OS_OSNUMBER_H
29 #include <libkern/c++/OSObject.h>
33 @abstract A container class for numeric values.
35 class OSNumber
: public OSObject
37 OSDeclareDefaultStructors ( OSNumber
)
40 unsigned long long value
;
43 struct ExpansionData
{ };
46 Reserved for future use. (Internal use only) */
47 ExpansionData
* reserved
;
52 @abstract A static constructor function to create and initialize an instance of OSNumber with a given value.
53 @param value The numeric integer value.
54 @param numberOfBits The number of bit required to represent the value.
55 @result Returns an instance of OSNumber or 0 if an error occurred.
57 static OSNumber
* withNumber ( unsigned long long value
,
58 unsigned int numberOfBits
);
61 @abstract A static constructor function to create and initialize an instance of OSNumber with a given value represented as a simple c-string.
62 @discussion This function does not work on IOKit versions prior to 8.0 (prior to 10.4). For IOKit version 8.0 and later, it works but is limited to parsing unsigned 32 bit quantities The format of the c-string may be decimal, hexadecimal ("0x" prefix), binary ("0b" prefix, or octal ("0" prefix).
63 @param value A c-string representing a numeric value.
64 @param numberOfBits The number of bit required to represent the value.
65 @result Returns an instance of OSNumber or 0 if an error occurred.
67 static OSNumber
* withNumber ( const char * value
, unsigned int numberOfBits
);
71 @abstract A member function to initialize an instance of OSNumber.
72 @param value An integer value.
73 @param numberOfBits The number of bit required to represent the value.
74 @result Returns true if instance was successfully initialized, false otherwise.
76 virtual bool init ( unsigned long long value
, unsigned int numberOfBits
);
79 @abstract A member function to initialize an instance of OSNumber.
80 @param value A c-string representation of a numeric value.
81 @param numberOfBits The number of bit required to represent the value.
82 @result Returns true if instance was successfully initialized, false otherwise.
84 virtual bool init ( const char * value
, unsigned int numberOfBits
);
87 @abstract Releases and deallocates resources created by the OSNumber instances.
88 @discussion This function should not be called directly, use release() instead.
93 @function numberOfBits
94 @abstract A member function which returns the number of bits used to represent the value.
95 @result Returns the number of bits required to represent the value.
97 virtual unsigned int numberOfBits () const ;
99 @function numberOfBytes
100 @abstract A member function which returns the number of bytes used to represent the value.
101 @result Returns the number of bytes required to represent the value.
103 virtual unsigned int numberOfBytes () const ;
106 @function unsigned8BitValue
107 @abstract A member function which returns its internal value as an 8-bit value.
108 @result Returns the internal value as an 8-bit value.
110 virtual unsigned char unsigned8BitValue () const ;
112 @function unsigned16BitValue
113 @abstract A member function which returns its internal value as an 16-bit value.
114 @result Returns the internal value as an 16-bit value.
116 virtual unsigned short unsigned16BitValue () const ;
118 @function unsigned32BitValue
119 @abstract A member function which returns its internal value as an 32-bit value.
120 @result Returns the internal value as an 32-bit value.
122 virtual unsigned int unsigned32BitValue () const ;
124 @function unsigned64BitValue
125 @abstract A member function which returns its internal value as an 64-bit value.
126 @result Returns the internal value as an 64-bit value.
128 virtual unsigned long long unsigned64BitValue () const ;
132 @abstract A member function which adds an integer value to the internal numeric value of the OSNumber object.
133 @param value The value to be added.
135 virtual void addValue ( signed long long value
);
138 @abstract Replaces the current internal numeric value of the OSNumber object by the value given.
139 @param value The new value for the OSNumber object.
141 virtual void setValue ( unsigned long long value
);
145 @abstract A member function to test the equality of two OSNumber objects.
146 @param integer The OSNumber object to be compared against the receiver.
147 @result Returns true if the two objects are equivalent, false otherwise.
149 virtual bool isEqualTo ( const OSNumber
* integer
) const ;
152 @abstract A member function to test the equality of an arbitrary OSObject derived object and an OSNumber object.
153 @param obj The OSObject derived object to be compared to the receiver.
154 @result Returns true if the two objects are equivalent, false otherwise.
156 virtual bool isEqualTo ( const OSMetaClassBase
* obj
) const ;
160 @abstract A member function which archives the receiver.
161 @param s The OSSerialize object.
162 @result Returns true if serialization was successful, false if not.
164 virtual bool serialize ( OSSerialize
* s
) const ;
167 OSMetaClassDeclareReservedUnused ( OSNumber
, 0 );
168 OSMetaClassDeclareReservedUnused ( OSNumber
, 1 );
169 OSMetaClassDeclareReservedUnused ( OSNumber
, 2 );
170 OSMetaClassDeclareReservedUnused ( OSNumber
, 3 );
171 OSMetaClassDeclareReservedUnused ( OSNumber
, 4 );
172 OSMetaClassDeclareReservedUnused ( OSNumber
, 5 );
173 OSMetaClassDeclareReservedUnused ( OSNumber
, 6 );
174 OSMetaClassDeclareReservedUnused ( OSNumber
, 7 );
177 #endif /* !_OS_OSNUMBER_H */