public interface CoreFoundation extends Library
Core Foundation functions have names that indicate when you own a returned
object: Object-creation functions have “Create” embedded in the name, and
Object-duplication functions that have “Copy” embedded in the name. If you
own an object, it is your responsibility to relinquish ownership (using
CFRelease(com.sun.jna.platform.mac.CoreFoundation.CFTypeRef)
) when you have finished with it.
If you receive an object from any Core Foundation function other than a
creation or copy function—such as a Get function—you do not own it and cannot
be certain of the object’s life span. If you want to ensure that such an
object is not disposed of while you are using it, you must claim ownership
(with the CFRetain(com.sun.jna.platform.mac.CoreFoundation.CFTypeRef)
function).
Modifier and Type | Interface and Description |
---|---|
static class |
CoreFoundation.CFAllocatorRef
A reference type used in many Core Foundation parameters and function
results.
|
static class |
CoreFoundation.CFArrayRef
A reference to an immutable
CFArray object. |
static class |
CoreFoundation.CFBooleanRef
A reference to a
CFBoolean object. |
static class |
CoreFoundation.CFDataRef
A reference to an immutable
CFData object. |
static class |
CoreFoundation.CFDictionaryRef
A reference to an immutable
CFDictionary object. |
static class |
CoreFoundation.CFIndex
A wrapper for the
NativeLong type, used for CoreFoundation.CFNumberRef
types, CoreFoundation.CFStringRef lengths, and CoreFoundation.CFArrayRef sizes and indices. |
static class |
CoreFoundation.CFMutableDictionaryRef
A reference to a mutable
CFDictionary object. |
static class |
CoreFoundation.CFNumberRef
A reference to a
CFNumber object. |
static class |
CoreFoundation.CFNumberType
|
static class |
CoreFoundation.CFStringRef
A reference to a
CFString object, which “encapsulates” a Unicode
string along with its length. |
static class |
CoreFoundation.CFTypeID
A type for unique, constant integer values that identify particular Core
Foundation opaque types.
|
static class |
CoreFoundation.CFTypeRef
The
CFTypeRef type is the base type defined in Core Foundation. |
Library.Handler
Modifier and Type | Field and Description |
---|---|
static CoreFoundation.CFTypeID |
ARRAY_TYPE_ID |
static CoreFoundation.CFTypeID |
BOOLEAN_TYPE_ID |
static CoreFoundation.CFTypeID |
DATA_TYPE_ID |
static CoreFoundation.CFTypeID |
DATE_TYPE_ID |
static CoreFoundation.CFTypeID |
DICTIONARY_TYPE_ID |
static CoreFoundation |
INSTANCE |
static int |
kCFNotFound |
static int |
kCFStringEncodingASCII |
static int |
kCFStringEncodingUTF8 |
static CoreFoundation.CFTypeID |
NUMBER_TYPE_ID |
static CoreFoundation.CFTypeID |
STRING_TYPE_ID |
OPTION_ALLOW_OBJECTS, OPTION_CALLING_CONVENTION, OPTION_CLASSLOADER, OPTION_FUNCTION_MAPPER, OPTION_INVOCATION_MAPPER, OPTION_OPEN_FLAGS, OPTION_STRING_ENCODING, OPTION_STRUCTURE_ALIGNMENT, OPTION_TYPE_MAPPER
Modifier and Type | Method and Description |
---|---|
CoreFoundation.CFAllocatorRef |
CFAllocatorGetDefault()
Gets the default allocator object for the current thread.
|
CoreFoundation.CFArrayRef |
CFArrayCreate(CoreFoundation.CFAllocatorRef alloc,
Pointer values,
CoreFoundation.CFIndex numValues,
Pointer callBacks)
Creates a new immutable array with the given values.
|
CoreFoundation.CFIndex |
CFArrayGetCount(CoreFoundation.CFArrayRef theArray)
Returns the number of values currently in an array.
|
CoreFoundation.CFTypeID |
CFArrayGetTypeID() |
Pointer |
CFArrayGetValueAtIndex(CoreFoundation.CFArrayRef theArray,
CoreFoundation.CFIndex idx)
Retrieves a value at a given index.
|
CoreFoundation.CFTypeID |
CFBooleanGetTypeID() |
byte |
CFBooleanGetValue(CoreFoundation.CFBooleanRef bool)
Returns the value of a
CFBoolean object. |
CoreFoundation.CFStringRef |
CFCopyDescription(CoreFoundation.CFTypeRef cf)
Returns a textual description of a Core Foundation object.
|
CoreFoundation.CFDataRef |
CFDataCreate(CoreFoundation.CFAllocatorRef alloc,
Pointer bytes,
CoreFoundation.CFIndex length)
Creates an immutable
CFData object using data copied from a specified
byte buffer. |
Pointer |
CFDataGetBytePtr(CoreFoundation.CFDataRef theData)
Returns a read-only pointer to the bytes of a
CFData object. |
CoreFoundation.CFIndex |
CFDataGetLength(CoreFoundation.CFDataRef theData)
Returns the number of bytes contained by a
CFData object. |
CoreFoundation.CFTypeID |
CFDataGetTypeID() |
CoreFoundation.CFTypeID |
CFDateGetTypeID() |
CoreFoundation.CFMutableDictionaryRef |
CFDictionaryCreateMutable(CoreFoundation.CFAllocatorRef alloc,
CoreFoundation.CFIndex capacity,
Pointer keyCallBacks,
Pointer valueCallBacks)
Creates a new mutable dictionary.
|
CoreFoundation.CFTypeID |
CFDictionaryGetTypeID() |
Pointer |
CFDictionaryGetValue(CoreFoundation.CFDictionaryRef theDict,
PointerType key)
Returns the value associated with a given key.
|
byte |
CFDictionaryGetValueIfPresent(CoreFoundation.CFDictionaryRef theDict,
PointerType key,
PointerByReference value)
Returns a boolean value that indicates whether a given value for a given key
is in a dictionary, and returns that value indirectly if it exists.
|
void |
CFDictionarySetValue(CoreFoundation.CFMutableDictionaryRef theDict,
PointerType key,
PointerType value)
Sets the value corresponding to a given key.
|
CoreFoundation.CFIndex |
CFGetRetainCount(CoreFoundation.CFTypeRef cf)
Returns the reference count of a Core Foundation object.
|
CoreFoundation.CFTypeID |
CFGetTypeID(CoreFoundation.CFTypeRef theObject)
Returns the type of a
CFType object. |
CoreFoundation.CFNumberRef |
CFNumberCreate(CoreFoundation.CFAllocatorRef alloc,
CoreFoundation.CFIndex theType,
ByReference valuePtr)
Creates a
CFNumber object using a specified value. |
CoreFoundation.CFIndex |
CFNumberGetType(CoreFoundation.CFNumberRef number)
Returns the type used by a
CFNumber object to store its value. |
CoreFoundation.CFTypeID |
CFNumberGetTypeID() |
byte |
CFNumberGetValue(CoreFoundation.CFNumberRef number,
CoreFoundation.CFIndex theType,
ByReference valuePtr)
Obtains the value of a
CFNumber object cast to a specified type. |
void |
CFRelease(CoreFoundation.CFTypeRef cf)
Releases a Core Foundation object.
|
CoreFoundation.CFTypeRef |
CFRetain(CoreFoundation.CFTypeRef cf)
Retains a Core Foundation object.
|
CoreFoundation.CFStringRef |
CFStringCreateWithCharacters(CoreFoundation.CFAllocatorRef alloc,
char[] chars,
CoreFoundation.CFIndex length)
Creates a string from a buffer of Unicode characters.
|
byte |
CFStringGetCString(CoreFoundation.CFStringRef theString,
Pointer bufferToFill,
CoreFoundation.CFIndex bufferSize,
int encoding)
Copies the character contents of a string to a local C string buffer after
converting the characters to a given encoding.
|
CoreFoundation.CFIndex |
CFStringGetLength(CoreFoundation.CFStringRef theString)
Returns the number (in terms of UTF-16 code pairs) of Unicode characters in a
string.
|
CoreFoundation.CFIndex |
CFStringGetMaximumSizeForEncoding(CoreFoundation.CFIndex length,
int encoding)
Returns the maximum number of bytes a string of a specified length (in
Unicode characters) will take up if encoded in a specified encoding.
|
CoreFoundation.CFTypeID |
CFStringGetTypeID() |
static final CoreFoundation INSTANCE
static final int kCFNotFound
static final int kCFStringEncodingASCII
static final int kCFStringEncodingUTF8
static final CoreFoundation.CFTypeID ARRAY_TYPE_ID
static final CoreFoundation.CFTypeID BOOLEAN_TYPE_ID
static final CoreFoundation.CFTypeID DATA_TYPE_ID
static final CoreFoundation.CFTypeID DATE_TYPE_ID
static final CoreFoundation.CFTypeID DICTIONARY_TYPE_ID
static final CoreFoundation.CFTypeID NUMBER_TYPE_ID
static final CoreFoundation.CFTypeID STRING_TYPE_ID
CoreFoundation.CFStringRef CFStringCreateWithCharacters(CoreFoundation.CFAllocatorRef alloc, char[] chars, CoreFoundation.CFIndex length)
This reference must be released with CFRelease(com.sun.jna.platform.mac.CoreFoundation.CFTypeRef)
to avoid leaking
references.
alloc
- The allocator to use to allocate memory for the new string. Pass
null
or kCFAllocatorDefault
to use the current
default allocator.chars
- The buffer of Unicode characters to copy into the new string.length
- The number of characters in the buffer pointed to by chars. Only
this number of characters will be copied to internal storage.chars
, or null
if
there was a problem creating the object.CoreFoundation.CFNumberRef CFNumberCreate(CoreFoundation.CFAllocatorRef alloc, CoreFoundation.CFIndex theType, ByReference valuePtr)
CFNumber
object using a specified value.
This reference must be released with CFRelease(com.sun.jna.platform.mac.CoreFoundation.CFTypeRef)
to avoid leaking
references.
alloc
- The allocator to use to allocate memory for the new object. Pass
null
or kCFAllocatorDefault
to use the current
default allocator.theType
- A constant that specifies the data type of the value to convert.
The ordinal value of the enum.
The theType
parameter is not necessarily preserved when
creating a new CFNumber
object. The CFNumber
object will be created using whatever internal storage type the
creation function deems appropriate. Use the function
CFNumberGetType(com.sun.jna.platform.mac.CoreFoundation.CFNumberRef)
to find out what type the
CFNumber
object used to store your value.
valuePtr
- A pointer to the value for the returned number object.valuePtr
.CoreFoundation.CFArrayRef CFArrayCreate(CoreFoundation.CFAllocatorRef alloc, Pointer values, CoreFoundation.CFIndex numValues, Pointer callBacks)
This reference must be released with CFRelease(com.sun.jna.platform.mac.CoreFoundation.CFTypeRef)
to avoid leaking
references.
alloc
- The allocator to use to allocate memory for the new array and its
storage for values. Pass null
or
kCFAllocatorDefault
to use the current default allocator.values
- A C array of the pointer-sized values to be in the new array. The
values in the new array are ordered in the same order in which
they appear in this C array. This value may be null
if
numValues
is 0. This C array is not changed or freed by
this function. If values
is not a valid pointer to a C
array of at least numValues
elements, the behavior is
undefined.numValues
- The number of values to copy from the values
C array into
the new array. This number will be the count of the new array—it
must not be negative or greater than the number of elements in
values.callBacks
- A pointer to a CFArrayCallBacks
structure initialized with
the callbacks for the array to use on each value in the
collection. The retain callback is used within this function, for
example, to retain all of the new values from the values
C
array. A copy of the contents of the callbacks structure is made,
so that a pointer to a structure on the stack can be passed in or
can be reused for multiple collection creations.
This value may be null
, which is treated as if a valid
structure of version 0 with all fields null
had been
passed in.
numValues
from
values
, or null
if there was a problem creating the
object.CoreFoundation.CFDataRef CFDataCreate(CoreFoundation.CFAllocatorRef alloc, Pointer bytes, CoreFoundation.CFIndex length)
CFData
object using data copied from a specified
byte buffer.
This reference must be released with CFRelease(com.sun.jna.platform.mac.CoreFoundation.CFTypeRef)
to avoid leaking
references.
alloc
- The allocator to use to allocate memory for the new object. Pass
null
or kCFAllocatorDefault
to use the current
default allocator.bytes
- A pointer to the byte buffer that contains the raw data to be
copied into the Data.length
- The number of bytes in the buffer (bytes
).CFData
object, or null
if there was a problem
creating the object.CoreFoundation.CFMutableDictionaryRef CFDictionaryCreateMutable(CoreFoundation.CFAllocatorRef alloc, CoreFoundation.CFIndex capacity, Pointer keyCallBacks, Pointer valueCallBacks)
This reference must be released with CFRelease(com.sun.jna.platform.mac.CoreFoundation.CFTypeRef)
to avoid leaking
references.
alloc
- The allocator to use to allocate memory for the new string. Pass
null
or kCFAllocatorDefault
to use the current
default allocator.capacity
- The maximum number of key-value pairs that can be contained by the
new dictionary. The dictionary starts empty and can grow to this
number of key-value pairs (and it can have less).
Pass 0 to specify that the maximum capacity is not limited. The value must not be negative.
keyCallBacks
- A pointer to a CFDictionaryKeyCallBacks
structure
initialized with the callbacks to use to retain, release,
describe, and compare keys in the dictionary. A copy of the
contents of the callbacks structure is made, so that a pointer to
a structure on the stack can be passed in or can be reused for
multiple collection creations.
This value may be null
, which is treated as a valid
structure of version 0 with all fields null
.
valueCallBacks
- A pointer to a CFDictionaryValueCallBacks
structure
initialized with the callbacks to use to retain, release,
describe, and compare values in the dictionary. A copy of the
contents of the callbacks structure is made, so that a pointer to
a structure on the stack can be passed in or can be reused for
multiple collection creations.
This value may be null
, which is treated as a valid
structure of version 0 with all fields null
.
null
if there was a problem creating the
object.CoreFoundation.CFStringRef CFCopyDescription(CoreFoundation.CFTypeRef cf)
The nature of the description differs by object. For example, a description of a CFArray object would include descriptions of each of the elements in the collection.
You can use this function for debugging Core Foundation objects in your code. Note, however, that the description for a given object may be different in different releases of the operating system. Do not create dependencies in your code on the content or format of the information returned by this function.
cf
- The CFType
object (a generic reference of type
CFTypeRef
) from which to derive a description.cf
.void CFRelease(CoreFoundation.CFTypeRef cf)
If the retain count of cf
becomes zero the memory allocated to the
object is deallocated and the object is destroyed. If you create, copy, or
explicitly retain (see the CFRetain(com.sun.jna.platform.mac.CoreFoundation.CFTypeRef)
function) a Core Foundation
object, you are responsible for releasing it when you no longer need it.
cf
- A CFType
object to release. This value must not be
null
.CoreFoundation.CFTypeRef CFRetain(CoreFoundation.CFTypeRef cf)
If you retain a Core Foundation object you are responsible for releasing it
with CFRelease(com.sun.jna.platform.mac.CoreFoundation.CFTypeRef)
.
cf
- The CFType
object to retain. This value must not be
null
.CoreFoundation.CFIndex CFGetRetainCount(CoreFoundation.CFTypeRef cf)
cf
- The CFType
object to examine.Pointer CFDictionaryGetValue(CoreFoundation.CFDictionaryRef theDict, PointerType key)
theDict
- The dictionary to examine.key
- The key for which to find a match in theDict
. The key hash
and equal callbacks provided when the dictionary was created are
used to compare. If the hash callback was null
, the key is
treated as a pointer and converted to an integer. If the equal
callback was null
, pointer equality (in C, ==) is used. If
key
, or any of the keys in theDict
, is not
understood by the equal callback, the behavior is undefined.theDict
, or null
if
no key-value pair matching key exists. Since null
is also a
valid value in some dictionaries, use
CFDictionaryGetValueIfPresent(com.sun.jna.platform.mac.CoreFoundation.CFDictionaryRef, com.sun.jna.PointerType, com.sun.jna.ptr.PointerByReference)
to distinguish between a value
that is not found, and a null
value.byte CFDictionaryGetValueIfPresent(CoreFoundation.CFDictionaryRef theDict, PointerType key, PointerByReference value)
theDict
- The dictionary to examine.key
- The key for which to find a match in theDict
. The key hash
and equal callbacks provided when the dictionary was created are
used to compare. If the hash callback was null
, the key is
treated as a pointer and converted to an integer. If the equal
callback was null
, pointer equality (in C, ==) is used. If
key
, or any of the keys in theDict
, is not
understood by the equal callback, the behavior is undefined.value
- A pointer to memory which, on return, is filled with the
pointer-sized value if a matching key is found. If no key match is
found, the contents of the storage pointed to by this parameter
are undefined. This value may be null
, in which case the
value from the dictionary is not returned (but the return value of
this function still indicates whether or not the key-value pair
was present).void CFDictionarySetValue(CoreFoundation.CFMutableDictionaryRef theDict, PointerType key, PointerType value)
theDict
- The dictionary to modify. If this parameter is a fixed-capacity
dictionary and it is full before this operation, and the key does
not exist in the dictionary, the behavior is undefined.key
- The key of the value to set in theDict
. If a key which
matches key
is already present in the dictionary, only the
value for the key is changed ("add if absent, replace if
present"). If no key matches key
, the key-value pair is
added to the dictionary.
If a key-value pair is added, both key and value are retained by
the dictionary, using the retain callback provided when
theDict
was created. key
must be of the type
expected by the key retain callback.
value
- The value to add to or replace in theDict
. value
is retained using the value retain callback provided when
theDict
was created, and the previous value if any is
released. value
must be of the type expected by the retain
and release callbacks.byte CFStringGetCString(CoreFoundation.CFStringRef theString, Pointer bufferToFill, CoreFoundation.CFIndex bufferSize, int encoding)
theString
- The string whose contents you wish to access.bufferToFill
- The C string buffer into which to copy the string. On return, the
buffer contains the converted characters. If there is an error in
conversion, the buffer contains only partial results.
The buffer must be large enough to contain the converted characters and a NUL terminator.
bufferSize
- The length of buffer
in bytes.encoding
- The string encoding to which the character contents of
theString
should be converted. The encoding must specify
an 8-bit encoding.byte CFBooleanGetValue(CoreFoundation.CFBooleanRef bool)
CFBoolean
object.bool
- The boolean to examine.bool
is true
, 0 otherwise.CoreFoundation.CFIndex CFArrayGetCount(CoreFoundation.CFArrayRef theArray)
theArray
- a CoreFoundation.CFArrayRef
object.array
.Pointer CFArrayGetValueAtIndex(CoreFoundation.CFArrayRef theArray, CoreFoundation.CFIndex idx)
theArray
- The array to examine.idx
- The index of the value to retrieve. If the index is outside the
index space of theArray
(0 to N-1 inclusive (where N is
the count of theArray
)), the behavior is undefined.idx
index in theArray
).CoreFoundation.CFIndex CFNumberGetType(CoreFoundation.CFNumberRef number)
CFNumber
object to store its value.number
- The CFNumber
object to examine.CoreFoundation.CFNumberType
for a list of possible values.byte CFNumberGetValue(CoreFoundation.CFNumberRef number, CoreFoundation.CFIndex theType, ByReference valuePtr)
CFNumber
object cast to a specified type.number
- The CFNumber
object to examine.theType
- A constant that specifies the data type to return. See
CoreFoundation.CFNumberType
for a list of possible values.valuePtr
- On return, contains the value of number
.CoreFoundation.CFIndex CFStringGetLength(CoreFoundation.CFStringRef theString)
theString
- The string to examine.theString
.CoreFoundation.CFIndex CFStringGetMaximumSizeForEncoding(CoreFoundation.CFIndex length, int encoding)
length
- The number of Unicode characters to evaluate.encoding
- The string encoding for the number of characters specified by
length.kCFNotFound
if the number exceeds Long.MAX_VALUE
.CoreFoundation.CFAllocatorRef CFAllocatorGetDefault()
The default allocator can never be released, so it is not necessary
to CFRetain(com.sun.jna.platform.mac.CoreFoundation.CFTypeRef)
this reference.
CoreFoundation.CFIndex CFDataGetLength(CoreFoundation.CFDataRef theData)
CFData
object.theData
- The CFData
object to examine.theData
.Pointer CFDataGetBytePtr(CoreFoundation.CFDataRef theData)
CFData
object.theData
- The CFData
object to examine.theData
.CoreFoundation.CFTypeID CFGetTypeID(CoreFoundation.CFTypeRef theObject)
CFType
object.theObject
- The CFData
object to examine.CoreFoundation.CFTypeID
that identifies the opaque type of
cf
.CoreFoundation.CFTypeID CFArrayGetTypeID()
CFArray
opaque type.CoreFoundation.CFTypeID CFBooleanGetTypeID()
CFBoolean
opaque type.CoreFoundation.CFTypeID CFDateGetTypeID()
CFDate
opaque type.CoreFoundation.CFTypeID CFDataGetTypeID()
CFData
opaque type.
CFMutableData
objects have the same type identifier as
CFData
objects.
CoreFoundation.CFTypeID CFDictionaryGetTypeID()
CFDictionary
opaque type.
CFMutableDictionary
objects have the same type identifier as
CFDictionary
objects.
CoreFoundation.CFTypeID CFNumberGetTypeID()
CFNumber
opaque type.CoreFoundation.CFTypeID CFStringGetTypeID()
CFString
opaque type.