]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/c++/OSNumber.h
aa32d0fcb76b25c3020f9594eab7170ebd6fbcb3
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
22 /* IOOffset.h created by rsulack on Wed 17-Sep-1997 */
23 /* IOOffset.h converted to C++ by gvdl on Fri 1998-10-30 */
25 #ifndef _OS_OSNUMBER_H
26 #define _OS_OSNUMBER_H
28 #include <libkern/c++/OSObject.h>
32 @abstract A container class for numeric values.
34 class OSNumber
: public OSObject
36 OSDeclareDefaultStructors(OSNumber
)
39 unsigned long long value
;
42 struct ExpansionData
{ };
45 Reserved for future use. (Internal use only) */
46 ExpansionData
*reserved
;
51 @abstract A static constructor function to create and initialize an instance of OSNumber with a given value.
52 @param value The numeric integer value.
53 @param numberOfBits The number of bit required to represent the value.
54 @result Returns an instance of OSNumber or 0 if an error occurred.
56 static OSNumber
*withNumber(unsigned long long value
,
57 unsigned int numberOfBits
);
60 @abstract A static constructor function to create and initialize an instance of OSNumber with a given value represented as a simple c-string.
61 @param value A c-string representing a numeric value.
62 @param numberOfBits The number of bit required to represent the value.
63 @result Returns an instance of OSNumber or 0 if an error occurred.
65 static OSNumber
*withNumber(const char *value
, unsigned int numberOfBits
);
69 @abstract A member function to initialize an instance of OSNumber.
70 @param value An integer value.
71 @param numberOfBits The number of bit required to represent the value.
72 @result Returns true if instance was successfully initialized, false otherwise.
74 virtual bool init(unsigned long long value
, unsigned int numberOfBits
);
77 @abstract A member function to initialize an instance of OSNumber.
78 @param value A c-string representation of a numeric value.
79 @param numberOfBits The number of bit required to represent the value.
80 @result Returns true if instance was successfully initialized, false otherwise.
82 virtual bool init(const char *value
, unsigned int numberOfBits
);
85 @abstract Releases and deallocates resources created by the OSNumber instances.
86 @discussion This function should not be called directly, use release() instead.
91 @function numberOfBits
92 @abstract A member function which returns the number of bits used to represent the value.
93 @result Returns the number of bits required to represent the value.
95 virtual unsigned int numberOfBits() const;
97 @function numberOfBytes
98 @abstract A member function which returns the number of bytes used to represent the value.
99 @result Returns the number of bytes required to represent the value.
101 virtual unsigned int numberOfBytes() const;
104 @function unsigned8BitValue
105 @abstract A member function which returns its internal value as an 8-bit value.
106 @result Returns the internal value as an 8-bit value.
108 virtual unsigned char unsigned8BitValue() const;
110 @function unsigned16BitValue
111 @abstract A member function which returns its internal value as an 16-bit value.
112 @result Returns the internal value as an 16-bit value.
114 virtual unsigned short unsigned16BitValue() const;
116 @function unsigned32BitValue
117 @abstract A member function which returns its internal value as an 32-bit value.
118 @result Returns the internal value as an 32-bit value.
120 virtual unsigned int unsigned32BitValue() const;
122 @function unsigned64BitValue
123 @abstract A member function which returns its internal value as an 64-bit value.
124 @result Returns the internal value as an 64-bit value.
126 virtual unsigned long long unsigned64BitValue() const;
130 @abstract A member function which adds an integer value to the internal numeric value of the OSNumber object.
131 @param value The value to be added.
133 virtual void addValue(signed long long value
);
136 @abstract Replaces the current internal numeric value of the OSNumber object by the value given.
137 @param value The new value for the OSNumber object.
139 virtual void setValue(unsigned long long value
);
143 @abstract A member function to test the equality of two OSNumber objects.
144 @param integer The OSNumber object to be compared against the receiver.
145 @result Returns true if the two objects are equivalent, false otherwise.
147 virtual bool isEqualTo(const OSNumber
*integer
) const;
150 @abstract A member function to test the equality of an arbitrary OSObject derived object and an OSNumber object.
151 @param obj The OSObject derived object to be compared to the receiver.
152 @result Returns true if the two objects are equivalent, false otherwise.
154 virtual bool isEqualTo(const OSMetaClassBase
*obj
) const;
158 @abstract A member function which archives the receiver.
159 @param s The OSSerialize object.
160 @result Returns true if serialization was successful, false if not.
162 virtual bool serialize(OSSerialize
*s
) const;
165 OSMetaClassDeclareReservedUnused(OSNumber
, 0);
166 OSMetaClassDeclareReservedUnused(OSNumber
, 1);
167 OSMetaClassDeclareReservedUnused(OSNumber
, 2);
168 OSMetaClassDeclareReservedUnused(OSNumber
, 3);
169 OSMetaClassDeclareReservedUnused(OSNumber
, 4);
170 OSMetaClassDeclareReservedUnused(OSNumber
, 5);
171 OSMetaClassDeclareReservedUnused(OSNumber
, 6);
172 OSMetaClassDeclareReservedUnused(OSNumber
, 7);
175 #endif /* !_OS_OSNUMBER_H */