mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-07 17:29:36 +00:00
1
This commit is contained in:
@@ -0,0 +1,692 @@
|
||||
/* CFArray.h
|
||||
Copyright (c) 1998-2003, Apple, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@header CFArray
|
||||
CFArray implements an ordered, compact container of pointer-sized
|
||||
values. Values are accessed via integer keys (indices), from the
|
||||
range 0 to N-1, where N is the number of values in the array when
|
||||
an operation is performed. The array is said to be "compact" because
|
||||
deleted or inserted values do not leave a gap in the key space --
|
||||
the values with higher-numbered indices have their indices
|
||||
renumbered lower (or higher, in the case of insertion) so that the
|
||||
set of valid indices is always in the integer range [0, N-1]. Thus,
|
||||
the index to access a particular value in the array may change over
|
||||
time as other values are inserted into or deleted from the array.
|
||||
|
||||
Arrays come in two flavors, immutable, which cannot have values
|
||||
added to them or removed from them after the array is created, and
|
||||
mutable, to which you can add values or from which remove values.
|
||||
Mutable arrays have two subflavors, fixed-capacity, for which there
|
||||
is a maximum number set at creation time of values which can be put
|
||||
into the array, and variable capacity, which can have an unlimited
|
||||
number of values (or rather, limited only by constraints external
|
||||
to CFArray, like the amount of available memory). Fixed-capacity
|
||||
arrays can be somewhat higher performing, if you can put a definite
|
||||
upper limit on the number of values that might be put into the
|
||||
array.
|
||||
|
||||
As with all CoreFoundation collection types, arrays maintain hard
|
||||
references on the values you put in them, but the retaining and
|
||||
releasing functions are user-defined callbacks that can actually do
|
||||
whatever the user wants (for example, nothing).
|
||||
|
||||
Computational Complexity
|
||||
The access time for a value in the array is guaranteed to be at
|
||||
worst O(lg N) for any implementation, current and future, but will
|
||||
often be O(1) (constant time). Linear search operations similarly
|
||||
have a worst case complexity of O(N*lg N), though typically the
|
||||
bounds will be tighter, and so on. Insertion or deletion operations
|
||||
will typically be linear in the number of values in the array, but
|
||||
may be O(N*lg N) clearly in the worst case in some implementations.
|
||||
There are no favored positions within the array for performance;
|
||||
that is, it is not necessarily faster to access values with low
|
||||
indices, or to insert or delete values with high indices, or
|
||||
whatever.
|
||||
*/
|
||||
|
||||
#if !defined(__COREFOUNDATION_CFARRAY__)
|
||||
#define __COREFOUNDATION_CFARRAY__ 1
|
||||
|
||||
#include <CoreFoundation/CFBase.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@typedef CFArrayCallBacks
|
||||
Structure containing the callbacks of a CFArray.
|
||||
@field version The version number of the structure type being passed
|
||||
in as a parameter to the CFArray creation functions. This
|
||||
structure is version 0.
|
||||
@field retain The callback used to add a retain for the array on
|
||||
values as they are put into the array. This callback returns
|
||||
the value to store in the array, which is usually the value
|
||||
parameter passed to this callback, but may be a different
|
||||
value if a different value should be stored in the array.
|
||||
The array's allocator is passed as the first argument.
|
||||
@field release The callback used to remove a retain previously added
|
||||
for the array from values as they are removed from the
|
||||
array. The array's allocator is passed as the first
|
||||
argument.
|
||||
@field copyDescription The callback used to create a descriptive
|
||||
string representation of each value in the array. This is
|
||||
used by the CFCopyDescription() function.
|
||||
@field equal The callback used to compare values in the array for
|
||||
equality for some operations.
|
||||
*/
|
||||
typedef const void * (*CFArrayRetainCallBack)(CFAllocatorRef allocator, const void *value);
|
||||
typedef void (*CFArrayReleaseCallBack)(CFAllocatorRef allocator, const void *value);
|
||||
typedef CFStringRef (*CFArrayCopyDescriptionCallBack)(const void *value);
|
||||
typedef Boolean (*CFArrayEqualCallBack)(const void *value1, const void *value2);
|
||||
typedef struct {
|
||||
CFIndex version;
|
||||
CFArrayRetainCallBack retain;
|
||||
CFArrayReleaseCallBack release;
|
||||
CFArrayCopyDescriptionCallBack copyDescription;
|
||||
CFArrayEqualCallBack equal;
|
||||
} CFArrayCallBacks;
|
||||
|
||||
/*!
|
||||
@constant kCFTypeArrayCallBacks
|
||||
Predefined CFArrayCallBacks structure containing a set of callbacks
|
||||
appropriate for use when the values in a CFArray are all CFTypes.
|
||||
*/
|
||||
#if TARGET_OS_WIN32
|
||||
#define kCFTypeArrayCallBacks (*((const CFArrayCallBacks *)QTGetCFConstant("kCFTypeArrayCallBacks")))
|
||||
#else
|
||||
CF_EXPORT
|
||||
const CFArrayCallBacks kCFTypeArrayCallBacks;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@typedef CFArrayApplierFunction
|
||||
Type of the callback function used by the apply functions of
|
||||
CFArrays.
|
||||
@param value The current value from the array.
|
||||
@param context The user-defined context parameter given to the apply
|
||||
function.
|
||||
*/
|
||||
typedef void (*CFArrayApplierFunction)(const void *value, void *context);
|
||||
|
||||
/*!
|
||||
@typedef CFArrayRef
|
||||
This is the type of a reference to immutable CFArrays.
|
||||
*/
|
||||
typedef const struct __CFArray * CFArrayRef;
|
||||
|
||||
/*!
|
||||
@typedef CFMutableArrayRef
|
||||
This is the type of a reference to mutable CFArrays.
|
||||
*/
|
||||
typedef struct __CFArray * CFMutableArrayRef;
|
||||
|
||||
/*!
|
||||
@function CFArrayGetTypeID
|
||||
Returns the type identifier of all CFArray instances.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFTypeID CFArrayGetTypeID(void);
|
||||
|
||||
/*!
|
||||
@function CFArrayCreate
|
||||
Creates a new immutable array with the given values.
|
||||
@param allocator The CFAllocator which should be used to allocate
|
||||
memory for the array and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param values A C array of the pointer-sized values to be in the
|
||||
array. The values in the array are ordered in the same order
|
||||
in which they appear in this C array. This parameter may be
|
||||
NULL if the numValues parameter is 0. This C array is not
|
||||
changed or freed by this function. If this parameter is not
|
||||
a valid pointer to a C array of at least numValues pointers,
|
||||
the behavior is undefined.
|
||||
@param numValues The number of values to copy from the values C
|
||||
array into the CFArray. This number will be the count of the
|
||||
array.
|
||||
If this parameter is negative, or greater than the number of
|
||||
values actually in the value's C array, the behavior is
|
||||
undefined.
|
||||
@param callBacks A pointer to a CFArrayCallBacks structure
|
||||
initialized with the callbacks for the array to use on each
|
||||
value in the array. The retain callback will be 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 array creations. If the version field of this
|
||||
callbacks structure is not one of the defined ones for
|
||||
CFArray, the behavior is undefined. The retain field may be
|
||||
NULL, in which case the CFArray will do nothing to add a
|
||||
retain to the contained values for the array. The release
|
||||
field may be NULL, in which case the CFArray will do nothing
|
||||
to remove the array's retain (if any) on the values when the
|
||||
array is destroyed. If the copyDescription field is NULL,
|
||||
the array will create a simple description for the value. If
|
||||
the equal field is NULL, the array will use pointer equality
|
||||
to test for equality of values. This callbacks parameter
|
||||
itself may be NULL, which is treated as if a valid structure
|
||||
of version 0 with all fields NULL had been passed in.
|
||||
Otherwise, if any of the fields are not valid pointers to
|
||||
functions of the correct type, or this parameter is not a
|
||||
valid pointer to a CFArrayCallBacks callbacks structure,
|
||||
the behavior is undefined. If any of the values put into the
|
||||
array is not one understood by one of the callback functions
|
||||
the behavior when that callback function is used is
|
||||
undefined.
|
||||
@result A reference to the new immutable CFArray.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFArrayCallBacks *callBacks);
|
||||
|
||||
/*!
|
||||
@function CFArrayCreateCopy
|
||||
Creates a new immutable array with the values from the given array.
|
||||
@param allocator The CFAllocator which should be used to allocate
|
||||
memory for the array and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param theArray The array which is to be copied. The values from the
|
||||
array are copied as pointers into the new array (that is,
|
||||
the values themselves are copied, not that which the values
|
||||
point to, if anything). However, the values are also
|
||||
retained by the new array. The count of the new array will
|
||||
be the same as the given array. The new array uses the same
|
||||
callbacks as the array to be copied. If this parameter is
|
||||
not a valid CFArray, the behavior is undefined.
|
||||
@result A reference to the new immutable CFArray.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFArrayRef CFArrayCreateCopy(CFAllocatorRef allocator, CFArrayRef theArray);
|
||||
|
||||
/*!
|
||||
@function CFArrayCreateMutable
|
||||
Creates a new empty mutable array.
|
||||
@param allocator The CFAllocator which should be used to allocate
|
||||
memory for the array and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param capacity The maximum number of values that can be contained
|
||||
by the CFArray. The array starts empty, and can grow to this
|
||||
number of values (and it can have less). If this parameter
|
||||
is 0, the array's maximum capacity is unlimited (or rather,
|
||||
only limited by address space and available memory
|
||||
constraints). If this parameter is negative, the behavior is
|
||||
undefined.
|
||||
@param callBacks A pointer to a CFArrayCallBacks structure
|
||||
initialized with the callbacks for the array to use on each
|
||||
value in the 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 array creations. If the version field of this
|
||||
callbacks structure is not one of the defined ones for
|
||||
CFArray, the behavior is undefined. The retain field may be
|
||||
NULL, in which case the CFArray will do nothing to add a
|
||||
retain to the contained values for the array. The release
|
||||
field may be NULL, in which case the CFArray will do nothing
|
||||
to remove the arrays retain (if any) on the values when the
|
||||
array is destroyed. If the copyDescription field is NULL,
|
||||
the array will create a simple description for the value. If
|
||||
the equal field is NULL, the array will use pointer equality
|
||||
to test for equality of values. This callbacks parameter
|
||||
itself may be NULL, which is treated as if a valid structure
|
||||
of version 0 with all fields NULL had been passed in.
|
||||
Otherwise, if any of the fields are not valid pointers to
|
||||
functions of the correct type, or this parameter is not a
|
||||
valid pointer to a CFArrayCallBacks callbacks structure,
|
||||
the behavior is undefined. If any of the values put into the
|
||||
array is not one understood by one of the callback functions
|
||||
the behavior when that callback function is used is
|
||||
undefined.
|
||||
@result A reference to the new mutable CFArray.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks);
|
||||
|
||||
/*!
|
||||
@function CFArrayCreateMutableCopy
|
||||
Creates a new mutable array with the values from the given array.
|
||||
@param allocator The CFAllocator which should be used to allocate
|
||||
memory for the array and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param capacity The maximum number of values that can be contained
|
||||
by the CFArray. The array starts empty, and can grow to this
|
||||
number of values (and it can have less). If this parameter
|
||||
is 0, the array's maximum capacity is unlimited (or rather,
|
||||
only limited by address space and available memory
|
||||
constraints). This parameter must be greater than or equal
|
||||
to the count of the array which is to be copied, or the
|
||||
behavior is undefined. If this parameter is negative, the
|
||||
behavior is undefined.
|
||||
@param theArray The array which is to be copied. The values from the
|
||||
array are copied as pointers into the new array (that is,
|
||||
the values themselves are copied, not that which the values
|
||||
point to, if anything). However, the values are also
|
||||
retained by the new array. The count of the new array will
|
||||
be the same as the given array. The new array uses the same
|
||||
callbacks as the array to be copied. If this parameter is
|
||||
not a valid CFArray, the behavior is undefined.
|
||||
@result A reference to the new mutable CFArray.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFMutableArrayRef CFArrayCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFArrayRef theArray);
|
||||
|
||||
/*!
|
||||
@function CFArrayGetCount
|
||||
Returns the number of values currently in the array.
|
||||
@param theArray The array to be queried. If this parameter is not a valid
|
||||
CFArray, the behavior is undefined.
|
||||
@result The number of values in the array.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFIndex CFArrayGetCount(CFArrayRef theArray);
|
||||
|
||||
/*!
|
||||
@function CFArrayGetCountOfValue
|
||||
Counts the number of times the given value occurs in the array.
|
||||
@param theArray The array to be searched. If this parameter is not a
|
||||
valid CFArray, the behavior is undefined.
|
||||
@param range The range within the array to search. If the range
|
||||
location or end point (defined by the location plus length
|
||||
minus 1) is outside the index space of the array (0 to
|
||||
N-1 inclusive, where N is the count of the array), the
|
||||
behavior is undefined. If the range length is negative, the
|
||||
behavior is undefined. The range may be empty (length 0).
|
||||
@param value The value for which to find matches in the array. The
|
||||
equal() callback provided when the array was created is
|
||||
used to compare. If the equal() callback was NULL, pointer
|
||||
equality (in C, ==) is used. If value, or any of the values
|
||||
in the array, are not understood by the equal() callback,
|
||||
the behavior is undefined.
|
||||
@result The number of times the given value occurs in the array,
|
||||
within the specified range.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFIndex CFArrayGetCountOfValue(CFArrayRef theArray, CFRange range, const void *value);
|
||||
|
||||
/*!
|
||||
@function CFArrayContainsValue
|
||||
Reports whether or not the value is in the array.
|
||||
@param theArray The array to be searched. If this parameter is not a
|
||||
valid CFArray, the behavior is undefined.
|
||||
@param range The range within the array to search. If the range
|
||||
location or end point (defined by the location plus length
|
||||
minus 1) is outside the index space of the array (0 to
|
||||
N-1 inclusive, where N is the count of the array), the
|
||||
behavior is undefined. If the range length is negative, the
|
||||
behavior is undefined. The range may be empty (length 0).
|
||||
@param value The value for which to find matches in the array. The
|
||||
equal() callback provided when the array was created is
|
||||
used to compare. If the equal() callback was NULL, pointer
|
||||
equality (in C, ==) is used. If value, or any of the values
|
||||
in the array, are not understood by the equal() callback,
|
||||
the behavior is undefined.
|
||||
@result true, if the value is in the specified range of the array,
|
||||
otherwise false.
|
||||
*/
|
||||
CF_EXPORT
|
||||
Boolean CFArrayContainsValue(CFArrayRef theArray, CFRange range, const void *value);
|
||||
|
||||
/*!
|
||||
@function CFArrayGetValueAtIndex
|
||||
Retrieves the value at the given index.
|
||||
@param theArray The array to be queried. If this parameter is not a
|
||||
valid CFArray, the behavior is undefined.
|
||||
@param idx The index of the value to retrieve. If the index is
|
||||
outside the index space of the array (0 to N-1 inclusive,
|
||||
where N is the count of the array), the behavior is
|
||||
undefined.
|
||||
@result The value with the given index in the array.
|
||||
*/
|
||||
CF_EXPORT
|
||||
const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
|
||||
|
||||
/*!
|
||||
@function CFArrayGetValues
|
||||
Fills the buffer with values from the array.
|
||||
@param theArray The array to be queried. If this parameter is not a
|
||||
valid CFArray, the behavior is undefined.
|
||||
@param range The range of values within the array to retrieve. If
|
||||
the range location or end point (defined by the location
|
||||
plus length minus 1) is outside the index space of the
|
||||
array (0 to N-1 inclusive, where N is the count of the
|
||||
array), the behavior is undefined. If the range length is
|
||||
negative, the behavior is undefined. The range may be empty
|
||||
(length 0), in which case no values are put into the buffer.
|
||||
@param values A C array of pointer-sized values to be filled with
|
||||
values from the array. The values in the C array are ordered
|
||||
in the same order in which they appear in the array. If this
|
||||
parameter is not a valid pointer to a C array of at least
|
||||
range.length pointers, the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFArrayGetValues(CFArrayRef theArray, CFRange range, const void **values);
|
||||
|
||||
/*!
|
||||
@function CFArrayApplyFunction
|
||||
Calls a function once for each value in the array.
|
||||
@param theArray The array to be operated upon. If this parameter is not
|
||||
a valid CFArray, the behavior is undefined.
|
||||
@param range The range of values within the array to which to apply
|
||||
the function. If the range location or end point (defined by
|
||||
the location plus length minus 1) is outside the index
|
||||
space of the array (0 to N-1 inclusive, where N is the count
|
||||
of the array), the behavior is undefined. If the range
|
||||
length is negative, the behavior is undefined. The range may
|
||||
be empty (length 0).
|
||||
@param applier The callback function to call once for each value in
|
||||
the given range in the array. If this parameter is not a
|
||||
pointer to a function of the correct prototype, the behavior
|
||||
is undefined. If there are values in the range which the
|
||||
applier function does not expect or cannot properly apply
|
||||
to, the behavior is undefined.
|
||||
@param context A pointer-sized user-defined value, which is passed
|
||||
as the second parameter to the applier function, but is
|
||||
otherwise unused by this function. If the context is not
|
||||
what is expected by the applier function, the behavior is
|
||||
undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFArrayApplyFunction(CFArrayRef theArray, CFRange range, CFArrayApplierFunction applier, void *context);
|
||||
|
||||
/*!
|
||||
@function CFArrayGetFirstIndexOfValue
|
||||
Searches the array for the value.
|
||||
@param theArray The array to be searched. If this parameter is not a
|
||||
valid CFArray, the behavior is undefined.
|
||||
@param range The range within the array to search. If the range
|
||||
location or end point (defined by the location plus length
|
||||
minus 1) is outside the index space of the array (0 to
|
||||
N-1 inclusive, where N is the count of the array), the
|
||||
behavior is undefined. If the range length is negative, the
|
||||
behavior is undefined. The range may be empty (length 0).
|
||||
The search progresses from the smallest index defined by
|
||||
the range to the largest.
|
||||
@param value The value for which to find a match in the array. The
|
||||
equal() callback provided when the array was created is
|
||||
used to compare. If the equal() callback was NULL, pointer
|
||||
equality (in C, ==) is used. If value, or any of the values
|
||||
in the array, are not understood by the equal() callback,
|
||||
the behavior is undefined.
|
||||
@result The lowest index of the matching values in the range, or
|
||||
kCFNotFound if no value in the range matched.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFIndex CFArrayGetFirstIndexOfValue(CFArrayRef theArray, CFRange range, const void *value);
|
||||
|
||||
/*!
|
||||
@function CFArrayGetLastIndexOfValue
|
||||
Searches the array for the value.
|
||||
@param theArray The array to be searched. If this parameter is not a
|
||||
valid CFArray, the behavior is undefined.
|
||||
@param range The range within the array to search. If the range
|
||||
location or end point (defined by the location plus length
|
||||
minus 1) is outside the index space of the array (0 to
|
||||
N-1 inclusive, where N is the count of the array), the
|
||||
behavior is undefined. If the range length is negative, the
|
||||
behavior is undefined. The range may be empty (length 0).
|
||||
The search progresses from the largest index defined by the
|
||||
range to the smallest.
|
||||
@param value The value for which to find a match in the array. The
|
||||
equal() callback provided when the array was created is
|
||||
used to compare. If the equal() callback was NULL, pointer
|
||||
equality (in C, ==) is used. If value, or any of the values
|
||||
in the array, are not understood by the equal() callback,
|
||||
the behavior is undefined.
|
||||
@result The highest index of the matching values in the range, or
|
||||
kCFNotFound if no value in the range matched.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFIndex CFArrayGetLastIndexOfValue(CFArrayRef theArray, CFRange range, const void *value);
|
||||
|
||||
/*!
|
||||
@function CFArrayBSearchValues
|
||||
Searches the array for the value using a binary search algorithm.
|
||||
@param theArray The array to be searched. If this parameter is not a
|
||||
valid CFArray, the behavior is undefined. If the array is
|
||||
not sorted from least to greatest according to the
|
||||
comparator function, the behavior is undefined.
|
||||
@param range The range within the array to search. If the range
|
||||
location or end point (defined by the location plus length
|
||||
minus 1) is outside the index space of the array (0 to
|
||||
N-1 inclusive, where N is the count of the array), the
|
||||
behavior is undefined. If the range length is negative, the
|
||||
behavior is undefined. The range may be empty (length 0).
|
||||
@param value The value for which to find a match in the array. If
|
||||
value, or any of the values in the array, are not understood
|
||||
by the comparator callback, the behavior is undefined.
|
||||
@param comparator The function with the comparator function type
|
||||
signature which is used in the binary search operation to
|
||||
compare values in the array with the given value. If this
|
||||
parameter is not a pointer to a function of the correct
|
||||
prototype, the behavior is undefined. If there are values
|
||||
in the range which the comparator function does not expect
|
||||
or cannot properly compare, the behavior is undefined.
|
||||
@param context A pointer-sized user-defined value, which is passed
|
||||
as the third parameter to the comparator function, but is
|
||||
otherwise unused by this function. If the context is not
|
||||
what is expected by the comparator function, the behavior is
|
||||
undefined.
|
||||
@result The return value is either 1) the index of a value that
|
||||
matched, if the target value matches one or more in the
|
||||
range, 2) greater than or equal to the end point of the
|
||||
range, if the value is greater than all the values in the
|
||||
range, or 3) the index of the value greater than the target
|
||||
value, if the value lies between two of (or less than all
|
||||
of) the values in the range.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFIndex CFArrayBSearchValues(CFArrayRef theArray, CFRange range, const void *value, CFComparatorFunction comparator, void *context);
|
||||
|
||||
/*!
|
||||
@function CFArrayAppendValue
|
||||
Adds the value to the array giving it a new largest index.
|
||||
@param theArray The array to which the value is to be added. If this
|
||||
parameter is not a valid mutable CFArray, the behavior is
|
||||
undefined. If the array is a fixed-capacity array and it
|
||||
is full before this operation, the behavior is undefined.
|
||||
@param value The value to add to the array. The value is retained by
|
||||
the array using the retain callback provided when the array
|
||||
was created. If the value is not of the sort expected by the
|
||||
retain callback, the behavior is undefined. The value is
|
||||
assigned to the index one larger than the previous largest
|
||||
index, and the count of the array is increased by one.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value);
|
||||
|
||||
/*!
|
||||
@function CFArrayInsertValueAtIndex
|
||||
Adds the value to the array, giving it the given index.
|
||||
@param theArray The array to which the value is to be added. If this
|
||||
parameter is not a valid mutable CFArray, the behavior is
|
||||
undefined. If the array is a fixed-capacity array and it
|
||||
is full before this operation, the behavior is undefined.
|
||||
@param idx The index to which to add the new value. If the index is
|
||||
outside the index space of the array (0 to N inclusive,
|
||||
where N is the count of the array before the operation), the
|
||||
behavior is undefined. If the index is the same as N, this
|
||||
function has the same effect as CFArrayAppendValue().
|
||||
@param value The value to add to the array. The value is retained by
|
||||
the array using the retain callback provided when the array
|
||||
was created. If the value is not of the sort expected by the
|
||||
retain callback, the behavior is undefined. The value is
|
||||
assigned to the given index, and all values with equal and
|
||||
larger indices have their indexes increased by one.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFArrayInsertValueAtIndex(CFMutableArrayRef theArray, CFIndex idx, const void *value);
|
||||
|
||||
/*!
|
||||
@function CFArraySetValueAtIndex
|
||||
Changes the value with the given index in the array.
|
||||
@param theArray The array in which the value is to be changed. If this
|
||||
parameter is not a valid mutable CFArray, the behavior is
|
||||
undefined. If the array is a fixed-capacity array and it
|
||||
is full before this operation and the index is the same as
|
||||
N, the behavior is undefined.
|
||||
@param idx The index to which to set the new value. If the index is
|
||||
outside the index space of the array (0 to N inclusive,
|
||||
where N is the count of the array before the operation), the
|
||||
behavior is undefined. If the index is the same as N, this
|
||||
function has the same effect as CFArrayAppendValue().
|
||||
@param value The value to set in the array. The value is retained by
|
||||
the array using the retain callback provided when the array
|
||||
was created, and the previous value with that index is
|
||||
released. If the value is not of the sort expected by the
|
||||
retain callback, the behavior is undefined. The indices of
|
||||
other values is not affected.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFArraySetValueAtIndex(CFMutableArrayRef theArray, CFIndex idx, const void *value);
|
||||
|
||||
/*!
|
||||
@function CFArrayRemoveValueAtIndex
|
||||
Removes the value with the given index from the array.
|
||||
@param theArray The array from which the value is to be removed. If
|
||||
this parameter is not a valid mutable CFArray, the behavior
|
||||
is undefined.
|
||||
@param idx The index from which to remove the value. If the index is
|
||||
outside the index space of the array (0 to N-1 inclusive,
|
||||
where N is the count of the array before the operation), the
|
||||
behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFArrayRemoveValueAtIndex(CFMutableArrayRef theArray, CFIndex idx);
|
||||
|
||||
/*!
|
||||
@function CFArrayRemoveAllValues
|
||||
Removes all the values from the array, making it empty.
|
||||
@param theArray The array from which all of the values are to be
|
||||
removed. If this parameter is not a valid mutable CFArray,
|
||||
the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFArrayRemoveAllValues(CFMutableArrayRef theArray);
|
||||
|
||||
/*!
|
||||
@function CFArrayReplaceValues
|
||||
Replaces a range of values in the array.
|
||||
@param theArray The array from which all of the values are to be
|
||||
removed. If this parameter is not a valid mutable CFArray,
|
||||
the behavior is undefined.
|
||||
@param range The range of values within the array to replace. If the
|
||||
range location or end point (defined by the location plus
|
||||
length minus 1) is outside the index space of the array (0
|
||||
to N inclusive, where N is the count of the array), the
|
||||
behavior is undefined. If the range length is negative, the
|
||||
behavior is undefined. The range may be empty (length 0),
|
||||
in which case the new values are merely inserted at the
|
||||
range location.
|
||||
@param newValues A C array of the pointer-sized values to be placed
|
||||
into the array. The new values in the array are ordered in
|
||||
the same order in which they appear in this C array. This
|
||||
parameter may be NULL if the newCount parameter is 0. This
|
||||
C array is not changed or freed by this function. If this
|
||||
parameter is not a valid pointer to a C array of at least
|
||||
newCount pointers, the behavior is undefined.
|
||||
@param newCount The number of values to copy from the values C
|
||||
array into the CFArray. If this parameter is different than
|
||||
the range length, the excess newCount values will be
|
||||
inserted after the range, or the excess range values will be
|
||||
deleted. This parameter may be 0, in which case no new
|
||||
values are replaced into the array and the values in the
|
||||
range are simply removed. If this parameter is negative, or
|
||||
greater than the number of values actually in the newValues
|
||||
C array, the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFArrayReplaceValues(CFMutableArrayRef theArray, CFRange range, const void **newValues, CFIndex newCount);
|
||||
|
||||
/*!
|
||||
@function CFArrayExchangeValuesAtIndices
|
||||
Exchanges the values at two indices of the array.
|
||||
@param theArray The array of which the values are to be swapped. If
|
||||
this parameter is not a valid mutable CFArray, the behavior
|
||||
is undefined.
|
||||
@param idx1 The first index whose values should be swapped. If the
|
||||
index is outside the index space of the array (0 to N-1
|
||||
inclusive, where N is the count of the array before the
|
||||
operation), the behavior is undefined.
|
||||
@param idx2 The second index whose values should be swapped. If the
|
||||
index is outside the index space of the array (0 to N-1
|
||||
inclusive, where N is the count of the array before the
|
||||
operation), the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFArrayExchangeValuesAtIndices(CFMutableArrayRef theArray, CFIndex idx1, CFIndex idx2);
|
||||
|
||||
/*!
|
||||
@function CFArraySortValues
|
||||
Sorts the values in the array using the given comparison function.
|
||||
@param theArray The array whose values are to be sorted. If this
|
||||
parameter is not a valid mutable CFArray, the behavior is
|
||||
undefined.
|
||||
@param range The range of values within the array to sort. If the
|
||||
range location or end point (defined by the location plus
|
||||
length minus 1) is outside the index space of the array (0
|
||||
to N-1 inclusive, where N is the count of the array), the
|
||||
behavior is undefined. If the range length is negative, the
|
||||
behavior is undefined. The range may be empty (length 0).
|
||||
@param comparator The function with the comparator function type
|
||||
signature which is used in the sort operation to compare
|
||||
values in the array with the given value. If this parameter
|
||||
is not a pointer to a function of the correct prototype, the
|
||||
the behavior is undefined. If there are values in the array
|
||||
which the comparator function does not expect or cannot
|
||||
properly compare, the behavior is undefined. The values in
|
||||
the range are sorted from least to greatest according to
|
||||
this function.
|
||||
@param context A pointer-sized user-defined value, which is passed
|
||||
as the third parameter to the comparator function, but is
|
||||
otherwise unused by this function. If the context is not
|
||||
what is expected by the comparator function, the behavior is
|
||||
undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFArraySortValues(CFMutableArrayRef theArray, CFRange range, CFComparatorFunction comparator, void *context);
|
||||
|
||||
/*!
|
||||
@function CFArrayAppendArray
|
||||
Adds the values from an array to another array.
|
||||
@param theArray The array to which values from the otherArray are to
|
||||
be added. If this parameter is not a valid mutable CFArray,
|
||||
the behavior is undefined. If the array is a fixed-capacity
|
||||
array and adding range.length values from the otherArray
|
||||
exceeds the capacity of the array, the behavior is
|
||||
undefined.
|
||||
@param otherArray The array providing the values to be added to the
|
||||
array. If this parameter is not a valid CFArray, the
|
||||
behavior is undefined.
|
||||
@param otherRange The range within the otherArray from which to add
|
||||
the values to the array. If the range location or end point
|
||||
(defined by the location plus length minus 1) is outside
|
||||
the index space of the otherArray (0 to N-1 inclusive, where
|
||||
N is the count of the otherArray), the behavior is
|
||||
undefined. The new values are retained by the array using
|
||||
the retain callback provided when the array was created. If
|
||||
the values are not of the sort expected by the retain
|
||||
callback, the behavior is undefined. The values are assigned
|
||||
to the indices one larger than the previous largest index
|
||||
in the array, and beyond, and the count of the array is
|
||||
increased by range.length. The values are assigned new
|
||||
indices in the array from smallest to largest index in the
|
||||
order in which they appear in the otherArray.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFArrayAppendArray(CFMutableArrayRef theArray, CFArrayRef otherArray, CFRange otherRange);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! __COREFOUNDATION_CFARRAY__ */
|
||||
|
||||
@@ -0,0 +1,378 @@
|
||||
/* CFBase.h
|
||||
Copyright (c) 1998-2003, Apple, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#if !defined(__COREFOUNDATION_CFBASE__)
|
||||
#define __COREFOUNDATION_CFBASE__ 1
|
||||
|
||||
#if CF_QUICKTIME
|
||||
#include <ConditionalMacros.h>
|
||||
#include "QTMLCompilerOptions.h"
|
||||
#include "QTCFRenames.h"
|
||||
|
||||
#pragma warning(disable:4090)
|
||||
#pragma warning(disable:4133)
|
||||
|
||||
#endif
|
||||
|
||||
// Look for various windows environments, boil them all down to defining __WIN32__.
|
||||
// _WIN32 comes from MS tools. When using MinGW __WIN32__ is already defined.
|
||||
#if (defined(__CYGWIN32__) || defined(_WIN32) || (defined(__MWERKS__) && defined(__INTEL__))) && !defined (__WIN32__)
|
||||
#define __WIN32__ 1
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(_M_IX86) && !defined(__i386__)
|
||||
#define __i386__ 1
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_WIN32
|
||||
#define CF_BUILDING_CF_AS_LIB 1
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__MWERKS__)
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
// mostly for the benefit of MSVC
|
||||
#include <stdint.h>
|
||||
#include <GNUCompatibility/stdbool.h>
|
||||
#if TARGET_OS_WIN32
|
||||
#undef pascal
|
||||
#define pascal
|
||||
typedef void *HANDLE;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
#include <MacTypes.h>
|
||||
|
||||
#if !defined(__MACTYPES__)
|
||||
typedef unsigned char Boolean;
|
||||
typedef unsigned char UInt8;
|
||||
typedef signed char SInt8;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed short SInt16;
|
||||
typedef unsigned long UInt32;
|
||||
typedef signed long SInt32;
|
||||
typedef uint64_t UInt64;
|
||||
typedef int64_t SInt64;
|
||||
typedef float Float32;
|
||||
typedef double Float64;
|
||||
typedef unsigned short UniChar;
|
||||
typedef unsigned char * StringPtr;
|
||||
typedef const unsigned char * ConstStringPtr;
|
||||
typedef unsigned char Str255[256];
|
||||
typedef const unsigned char * ConstStr255Param;
|
||||
typedef SInt16 OSErr;
|
||||
typedef SInt32 OSStatus;
|
||||
#endif
|
||||
#if !defined(__MACTYPES__) || (defined(UNIVERSAL_INTERFACES_VERSION) && UNIVERSAL_INTERFACES_VERSION < 0x0340)
|
||||
typedef UInt32 UTF32Char;
|
||||
typedef UInt16 UTF16Char;
|
||||
typedef UInt8 UTF8Char;
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN32__) || defined (D__CYGWIN_)
|
||||
#error CoreFoundation is currently built with the Microsoft C Runtime, which is incompatible with the Cygwin DLL. You must either use the -mno-cygwin flag, or complete a port of CF to the Cygwin environment.
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(NULL)
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#if !defined(TRUE)
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#if !defined(FALSE)
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#undef CF_EXPORT
|
||||
#if defined(CF_BUILDING_CF_AS_LIB)
|
||||
// we're building CF as a library
|
||||
#define CF_EXPORT extern
|
||||
#elif defined(CF_BUILDING_CF)
|
||||
// we're building CF as a DLL
|
||||
#define CF_EXPORT __declspec(dllexport) extern
|
||||
#else
|
||||
#define CF_EXPORT __declspec(dllimport) extern
|
||||
#endif
|
||||
#elif defined(macintosh)
|
||||
#if defined(__MWERKS__)
|
||||
#define CF_EXPORT __declspec(export) extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(CF_EXPORT)
|
||||
#define CF_EXPORT extern
|
||||
#endif
|
||||
|
||||
#if !defined(CF_INLINE)
|
||||
#if defined(__GNUC__)
|
||||
#define CF_INLINE static __inline__
|
||||
#elif defined(__MWERKS__) || defined(__cplusplus)
|
||||
#define CF_INLINE static inline
|
||||
#elif defined(_MSC_VER)
|
||||
#define CF_INLINE static __inline
|
||||
#elif defined(__WIN32__)
|
||||
#define CF_INLINE static __inline__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
CF_EXPORT double kCFCoreFoundationVersionNumber;
|
||||
|
||||
#define kCFCoreFoundationVersionNumber10_0 196.4
|
||||
#define kCFCoreFoundationVersionNumber10_0_3 196.5
|
||||
#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
#define kCFCoreFoundationVersionNumber10_1 226.0
|
||||
/* Note these do not follow the usual numbering policy from the base release */
|
||||
#define kCFCoreFoundationVersionNumber10_1_2 227.2
|
||||
#define kCFCoreFoundationVersionNumber10_1_4 227.3
|
||||
#endif
|
||||
#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
#define kCFCoreFoundationVersionNumber10_2 263.0
|
||||
#endif
|
||||
|
||||
typedef UInt32 CFTypeID;
|
||||
typedef UInt32 CFOptionFlags;
|
||||
typedef UInt32 CFHashCode;
|
||||
typedef SInt32 CFIndex;
|
||||
|
||||
/* Base "type" of all "CF objects", and polymorphic functions on them */
|
||||
typedef const void * CFTypeRef;
|
||||
|
||||
typedef const struct __CFString * CFStringRef;
|
||||
typedef struct __CFString * CFMutableStringRef;
|
||||
|
||||
/*
|
||||
Type to mean any instance of a property list type;
|
||||
currently, CFString, CFData, CFNumber, CFBoolean, CFDate,
|
||||
CFArray, and CFDictionary.
|
||||
*/
|
||||
typedef CFTypeRef CFPropertyListRef;
|
||||
|
||||
/* Values returned from comparison functions */
|
||||
typedef enum {
|
||||
kCFCompareLessThan = -1,
|
||||
kCFCompareEqualTo = 0,
|
||||
kCFCompareGreaterThan = 1
|
||||
} CFComparisonResult;
|
||||
|
||||
/* A standard comparison function */
|
||||
typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context);
|
||||
|
||||
/* Constant used by some functions to indicate failed searches. */
|
||||
/* This is of type CFIndex. */
|
||||
enum {
|
||||
kCFNotFound = -1
|
||||
};
|
||||
|
||||
|
||||
#if TARGET_OS_WIN32
|
||||
CF_EXPORT
|
||||
void *QTGetCFConstant(const char *cfGlobalConstantKey);
|
||||
#endif // TARGET_OS_WIN32
|
||||
|
||||
/* Range type */
|
||||
typedef struct {
|
||||
CFIndex location;
|
||||
CFIndex length;
|
||||
} CFRange;
|
||||
|
||||
#if defined(CF_INLINE)
|
||||
CF_INLINE CFRange CFRangeMake(CFIndex loc, CFIndex len) {
|
||||
CFRange range;
|
||||
range.location = loc;
|
||||
range.length = len;
|
||||
return range;
|
||||
}
|
||||
#else
|
||||
#define CFRangeMake(LOC, LEN) __CFRangeMake(LOC, LEN)
|
||||
#endif
|
||||
|
||||
/* Private; do not use */
|
||||
CF_EXPORT
|
||||
CFRange __CFRangeMake(CFIndex loc, CFIndex len);
|
||||
|
||||
|
||||
#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
/* Null representant */
|
||||
|
||||
typedef const struct __CFNull * CFNullRef;
|
||||
|
||||
CF_EXPORT
|
||||
CFTypeID CFNullGetTypeID(void);
|
||||
|
||||
#if TARGET_OS_WIN32
|
||||
#define kCFNull (*((const CFNullRef *)QTGetCFConstant("kCFNull")))
|
||||
#else
|
||||
CF_EXPORT
|
||||
const CFNullRef kCFNull; // the singleton null instance
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Allocator API
|
||||
|
||||
Most of the time when specifying an allocator to Create functions, the NULL
|
||||
argument indicates "use the default"; this is the same as using kCFAllocatorDefault
|
||||
or the return value from CFAllocatorGetDefault(). This assures that you will use
|
||||
the allocator in effect at that time.
|
||||
|
||||
You should rarely use kCFAllocatorSystemDefault, the default default allocator.
|
||||
*/
|
||||
typedef const struct __CFAllocator * CFAllocatorRef;
|
||||
|
||||
#if TARGET_OS_WIN32
|
||||
#define kCFAllocatorDefault (*((const CFAllocatorRef *)QTGetCFConstant("kCFAllocatorDefault")))
|
||||
#define kCFAllocatorSystemDefault (*((const CFAllocatorRef *)QTGetCFConstant("kCFAllocatorSystemDefault")))
|
||||
#define kCFAllocatorMalloc (*((const CFAllocatorRef *)QTGetCFConstant("kCFAllocatorMalloc")))
|
||||
#define kCFAllocatorNull (*((const CFAllocatorRef *)QTGetCFConstant("kCFAllocatorNull")))
|
||||
#define kCFAllocatorUseContext (*((const CFAllocatorRef *)QTGetCFConstant("kCFAllocatorUseContext")))
|
||||
#else
|
||||
/* This is a synonym for NULL, if you'd rather use a named constant. */
|
||||
CF_EXPORT
|
||||
const CFAllocatorRef kCFAllocatorDefault;
|
||||
|
||||
/* Default system allocator; you rarely need to use this. */
|
||||
CF_EXPORT
|
||||
const CFAllocatorRef kCFAllocatorSystemDefault;
|
||||
|
||||
/* This allocator uses malloc(), realloc(), and free(). This should not be
|
||||
generally used; stick to kCFAllocatorDefault whenever possible. This
|
||||
allocator is useful as the "bytesDeallocator" in CFData or
|
||||
"contentsDeallocator" in CFString where the memory was obtained as a
|
||||
result of malloc() type functions.
|
||||
*/
|
||||
CF_EXPORT
|
||||
const CFAllocatorRef kCFAllocatorMalloc;
|
||||
|
||||
/* Null allocator which does nothing and allocates no memory. This allocator
|
||||
is useful as the "bytesDeallocator" in CFData or "contentsDeallocator"
|
||||
in CFString where the memory should not be freed.
|
||||
*/
|
||||
CF_EXPORT
|
||||
const CFAllocatorRef kCFAllocatorNull;
|
||||
|
||||
/* Special allocator argument to CFAllocatorCreate() which means
|
||||
"use the functions given in the context to allocate the allocator
|
||||
itself as well".
|
||||
*/
|
||||
CF_EXPORT
|
||||
const CFAllocatorRef kCFAllocatorUseContext;
|
||||
#endif
|
||||
|
||||
typedef const void * (*CFAllocatorRetainCallBack)(const void *info);
|
||||
typedef void (*CFAllocatorReleaseCallBack)(const void *info);
|
||||
typedef CFStringRef (*CFAllocatorCopyDescriptionCallBack)(const void *info);
|
||||
typedef void * (*CFAllocatorAllocateCallBack)(CFIndex allocSize, CFOptionFlags hint, void *info);
|
||||
typedef void * (*CFAllocatorReallocateCallBack)(void *ptr, CFIndex newsize, CFOptionFlags hint, void *info);
|
||||
typedef void (*CFAllocatorDeallocateCallBack)(void *ptr, void *info);
|
||||
typedef CFIndex (*CFAllocatorPreferredSizeCallBack)(CFIndex size, CFOptionFlags hint, void *info);
|
||||
typedef struct {
|
||||
CFIndex version;
|
||||
void * info;
|
||||
CFAllocatorRetainCallBack retain;
|
||||
CFAllocatorReleaseCallBack release;
|
||||
CFAllocatorCopyDescriptionCallBack copyDescription;
|
||||
CFAllocatorAllocateCallBack allocate;
|
||||
CFAllocatorReallocateCallBack reallocate;
|
||||
CFAllocatorDeallocateCallBack deallocate;
|
||||
CFAllocatorPreferredSizeCallBack preferredSize;
|
||||
} CFAllocatorContext;
|
||||
|
||||
CF_EXPORT
|
||||
CFTypeID CFAllocatorGetTypeID(void);
|
||||
|
||||
/*
|
||||
CFAllocatorSetDefault() sets the allocator that is used in the current
|
||||
thread whenever NULL is specified as an allocator argument. This means
|
||||
that most, if not all allocations will go through this allocator. It
|
||||
also means that any allocator set as the default needs to be ready to
|
||||
deal with arbitrary memory allocation requests; in addition, the size
|
||||
and number of requests will change between releases.
|
||||
|
||||
An allocator set as the default will never be released, even if later
|
||||
another allocator replaces it as the default. Not only is it impractical
|
||||
for it to be released (as there might be caches created under the covers
|
||||
that refer to the allocator), in general it's also safer and more
|
||||
efficient to keep it around.
|
||||
|
||||
If you wish to use a custom allocator in a context, it's best to provide
|
||||
it as the argument to the various creation functions rather than setting
|
||||
it as the default. Setting the default allocator is not encouraged.
|
||||
|
||||
If you do set an allocator as the default, either do it for all time in
|
||||
your app, or do it in a nested fashion (by restoring the previous allocator
|
||||
when you exit your context). The latter might be appropriate for plug-ins
|
||||
or libraries that wish to set the default allocator.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFAllocatorSetDefault(CFAllocatorRef allocator);
|
||||
|
||||
CF_EXPORT
|
||||
CFAllocatorRef CFAllocatorGetDefault(void);
|
||||
|
||||
CF_EXPORT
|
||||
CFAllocatorRef CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorContext *context);
|
||||
|
||||
CF_EXPORT
|
||||
void *CFAllocatorAllocate(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint);
|
||||
|
||||
CF_EXPORT
|
||||
void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize, CFOptionFlags hint);
|
||||
|
||||
CF_EXPORT
|
||||
void CFAllocatorDeallocate(CFAllocatorRef allocator, void *ptr);
|
||||
|
||||
CF_EXPORT
|
||||
CFIndex CFAllocatorGetPreferredSizeForSize(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint);
|
||||
|
||||
CF_EXPORT
|
||||
void CFAllocatorGetContext(CFAllocatorRef allocator, CFAllocatorContext *context);
|
||||
|
||||
|
||||
/* Polymorphic CF functions */
|
||||
|
||||
CF_EXPORT
|
||||
CFTypeID CFGetTypeID(CFTypeRef cf);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFCopyTypeIDDescription(CFTypeID type_id);
|
||||
|
||||
CF_EXPORT
|
||||
CFTypeRef CFRetain(CFTypeRef cf);
|
||||
|
||||
CF_EXPORT
|
||||
void CFRelease(CFTypeRef cf);
|
||||
|
||||
CF_EXPORT
|
||||
CFIndex CFGetRetainCount(CFTypeRef cf);
|
||||
|
||||
CF_EXPORT
|
||||
Boolean CFEqual(CFTypeRef cf1, CFTypeRef cf2);
|
||||
|
||||
CF_EXPORT
|
||||
CFHashCode CFHash(CFTypeRef cf);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFCopyDescription(CFTypeRef cf);
|
||||
|
||||
CF_EXPORT
|
||||
CFAllocatorRef CFGetAllocator(CFTypeRef cf);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! __COREFOUNDATION_CFBASE__ */
|
||||
|
||||
@@ -0,0 +1,392 @@
|
||||
/* CFCharacterSet.h
|
||||
Copyright (c) 1999-2003, Apple, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@header CFCharacterSet
|
||||
CFCharacterSet represents a set, or a bag, of Unicode characters.
|
||||
The API consists of 3 groups:
|
||||
1) creation/manipulation of CFCharacterSet instances,
|
||||
2) query of a single Unicode character membership,
|
||||
and 3) bitmap representation related (reading/writing).
|
||||
Conceptually, CFCharacterSet is a 136K byte bitmap array of
|
||||
which each bit represents a Unicode code point. It could
|
||||
contain the Unicode characters in ISO 10646 Basic Multilingual
|
||||
Plane (BMP) and characters in Plane 1 through Plane 16
|
||||
accessible via surrogate paris in the Unicode Transformation
|
||||
Format, 16-bit encoding form (UTF-16). In other words, it can
|
||||
store values from 0x00000 to 0x10FFFF in the Unicode
|
||||
Transformation Format, 32-bit encoding form (UTF-32). However,
|
||||
in general, how CFCharacterSet stores the information is an
|
||||
implementation detail. Note even CFData used for the external
|
||||
bitmap representation rarely has 136K byte. For detailed
|
||||
discussion of the external bitmap representation, refer to the
|
||||
comments for CFCharacterSetCreateWithBitmapRepresentation below.
|
||||
Note that the existance of non-BMP characters in a character set
|
||||
does not imply the membership of the corresponding surrogate
|
||||
characters. For example, a character set with U+10000 does not
|
||||
match with U+D800.
|
||||
*/
|
||||
|
||||
#if !defined(__COREFOUNDATION_CFCHARACTERSET__)
|
||||
#define __COREFOUNDATION_CFCHARACTERSET__ 1
|
||||
|
||||
#include <CoreFoundation/CFBase.h>
|
||||
#include <CoreFoundation/CFData.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@typedef CFCharacterSetRef
|
||||
This is the type of a reference to immutable CFCharacterSets.
|
||||
*/
|
||||
typedef const struct __CFCharacterSet * CFCharacterSetRef;
|
||||
|
||||
/*!
|
||||
@typedef CFMutableCharacterSetRef
|
||||
This is the type of a reference to mutable CFMutableCharacterSets.
|
||||
*/
|
||||
typedef struct __CFCharacterSet * CFMutableCharacterSetRef;
|
||||
|
||||
/*!
|
||||
@typedef CFCharacterSetPredefinedSet
|
||||
Type of the predefined CFCharacterSet selector values.
|
||||
*/
|
||||
typedef enum {
|
||||
kCFCharacterSetControl = 1, /* Control character set (Unicode General Category Cc and Cf) */
|
||||
kCFCharacterSetWhitespace, /* Whitespace character set (Unicode General Category Zs and U0009 CHARACTER TABULATION) */
|
||||
kCFCharacterSetWhitespaceAndNewline, /* Whitespace and Newline character set (Unicode General Category Z*, U000A ~ U000D, and U0085) */
|
||||
kCFCharacterSetDecimalDigit, /* Decimal digit character set */
|
||||
kCFCharacterSetLetter, /* Letter character set (Unicode General Category L* & M*) */
|
||||
kCFCharacterSetLowercaseLetter, /* Lowercase character set (Unicode General Category Ll) */
|
||||
kCFCharacterSetUppercaseLetter, /* Uppercase character set (Unicode General Category Lu and Lt) */
|
||||
kCFCharacterSetNonBase, /* Non-base character set (Unicode General Category M*) */
|
||||
kCFCharacterSetDecomposable, /* Canonically decomposable character set */
|
||||
kCFCharacterSetAlphaNumeric, /* Alpha Numeric character set (Unicode General Category L*, M*, & N*) */
|
||||
kCFCharacterSetPunctuation, /* Punctuation character set (Unicode General Category P*) */
|
||||
kCFCharacterSetIllegal /* Illegal character set */
|
||||
#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
, kCFCharacterSetCapitalizedLetter /* Titlecase character set (Unicode General Category Lt) */
|
||||
#endif
|
||||
#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
, kCFCharacterSetSymbol /* Symbol character set (Unicode General Category S*) */
|
||||
#endif
|
||||
} CFCharacterSetPredefinedSet;
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetGetTypeID
|
||||
Returns the type identifier of all CFCharacterSet instances.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFTypeID CFCharacterSetGetTypeID(void);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetGetPredefined
|
||||
Returns a predefined CFCharacterSet instance.
|
||||
@param theSetIdentifier The CFCharacterSetPredefinedSet selector
|
||||
which specifies the predefined character set. If the
|
||||
value is not in CFCharacterSetPredefinedSet, the behavior
|
||||
is undefined.
|
||||
@result A reference to the predefined immutable CFCharacterSet.
|
||||
This instance is owned by CF.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFCharacterSetRef CFCharacterSetGetPredefined(CFCharacterSetPredefinedSet theSetIdentifier);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetCreateWithCharactersInRange
|
||||
Creates a new immutable character set with the values from the given range.
|
||||
@param alloc The CFAllocator which should be used to allocate
|
||||
memory for the array and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param theRange The CFRange which should be used to specify the
|
||||
Unicode range the character set is filled with. It
|
||||
accepts the range in 32-bit in the UTF-32 format. The
|
||||
valid character point range is from 0x00000 to 0x10FFFF.
|
||||
If the range is outside of the valid Unicode character
|
||||
point, the behavior is undefined.
|
||||
@result A reference to the new immutable CFCharacterSet.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFCharacterSetRef CFCharacterSetCreateWithCharactersInRange(CFAllocatorRef alloc, CFRange theRange);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetCreateWithCharactersInString
|
||||
Creates a new immutable character set with the values in the given string.
|
||||
@param alloc The CFAllocator which should be used to allocate
|
||||
memory for the array and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param theString The CFString which should be used to specify
|
||||
the Unicode characters the character set is filled with.
|
||||
If this parameter is not a valid CFString, the behavior
|
||||
is undefined.
|
||||
@result A reference to the new immutable CFCharacterSet.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFCharacterSetRef CFCharacterSetCreateWithCharactersInString(CFAllocatorRef alloc, CFStringRef theString);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetCreateWithBitmapRepresentation
|
||||
Creates a new immutable character set with the bitmap representtion in the given data.
|
||||
@param alloc The CFAllocator which should be used to allocate
|
||||
memory for the array and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param theData The CFData which should be used to specify the
|
||||
bitmap representation of the Unicode character points
|
||||
the character set is filled with. The bitmap
|
||||
representation could contain all the Unicode character
|
||||
range starting from BMP to Plane 16. The first 8K bytes
|
||||
of the data represents the BMP range. The BMP range 8K
|
||||
bytes can be followed by zero to sixteen 8K byte
|
||||
bitmaps, each one with the plane index byte prepended.
|
||||
For example, the bitmap representing the BMP and Plane 2
|
||||
has the size of 16385 bytes (8K bytes for BMP, 1 byte
|
||||
index + 8K bytes bitmap for Plane 2). The plane index
|
||||
byte, in this case, contains the integer value two. If
|
||||
this parameter is not a valid CFData or it contains a
|
||||
Plane index byte outside of the valid Plane range
|
||||
(1 to 16), the behavior is undefined.
|
||||
@result A reference to the new immutable CFCharacterSet.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFCharacterSetRef CFCharacterSetCreateWithBitmapRepresentation(CFAllocatorRef alloc, CFDataRef theData);
|
||||
|
||||
#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
/*!
|
||||
@function CFCharacterSetCreateInvertedSet
|
||||
Creates a new immutable character set that is the invert of the specified character set.
|
||||
@param alloc The CFAllocator which should be used to allocate
|
||||
memory for the array and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param theSet The CFCharacterSet which is to be inverted. If this
|
||||
parameter is not a valid CFCharacterSet, the behavior is
|
||||
undefined.
|
||||
@result A reference to the new immutable CFCharacterSet.
|
||||
*/
|
||||
CF_EXPORT CFCharacterSetRef CFCharacterSetCreateInvertedSet(CFAllocatorRef alloc, CFCharacterSetRef theSet);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetIsSupersetOfSet
|
||||
Reports whether or not the character set is a superset of the character set specified as the second parameter.
|
||||
@param theSet The character set to be checked for the membership of theOtherSet.
|
||||
If this parameter is not a valid CFCharacterSet, the behavior is undefined.
|
||||
@param theOtherset The character set to be checked whether or not it is a subset of theSet.
|
||||
If this parameter is not a valid CFCharacterSet, the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT Boolean CFCharacterSetIsSupersetOfSet(CFCharacterSetRef theSet, CFCharacterSetRef theOtherset);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetHasMemberInPlane
|
||||
Reports whether or not the character set contains at least one member character in the specified plane.
|
||||
@param theSet The character set to be checked for the membership. If this
|
||||
parameter is not a valid CFCharacterSet, the behavior is undefined.
|
||||
@param thePlane The plane number to be checked for the membership.
|
||||
The valid value range is from 0 to 16. If the value is outside of the valid
|
||||
plane number range, the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT Boolean CFCharacterSetHasMemberInPlane(CFCharacterSetRef theSet, CFIndex thePlane);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetCreateMutable
|
||||
Creates a new empty mutable character set.
|
||||
@param allocator The CFAllocator which should be used to allocate
|
||||
memory for the array and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@result A reference to the new mutable CFCharacterSet.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFMutableCharacterSetRef CFCharacterSetCreateMutable(CFAllocatorRef alloc);
|
||||
|
||||
#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
/*!
|
||||
@function CFCharacterSetCreateCopy
|
||||
Creates a new character set with the values from the given character set. This function tries to compact the backing store where applicable.
|
||||
@param allocator The CFAllocator which should be used to allocate
|
||||
memory for the array and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param theSet The CFCharacterSet which is to be copied. If this
|
||||
parameter is not a valid CFCharacterSet, the behavior is
|
||||
undefined.
|
||||
@result A reference to the new CFCharacterSet.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFCharacterSetRef CFCharacterSetCreateCopy(CFAllocatorRef alloc, CFCharacterSetRef theSet) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
|
||||
#endif /* MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED */
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetCreateMutableCopy
|
||||
Creates a new mutable character set with the values from the given character set.
|
||||
@param allocator The CFAllocator which should be used to allocate
|
||||
memory for the array and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param theSet The CFCharacterSet which is to be copied. If this
|
||||
parameter is not a valid CFCharacterSet, the behavior is
|
||||
undefined.
|
||||
@result A reference to the new mutable CFCharacterSet.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFMutableCharacterSetRef CFCharacterSetCreateMutableCopy(CFAllocatorRef alloc, CFCharacterSetRef theSet);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetIsCharacterMember
|
||||
Reports whether or not the Unicode character is in the character set.
|
||||
@param theSet The character set to be searched. If this parameter
|
||||
is not a valid CFCharacterSet, the behavior is undefined.
|
||||
@param theChar The Unicode character for which to test against the
|
||||
character set. Note that this function takes 16-bit Unicode
|
||||
character value; hence, it does not support access to the
|
||||
non-BMP planes.
|
||||
@result true, if the value is in the character set, otherwise false.
|
||||
*/
|
||||
CF_EXPORT
|
||||
Boolean CFCharacterSetIsCharacterMember(CFCharacterSetRef theSet, UniChar theChar);
|
||||
|
||||
#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
/*!
|
||||
@function CFCharacterSetIsLongCharacterMember
|
||||
Reports whether or not the UTF-32 character is in the character set.
|
||||
@param theSet The character set to be searched. If this parameter
|
||||
is not a valid CFCharacterSet, the behavior is undefined.
|
||||
@param theChar The UTF-32 character for which to test against the
|
||||
character set.
|
||||
@result true, if the value is in the character set, otherwise false.
|
||||
*/
|
||||
CF_EXPORT Boolean CFCharacterSetIsLongCharacterMember(CFCharacterSetRef theSet, UTF32Char theChar);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetCreateBitmapRepresentation
|
||||
Creates a new immutable data with the bitmap representation from the given character set.
|
||||
@param allocator The CFAllocator which should be used to allocate
|
||||
memory for the array and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param theSet The CFCharacterSet which is to be used create the
|
||||
bitmap representation from. Refer to the comments for
|
||||
CFCharacterSetCreateWithBitmapRepresentation for the
|
||||
detailed discussion of the bitmap representation format.
|
||||
If this parameter is not a valid CFCharacterSet, the
|
||||
behavior is undefined.
|
||||
@result A reference to the new immutable CFData.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFDataRef CFCharacterSetCreateBitmapRepresentation(CFAllocatorRef alloc, CFCharacterSetRef theSet);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetAddCharactersInRange
|
||||
Adds the given range to the charaacter set.
|
||||
@param theSet The character set to which the range is to be added.
|
||||
If this parameter is not a valid mutable CFCharacterSet,
|
||||
the behavior is undefined.
|
||||
@param theRange The range to add to the character set. It accepts
|
||||
the range in 32-bit in the UTF-32 format. The valid
|
||||
character point range is from 0x00000 to 0x10FFFF. If the
|
||||
range is outside of the valid Unicode character point,
|
||||
the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFCharacterSetAddCharactersInRange(CFMutableCharacterSetRef theSet, CFRange theRange);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetRemoveCharactersInRange
|
||||
Removes the given range from the charaacter set.
|
||||
@param theSet The character set from which the range is to be
|
||||
removed. If this parameter is not a valid mutable
|
||||
CFCharacterSet, the behavior is undefined.
|
||||
@param theRange The range to remove from the character set.
|
||||
It accepts the range in 32-bit in the UTF-32 format.
|
||||
The valid character point range is from 0x00000 to 0x10FFFF.
|
||||
If the range is outside of the valid Unicode character point,
|
||||
the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFCharacterSetRemoveCharactersInRange(CFMutableCharacterSetRef theSet, CFRange theRange);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetAddCharactersInString
|
||||
Adds the characters in the given string to the charaacter set.
|
||||
@param theSet The character set to which the characters in the
|
||||
string are to be added. If this parameter is not a
|
||||
valid mutable CFCharacterSet, the behavior is undefined.
|
||||
@param theString The string to add to the character set.
|
||||
If this parameter is not a valid CFString, the behavior
|
||||
is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFCharacterSetAddCharactersInString(CFMutableCharacterSetRef theSet, CFStringRef theString);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetRemoveCharactersInString
|
||||
Removes the characters in the given string from the charaacter set.
|
||||
@param theSet The character set from which the characters in the
|
||||
string are to be remove. If this parameter is not a
|
||||
valid mutable CFCharacterSet, the behavior is undefined.
|
||||
@param theString The string to remove from the character set.
|
||||
If this parameter is not a valid CFString, the behavior
|
||||
is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFCharacterSetRemoveCharactersInString(CFMutableCharacterSetRef theSet, CFStringRef theString);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetUnion
|
||||
Forms the union with the given character set.
|
||||
@param theSet The destination character set into which the
|
||||
union of the two character sets is stored. If this
|
||||
parameter is not a valid mutable CFCharacterSet, the
|
||||
behavior is undefined.
|
||||
@param theOtherSet The character set with which the union is
|
||||
formed. If this parameter is not a valid CFCharacterSet,
|
||||
the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFCharacterSetUnion(CFMutableCharacterSetRef theSet, CFCharacterSetRef theOtherSet);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetIntersect
|
||||
Forms the intersection with the given character set.
|
||||
@param theSet The destination character set into which the
|
||||
intersection of the two character sets is stored.
|
||||
If this parameter is not a valid mutable CFCharacterSet,
|
||||
the behavior is undefined.
|
||||
@param theOtherSet The character set with which the intersection
|
||||
is formed. If this parameter is not a valid CFCharacterSet,
|
||||
the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFCharacterSetIntersect(CFMutableCharacterSetRef theSet, CFCharacterSetRef theOtherSet);
|
||||
|
||||
/*!
|
||||
@function CFCharacterSetInvert
|
||||
Inverts the content of the given character set.
|
||||
@param theSet The character set to be inverted.
|
||||
If this parameter is not a valid mutable CFCharacterSet,
|
||||
the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFCharacterSetInvert(CFMutableCharacterSetRef theSet);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !__COREFOUNDATION_CFCHARACTERSET__ */
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/* CFData.h
|
||||
Copyright (c) 1998-2003, Apple, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#if !defined(__COREFOUNDATION_CFDATA__)
|
||||
#define __COREFOUNDATION_CFDATA__ 1
|
||||
|
||||
#include <CoreFoundation/CFBase.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef const struct __CFData * CFDataRef;
|
||||
typedef struct __CFData * CFMutableDataRef;
|
||||
|
||||
CF_EXPORT
|
||||
CFTypeID CFDataGetTypeID(void);
|
||||
|
||||
CF_EXPORT
|
||||
CFDataRef CFDataCreate(CFAllocatorRef allocator, const UInt8 *bytes, CFIndex length);
|
||||
|
||||
CF_EXPORT
|
||||
CFDataRef CFDataCreateWithBytesNoCopy(CFAllocatorRef allocator, const UInt8 *bytes, CFIndex length, CFAllocatorRef bytesDeallocator);
|
||||
/* Pass kCFAllocatorNull as bytesDeallocator to assure the bytes aren't freed */
|
||||
|
||||
CF_EXPORT
|
||||
CFDataRef CFDataCreateCopy(CFAllocatorRef allocator, CFDataRef theData);
|
||||
|
||||
CF_EXPORT
|
||||
CFMutableDataRef CFDataCreateMutable(CFAllocatorRef allocator, CFIndex capacity);
|
||||
|
||||
CF_EXPORT
|
||||
CFMutableDataRef CFDataCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDataRef theData);
|
||||
|
||||
CF_EXPORT
|
||||
CFIndex CFDataGetLength(CFDataRef theData);
|
||||
|
||||
CF_EXPORT
|
||||
const UInt8 *CFDataGetBytePtr(CFDataRef theData);
|
||||
|
||||
CF_EXPORT
|
||||
UInt8 *CFDataGetMutableBytePtr(CFMutableDataRef theData);
|
||||
|
||||
CF_EXPORT
|
||||
void CFDataGetBytes(CFDataRef theData, CFRange range, UInt8 *buffer);
|
||||
|
||||
CF_EXPORT
|
||||
void CFDataSetLength(CFMutableDataRef theData, CFIndex length);
|
||||
|
||||
CF_EXPORT
|
||||
void CFDataIncreaseLength(CFMutableDataRef theData, CFIndex extraLength);
|
||||
|
||||
CF_EXPORT
|
||||
void CFDataAppendBytes(CFMutableDataRef theData, const UInt8 *bytes, CFIndex length);
|
||||
|
||||
CF_EXPORT
|
||||
void CFDataReplaceBytes(CFMutableDataRef theData, CFRange range, const UInt8 *newBytes, CFIndex newLength);
|
||||
|
||||
CF_EXPORT
|
||||
void CFDataDeleteBytes(CFMutableDataRef theData, CFRange range);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! __COREFOUNDATION_CFDATA__ */
|
||||
|
||||
@@ -0,0 +1,692 @@
|
||||
/* CFDictionary.h
|
||||
Copyright (c) 1998-2003, Apple, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@header CFDictionary
|
||||
CFDictionary implements a container which pairs pointer-sized keys
|
||||
with pointer-sized values. Values are accessed via arbitrary
|
||||
user-defined keys. A CFDictionary differs from a CFArray in that
|
||||
the key used to access a particular value in the dictionary remains
|
||||
the same as values are added to or removed from the dictionary,
|
||||
unless a value associated with its particular key is replaced or
|
||||
removed. In a CFArray, the key (or index) used to retrieve a
|
||||
particular value can change over time as values are added to or
|
||||
deleted from the array. Also unlike an array, there is no ordering
|
||||
among values in a dictionary. To enable later retrieval of a value,
|
||||
the key of the key-value pair should be constant (or treated as
|
||||
constant); if the key changes after being used to put a value in
|
||||
the dictionary, the value may not be retrievable. The keys of a
|
||||
dictionary form a set; that is, no two keys which are equal to
|
||||
one another are present in the dictionary at any time.
|
||||
|
||||
Dictionaries come in two flavors, immutable, which cannot have
|
||||
values added to them or removed from them after the dictionary is
|
||||
created, and mutable, to which you can add values or from which
|
||||
remove values. Mutable dictionaries have two subflavors,
|
||||
fixed-capacity, for which there is a maximum number set at creation
|
||||
time of values which can be put into the dictionary, and variable
|
||||
capacity, which can have an unlimited number of values (or rather,
|
||||
limited only by constraints external to CFDictionary, like the
|
||||
amount of available memory). Fixed-capacity dictionaries can be
|
||||
somewhat higher performing, if you can put a definate upper limit
|
||||
on the number of values that might be put into the dictionary.
|
||||
|
||||
As with all CoreFoundation collection types, dictionaries maintain
|
||||
hard references on the values you put in them, but the retaining and
|
||||
releasing functions are user-defined callbacks that can actually do
|
||||
whatever the user wants (for example, nothing).
|
||||
|
||||
Although a particular implementation of CFDictionary may not use
|
||||
hashing and a hash table for storage of the values, the keys have
|
||||
a hash-code generating function defined for them, and a function
|
||||
to test for equality of two keys. These two functions together
|
||||
must maintain the invariant that if equal(X, Y), then hash(X) ==
|
||||
hash(Y). Note that the converse will not generally be true (but
|
||||
the contrapositive, if hash(X) != hash(Y), then !equal(X, Y),
|
||||
will be as required by Boolean logic). If the hash() and equal()
|
||||
key callbacks are NULL, the key is used as a pointer-sized integer,
|
||||
and pointer equality is used. Care should be taken to provide a
|
||||
hash() callback which will compute sufficiently dispersed hash
|
||||
codes for the key set for best performance.
|
||||
|
||||
Computational Complexity
|
||||
The access time for a value in the dictionary is guaranteed to be at
|
||||
worst O(lg N) for any implementation, current and future, but will
|
||||
often be O(1) (constant time). Insertion or deletion operations
|
||||
will typically be constant time as well, but are O(N*lg N) in the
|
||||
worst case in some implementations. Access of values through a key
|
||||
is faster than accessing values directly (if there are any such
|
||||
operations). Dictionaries will tend to use significantly more memory
|
||||
than a array with the same number of values.
|
||||
*/
|
||||
|
||||
#if !defined(__COREFOUNDATION_CFDICTIONARY__)
|
||||
#define __COREFOUNDATION_CFDICTIONARY__ 1
|
||||
|
||||
#include <CoreFoundation/CFBase.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@typedef CFDictionaryKeyCallBacks
|
||||
Structure containing the callbacks for keys of a CFDictionary.
|
||||
@field version The version number of the structure type being passed
|
||||
in as a parameter to the CFDictionary creation functions.
|
||||
This structure is version 0.
|
||||
@field retain The callback used to add a retain for the dictionary
|
||||
on keys as they are used to put values into the dictionary.
|
||||
This callback returns the value to use as the key in the
|
||||
dictionary, which is usually the value parameter passed to
|
||||
this callback, but may be a different value if a different
|
||||
value should be used as the key. The dictionary's allocator
|
||||
is passed as the first argument.
|
||||
@field release The callback used to remove a retain previously added
|
||||
for the dictionary from keys as their values are removed from
|
||||
the dictionary. The dictionary's allocator is passed as the
|
||||
first argument.
|
||||
@field copyDescription The callback used to create a descriptive
|
||||
string representation of each key in the dictionary. This
|
||||
is used by the CFCopyDescription() function.
|
||||
@field equal The callback used to compare keys in the dictionary for
|
||||
equality.
|
||||
@field hash The callback used to compute a hash code for keys as they
|
||||
are used to access, add, or remove values in the dictionary.
|
||||
*/
|
||||
typedef const void * (*CFDictionaryRetainCallBack)(CFAllocatorRef allocator, const void *value);
|
||||
typedef void (*CFDictionaryReleaseCallBack)(CFAllocatorRef allocator, const void *value);
|
||||
typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack)(const void *value);
|
||||
typedef Boolean (*CFDictionaryEqualCallBack)(const void *value1, const void *value2);
|
||||
typedef CFHashCode (*CFDictionaryHashCallBack)(const void *value);
|
||||
typedef struct {
|
||||
CFIndex version;
|
||||
CFDictionaryRetainCallBack retain;
|
||||
CFDictionaryReleaseCallBack release;
|
||||
CFDictionaryCopyDescriptionCallBack copyDescription;
|
||||
CFDictionaryEqualCallBack equal;
|
||||
CFDictionaryHashCallBack hash;
|
||||
} CFDictionaryKeyCallBacks;
|
||||
|
||||
/*!
|
||||
@constant kCFTypeDictionaryKeyCallBacks
|
||||
Predefined CFDictionaryKeyCallBacks structure containing a
|
||||
set of callbacks appropriate for use when the keys of a
|
||||
CFDictionary are all CFTypes.
|
||||
*/
|
||||
#if TARGET_OS_WIN32
|
||||
#define kCFTypeDictionaryKeyCallBacks (*((const CFDictionaryKeyCallBacks *)QTGetCFConstant("kCFTypeDictionaryKeyCallBacks")))
|
||||
#else
|
||||
CF_EXPORT
|
||||
const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@constant kCFCopyStringDictionaryKeyCallBacks
|
||||
Predefined CFDictionaryKeyCallBacks structure containing a
|
||||
set of callbacks appropriate for use when the keys of a
|
||||
CFDictionary are all CFStrings, which may be mutable and
|
||||
need to be copied in order to serve as constant keys for
|
||||
the values in the dictionary.
|
||||
*/
|
||||
#if TARGET_OS_WIN32
|
||||
#define kCFCopyStringDictionaryKeyCallBacks (*((const CFDictionaryKeyCallBacks *)QTGetCFConstant("kCFCopyStringDictionaryKeyCallBacks")))
|
||||
#else
|
||||
CF_EXPORT
|
||||
const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@typedef CFDictionaryValueCallBacks
|
||||
Structure containing the callbacks for values of a CFDictionary.
|
||||
@field version The version number of the structure type being passed
|
||||
in as a parameter to the CFDictionary creation functions.
|
||||
This structure is version 0.
|
||||
@field retain The callback used to add a retain for the dictionary
|
||||
on values as they are put into the dictionary.
|
||||
This callback returns the value to use as the value in the
|
||||
dictionary, which is usually the value parameter passed to
|
||||
this callback, but may be a different value if a different
|
||||
value should be added to the dictionary. The dictionary's
|
||||
allocator is passed as the first argument.
|
||||
@field release The callback used to remove a retain previously added
|
||||
for the dictionary from values as they are removed from
|
||||
the dictionary. The dictionary's allocator is passed as the
|
||||
first argument.
|
||||
@field copyDescription The callback used to create a descriptive
|
||||
string representation of each value in the dictionary. This
|
||||
is used by the CFCopyDescription() function.
|
||||
@field equal The callback used to compare values in the dictionary for
|
||||
equality in some operations.
|
||||
*/
|
||||
typedef struct {
|
||||
CFIndex version;
|
||||
CFDictionaryRetainCallBack retain;
|
||||
CFDictionaryReleaseCallBack release;
|
||||
CFDictionaryCopyDescriptionCallBack copyDescription;
|
||||
CFDictionaryEqualCallBack equal;
|
||||
} CFDictionaryValueCallBacks;
|
||||
|
||||
/*!
|
||||
@constant kCFTypeDictionaryValueCallBacks
|
||||
Predefined CFDictionaryValueCallBacks structure containing a set
|
||||
of callbacks appropriate for use when the values in a CFDictionary
|
||||
are all CFTypes.
|
||||
*/
|
||||
#if TARGET_OS_WIN32
|
||||
#define kCFTypeDictionaryValueCallBacks (*((const CFDictionaryValueCallBacks *)QTGetCFConstant("kCFTypeDictionaryValueCallBacks")))
|
||||
#else
|
||||
CF_EXPORT
|
||||
const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@typedef CFDictionaryApplierFunction
|
||||
Type of the callback function used by the apply functions of
|
||||
CFDictionarys.
|
||||
@param key The current key for the value.
|
||||
@param value The current value from the dictionary.
|
||||
@param context The user-defined context parameter given to the apply
|
||||
function.
|
||||
*/
|
||||
typedef void (*CFDictionaryApplierFunction)(const void *key, const void *value, void *context);
|
||||
|
||||
/*!
|
||||
@typedef CFDictionaryRef
|
||||
This is the type of a reference to immutable CFDictionarys.
|
||||
*/
|
||||
typedef const struct __CFDictionary * CFDictionaryRef;
|
||||
|
||||
/*!
|
||||
@typedef CFMutableDictionaryRef
|
||||
This is the type of a reference to mutable CFDictionarys.
|
||||
*/
|
||||
typedef struct __CFDictionary * CFMutableDictionaryRef;
|
||||
|
||||
/*!
|
||||
@function CFDictionaryGetTypeID
|
||||
Returns the type identifier of all CFDictionary instances.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFTypeID CFDictionaryGetTypeID(void);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryCreate
|
||||
Creates a new immutable dictionary with the given values.
|
||||
@param allocator The CFAllocator which should be used to allocate
|
||||
memory for the dictionary and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param keys A C array of the pointer-sized keys to be used for
|
||||
the parallel C array of values to be put into the dictionary.
|
||||
This parameter may be NULL if the numValues parameter is 0.
|
||||
This C array is not changed or freed by this function. If
|
||||
this parameter is not a valid pointer to a C array of at
|
||||
least numValues pointers, the behavior is undefined.
|
||||
@param values A C array of the pointer-sized values to be in the
|
||||
dictionary. This parameter may be NULL if the numValues
|
||||
parameter is 0. This C array is not changed or freed by
|
||||
this function. If this parameter is not a valid pointer to
|
||||
a C array of at least numValues pointers, the behavior is
|
||||
undefined.
|
||||
@param numValues The number of values to copy from the keys and
|
||||
values C arrays into the CFDictionary. This number will be
|
||||
the count of the dictionary. If this parameter is
|
||||
negative, or greater than the number of values actually
|
||||
in the keys or values C arrays, the behavior is undefined.
|
||||
@param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure
|
||||
initialized with the callbacks for the dictionary to use on
|
||||
each key in the dictionary. The retain callback will be used
|
||||
within this function, for example, to retain all of the new
|
||||
keys from the keys 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
|
||||
dictionary creations. If the version field of this
|
||||
callbacks structure is not one of the defined ones for
|
||||
CFDictionary, the behavior is undefined. The retain field may
|
||||
be NULL, in which case the CFDictionary will do nothing to add
|
||||
a retain to the keys of the contained values. The release field
|
||||
may be NULL, in which case the CFDictionary will do nothing
|
||||
to remove the dictionary's retain (if any) on the keys when the
|
||||
dictionary is destroyed or a key-value pair is removed. If the
|
||||
copyDescription field is NULL, the dictionary will create a
|
||||
simple description for a key. If the equal field is NULL, the
|
||||
dictionary will use pointer equality to test for equality of
|
||||
keys. If the hash field is NULL, a key will be converted from
|
||||
a pointer to an integer to compute the hash code. This callbacks
|
||||
parameter itself may be NULL, which is treated as if a valid
|
||||
structure of version 0 with all fields NULL had been passed in.
|
||||
Otherwise, if any of the fields are not valid pointers to
|
||||
functions of the correct type, or this parameter is not a
|
||||
valid pointer to a CFDictionaryKeyCallBacks callbacks structure,
|
||||
the behavior is undefined. If any of the keys put into the
|
||||
dictionary is not one understood by one of the callback functions
|
||||
the behavior when that callback function is used is undefined.
|
||||
@param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure
|
||||
initialized with the callbacks for the dictionary to use on
|
||||
each value in the dictionary. The retain callback will be 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
|
||||
dictionary creations. If the version field of this callbacks
|
||||
structure is not one of the defined ones for CFDictionary, the
|
||||
behavior is undefined. The retain field may be NULL, in which
|
||||
case the CFDictionary will do nothing to add a retain to values
|
||||
as they are put into the dictionary. The release field may be
|
||||
NULL, in which case the CFDictionary will do nothing to remove
|
||||
the dictionary's retain (if any) on the values when the
|
||||
dictionary is destroyed or a key-value pair is removed. If the
|
||||
copyDescription field is NULL, the dictionary will create a
|
||||
simple description for a value. If the equal field is NULL, the
|
||||
dictionary will use pointer equality to test for equality of
|
||||
values. This callbacks parameter itself may be NULL, which is
|
||||
treated as if a valid structure of version 0 with all fields
|
||||
NULL had been passed in. Otherwise,
|
||||
if any of the fields are not valid pointers to functions
|
||||
of the correct type, or this parameter is not a valid
|
||||
pointer to a CFDictionaryValueCallBacks callbacks structure,
|
||||
the behavior is undefined. If any of the values put into the
|
||||
dictionary is not one understood by one of the callback functions
|
||||
the behavior when that callback function is used is undefined.
|
||||
@result A reference to the new immutable CFDictionary.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryCreateCopy
|
||||
Creates a new immutable dictionary with the key-value pairs from
|
||||
the given dictionary.
|
||||
@param allocator The CFAllocator which should be used to allocate
|
||||
memory for the dictionary and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param theDict The dictionary which is to be copied. The keys and values
|
||||
from the dictionary are copied as pointers into the new
|
||||
dictionary (that is, the values themselves are copied, not
|
||||
that which the values point to, if anything). However, the
|
||||
keys and values are also retained by the new dictionary using
|
||||
the retain function of the original dictionary.
|
||||
The count of the new dictionary will be the same as the
|
||||
given dictionary. The new dictionary uses the same callbacks
|
||||
as the dictionary to be copied. If this parameter is
|
||||
not a valid CFDictionary, the behavior is undefined.
|
||||
@result A reference to the new immutable CFDictionary.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFDictionaryRef CFDictionaryCreateCopy(CFAllocatorRef allocator, CFDictionaryRef theDict);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryCreateMutable
|
||||
Creates a new mutable dictionary.
|
||||
@param allocator The CFAllocator which should be used to allocate
|
||||
memory for the dictionary and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param capacity The maximum number of values that can be contained by
|
||||
the CFDictionary. The dictionary starts empty, and can grow
|
||||
to this number of values (and it can have less). If this
|
||||
parameter is 0, the dictionary's maximum capacity is unlimited
|
||||
(or rather, only limited by address space and available memory
|
||||
constraints). If this parameter is negative, the behavior is
|
||||
undefined.
|
||||
@param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure
|
||||
initialized with the callbacks for the dictionary to use on
|
||||
each key 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
|
||||
dictionary creations. If the version field of this
|
||||
callbacks structure is not one of the defined ones for
|
||||
CFDictionary, the behavior is undefined. The retain field may
|
||||
be NULL, in which case the CFDictionary will do nothing to add
|
||||
a retain to the keys of the contained values. The release field
|
||||
may be NULL, in which case the CFDictionary will do nothing
|
||||
to remove the dictionary's retain (if any) on the keys when the
|
||||
dictionary is destroyed or a key-value pair is removed. If the
|
||||
copyDescription field is NULL, the dictionary will create a
|
||||
simple description for a key. If the equal field is NULL, the
|
||||
dictionary will use pointer equality to test for equality of
|
||||
keys. If the hash field is NULL, a key will be converted from
|
||||
a pointer to an integer to compute the hash code. This callbacks
|
||||
parameter itself may be NULL, which is treated as if a valid
|
||||
structure of version 0 with all fields NULL had been passed in.
|
||||
Otherwise, if any of the fields are not valid pointers to
|
||||
functions of the correct type, or this parameter is not a
|
||||
valid pointer to a CFDictionaryKeyCallBacks callbacks structure,
|
||||
the behavior is undefined. If any of the keys put into the
|
||||
dictionary is not one understood by one of the callback functions
|
||||
the behavior when that callback function is used is undefined.
|
||||
@param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure
|
||||
initialized with the callbacks for the dictionary to use on
|
||||
each value in the dictionary. The retain callback will be 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
|
||||
dictionary creations. If the version field of this callbacks
|
||||
structure is not one of the defined ones for CFDictionary, the
|
||||
behavior is undefined. The retain field may be NULL, in which
|
||||
case the CFDictionary will do nothing to add a retain to values
|
||||
as they are put into the dictionary. The release field may be
|
||||
NULL, in which case the CFDictionary will do nothing to remove
|
||||
the dictionary's retain (if any) on the values when the
|
||||
dictionary is destroyed or a key-value pair is removed. If the
|
||||
copyDescription field is NULL, the dictionary will create a
|
||||
simple description for a value. If the equal field is NULL, the
|
||||
dictionary will use pointer equality to test for equality of
|
||||
values. This callbacks parameter itself may be NULL, which is
|
||||
treated as if a valid structure of version 0 with all fields
|
||||
NULL had been passed in. Otherwise,
|
||||
if any of the fields are not valid pointers to functions
|
||||
of the correct type, or this parameter is not a valid
|
||||
pointer to a CFDictionaryValueCallBacks callbacks structure,
|
||||
the behavior is undefined. If any of the values put into the
|
||||
dictionary is not one understood by one of the callback functions
|
||||
the behavior when that callback function is used is undefined.
|
||||
@result A reference to the new mutable CFDictionary.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryCreateMutableCopy
|
||||
Creates a new mutable dictionary with the key-value pairs from
|
||||
the given dictionary.
|
||||
@param allocator The CFAllocator which should be used to allocate
|
||||
memory for the dictionary and its storage for values. This
|
||||
parameter may be NULL in which case the current default
|
||||
CFAllocator is used. If this reference is not a valid
|
||||
CFAllocator, the behavior is undefined.
|
||||
@param capacity The maximum number of values that can be contained
|
||||
by the CFDictionary. The dictionary starts empty, and can grow
|
||||
to this number of values (and it can have less). If this
|
||||
parameter is 0, the dictionary's maximum capacity is unlimited
|
||||
(or rather, only limited by address space and available memory
|
||||
constraints). This parameter must be greater than or equal
|
||||
to the count of the dictionary which is to be copied, or the
|
||||
behavior is undefined. If this parameter is negative, the
|
||||
behavior is undefined.
|
||||
@param theDict The dictionary which is to be copied. The keys and values
|
||||
from the dictionary are copied as pointers into the new
|
||||
dictionary (that is, the values themselves are copied, not
|
||||
that which the values point to, if anything). However, the
|
||||
keys and values are also retained by the new dictionary using
|
||||
the retain function of the original dictionary.
|
||||
The count of the new dictionary will be the same as the
|
||||
given dictionary. The new dictionary uses the same callbacks
|
||||
as the dictionary to be copied. If this parameter is
|
||||
not a valid CFDictionary, the behavior is undefined.
|
||||
@result A reference to the new mutable CFDictionary.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFMutableDictionaryRef CFDictionaryCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDictionaryRef theDict);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryGetCount
|
||||
Returns the number of values currently in the dictionary.
|
||||
@param theDict The dictionary to be queried. If this parameter is
|
||||
not a valid CFDictionary, the behavior is undefined.
|
||||
@result The number of values in the dictionary.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFIndex CFDictionaryGetCount(CFDictionaryRef theDict);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryGetCountOfKey
|
||||
Counts the number of times the given key occurs in the dictionary.
|
||||
@param theDict The dictionary to be searched. If this parameter is
|
||||
not a valid CFDictionary, the behavior is undefined.
|
||||
@param key The key for which to find matches in the dictionary. The
|
||||
hash() and equal() key callbacks provided when the dictionary
|
||||
was created are used to compare. If the hash() key callback
|
||||
was NULL, the key is treated as a pointer and converted to
|
||||
an integer. If the equal() key callback was NULL, pointer
|
||||
equality (in C, ==) is used. If key, or any of the keys in
|
||||
the dictionary, are not understood by the equal() callback,
|
||||
the behavior is undefined.
|
||||
@result Returns 1 if a matching key is used by the dictionary,
|
||||
0 otherwise.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFIndex CFDictionaryGetCountOfKey(CFDictionaryRef theDict, const void *key);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryGetCountOfValue
|
||||
Counts the number of times the given value occurs in the dictionary.
|
||||
@param theDict The dictionary to be searched. If this parameter is
|
||||
not a valid CFDictionary, the behavior is undefined.
|
||||
@param value The value for which to find matches in the dictionary. The
|
||||
equal() callback provided when the dictionary was created is
|
||||
used to compare. If the equal() value callback was NULL, pointer
|
||||
equality (in C, ==) is used. If value, or any of the values in
|
||||
the dictionary, are not understood by the equal() callback,
|
||||
the behavior is undefined.
|
||||
@result The number of times the given value occurs in the dictionary.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFIndex CFDictionaryGetCountOfValue(CFDictionaryRef theDict, const void *value);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryContainsKey
|
||||
Reports whether or not the key is in the dictionary.
|
||||
@param theDict The dictionary to be searched. If this parameter is
|
||||
not a valid CFDictionary, the behavior is undefined.
|
||||
@param key The key for which to find matches in the dictionary. The
|
||||
hash() and equal() key callbacks provided when the dictionary
|
||||
was created are used to compare. If the hash() key callback
|
||||
was NULL, the key is treated as a pointer and converted to
|
||||
an integer. If the equal() key callback was NULL, pointer
|
||||
equality (in C, ==) is used. If key, or any of the keys in
|
||||
the dictionary, are not understood by the equal() callback,
|
||||
the behavior is undefined.
|
||||
@result true, if the key is in the dictionary, otherwise false.
|
||||
*/
|
||||
CF_EXPORT
|
||||
Boolean CFDictionaryContainsKey(CFDictionaryRef theDict, const void *key);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryContainsValue
|
||||
Reports whether or not the value is in the dictionary.
|
||||
@param theDict The dictionary to be searched. If this parameter is
|
||||
not a valid CFDictionary, the behavior is undefined.
|
||||
@param value The value for which to find matches in the dictionary. The
|
||||
equal() callback provided when the dictionary was created is
|
||||
used to compare. If the equal() callback was NULL, pointer
|
||||
equality (in C, ==) is used. If value, or any of the values
|
||||
in the dictionary, are not understood by the equal() callback,
|
||||
the behavior is undefined.
|
||||
@result true, if the value is in the dictionary, otherwise false.
|
||||
*/
|
||||
CF_EXPORT
|
||||
Boolean CFDictionaryContainsValue(CFDictionaryRef theDict, const void *value);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryGetValue
|
||||
Retrieves the value associated with the given key.
|
||||
@param theDict The dictionary to be queried. If this parameter is
|
||||
not a valid CFDictionary, the behavior is undefined.
|
||||
@param key The key for which to find a match in the dictionary. The
|
||||
hash() and equal() key callbacks provided when the dictionary
|
||||
was created are used to compare. If the hash() key callback
|
||||
was NULL, the key is treated as a pointer and converted to
|
||||
an integer. If the equal() key callback was NULL, pointer
|
||||
equality (in C, ==) is used. If key, or any of the keys in
|
||||
the dictionary, are not understood by the equal() callback,
|
||||
the behavior is undefined.
|
||||
@result The value with the given key in the dictionary, or NULL if
|
||||
no key-value pair with a matching key exists. Since NULL
|
||||
can be a valid value in some dictionaries, the function
|
||||
CFDictionaryGetValueIfPresent() must be used to distinguish
|
||||
NULL-no-found from NULL-is-the-value.
|
||||
*/
|
||||
CF_EXPORT
|
||||
const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryGetValueIfPresent
|
||||
Retrieves the value associated with the given key.
|
||||
@param theDict The dictionary to be queried. If this parameter is
|
||||
not a valid CFDictionary, the behavior is undefined.
|
||||
@param key The key for which to find a match in the dictionary. The
|
||||
hash() and equal() key callbacks provided when the dictionary
|
||||
was created are used to compare. If the hash() key callback
|
||||
was NULL, the key is treated as a pointer and converted to
|
||||
an integer. If the equal() key callback was NULL, pointer
|
||||
equality (in C, ==) is used. If key, or any of the keys in
|
||||
the dictionary, are not understood by the equal() callback,
|
||||
the behavior is undefined.
|
||||
@param value A pointer to memory which should be 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 parameter 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).
|
||||
@result true, if a matching key was found, false otherwise.
|
||||
*/
|
||||
CF_EXPORT
|
||||
Boolean CFDictionaryGetValueIfPresent(CFDictionaryRef theDict, const void *key, const void **value);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryGetKeysAndValues
|
||||
Fills the two buffers with the keys and values from the dictionary.
|
||||
@param theDict The dictionary to be queried. If this parameter is
|
||||
not a valid CFDictionary, the behavior is undefined.
|
||||
@param keys A C array of pointer-sized values to be filled with keys
|
||||
from the dictionary. The keys and values C arrays are parallel
|
||||
to each other (that is, the items at the same indices form a
|
||||
key-value pair from the dictionary). This parameter may be NULL
|
||||
if the keys are not desired. If this parameter is not a valid
|
||||
pointer to a C array of at least CFDictionaryGetCount() pointers,
|
||||
or NULL, the behavior is undefined.
|
||||
@param values A C array of pointer-sized values to be filled with values
|
||||
from the dictionary. The keys and values C arrays are parallel
|
||||
to each other (that is, the items at the same indices form a
|
||||
key-value pair from the dictionary). This parameter may be NULL
|
||||
if the values are not desired. If this parameter is not a valid
|
||||
pointer to a C array of at least CFDictionaryGetCount() pointers,
|
||||
or NULL, the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFDictionaryGetKeysAndValues(CFDictionaryRef theDict, const void **keys, const void **values);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryApplyFunction
|
||||
Calls a function once for each value in the dictionary.
|
||||
@param theDict The dictionary to be queried. If this parameter is
|
||||
not a valid CFDictionary, the behavior is undefined.
|
||||
@param applier The callback function to call once for each value in
|
||||
the dictionary. If this parameter is not a
|
||||
pointer to a function of the correct prototype, the behavior
|
||||
is undefined. If there are keys or values which the
|
||||
applier function does not expect or cannot properly apply
|
||||
to, the behavior is undefined.
|
||||
@param context A pointer-sized user-defined value, which is passed
|
||||
as the third parameter to the applier function, but is
|
||||
otherwise unused by this function. If the context is not
|
||||
what is expected by the applier function, the behavior is
|
||||
undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFDictionaryApplyFunction(CFDictionaryRef theDict, CFDictionaryApplierFunction applier, void *context);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryAddValue
|
||||
Adds the key-value pair to the dictionary if no such key already exists.
|
||||
@param theDict The dictionary to which the value is to be added. If this
|
||||
parameter is not a valid mutable CFDictionary, the behavior is
|
||||
undefined. If the dictionary is a fixed-capacity dictionary and
|
||||
it is full before this operation, the behavior is undefined.
|
||||
@param key The key of the value to add to the dictionary. The key is
|
||||
retained by the dictionary using the retain callback provided
|
||||
when the dictionary was created. If the key is not of the sort
|
||||
expected by the retain callback, the behavior is undefined. If
|
||||
a key which matches this key is already present in the dictionary,
|
||||
this function does nothing ("add if absent").
|
||||
@param value The value to add to the dictionary. The value is retained
|
||||
by the dictionary using the retain callback provided when the
|
||||
dictionary was created. If the value is not of the sort expected
|
||||
by the retain callback, the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFDictionaryAddValue(CFMutableDictionaryRef theDict, const void *key, const void *value);
|
||||
|
||||
/*!
|
||||
@function CFDictionarySetValue
|
||||
Sets the value of the key in the dictionary.
|
||||
@param theDict The dictionary to which the value is to be set. If this
|
||||
parameter is not a valid mutable CFDictionary, the behavior is
|
||||
undefined. If the dictionary 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.
|
||||
@param key The key of the value to set into the dictionary. If a key
|
||||
which matches this key is already present in the dictionary, only
|
||||
the value is changed ("add if absent, replace if present"). If
|
||||
no key matches the given key, the key-value pair is added to the
|
||||
dictionary. If added, the key is retained by the dictionary,
|
||||
using the retain callback provided
|
||||
when the dictionary was created. If the key is not of the sort
|
||||
expected by the key retain callback, the behavior is undefined.
|
||||
@param value The value to add to or replace into the dictionary. The value
|
||||
is retained by the dictionary using the retain callback provided
|
||||
when the dictionary was created, and the previous value if any is
|
||||
released. If the value is not of the sort expected by the
|
||||
retain or release callbacks, the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFDictionarySetValue(CFMutableDictionaryRef theDict, const void *key, const void *value);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryReplaceValue
|
||||
Replaces the value of the key in the dictionary.
|
||||
@param theDict The dictionary to which the value is to be replaced. If this
|
||||
parameter is not a valid mutable CFDictionary, the behavior is
|
||||
undefined.
|
||||
@param key The key of the value to replace in the dictionary. If a key
|
||||
which matches this key is present in the dictionary, the value
|
||||
is changed to the given value, otherwise this function does
|
||||
nothing ("replace if present").
|
||||
@param value The value to replace into the dictionary. The value
|
||||
is retained by the dictionary using the retain callback provided
|
||||
when the dictionary was created, and the previous value is
|
||||
released. If the value is not of the sort expected by the
|
||||
retain or release callbacks, the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFDictionaryReplaceValue(CFMutableDictionaryRef theDict, const void *key, const void *value);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryRemoveValue
|
||||
Removes the value of the key from the dictionary.
|
||||
@param theDict The dictionary from which the value is to be removed. If this
|
||||
parameter is not a valid mutable CFDictionary, the behavior is
|
||||
undefined.
|
||||
@param key The key of the value to remove from the dictionary. If a key
|
||||
which matches this key is present in the dictionary, the key-value
|
||||
pair is removed from the dictionary, otherwise this function does
|
||||
nothing ("remove if present").
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFDictionaryRemoveValue(CFMutableDictionaryRef theDict, const void *key);
|
||||
|
||||
/*!
|
||||
@function CFDictionaryRemoveAllValues
|
||||
Removes all the values from the dictionary, making it empty.
|
||||
@param theDict The dictionary from which all of the values are to be
|
||||
removed. If this parameter is not a valid mutable
|
||||
CFDictionary, the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFDictionaryRemoveAllValues(CFMutableDictionaryRef theDict);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! __COREFOUNDATION_CFDICTIONARY__ */
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/* CFLocale.h
|
||||
Copyright (c) 2002-2003, Apple, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#if !defined(__COREFOUNDATION_CFLOCALE__)
|
||||
#define __COREFOUNDATION_CFLOCALE__ 1
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
||||
|
||||
#include <CoreFoundation/CFBase.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef const struct __CFLocale *CFLocaleRef;
|
||||
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* ! __COREFOUNDATION_CFLOCALE__ */
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/* CFNumber.h
|
||||
Copyright (c) 1999-2003, Apple, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#if !defined(__COREFOUNDATION_CFNUMBER__)
|
||||
#define __COREFOUNDATION_CFNUMBER__ 1
|
||||
|
||||
#include <CoreFoundation/CFBase.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef const struct __CFBoolean * CFBooleanRef;
|
||||
|
||||
#if TARGET_OS_WIN32
|
||||
#define kCFBooleanTrue (*((const CFBooleanRef *)QTGetCFConstant("kCFBooleanTrue")))
|
||||
#define kCFBooleanFalse (*((const CFBooleanRef *)QTGetCFConstant("kCFBooleanFalse")))
|
||||
#else
|
||||
CF_EXPORT
|
||||
const CFBooleanRef kCFBooleanTrue;
|
||||
CF_EXPORT
|
||||
const CFBooleanRef kCFBooleanFalse;
|
||||
#endif
|
||||
|
||||
CF_EXPORT
|
||||
CFTypeID CFBooleanGetTypeID(void);
|
||||
|
||||
CF_EXPORT
|
||||
Boolean CFBooleanGetValue(CFBooleanRef boolean);
|
||||
|
||||
typedef enum {
|
||||
/* Types from MacTypes.h */
|
||||
kCFNumberSInt8Type = 1,
|
||||
kCFNumberSInt16Type = 2,
|
||||
kCFNumberSInt32Type = 3,
|
||||
kCFNumberSInt64Type = 4,
|
||||
kCFNumberFloat32Type = 5,
|
||||
kCFNumberFloat64Type = 6, /* 64-bit IEEE 754 */
|
||||
/* Basic C types */
|
||||
kCFNumberCharType = 7,
|
||||
kCFNumberShortType = 8,
|
||||
kCFNumberIntType = 9,
|
||||
kCFNumberLongType = 10,
|
||||
kCFNumberLongLongType = 11,
|
||||
kCFNumberFloatType = 12,
|
||||
kCFNumberDoubleType = 13,
|
||||
/* Other */
|
||||
kCFNumberCFIndexType = 14,
|
||||
kCFNumberMaxType = 14
|
||||
} CFNumberType;
|
||||
|
||||
typedef const struct __CFNumber * CFNumberRef;
|
||||
|
||||
#if TARGET_OS_WIN32
|
||||
#define kCFNumberPositiveInfinity (*((const CFNumberRef *)QTGetCFConstant("kCFNumberPositiveInfinity")))
|
||||
#define kCFNumberNegativeInfinity (*((const CFNumberRef *)QTGetCFConstant("kCFNumberNegativeInfinity")))
|
||||
#define kCFNumberNaN (*((const CFNumberRef *)QTGetCFConstant("kCFNumberNaN")))
|
||||
#else
|
||||
CF_EXPORT
|
||||
const CFNumberRef kCFNumberPositiveInfinity;
|
||||
CF_EXPORT
|
||||
const CFNumberRef kCFNumberNegativeInfinity;
|
||||
CF_EXPORT
|
||||
const CFNumberRef kCFNumberNaN;
|
||||
#endif
|
||||
|
||||
CF_EXPORT
|
||||
CFTypeID CFNumberGetTypeID(void);
|
||||
|
||||
/*
|
||||
Creates a CFNumber with the given value. The type of number pointed
|
||||
to by the valuePtr is specified by type. If type is a floating point
|
||||
type and the value represents one of the infinities or NaN, the
|
||||
well-defined CFNumber for that value is returned. If either of
|
||||
valuePtr or type is an invalid value, the result is undefined.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
|
||||
|
||||
/*
|
||||
Returns the storage format of the CFNumber's value. Note that
|
||||
this is not necessarily the type provided in CFNumberCreate().
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFNumberType CFNumberGetType(CFNumberRef number);
|
||||
|
||||
/*
|
||||
Returns the size in bytes of the type of the number.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFIndex CFNumberGetByteSize(CFNumberRef number);
|
||||
|
||||
/*
|
||||
Returns true if the type of the CFNumber's value is one of
|
||||
the defined floating point types.
|
||||
*/
|
||||
CF_EXPORT
|
||||
Boolean CFNumberIsFloatType(CFNumberRef number);
|
||||
|
||||
/*
|
||||
Copies the CFNumber's value into the space pointed to by
|
||||
valuePtr, as the specified type. If conversion needs to take
|
||||
place, the conversion rules follow human expectation and not
|
||||
C's promotion and truncation rules. If the conversion is
|
||||
lossy, or the value is out of range, false is returned. Best
|
||||
attempt at conversion will still be in *valuePtr.
|
||||
*/
|
||||
CF_EXPORT
|
||||
Boolean CFNumberGetValue(CFNumberRef number, CFNumberType theType, void *valuePtr);
|
||||
|
||||
/*
|
||||
Compares the two CFNumber instances. If conversion of the
|
||||
types of the values is needed, the conversion and comparison
|
||||
follow human expectations and not C's promotion and comparison
|
||||
rules. Negative zero compares less than positive zero.
|
||||
Positive infinity compares greater than everything except
|
||||
itself, to which it compares equal. Negative infinity compares
|
||||
less than everything except itself, to which it compares equal.
|
||||
Unlike standard practice, if both numbers are NaN, then they
|
||||
compare equal; if only one of the numbers is NaN, then the NaN
|
||||
compares greater than the other number if it is negative, and
|
||||
smaller than the other number if it is positive. (Note that in
|
||||
CFEqual() with two CFNumbers, if either or both of the numbers
|
||||
is NaN, true is returned.)
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFComparisonResult CFNumberCompare(CFNumberRef number, CFNumberRef otherNumber, void *context);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! __COREFOUNDATION_CFNUMBER__ */
|
||||
|
||||
@@ -0,0 +1,692 @@
|
||||
/* CFString.h
|
||||
Copyright (c) 1998-2003, Apple, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#if !defined(__COREFOUNDATION_CFSTRING__)
|
||||
#define __COREFOUNDATION_CFSTRING__ 1
|
||||
|
||||
#include <CoreFoundation/CFBase.h>
|
||||
#include <CoreFoundation/CFArray.h>
|
||||
#include <CoreFoundation/CFData.h>
|
||||
#include <CoreFoundation/CFDictionary.h>
|
||||
#include <CoreFoundation/CFCharacterSet.h>
|
||||
#include <CoreFoundation/CFLocale.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
Please note: CFStrings are conceptually an array of Unicode characters.
|
||||
However, in general, how a CFString stores this array is an implementation
|
||||
detail. For instance, CFString might choose to use an array of 8-bit characters;
|
||||
to store its contents; or it might use multiple blocks of memory; or whatever.
|
||||
Furthermore, the implementation might change depending on the default
|
||||
system encoding, the user's language, the OS, or even a given release.
|
||||
|
||||
What this means is that you should use the following advanced functions with care:
|
||||
|
||||
CFStringGetPascalStringPtr()
|
||||
CFStringGetCStringPtr()
|
||||
CFStringGetCharactersPtr()
|
||||
|
||||
These functions are provided for optimization only. They will either return the desired
|
||||
pointer quickly, in constant time, or they return NULL. They might choose to return NULL
|
||||
for many reasons; for instance it's possible that for users running in different
|
||||
languages these sometimes return NULL; or in a future OS release the first two might
|
||||
switch to always returning NULL. Never observing NULL returns in your usages of these
|
||||
functions does not mean they won't ever return NULL. (But note the CFStringGetCharactersPtr()
|
||||
exception mentioned further below.)
|
||||
|
||||
In your usages of these functions, if you get a NULL return, use the non-Ptr version
|
||||
of the functions as shown in this example:
|
||||
|
||||
Str255 buffer;
|
||||
StringPtr ptr = CFStringGetPascalStringPtr(str, encoding);
|
||||
if (ptr == NULL) {
|
||||
if (CFStringGetPascalString(str, buffer, 256, encoding)) ptr = buffer;
|
||||
}
|
||||
|
||||
Note that CFStringGetPascalString() or CFStringGetCString() calls might still fail --- but
|
||||
that will happen in two circumstances only: The conversion from the UniChar contents of CFString
|
||||
to the specified encoding fails, or the buffer is too small. If they fail, that means
|
||||
the conversion was not possible.
|
||||
|
||||
If you need a copy of the buffer in the above example, you might consider simply
|
||||
calling CFStringGetPascalString() in all cases --- CFStringGetPascalStringPtr()
|
||||
is simply an optimization.
|
||||
|
||||
In addition, the following functions, which create immutable CFStrings from developer
|
||||
supplied buffers without copying the buffers, might have to actually copy
|
||||
under certain circumstances (If they do copy, the buffer will be dealt with by the
|
||||
"contentsDeallocator" argument.):
|
||||
|
||||
CFStringCreateWithPascalStringNoCopy()
|
||||
CFStringCreateWithCStringNoCopy()
|
||||
CFStringCreateWithCharactersNoCopy()
|
||||
|
||||
You should of course never depend on the backing store of these CFStrings being
|
||||
what you provided, and in other no circumstance should you change the contents
|
||||
of that buffer (given that would break the invariant about the CFString being immutable).
|
||||
|
||||
Having said all this, there are actually ways to create a CFString where the backing store
|
||||
is external, and can be manipulated by the developer or CFString itself:
|
||||
|
||||
CFStringCreateMutableWithExternalCharactersNoCopy()
|
||||
CFStringSetExternalCharactersNoCopy()
|
||||
|
||||
A "contentsAllocator" is used to realloc or free the backing store by CFString.
|
||||
kCFAllocatorNull can be provided to assure CFString will never realloc or free the buffer.
|
||||
Developer can call CFStringSetExternalCharactersNoCopy() to update
|
||||
CFString's idea of what's going on, if the buffer is changed externally. In these
|
||||
strings, CFStringGetCharactersPtr() is guaranteed to return the external buffer.
|
||||
|
||||
These functions are here to allow wrapping a buffer of UniChar characters in a CFString,
|
||||
allowing the buffer to passed into CFString functions and also manipulated via CFString
|
||||
mutation functions. In general, developers should not use this technique for all strings,
|
||||
as it prevents CFString from using certain optimizations.
|
||||
*/
|
||||
|
||||
/* Identifier for character encoding; the values are the same as Text Encoding Converter TextEncoding.
|
||||
*/
|
||||
typedef UInt32 CFStringEncoding;
|
||||
|
||||
/* Platform-independent built-in encodings; always available on all platforms.
|
||||
Call CFStringGetSystemEncoding() to get the default system encoding.
|
||||
*/
|
||||
#define kCFStringEncodingInvalidId (0xffffffffU)
|
||||
typedef enum {
|
||||
kCFStringEncodingMacRoman = 0,
|
||||
kCFStringEncodingWindowsLatin1 = 0x0500, /* ANSI codepage 1252 */
|
||||
kCFStringEncodingISOLatin1 = 0x0201, /* ISO 8859-1 */
|
||||
kCFStringEncodingNextStepLatin = 0x0B01, /* NextStep encoding*/
|
||||
kCFStringEncodingASCII = 0x0600, /* 0..127 (in creating CFString, values greater than 0x7F are treated as corresponding Unicode value) */
|
||||
kCFStringEncodingUnicode = 0x0100, /* kTextEncodingUnicodeDefault + kTextEncodingDefaultFormat (aka kUnicode16BitFormat) */
|
||||
kCFStringEncodingUTF8 = 0x08000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF8Format */
|
||||
kCFStringEncodingNonLossyASCII = 0x0BFF /* 7bit Unicode variants used by Cocoa & Java */
|
||||
} CFStringBuiltInEncodings;
|
||||
|
||||
/* CFString type ID */
|
||||
CF_EXPORT
|
||||
CFTypeID CFStringGetTypeID(void);
|
||||
|
||||
/* Macro to allow creation of compile-time constant strings; the argument should be a constant string.
|
||||
|
||||
CFSTR(), not being a "Copy" or "Create" function, does not return a new
|
||||
reference for you. So, you should not release the return value. This is
|
||||
much like constant C or Pascal strings --- when you use "hello world"
|
||||
in a program, you do not free it.
|
||||
|
||||
However, strings returned from CFSTR() can be retained and released in a
|
||||
properly nested fashion, just like any other CF type. That is, if you pass
|
||||
a CFSTR() return value to a function such as SetMenuItemWithCFString(), the
|
||||
function can retain it, then later, when it's done with it, it can release it.
|
||||
|
||||
At this point non-7 bit characters (that is, characters > 127) in CFSTR() are not
|
||||
supported and using them will lead to unpredictable results. This includes escaped
|
||||
(\nnn) characters whose values are > 127. Even if it works for you in testing,
|
||||
it might not work for a user with a different language preference.
|
||||
*/
|
||||
#ifdef __CONSTANT_CFSTRINGS__
|
||||
#define CFSTR(cStr) ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr ""))
|
||||
#else
|
||||
#define CFSTR(cStr) __CFStringMakeConstantString("" cStr "")
|
||||
#endif
|
||||
|
||||
/*** Immutable string creation functions ***/
|
||||
|
||||
/* Functions to create basic immutable strings. The provided allocator is used for all memory activity in these functions.
|
||||
*/
|
||||
|
||||
/* These functions copy the provided buffer into CFString's internal storage. */
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateWithPascalString(CFAllocatorRef alloc, ConstStr255Param pStr, CFStringEncoding encoding);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateWithCharacters(CFAllocatorRef alloc, const UniChar *chars, CFIndex numChars);
|
||||
|
||||
/* These functions try not to copy the provided buffer. The buffer will be deallocated
|
||||
with the provided contentsDeallocator when it's no longer needed; to not free
|
||||
the buffer, specify kCFAllocatorNull here. As usual, NULL means default allocator.
|
||||
|
||||
NOTE: Do not count on these buffers as being used by the string;
|
||||
in some cases the CFString might free the buffer and use something else
|
||||
(for instance if it decides to always use Unicode encoding internally).
|
||||
|
||||
NOTE: If you are not transferring ownership of the buffer to the CFString
|
||||
(for instance, you supplied contentsDeallocator = kCFAllocatorNull), it is your
|
||||
responsibility to assure the buffer does not go away during the lifetime of the string.
|
||||
If the string is retained or copied, its lifetime might extend in ways you cannot
|
||||
predict. So, for strings created with buffers whose lifetimes you cannot
|
||||
guarantee, you need to be extremely careful --- do not hand it out to any
|
||||
APIs which might retain or copy the strings.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateWithPascalStringNoCopy(CFAllocatorRef alloc, ConstStr255Param pStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateWithCharactersNoCopy(CFAllocatorRef alloc, const UniChar *chars, CFIndex numChars, CFAllocatorRef contentsDeallocator);
|
||||
|
||||
/* Create copies of part or all of the string.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateWithSubstring(CFAllocatorRef alloc, CFStringRef str, CFRange range);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateCopy(CFAllocatorRef alloc, CFStringRef theString);
|
||||
|
||||
/* These functions create a CFString from the provided printf-like format string and arguments.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateWithFormat(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateWithFormatAndArguments(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments);
|
||||
|
||||
/* Functions to create mutable strings. "maxLength", if not 0, is a hard bound on the length of the string. If 0, there is no limit on the length.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFMutableStringRef CFStringCreateMutable(CFAllocatorRef alloc, CFIndex maxLength);
|
||||
|
||||
CF_EXPORT
|
||||
CFMutableStringRef CFStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFStringRef theString);
|
||||
|
||||
/* This function creates a mutable string that has a developer supplied and directly editable backing store.
|
||||
The string will be manipulated within the provided buffer (if any) until it outgrows capacity; then the
|
||||
externalCharactersAllocator will be consulted for more memory. When the CFString is deallocated, the
|
||||
buffer will be freed with the externalCharactersAllocator. Provide kCFAllocatorNull here to prevent the buffer
|
||||
from ever being reallocated or deallocated by CFString. See comments at top of this file for more info.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFMutableStringRef CFStringCreateMutableWithExternalCharactersNoCopy(CFAllocatorRef alloc, UniChar *chars, CFIndex numChars, CFIndex capacity, CFAllocatorRef externalCharactersAllocator);
|
||||
|
||||
/*** Basic accessors for the contents ***/
|
||||
|
||||
/* Number of 16-bit Unicode characters in the string.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFIndex CFStringGetLength(CFStringRef theString);
|
||||
|
||||
/* Extracting the contents of the string. For obtaining multiple characters, calling
|
||||
CFStringGetCharacters() is more efficient than multiple calls to CFStringGetCharacterAtIndex().
|
||||
If the length of the string is not known (so you can't use a fixed size buffer for CFStringGetCharacters()),
|
||||
another method is to use is CFStringGetCharacterFromInlineBuffer() (see further below).
|
||||
*/
|
||||
CF_EXPORT
|
||||
UniChar CFStringGetCharacterAtIndex(CFStringRef theString, CFIndex idx);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringGetCharacters(CFStringRef theString, CFRange range, UniChar *buffer);
|
||||
|
||||
/*** Conversion to other encodings ***/
|
||||
|
||||
/* These two convert into the provided buffer; they return false if conversion isn't possible
|
||||
(due to conversion error, or not enough space in the provided buffer).
|
||||
These functions do zero-terminate or put the length byte; the provided bufferSize should include
|
||||
space for this (so pass 256 for Str255). More sophisticated usages can go through CFStringGetBytes().
|
||||
These functions are equivalent to calling CFStringGetBytes() with
|
||||
the range of the string; lossByte = 0; and isExternalRepresentation = false;
|
||||
if successful, they then insert the leading length of terminating zero, as desired.
|
||||
*/
|
||||
CF_EXPORT
|
||||
Boolean CFStringGetPascalString(CFStringRef theString, StringPtr buffer, CFIndex bufferSize, CFStringEncoding encoding);
|
||||
|
||||
CF_EXPORT
|
||||
Boolean CFStringGetCString(CFStringRef theString, char *buffer, CFIndex bufferSize, CFStringEncoding encoding);
|
||||
|
||||
/* These functions attempt to return in O(1) time the desired format for the string.
|
||||
Note that although this means a pointer to the internal structure is being returned,
|
||||
this can't always be counted on. Please see note at the top of the file for more
|
||||
details.
|
||||
*/
|
||||
CF_EXPORT
|
||||
ConstStringPtr CFStringGetPascalStringPtr(CFStringRef theString, CFStringEncoding encoding); /* May return NULL at any time; be prepared for NULL */
|
||||
|
||||
CF_EXPORT
|
||||
const char *CFStringGetCStringPtr(CFStringRef theString, CFStringEncoding encoding); /* May return NULL at any time; be prepared for NULL */
|
||||
|
||||
CF_EXPORT
|
||||
const UniChar *CFStringGetCharactersPtr(CFStringRef theString); /* May return NULL at any time; be prepared for NULL */
|
||||
|
||||
/* The primitive conversion routine; allows you to convert a string piece at a time
|
||||
into a fixed size buffer. Returns number of characters converted.
|
||||
Characters that cannot be converted to the specified encoding are represented
|
||||
with the byte specified by lossByte; if lossByte is 0, then lossy conversion
|
||||
is not allowed and conversion stops, returning partial results.
|
||||
Pass buffer==NULL if you don't care about the converted string (but just the convertability,
|
||||
or number of bytes required).
|
||||
maxBufLength indicates the maximum number of bytes to generate. It is ignored when buffer==NULL.
|
||||
Does not zero-terminate. If you want to create Pascal or C string, allow one extra byte at start or end.
|
||||
Setting isExternalRepresentation causes any extra bytes that would allow
|
||||
the data to be made persistent to be included; for instance, the Unicode BOM.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFIndex CFStringGetBytes(CFStringRef theString, CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, UInt8 *buffer, CFIndex maxBufLen, CFIndex *usedBufLen);
|
||||
|
||||
/* This one goes the other way by creating a CFString from a bag of bytes.
|
||||
This is much like CFStringCreateWithPascalString or CFStringCreateWithCString,
|
||||
except the length is supplied explicitly. In addition, you can specify whether
|
||||
the data is an external format --- that is, whether to pay attention to the
|
||||
BOM character (if any) and do byte swapping if necessary
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateWithBytes(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean isExternalRepresentation);
|
||||
|
||||
/* Convenience functions String <-> Data. These generate "external" formats, that is, formats that
|
||||
can be written out to disk. For instance, if the encoding is Unicode, CFStringCreateFromExternalRepresentation()
|
||||
pays attention to the BOM character (if any) and does byte swapping if necessary.
|
||||
Similarly CFStringCreateExternalRepresentation() will always include a BOM character if the encoding is
|
||||
Unicode. See above for description of lossByte.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateFromExternalRepresentation(CFAllocatorRef alloc, CFDataRef data, CFStringEncoding encoding); /* May return NULL on conversion error */
|
||||
|
||||
CF_EXPORT
|
||||
CFDataRef CFStringCreateExternalRepresentation(CFAllocatorRef alloc, CFStringRef theString, CFStringEncoding encoding, UInt8 lossByte); /* May return NULL on conversion error */
|
||||
|
||||
/* Hints about the contents of a string
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFStringEncoding CFStringGetSmallestEncoding(CFStringRef theString); /* Result in O(n) time max */
|
||||
|
||||
CF_EXPORT
|
||||
CFStringEncoding CFStringGetFastestEncoding(CFStringRef theString); /* Result in O(1) time max */
|
||||
|
||||
/* General encoding info
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFStringEncoding CFStringGetSystemEncoding(void); /* The default encoding for the system; untagged 8-bit characters are usually in this encoding */
|
||||
|
||||
CF_EXPORT
|
||||
CFIndex CFStringGetMaximumSizeForEncoding(CFIndex length, CFStringEncoding encoding); /* Max bytes a string of specified length (in UniChars) will take up if encoded */
|
||||
|
||||
/*** Comparison functions. ***/
|
||||
|
||||
/* Find and compare flags; these are OR'ed together as compareOptions or searchOptions in the various functions.
|
||||
This typedef doesn't appear in the functions; instead the argument is CFOptionFlags.
|
||||
*/
|
||||
typedef enum {
|
||||
kCFCompareCaseInsensitive = 1,
|
||||
kCFCompareBackwards = 4, /* Starting from the end of the string */
|
||||
kCFCompareAnchored = 8, /* Only at the specified starting point */
|
||||
kCFCompareNonliteral = 16, /* If specified, loose equivalence is performed (o-umlaut == o, umlaut) */
|
||||
kCFCompareLocalized = 32, /* User's default locale is used for the comparisons */
|
||||
kCFCompareNumerically = 64 /* Numeric comparison is used; that is, Foo2.txt < Foo7.txt < Foo25.txt */
|
||||
} CFStringCompareFlags;
|
||||
|
||||
/* The main comparison routine; compares specified range of the first string to (the full range of) the second string.
|
||||
locale == NULL indicates canonical locale.
|
||||
kCFCompareNumerically, added in 10.2, does not work if kCFCompareLocalized is specified on systems before 10.3
|
||||
kCFCompareBackwards and kCFCompareAnchored are not applicable.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFComparisonResult CFStringCompareWithOptions(CFStringRef theString1, CFStringRef theString2, CFRange rangeToCompare, CFOptionFlags compareOptions);
|
||||
|
||||
/* Comparison convenience suitable for passing as sorting functions.
|
||||
kCFCompareNumerically, added in 10.2, does not work if kCFCompareLocalized is specified on systems before 10.3
|
||||
kCFCompareBackwards and kCFCompareAnchored are not applicable.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFComparisonResult CFStringCompare(CFStringRef theString1, CFStringRef theString2, CFOptionFlags compareOptions);
|
||||
|
||||
/* CFStringFindWithOptions() returns the found range in the CFRange * argument; you can pass NULL for simple discovery check.
|
||||
If stringToFind is the empty string (zero length), nothing is found.
|
||||
Ignores the kCFCompareNumerically option.
|
||||
*/
|
||||
CF_EXPORT
|
||||
Boolean CFStringFindWithOptions(CFStringRef theString, CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags searchOptions, CFRange *result);
|
||||
|
||||
/* CFStringCreateArrayWithFindResults() returns an array of CFRange pointers, or NULL if there are no matches.
|
||||
Overlapping instances are not found; so looking for "AA" in "AAA" finds just one range.
|
||||
Post 10.1: If kCFCompareBackwards is provided, the scan is done from the end (which can give a different result), and
|
||||
the results are stored in the array backwards (last found range in slot 0).
|
||||
If stringToFind is the empty string (zero length), nothing is found.
|
||||
kCFCompareAnchored causes just the consecutive instances at start (or end, if kCFCompareBackwards) to be reported. So, searching for "AB" in "ABABXAB..." you just get the first two occurrences.
|
||||
Ignores the kCFCompareNumerically option.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFArrayRef CFStringCreateArrayWithFindResults(CFAllocatorRef alloc, CFStringRef theString, CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions);
|
||||
|
||||
/* Find conveniences; see comments above concerning empty string and options.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFRange CFStringFind(CFStringRef theString, CFStringRef stringToFind, CFOptionFlags compareOptions);
|
||||
|
||||
CF_EXPORT
|
||||
Boolean CFStringHasPrefix(CFStringRef theString, CFStringRef prefix);
|
||||
|
||||
CF_EXPORT
|
||||
Boolean CFStringHasSuffix(CFStringRef theString, CFStringRef suffix);
|
||||
|
||||
#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
/*!
|
||||
@function CFStringGetRangeOfComposedCharactersAtIndex
|
||||
Returns the range of the composed character sequence at the specified index.
|
||||
@param theString The CFString which is to be searched. If this
|
||||
parameter is not a valid CFString, the behavior is
|
||||
undefined.
|
||||
@param theIndex The index of the character contained in the
|
||||
composed character sequence. If the index is
|
||||
outside the index space of the string (0 to N-1 inclusive,
|
||||
where N is the length of the string), the behavior is
|
||||
undefined.
|
||||
@result The range of the composed character sequence.
|
||||
*/
|
||||
CF_EXPORT CFRange CFStringGetRangeOfComposedCharactersAtIndex(CFStringRef theString, CFIndex theIndex);
|
||||
|
||||
/*!
|
||||
@function CFStringFindCharacterFromSet
|
||||
Query the range of the first character contained in the specified character set.
|
||||
@param theString The CFString which is to be searched. If this
|
||||
parameter is not a valid CFString, the behavior is
|
||||
undefined.
|
||||
@param theSet The CFCharacterSet against which the membership
|
||||
of characters is checked. If this parameter is not a valid
|
||||
CFCharacterSet, the behavior is undefined.
|
||||
@param range The range of characters within the string to search. If
|
||||
the range location or end point (defined by the location
|
||||
plus length minus 1) are outside the index space of the
|
||||
string (0 to N-1 inclusive, where N is the length of the
|
||||
string), the behavior is undefined. If the range length is
|
||||
negative, the behavior is undefined. The range may be empty
|
||||
(length 0), in which case no search is performed.
|
||||
@param searchOptions The bitwise-or'ed option flags to control
|
||||
the search behavior. The supported options are
|
||||
kCFCompareBackwards andkCFCompareAnchored.
|
||||
If other option flags are specified, the behavior
|
||||
is undefined.
|
||||
@param result The pointer to a CFRange supplied by the caller in
|
||||
which the search result is stored. Note that the length
|
||||
of this range could be more than If a pointer to an invalid
|
||||
memory is specified, the behavior is undefined.
|
||||
@result true, if at least a character which is a member of the character
|
||||
set is found and result is filled, otherwise, false.
|
||||
*/
|
||||
CF_EXPORT Boolean CFStringFindCharacterFromSet(CFStringRef theString, CFCharacterSetRef theSet, CFRange rangeToSearch, CFOptionFlags searchOptions, CFRange *result);
|
||||
#endif
|
||||
|
||||
/* Find range of bounds of the line(s) that span the indicated range (startIndex, numChars),
|
||||
taking into account various possible line separator sequences (CR, CRLF, LF, and Unicode LS, PS).
|
||||
All return values are "optional" (provide NULL if you don't want them)
|
||||
lineStartIndex: index of first character in line
|
||||
lineEndIndex: index of first character of the next line (including terminating line separator characters)
|
||||
contentsEndIndex: index of the first line separator character
|
||||
Thus, lineEndIndex - lineStartIndex is the number of chars in the line, including the line separators
|
||||
contentsEndIndex - lineStartIndex is the number of chars in the line w/out the line separators
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFStringGetLineBounds(CFStringRef theString, CFRange range, CFIndex *lineBeginIndex, CFIndex *lineEndIndex, CFIndex *contentsEndIndex);
|
||||
|
||||
/*** Exploding and joining strings with a separator string ***/
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringCreateByCombiningStrings(CFAllocatorRef alloc, CFArrayRef theArray, CFStringRef separatorString); /* Empty array returns empty string; one element array returns the element */
|
||||
|
||||
CF_EXPORT
|
||||
CFArrayRef CFStringCreateArrayBySeparatingStrings(CFAllocatorRef alloc, CFStringRef theString, CFStringRef separatorString); /* No separators in the string returns array with that string; string == sep returns two empty strings */
|
||||
|
||||
/*** Parsing non-localized numbers from strings ***/
|
||||
|
||||
CF_EXPORT
|
||||
SInt32 CFStringGetIntValue(CFStringRef str); /* Skips whitespace; returns 0 on error, MAX or -MAX on overflow */
|
||||
|
||||
CF_EXPORT
|
||||
double CFStringGetDoubleValue(CFStringRef str); /* Skips whitespace; returns 0.0 on error */
|
||||
|
||||
/*** MutableString functions ***/
|
||||
|
||||
/* CFStringAppend("abcdef", "xxxxx") -> "abcdefxxxxx"
|
||||
CFStringDelete("abcdef", CFRangeMake(2, 3)) -> "abf"
|
||||
CFStringReplace("abcdef", CFRangeMake(2, 3), "xxxxx") -> "abxxxxxf"
|
||||
CFStringReplaceAll("abcdef", "xxxxx") -> "xxxxx"
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFStringAppend(CFMutableStringRef theString, CFStringRef appendedString);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringAppendCharacters(CFMutableStringRef theString, const UniChar *chars, CFIndex numChars);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringAppendPascalString(CFMutableStringRef theString, ConstStr255Param pStr, CFStringEncoding encoding);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringAppendCString(CFMutableStringRef theString, const char *cStr, CFStringEncoding encoding);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringAppendFormat(CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, ...);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringAppendFormatAndArguments(CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringInsert(CFMutableStringRef str, CFIndex idx, CFStringRef insertedStr);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringDelete(CFMutableStringRef theString, CFRange range);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringReplace(CFMutableStringRef theString, CFRange range, CFStringRef replacement);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringReplaceAll(CFMutableStringRef theString, CFStringRef replacement); /* Replaces whole string */
|
||||
|
||||
#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
/* Replace all occurrences of target in rangeToSearch of theString with replacement.
|
||||
Pays attention to kCFCompareCaseInsensitive, kCFCompareBackwards, kCFCompareNonliteral, and kCFCompareAnchored.
|
||||
kCFCompareBackwards can be used to do the replacement starting from the end, which could give a different result.
|
||||
ex. AAAAA, replace AA with B -> BBA or ABB; latter if kCFCompareBackwards
|
||||
kCFCompareAnchored assures only anchored but multiple instances are found (the instances must be consecutive at start or end)
|
||||
ex. AAXAA, replace A with B -> BBXBB or BBXAA; latter if kCFCompareAnchored
|
||||
Returns number of replacements performed.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFIndex CFStringFindAndReplace(CFMutableStringRef theString, CFStringRef stringToFind, CFStringRef replacementString, CFRange rangeToSearch, CFOptionFlags compareOptions);
|
||||
|
||||
#endif
|
||||
|
||||
/* This function will make the contents of a mutable CFString point directly at the specified UniChar array.
|
||||
It works only with CFStrings created with CFStringCreateMutableWithExternalCharactersNoCopy().
|
||||
This function does not free the previous buffer.
|
||||
The string will be manipulated within the provided buffer (if any) until it outgrows capacity; then the
|
||||
externalCharactersAllocator will be consulted for more memory.
|
||||
See comments at the top of this file for more info.
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFStringSetExternalCharactersNoCopy(CFMutableStringRef theString, UniChar *chars, CFIndex length, CFIndex capacity); /* Works only on specially created mutable strings! */
|
||||
|
||||
/* CFStringPad() will pad or cut down a string to the specified size.
|
||||
The pad string is used as the fill string; indexIntoPad specifies which character to start with.
|
||||
CFStringPad("abc", " ", 9, 0) -> "abc "
|
||||
CFStringPad("abc", ". ", 9, 1) -> "abc . . ."
|
||||
CFStringPad("abcdef", ?, 3, ?) -> "abc"
|
||||
|
||||
CFStringTrim() will trim the specified string from both ends of the string.
|
||||
CFStringTrimWhitespace() will do the same with white space characters (tab, newline, etc)
|
||||
CFStringTrim(" abc ", " ") -> "abc"
|
||||
CFStringTrim("* * * *abc * ", "* ") -> "*abc "
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFStringPad(CFMutableStringRef theString, CFStringRef padString, CFIndex length, CFIndex indexIntoPad);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringTrim(CFMutableStringRef theString, CFStringRef trimString);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringTrimWhitespace(CFMutableStringRef theString);
|
||||
|
||||
#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
CF_EXPORT
|
||||
void CFStringLowercase(CFMutableStringRef theString, CFLocaleRef locale);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringUppercase(CFMutableStringRef theString, CFLocaleRef locale);
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringCapitalize(CFMutableStringRef theString, CFLocaleRef locale);
|
||||
#else
|
||||
CF_EXPORT
|
||||
void CFStringLowercase(CFMutableStringRef theString, const void *localeTBD); // localeTBD must be NULL on pre-10.3
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringUppercase(CFMutableStringRef theString, const void *localeTBD); // localeTBD must be NULL on pre-10.3
|
||||
|
||||
CF_EXPORT
|
||||
void CFStringCapitalize(CFMutableStringRef theString, const void *localeTBD); // localeTBD must be NULL on pre-10.3
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
/*!
|
||||
@typedef CFStringNormalizationForm
|
||||
This is the type of Unicode normalization forms as described in
|
||||
Unicode Technical Report #15.
|
||||
*/
|
||||
typedef enum {
|
||||
kCFStringNormalizationFormD = 0, // Canonical Decomposition
|
||||
kCFStringNormalizationFormKD, // Compatibility Decomposition
|
||||
kCFStringNormalizationFormC, // Canonical Decomposition followed by Canonical Composition
|
||||
kCFStringNormalizationFormKC // Compatibility Decomposition followed by Canonical Composition
|
||||
} CFStringNormalizationForm;
|
||||
|
||||
/*!
|
||||
@function CFStringNormalize
|
||||
Normalizes the string into the specified form as described in
|
||||
Unicode Technical Report #15.
|
||||
@param theString The string which is to be normalized. If this
|
||||
parameter is not a valid mutable CFString, the behavior is
|
||||
undefined.
|
||||
@param theForm The form into which the string is to be normalized.
|
||||
If this parameter is not a valid CFStringNormalizationForm value,
|
||||
the behavior is undefined.
|
||||
*/
|
||||
CF_EXPORT void CFStringNormalize(CFMutableStringRef theString, CFStringNormalizationForm theForm);
|
||||
#endif
|
||||
|
||||
/* This returns availability of the encoding on the system
|
||||
*/
|
||||
CF_EXPORT
|
||||
Boolean CFStringIsEncodingAvailable(CFStringEncoding encoding);
|
||||
|
||||
/* This function returns list of available encodings. The returned list is terminated with kCFStringEncodingInvalidId and owned by the system.
|
||||
*/
|
||||
CF_EXPORT
|
||||
const CFStringEncoding *CFStringGetListOfAvailableEncodings(void);
|
||||
|
||||
/* Returns name of the encoding; non-localized.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringGetNameOfEncoding(CFStringEncoding encoding);
|
||||
|
||||
/* ID mapping functions from/to Cocoa NSStringEncoding. Returns kCFStringEncodingInvalidId if no mapping exists.
|
||||
*/
|
||||
CF_EXPORT
|
||||
UInt32 CFStringConvertEncodingToNSStringEncoding(CFStringEncoding encoding);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringEncoding CFStringConvertNSStringEncodingToEncoding(UInt32 encoding);
|
||||
|
||||
/* ID mapping functions from/to Microsoft Windows codepage (covers both OEM & ANSI). Returns kCFStringEncodingInvalidId if no mapping exists.
|
||||
*/
|
||||
CF_EXPORT
|
||||
UInt32 CFStringConvertEncodingToWindowsCodepage(CFStringEncoding encoding);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringEncoding CFStringConvertWindowsCodepageToEncoding(UInt32 codepage);
|
||||
|
||||
/* ID mapping functions from/to IANA registery charset names. Returns kCFStringEncodingInvalidId if no mapping exists.
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFStringEncoding CFStringConvertIANACharSetNameToEncoding(CFStringRef theString);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFStringConvertEncodingToIANACharSetName(CFStringEncoding encoding);
|
||||
|
||||
/* Returns the most compatible MacOS script value for the input encoding */
|
||||
/* i.e. kCFStringEncodingMacRoman -> kCFStringEncodingMacRoman */
|
||||
/* kCFStringEncodingWindowsLatin1 -> kCFStringEncodingMacRoman */
|
||||
/* kCFStringEncodingISO_2022_JP -> kCFStringEncodingMacJapanese */
|
||||
CF_EXPORT
|
||||
CFStringEncoding CFStringGetMostCompatibleMacStringEncoding(CFStringEncoding encoding);
|
||||
|
||||
/* The next two functions allow fast access to the contents of a string,
|
||||
assuming you are doing sequential or localized accesses. To use, call
|
||||
CFStringInitInlineBuffer() with a CFStringInlineBuffer (on the stack, say),
|
||||
and a range in the string to look at. Then call CFStringGetCharacterFromInlineBuffer()
|
||||
as many times as you want, with a index into that range (relative to the start
|
||||
of that range). These are INLINE functions and will end up calling CFString only
|
||||
once in a while, to fill a buffer. CFStringGetCharacterFromInlineBuffer() returns 0 if
|
||||
a location outside the original range is specified.
|
||||
*/
|
||||
#define __kCFStringInlineBufferLength 64
|
||||
typedef struct {
|
||||
UniChar buffer[__kCFStringInlineBufferLength];
|
||||
CFStringRef theString;
|
||||
const UniChar *directBuffer;
|
||||
CFRange rangeToBuffer; /* Range in string to buffer */
|
||||
CFIndex bufferedRangeStart; /* Start of range currently buffered (relative to rangeToBuffer.location) */
|
||||
CFIndex bufferedRangeEnd; /* bufferedRangeStart + number of chars actually buffered */
|
||||
} CFStringInlineBuffer;
|
||||
|
||||
#if defined(CF_INLINE)
|
||||
CF_INLINE void CFStringInitInlineBuffer(CFStringRef str, CFStringInlineBuffer *buf, CFRange range) {
|
||||
buf->theString = str;
|
||||
buf->rangeToBuffer = range;
|
||||
buf->directBuffer = CFStringGetCharactersPtr(str);
|
||||
buf->bufferedRangeStart = buf->bufferedRangeEnd = 0;
|
||||
}
|
||||
|
||||
CF_INLINE UniChar CFStringGetCharacterFromInlineBuffer(CFStringInlineBuffer *buf, CFIndex idx) {
|
||||
if (buf->directBuffer) {
|
||||
if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0;
|
||||
return buf->directBuffer[idx + buf->rangeToBuffer.location];
|
||||
}
|
||||
if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) {
|
||||
if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0;
|
||||
if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0;
|
||||
buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength;
|
||||
if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length;
|
||||
CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer);
|
||||
}
|
||||
return buf->buffer[idx - buf->bufferedRangeStart];
|
||||
}
|
||||
|
||||
#else
|
||||
/* If INLINE functions are not available, we do somewhat less powerful macros that work similarly (except be aware that the buf argument is evaluated multiple times).
|
||||
*/
|
||||
#define CFStringInitInlineBuffer(str, buf, range) \
|
||||
do {(buf)->theString = str; (buf)->rangeToBuffer = range; (buf)->directBuffer = CFStringGetCharactersPtr(str);} while (0)
|
||||
|
||||
#define CFStringGetCharacterFromInlineBuffer(buf, idx) \
|
||||
(((idx) < 0 || (idx) >= (buf)->rangeToBuffer.length) ? 0 : ((buf)->directBuffer ? (buf)->directBuffer[(idx) + (buf)->rangeToBuffer.location] : CFStringGetCharacterAtIndex((buf)->theString, (idx) + (buf)->rangeToBuffer.location)))
|
||||
|
||||
#endif /* CF_INLINE */
|
||||
|
||||
|
||||
/* Rest of the stuff in this file is private and should not be used directly
|
||||
*/
|
||||
/* For debugging only
|
||||
Use CFShow() to printf the description of any CFType;
|
||||
Use CFShowStr() to printf detailed info about a CFString
|
||||
*/
|
||||
CF_EXPORT
|
||||
void CFShow(CFTypeRef obj);
|
||||
|
||||
CF_EXPORT
|
||||
void CFShowStr(CFStringRef str);
|
||||
|
||||
/* This function is private and should not be used directly */
|
||||
CF_EXPORT
|
||||
CFStringRef __CFStringMakeConstantString(const char *cStr); /* Private; do not use */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !__COREFOUNDATION_CFSTRING__ */
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
/* CFStringEncodingExt.h
|
||||
Copyright (c) 1998-2003, Apple, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#if !defined(__COREFOUNDATION_CFSTRINGENCODINGEXT__)
|
||||
#define __COREFOUNDATION_CFSTRINGENCODINGEXT__ 1
|
||||
|
||||
#include <CoreFoundation/CFBase.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
/* kCFStringEncodingMacRoman = 0L, defined in CoreFoundation/CFString.h */
|
||||
kCFStringEncodingMacJapanese = 1,
|
||||
kCFStringEncodingMacChineseTrad = 2,
|
||||
kCFStringEncodingMacKorean = 3,
|
||||
kCFStringEncodingMacArabic = 4,
|
||||
kCFStringEncodingMacHebrew = 5,
|
||||
kCFStringEncodingMacGreek = 6,
|
||||
kCFStringEncodingMacCyrillic = 7,
|
||||
kCFStringEncodingMacDevanagari = 9,
|
||||
kCFStringEncodingMacGurmukhi = 10,
|
||||
kCFStringEncodingMacGujarati = 11,
|
||||
kCFStringEncodingMacOriya = 12,
|
||||
kCFStringEncodingMacBengali = 13,
|
||||
kCFStringEncodingMacTamil = 14,
|
||||
kCFStringEncodingMacTelugu = 15,
|
||||
kCFStringEncodingMacKannada = 16,
|
||||
kCFStringEncodingMacMalayalam = 17,
|
||||
kCFStringEncodingMacSinhalese = 18,
|
||||
kCFStringEncodingMacBurmese = 19,
|
||||
kCFStringEncodingMacKhmer = 20,
|
||||
kCFStringEncodingMacThai = 21,
|
||||
kCFStringEncodingMacLaotian = 22,
|
||||
kCFStringEncodingMacGeorgian = 23,
|
||||
kCFStringEncodingMacArmenian = 24,
|
||||
kCFStringEncodingMacChineseSimp = 25,
|
||||
kCFStringEncodingMacTibetan = 26,
|
||||
kCFStringEncodingMacMongolian = 27,
|
||||
kCFStringEncodingMacEthiopic = 28,
|
||||
kCFStringEncodingMacCentralEurRoman = 29,
|
||||
kCFStringEncodingMacVietnamese = 30,
|
||||
kCFStringEncodingMacExtArabic = 31,
|
||||
/* The following use script code 0, smRoman */
|
||||
kCFStringEncodingMacSymbol = 33,
|
||||
kCFStringEncodingMacDingbats = 34,
|
||||
kCFStringEncodingMacTurkish = 35,
|
||||
kCFStringEncodingMacCroatian = 36,
|
||||
kCFStringEncodingMacIcelandic = 37,
|
||||
kCFStringEncodingMacRomanian = 38,
|
||||
kCFStringEncodingMacCeltic = 39,
|
||||
kCFStringEncodingMacGaelic = 40,
|
||||
/* The following use script code 4, smArabic */
|
||||
kCFStringEncodingMacFarsi = 0x8C, /* Like MacArabic but uses Farsi digits */
|
||||
/* The following use script code 7, smCyrillic */
|
||||
kCFStringEncodingMacUkrainian = 0x98,
|
||||
/* The following use script code 32, smUnimplemented */
|
||||
kCFStringEncodingMacInuit = 0xEC,
|
||||
kCFStringEncodingMacVT100 = 0xFC, /* VT100/102 font from Comm Toolbox: Latin-1 repertoire + box drawing etc */
|
||||
/* Special Mac OS encodings*/
|
||||
kCFStringEncodingMacHFS = 0xFF, /* Meta-value, should never appear in a table */
|
||||
|
||||
/* Unicode & ISO UCS encodings begin at 0x100 */
|
||||
/* We don't use Unicode variations defined in TextEncoding; use the ones in CFString.h, instead. */
|
||||
|
||||
/* ISO 8-bit and 7-bit encodings begin at 0x200 */
|
||||
/* kCFStringEncodingISOLatin1 = 0x0201, defined in CoreFoundation/CFString.h */
|
||||
kCFStringEncodingISOLatin2 = 0x0202, /* ISO 8859-2 */
|
||||
kCFStringEncodingISOLatin3 = 0x0203, /* ISO 8859-3 */
|
||||
kCFStringEncodingISOLatin4 = 0x0204, /* ISO 8859-4 */
|
||||
kCFStringEncodingISOLatinCyrillic = 0x0205, /* ISO 8859-5 */
|
||||
kCFStringEncodingISOLatinArabic = 0x0206, /* ISO 8859-6, =ASMO 708, =DOS CP 708 */
|
||||
kCFStringEncodingISOLatinGreek = 0x0207, /* ISO 8859-7 */
|
||||
kCFStringEncodingISOLatinHebrew = 0x0208, /* ISO 8859-8 */
|
||||
kCFStringEncodingISOLatin5 = 0x0209, /* ISO 8859-9 */
|
||||
kCFStringEncodingISOLatin6 = 0x020A, /* ISO 8859-10 */
|
||||
kCFStringEncodingISOLatinThai = 0x020B, /* ISO 8859-11 */
|
||||
kCFStringEncodingISOLatin7 = 0x020D, /* ISO 8859-13 */
|
||||
kCFStringEncodingISOLatin8 = 0x020E, /* ISO 8859-14 */
|
||||
kCFStringEncodingISOLatin9 = 0x020F, /* ISO 8859-15 */
|
||||
|
||||
/* MS-DOS & Windows encodings begin at 0x400 */
|
||||
kCFStringEncodingDOSLatinUS = 0x0400, /* code page 437 */
|
||||
kCFStringEncodingDOSGreek = 0x0405, /* code page 737 (formerly code page 437G) */
|
||||
kCFStringEncodingDOSBalticRim = 0x0406, /* code page 775 */
|
||||
kCFStringEncodingDOSLatin1 = 0x0410, /* code page 850, "Multilingual" */
|
||||
kCFStringEncodingDOSGreek1 = 0x0411, /* code page 851 */
|
||||
kCFStringEncodingDOSLatin2 = 0x0412, /* code page 852, Slavic */
|
||||
kCFStringEncodingDOSCyrillic = 0x0413, /* code page 855, IBM Cyrillic */
|
||||
kCFStringEncodingDOSTurkish = 0x0414, /* code page 857, IBM Turkish */
|
||||
kCFStringEncodingDOSPortuguese = 0x0415, /* code page 860 */
|
||||
kCFStringEncodingDOSIcelandic = 0x0416, /* code page 861 */
|
||||
kCFStringEncodingDOSHebrew = 0x0417, /* code page 862 */
|
||||
kCFStringEncodingDOSCanadianFrench = 0x0418, /* code page 863 */
|
||||
kCFStringEncodingDOSArabic = 0x0419, /* code page 864 */
|
||||
kCFStringEncodingDOSNordic = 0x041A, /* code page 865 */
|
||||
kCFStringEncodingDOSRussian = 0x041B, /* code page 866 */
|
||||
kCFStringEncodingDOSGreek2 = 0x041C, /* code page 869, IBM Modern Greek */
|
||||
kCFStringEncodingDOSThai = 0x041D, /* code page 874, also for Windows */
|
||||
kCFStringEncodingDOSJapanese = 0x0420, /* code page 932, also for Windows */
|
||||
kCFStringEncodingDOSChineseSimplif = 0x0421, /* code page 936, also for Windows */
|
||||
kCFStringEncodingDOSKorean = 0x0422, /* code page 949, also for Windows; Unified Hangul Code */
|
||||
kCFStringEncodingDOSChineseTrad = 0x0423, /* code page 950, also for Windows */
|
||||
/* kCFStringEncodingWindowsLatin1 = 0x0500, defined in CoreFoundation/CFString.h */
|
||||
kCFStringEncodingWindowsLatin2 = 0x0501, /* code page 1250, Central Europe */
|
||||
kCFStringEncodingWindowsCyrillic = 0x0502, /* code page 1251, Slavic Cyrillic */
|
||||
kCFStringEncodingWindowsGreek = 0x0503, /* code page 1253 */
|
||||
kCFStringEncodingWindowsLatin5 = 0x0504, /* code page 1254, Turkish */
|
||||
kCFStringEncodingWindowsHebrew = 0x0505, /* code page 1255 */
|
||||
kCFStringEncodingWindowsArabic = 0x0506, /* code page 1256 */
|
||||
kCFStringEncodingWindowsBalticRim = 0x0507, /* code page 1257 */
|
||||
kCFStringEncodingWindowsKoreanJohab = 0x0510, /* code page 1361, for Windows NT */
|
||||
kCFStringEncodingWindowsVietnamese = 0x0508, /* code page 1258 */
|
||||
|
||||
/* Various national standards begin at 0x600 */
|
||||
/* kCFStringEncodingASCII = 0x0600, defined in CoreFoundation/CFString.h */
|
||||
kCFStringEncodingJIS_X0201_76 = 0x0620,
|
||||
kCFStringEncodingJIS_X0208_83 = 0x0621,
|
||||
kCFStringEncodingJIS_X0208_90 = 0x0622,
|
||||
kCFStringEncodingJIS_X0212_90 = 0x0623,
|
||||
kCFStringEncodingJIS_C6226_78 = 0x0624,
|
||||
kCFStringEncodingShiftJIS_X0213_00 = 0x0628, /* Shift-JIS format encoding of JIS X0213 planes 1 and 2*/
|
||||
kCFStringEncodingGB_2312_80 = 0x0630,
|
||||
kCFStringEncodingGBK_95 = 0x0631, /* annex to GB 13000-93; for Windows 95 */
|
||||
kCFStringEncodingGB_18030_2000 = 0x0632,
|
||||
kCFStringEncodingKSC_5601_87 = 0x0640, /* same as KSC 5601-92 without Johab annex */
|
||||
kCFStringEncodingKSC_5601_92_Johab = 0x0641, /* KSC 5601-92 Johab annex */
|
||||
kCFStringEncodingCNS_11643_92_P1 = 0x0651, /* CNS 11643-1992 plane 1 */
|
||||
kCFStringEncodingCNS_11643_92_P2 = 0x0652, /* CNS 11643-1992 plane 2 */
|
||||
kCFStringEncodingCNS_11643_92_P3 = 0x0653, /* CNS 11643-1992 plane 3 (was plane 14 in 1986 version) */
|
||||
|
||||
/* ISO 2022 collections begin at 0x800 */
|
||||
kCFStringEncodingISO_2022_JP = 0x0820,
|
||||
kCFStringEncodingISO_2022_JP_2 = 0x0821,
|
||||
kCFStringEncodingISO_2022_JP_1 = 0x0822, /* RFC 2237*/
|
||||
kCFStringEncodingISO_2022_JP_3 = 0x0823, /* JIS X0213*/
|
||||
kCFStringEncodingISO_2022_CN = 0x0830,
|
||||
kCFStringEncodingISO_2022_CN_EXT = 0x0831,
|
||||
kCFStringEncodingISO_2022_KR = 0x0840,
|
||||
|
||||
/* EUC collections begin at 0x900 */
|
||||
kCFStringEncodingEUC_JP = 0x0920, /* ISO 646, 1-byte katakana, JIS 208, JIS 212 */
|
||||
kCFStringEncodingEUC_CN = 0x0930, /* ISO 646, GB 2312-80 */
|
||||
kCFStringEncodingEUC_TW = 0x0931, /* ISO 646, CNS 11643-1992 Planes 1-16 */
|
||||
kCFStringEncodingEUC_KR = 0x0940, /* ISO 646, KS C 5601-1987 */
|
||||
|
||||
/* Misc standards begin at 0xA00 */
|
||||
kCFStringEncodingShiftJIS = 0x0A01, /* plain Shift-JIS */
|
||||
kCFStringEncodingKOI8_R = 0x0A02, /* Russian internet standard */
|
||||
kCFStringEncodingBig5 = 0x0A03, /* Big-5 (has variants) */
|
||||
kCFStringEncodingMacRomanLatin1 = 0x0A04, /* Mac OS Roman permuted to align with ISO Latin-1 */
|
||||
kCFStringEncodingHZ_GB_2312 = 0x0A05, /* HZ (RFC 1842, for Chinese mail & news) */
|
||||
kCFStringEncodingBig5_HKSCS_1999 = 0x0A06, /* Big-5 with Hong Kong special char set supplement*/
|
||||
|
||||
/* Other platform encodings*/
|
||||
/* kCFStringEncodingNextStepLatin = 0x0B01, defined in CoreFoundation/CFString.h */
|
||||
|
||||
/* EBCDIC & IBM host encodings begin at 0xC00 */
|
||||
kCFStringEncodingEBCDIC_US = 0x0C01, /* basic EBCDIC-US */
|
||||
kCFStringEncodingEBCDIC_CP037 = 0x0C02 /* code page 037, extended EBCDIC (Latin-1 set) for US,Canada... */
|
||||
} CFStringEncodings;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !__COREFOUNDATION_CFSTRINGENCODINGEXT__ */
|
||||
|
||||
@@ -0,0 +1,403 @@
|
||||
/* CFURL.h
|
||||
Copyright (c) 1998-2003, Apple, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#if !defined(__COREFOUNDATION_CFURL__)
|
||||
#define __COREFOUNDATION_CFURL__ 1
|
||||
|
||||
#include <CoreFoundation/CFBase.h>
|
||||
#include <CoreFoundation/CFData.h>
|
||||
#include <CoreFoundation/CFString.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
kCFURLPOSIXPathStyle = 0,
|
||||
kCFURLHFSPathStyle,
|
||||
kCFURLWindowsPathStyle
|
||||
} CFURLPathStyle;
|
||||
|
||||
typedef const struct __CFURL * CFURLRef;
|
||||
|
||||
/* CFURLs are composed of two fundamental pieces - their string, and a */
|
||||
/* (possibly NULL) base URL. A relative URL is one in which the string */
|
||||
/* by itself does not fully specify the URL (for instance "myDir/image.tiff"); */
|
||||
/* an absolute URL is one in which the string does fully specify the URL */
|
||||
/* ("file://localhost/myDir/image.tiff"). Absolute URLs always have NULL */
|
||||
/* base URLs; however, it is possible for a URL to have a NULL base, and still */
|
||||
/* not be absolute. Such a URL has only a relative string, and cannot be */
|
||||
/* resolved. Two CFURLs are considered equal if and only if their strings */
|
||||
/* are equal and their bases are equal. In other words, */
|
||||
/* "file://localhost/myDir/image.tiff" is NOT equal to the URL with relative */
|
||||
/* string "myDir/image.tiff" and base URL "file://localhost/". Clients that */
|
||||
/* need these less strict form of equality should convert all URLs to their */
|
||||
/* absolute form via CFURLCopyAbsoluteURL(), then compare the absolute forms. */
|
||||
|
||||
CF_EXPORT
|
||||
CFTypeID CFURLGetTypeID(void);
|
||||
|
||||
/* encoding will be used both to interpret the bytes of URLBytes, and to */
|
||||
/* interpret any percent-escapes within the bytes. */
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLCreateWithBytes(CFAllocatorRef allocator, const UInt8 *URLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL);
|
||||
|
||||
/* Escapes any character that is not 7-bit ASCII with the byte-code */
|
||||
/* for the given encoding. If escapeWhitespace is true, whitespace */
|
||||
/* characters (' ', '\t', '\r', '\n') will be escaped also (desirable */
|
||||
/* if embedding the URL into a larger text stream like HTML) */
|
||||
CF_EXPORT
|
||||
CFDataRef CFURLCreateData(CFAllocatorRef allocator, CFURLRef url, CFStringEncoding encoding, Boolean escapeWhitespace);
|
||||
|
||||
/* Any escape sequences in URLString will be interpreted via UTF-8. */
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLCreateWithString(CFAllocatorRef allocator, CFStringRef URLString, CFURLRef baseURL);
|
||||
|
||||
#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
|
||||
/* Create an absolute URL directly, without requiring the extra step */
|
||||
/* of calling CFURLCopyAbsoluteURL(). If useCompatibilityMode is */
|
||||
/* true, the rules historically used on the web are used to resolve */
|
||||
/* relativeString against baseURL - these rules are generally listed */
|
||||
/* in the RFC as optional or alternate interpretations. Otherwise, */
|
||||
/* the strict rules from the RFC are used. The major differences are */
|
||||
/* that in compatibility mode, we are lenient of the scheme appearing */
|
||||
/* in relative portion, leading "../" components are removed from the */
|
||||
/* final URL's path, and if the relative portion contains only */
|
||||
/* resource specifier pieces (query, parameters, and fragment), then */
|
||||
/* the last path component of the base URL will not be deleted */
|
||||
CFURLRef CFURLCreateAbsoluteURLWithBytes(CFAllocatorRef alloc, const UInt8 *relativeURLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL, Boolean useCompatibilityMode) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
|
||||
#endif
|
||||
|
||||
/* filePath should be the URL's path expressed as a path of the type */
|
||||
/* fsType. If filePath is not absolute, the resulting URL will be */
|
||||
/* considered relative to the current working directory (evaluated */
|
||||
/* at creation time). isDirectory determines whether filePath is */
|
||||
/* treated as a directory path when resolving against relative path */
|
||||
/* components */
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLCreateWithFileSystemPath(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory);
|
||||
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLCreateFromFileSystemRepresentation(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory);
|
||||
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLCreateWithFileSystemPathRelativeToBase(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL);
|
||||
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLCreateFromFileSystemRepresentationRelativeToBase(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory, CFURLRef baseURL);
|
||||
|
||||
/* Fills buffer with the file system's native representation of */
|
||||
/* url's path. No more than maxBufLen bytes are written to buffer. */
|
||||
/* The buffer should be at least the maximum path length for */
|
||||
/* the file system in question to avoid failures for insufficiently */
|
||||
/* large buffers. If resolveAgainstBase is true, the url's relative */
|
||||
/* portion is resolved against its base before the path is computed. */
|
||||
/* Returns success or failure. */
|
||||
CF_EXPORT
|
||||
Boolean CFURLGetFileSystemRepresentation(CFURLRef url, Boolean resolveAgainstBase, UInt8 *buffer, CFIndex maxBufLen);
|
||||
|
||||
/* Creates a new URL by resolving the relative portion of relativeURL against its base. */
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLCopyAbsoluteURL(CFURLRef relativeURL);
|
||||
|
||||
/* Returns the URL's string. */
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLGetString(CFURLRef anURL);
|
||||
|
||||
/* Returns the base URL if it exists */
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLGetBaseURL(CFURLRef anURL);
|
||||
|
||||
/*
|
||||
All URLs can be broken into two pieces - the scheme (preceding the
|
||||
first colon) and the resource specifier (following the first colon).
|
||||
Most URLs are also "standard" URLs conforming to RFC 1808 (available
|
||||
from www.w3c.org). This category includes URLs of the file, http,
|
||||
https, and ftp schemes, to name a few. Standard URLs start the
|
||||
resource specifier with two slashes ("//"), and can be broken into
|
||||
four distinct pieces - the scheme, the net location, the path, and
|
||||
further resource specifiers (typically an optional parameter, query,
|
||||
and/or fragment). The net location appears immediately following
|
||||
the two slashes and goes up to the next slash; it's format is
|
||||
scheme-specific, but is usually composed of some or all of a username,
|
||||
password, host name, and port. The path is a series of path components
|
||||
separated by slashes; if the net location is present, the path always
|
||||
begins with a slash. Standard URLs can be relative to another URL,
|
||||
in which case at least the scheme and possibly other pieces as well
|
||||
come from the base URL (see RFC 1808 for precise details when resolving
|
||||
a relative URL against its base). The full URL is therefore
|
||||
|
||||
<scheme> "://" <net location> <path, always starting with slash> <add'l resource specifiers>
|
||||
|
||||
If a given CFURL can be decomposed (that is, conforms to RFC 1808), you
|
||||
can ask for each of the four basic pieces (scheme, net location, path,
|
||||
and resource specifer) separately, as well as for its base URL. The
|
||||
basic pieces are returned with any percent escape sequences still in
|
||||
place (although note that the scheme may not legally include any
|
||||
percent escapes); this is to allow the caller to distinguish between
|
||||
percent sequences that may have syntactic meaning if replaced by the
|
||||
character being escaped (for instance, a '/' in a path component).
|
||||
Since only the individual schemes know which characters are
|
||||
syntactically significant, CFURL cannot safely replace any percent
|
||||
escape sequences. However, you can use
|
||||
CFURLCreateStringByReplacingPercentEscapes() to create a new string with
|
||||
the percent escapes removed; see below.
|
||||
|
||||
If a given CFURL can not be decomposed, you can ask for its scheme and its
|
||||
resource specifier; asking it for its net location or path will return NULL.
|
||||
|
||||
To get more refined information about the components of a decomposable
|
||||
CFURL, you may ask for more specific pieces of the URL, expressed with
|
||||
the percent escapes removed. The available functions are CFURLCopyHostName(),
|
||||
CFURLGetPortNumber() (returns an Int32), CFURLCopyUserName(),
|
||||
CFURLCopyPassword(), CFURLCopyQuery(), CFURLCopyParameters(), and
|
||||
CFURLCopyFragment(). Because the parameters, query, and fragment of an
|
||||
URL may contain scheme-specific syntaxes, these methods take a second
|
||||
argument, giving a list of characters which should NOT be replaced if
|
||||
percent escaped. For instance, the ftp parameter syntax gives simple
|
||||
key-value pairs as "<key>=<value>;" Clearly if a key or value includes
|
||||
either '=' or ';', it must be escaped to avoid corrupting the meaning of
|
||||
the parameters, so the caller may request the parameter string as
|
||||
|
||||
CFStringRef myParams = CFURLCopyParameters(ftpURL, CFSTR("=;%"));
|
||||
|
||||
requesting that all percent escape sequences be replaced by the represented
|
||||
characters, except for escaped '=', '%' or ';' characters. Pass the empty
|
||||
string (CFSTR("")) to request that all percent escapes be replaced, or NULL
|
||||
to request that none be.
|
||||
*/
|
||||
|
||||
/* Returns true if anURL conforms to RFC 1808 */
|
||||
CF_EXPORT
|
||||
Boolean CFURLCanBeDecomposed(CFURLRef anURL);
|
||||
|
||||
/* The next several methods leave any percent escape sequences intact */
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyScheme(CFURLRef anURL);
|
||||
|
||||
/* NULL if CFURLCanBeDecomposed(anURL) is false */
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyNetLocation(CFURLRef anURL);
|
||||
|
||||
/* NULL if CFURLCanBeDecomposed(anURL) is false; also does not resolve the URL */
|
||||
/* against its base. See also CFURLCopyAbsoluteURL(). Note that, strictly */
|
||||
/* speaking, any leading '/' is not considered part of the URL's path, although */
|
||||
/* its presence or absence determines whether the path is absolute. */
|
||||
/* CFURLCopyPath()'s return value includes any leading slash (giving the path */
|
||||
/* the normal POSIX appearance); CFURLCopyStrictPath()'s return value omits any */
|
||||
/* leading slash, and uses isAbsolute to report whether the URL's path is absolute. */
|
||||
|
||||
/* CFURLCopyFileSystemPath() returns the URL's path as a file system path for the */
|
||||
/* given path style. All percent escape sequences are replaced. The URL is not */
|
||||
/* resolved against its base before computing the path. */
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyPath(CFURLRef anURL);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyStrictPath(CFURLRef anURL, Boolean *isAbsolute);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyFileSystemPath(CFURLRef anURL, CFURLPathStyle pathStyle);
|
||||
|
||||
/* Returns whether anURL's path represents a directory */
|
||||
/* (true returned) or a simple file (false returned) */
|
||||
CF_EXPORT
|
||||
Boolean CFURLHasDirectoryPath(CFURLRef anURL);
|
||||
|
||||
/* Any additional resource specifiers after the path. For URLs */
|
||||
/* that cannot be decomposed, this is everything except the scheme itself. */
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyResourceSpecifier(CFURLRef anURL);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyHostName(CFURLRef anURL);
|
||||
|
||||
CF_EXPORT
|
||||
SInt32 CFURLGetPortNumber(CFURLRef anURL); /* Returns -1 if no port number is specified */
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyUserName(CFURLRef anURL);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyPassword(CFURLRef anURL);
|
||||
|
||||
/* These remove all percent escape sequences except those for */
|
||||
/* characters in charactersToLeaveEscaped. If charactersToLeaveEscaped */
|
||||
/* is empty (""), all percent escape sequences are replaced by their */
|
||||
/* corresponding characters. If charactersToLeaveEscaped is NULL, */
|
||||
/* then no escape sequences are removed at all */
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyParameterString(CFURLRef anURL, CFStringRef charactersToLeaveEscaped);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyQueryString(CFURLRef anURL, CFStringRef charactersToLeaveEscaped);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyFragment(CFURLRef anURL, CFStringRef charactersToLeaveEscaped);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyLastPathComponent(CFURLRef url);
|
||||
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCopyPathExtension(CFURLRef url);
|
||||
|
||||
/* These functions all treat the base URL of the supplied url as */
|
||||
/* invariant. In other words, the URL returned will always have */
|
||||
/* the same base as the URL supplied as an argument. */
|
||||
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLCreateCopyAppendingPathComponent(CFAllocatorRef allocator, CFURLRef url, CFStringRef pathComponent, Boolean isDirectory);
|
||||
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLCreateCopyDeletingLastPathComponent(CFAllocatorRef allocator, CFURLRef url);
|
||||
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLCreateCopyAppendingPathExtension(CFAllocatorRef allocator, CFURLRef url, CFStringRef extension);
|
||||
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLCreateCopyDeletingPathExtension(CFAllocatorRef allocator, CFURLRef url);
|
||||
|
||||
#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
/* Fills buffer with the bytes for url, returning the number of bytes */
|
||||
/* filled. If buffer is of insufficient size, returns -1 and no bytes */
|
||||
/* are placed in buffer. If buffer is NULL, the needed length is */
|
||||
/* computed and returned. The returned bytes are the original bytes */
|
||||
/* from which the URL was created; if the URL was created from a */
|
||||
/* string, the bytes will be the bytes of the string encoded via UTF-8 */
|
||||
CF_EXPORT
|
||||
CFIndex CFURLGetBytes(CFURLRef url, UInt8 *buffer, CFIndex bufferLength) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
|
||||
|
||||
typedef enum {
|
||||
kCFURLComponentScheme = 1,
|
||||
kCFURLComponentNetLocation = 2,
|
||||
kCFURLComponentPath = 3,
|
||||
kCFURLComponentResourceSpecifier = 4,
|
||||
|
||||
kCFURLComponentUser = 5,
|
||||
kCFURLComponentPassword = 6,
|
||||
kCFURLComponentUserInfo = 7,
|
||||
kCFURLComponentHost = 8,
|
||||
kCFURLComponentPort = 9,
|
||||
kCFURLComponentParameterString = 10,
|
||||
kCFURLComponentQuery = 11,
|
||||
kCFURLComponentFragment = 12
|
||||
} CFURLComponentType;
|
||||
|
||||
/*
|
||||
Gets the range of the requested component in the bytes of url, as
|
||||
returned by CFURLGetBytes(). This range is only good for use in the
|
||||
bytes returned by CFURLGetBytes!
|
||||
|
||||
If non-NULL, rangeIncludingSeparators gives the range of component
|
||||
including the sequences that separate component from the previous and
|
||||
next components. If there is no previous or next component, that end of
|
||||
rangeIncludingSeparators will match the range of the component itself.
|
||||
If url does not contain the given component type, (kCFNotFound, 0) is
|
||||
returned, and rangeIncludingSeparators is set to the location where the
|
||||
component would be inserted. Some examples -
|
||||
|
||||
For the URL http://www.apple.com/hotnews/
|
||||
|
||||
Component returned range rangeIncludingSeparators
|
||||
scheme (0, 4) (0, 7)
|
||||
net location (7, 13) (4, 16)
|
||||
path (20, 9) (20, 9)
|
||||
resource specifier (kCFNotFound, 0) (29, 0)
|
||||
user (kCFNotFound, 0) (7, 0)
|
||||
password (kCFNotFound, 0) (7, 0)
|
||||
user info (kCFNotFound, 0) (7, 0)
|
||||
host (7, 13) (4, 16)
|
||||
port (kCFNotFound, 0) (20, 0)
|
||||
parameter (kCFNotFound, 0) (29, 0)
|
||||
query (kCFNotFound, 0) (29, 0)
|
||||
fragment (kCFNotFound, 0) (29, 0)
|
||||
|
||||
|
||||
For the URL ./relPath/file.html#fragment
|
||||
|
||||
Component returned range rangeIncludingSeparators
|
||||
scheme (kCFNotFound, 0) (0, 0)
|
||||
net location (kCFNotFound, 0) (0, 0)
|
||||
path (0, 19) (0, 20)
|
||||
resource specifier (20, 8) (19, 9)
|
||||
user (kCFNotFound, 0) (0, 0)
|
||||
password (kCFNotFound, 0) (0, 0)
|
||||
user info (kCFNotFound, 0) (0, 0)
|
||||
host (kCFNotFound, 0) (0, 0)
|
||||
port (kCFNotFound, 0) (0, 0)
|
||||
parameter (kCFNotFound, 0) (19, 0)
|
||||
query (kCFNotFound, 0) (19, 0)
|
||||
fragment (20, 8) (19, 9)
|
||||
|
||||
|
||||
For the URL scheme://user:pass@host:1/path/path2/file.html;params?query#fragment
|
||||
|
||||
Component returned range rangeIncludingSeparators
|
||||
scheme (0, 6) (0, 9)
|
||||
net location (9, 16) (6, 19)
|
||||
path (25, 21) (25, 22)
|
||||
resource specifier (47, 21) (46, 22)
|
||||
user (9, 4) (6, 8)
|
||||
password (14, 4) (13, 6)
|
||||
user info (9, 9) (6, 13)
|
||||
host (19, 4) (18, 6)
|
||||
port (24, 1) (23, 2)
|
||||
parameter (47, 6) (46, 8)
|
||||
query (54, 5) (53, 7)
|
||||
fragment (60, 8) (59, 9)
|
||||
*/
|
||||
CF_EXPORT
|
||||
CFRange CFURLGetByteRangeForComponent(CFURLRef url, CFURLComponentType component, CFRange *rangeIncludingSeparators) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
|
||||
#endif
|
||||
|
||||
/* Returns a string with any percent escape sequences that do NOT */
|
||||
/* correspond to characters in charactersToLeaveEscaped with their */
|
||||
/* equivalent. Returns NULL on failure (if an invalid percent sequence */
|
||||
/* is encountered), or the original string (retained) if no characters */
|
||||
/* need to be replaced. Pass NULL to request that no percent escapes be */
|
||||
/* replaced, or the empty string (CFSTR("")) to request that all percent */
|
||||
/* escapes be replaced. Uses UTF8 to interpret percent escapes. */
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCreateStringByReplacingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveEscaped);
|
||||
|
||||
#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
|
||||
/* As above, but allows you to specify the encoding to use when interpreting percent escapes */
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFAllocatorRef allocator, CFStringRef origString, CFStringRef charsToLeaveEscaped, CFStringEncoding encoding) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
|
||||
#endif
|
||||
|
||||
/* Creates a copy or originalString, replacing certain characters with */
|
||||
/* the equivalent percent escape sequence based on the encoding specified. */
|
||||
/* If the originalString does not need to be modified (no percent escape */
|
||||
/* sequences are missing), may retain and return originalString. */
|
||||
/* If you are uncertain of the correct encoding, you should use UTF-8, */
|
||||
/* which is the encoding designated by RFC 2396 as the correct encoding */
|
||||
/* for use in URLs. The characters so escaped are all characters that */
|
||||
/* are not legal URL characters (based on RFC 2396), plus any characters */
|
||||
/* in legalURLCharactersToBeEscaped, less any characters in */
|
||||
/* charactersToLeaveUnescaped. To simply correct any non-URL characters */
|
||||
/* in an otherwise correct URL string, do: */
|
||||
|
||||
/* newString = CFURLCreateStringByAddingPercentEscapes(NULL, origString, NULL, NULL, kCFStringEncodingUTF8); */
|
||||
CF_EXPORT
|
||||
CFStringRef CFURLCreateStringByAddingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding);
|
||||
|
||||
|
||||
struct FSRef;
|
||||
|
||||
CF_EXPORT
|
||||
CFURLRef CFURLCreateFromFSRef(CFAllocatorRef allocator, const struct FSRef *fsRef);
|
||||
|
||||
CF_EXPORT
|
||||
Boolean CFURLGetFSRef(CFURLRef url, struct FSRef *fsRef);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !__COREFOUNDATION_CFURL__ */
|
||||
|
||||
Reference in New Issue
Block a user