]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/core/cfdataref.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/core/cfdataref.h
3 // Purpose: wxCFDataRef class
4 // Author: Stefan Csomor
7 // RCS-ID: $Id: cfdataref.h 46095 2007-05-18 07:29:49Z SC $
8 // Copyright: (c) 2007 Stefan Csomor
9 // Licence: wxWindows licence
10 // Notes: See http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBinaryData/index.html
11 /////////////////////////////////////////////////////////////////////////////
12 /*! @header wx/osx/core/cfdataref.h
13 @abstract wxCFDataRef template class
16 #ifndef _WX_MAC_COREFOUNDATION_CFDATAREF_H__
17 #define _WX_MAC_COREFOUNDATION_CFDATAREF_H__
19 #include "wx/osx/core/cfref.h"
21 #include <CoreFoundation/CFData.h>
23 /*! @class wxCFDataRef
24 @discussion Properly retains/releases reference to CoreFoundation data objects
26 class wxCFDataRef
: public wxCFRef
< CFDataRef
>
29 /*! @method wxCFDataRef
30 @abstract Creates a NULL data ref
35 typedef wxCFRef
<CFDataRef
> super_type
;
37 /*! @method wxCFDataRef
38 @abstract Assumes ownership of p and creates a reference to it.
39 @templatefield otherType Any type.
40 @param p The raw pointer to assume ownership of. May be NULL.
41 @discussion Like shared_ptr, it is assumed that the caller has a strong reference to p and intends
42 to transfer ownership of that reference to this ref holder. If the object comes from
43 a Create or Copy method then this is the correct behavior. If the object comes from
44 a Get method then you must CFRetain it yourself before passing it to this constructor.
45 A handy way to do this is to use the non-member wxCFRefFromGet factory funcion.
46 This method is templated and takes an otherType *p. This prevents implicit conversion
47 using an operator refType() in a different ref-holding class type.
49 explicit wxCFDataRef(CFDataRef r
)
53 /*! @method wxCFDataRef
54 @abstract Copies a ref holder of the same type
55 @param otherRef The other ref holder to copy.
56 @discussion Ownership will be shared by the original ref and the newly created ref. That is,
57 the object will be explicitly retained by this new ref.
59 wxCFDataRef(const wxCFDataRef
& otherRef
)
60 : super_type( otherRef
)
63 /*! @method wxCFDataRef
64 @abstract Copies raw data into a data ref
65 @param data The raw data.
66 @param length The data length.
68 wxCFDataRef(const UInt8
* data
, CFIndex length
)
69 : super_type(CFDataCreate(kCFAllocatorDefault
, data
, length
))
74 @abstract returns the length in bytes of the data stored
76 CFIndex
GetLength() const
79 return CFDataGetLength( *this );
85 @abstract Copies the data into an external buffer
86 @param range The desired range.
87 @param buffer The target buffer.
89 void GetBytes( CFRange range
, UInt8
*buffer
) const
92 CFDataGetBytes(m_ptr
, range
, buffer
);
96 #endif //ifndef _WX_MAC_COREFOUNDATION_CFDATAREF_H__