1 /* CFData.h
2 
3    Copyright (C) 2010 Free Software Foundation, Inc.
4 
5    Written by: Stefan Bidigaray
6    Date: January, 2010
7 
8    This file is part of CoreBase.
9 
10    This library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Lesser General Public
12    License as published by the Free Software Foundation; either
13    version 2.1 of the License, or (at your option) any later version.
14 
15    This library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18    Lesser General Public License for more details.
19 
20    You should have received a copy of the GNU Lesser General Public
21    License along with this library; see the file COPYING.LIB.
22    If not, see <http://www.gnu.org/licenses/> or write to the
23    Free Software Foundation, 51 Franklin Street, Fifth Floor,
24    Boston, MA 02110-1301, USA.
25 */
26 
27 #ifndef __COREFOUNDATION_CFDATA_H__
28 #define __COREFOUNDATION_CFDATA_H__
29 
30 #include "CFBase.h"
31 
32 CF_EXTERN_C_BEGIN
33 /** \ingroup CFDataRef */
34 typedef const struct __CFData *CFDataRef;
35 /** \ingroup CFMutableDataRef */
36 typedef struct __CFData *CFMutableDataRef;
37 
38 /** \defgroup CFDataRef CFData Reference
39     \{
40  */
41 /** \name Creating a CFData Object
42     \{
43  */
44 CF_EXPORT CFDataRef
45 CFDataCreate (CFAllocatorRef allocator, const UInt8 * bytes, CFIndex length);
46 
47 CF_EXPORT CFDataRef
48 CFDataCreateCopy (CFAllocatorRef allocator, CFDataRef theData);
49 
50 CF_EXPORT CFDataRef
51 CFDataCreateWithBytesNoCopy (CFAllocatorRef allocator, const UInt8 * bytes,
52                              CFIndex length, CFAllocatorRef bytesDeallocator);
53 /** \} */
54 
55 /** \name Examining a CFData Object
56     \{
57  */
58 CF_EXPORT const UInt8 *CFDataGetBytePtr (CFDataRef theData);
59 
60 CF_EXPORT void
61 CFDataGetBytes (CFDataRef theData, CFRange range, UInt8 * buffer);
62 
63 CF_EXPORT CFIndex CFDataGetLength (CFDataRef theData);
64 /** \} */
65 
66 /** \name Getting the CFData Type ID
67     \{
68  */
69 CF_EXPORT CFTypeID CFDataGetTypeID (void);
70 /** \} */
71 /** \} */
72 
73 /** \defgroup CFMutableDataRef CFMutableData Reference
74     \{
75  */
76 /** \name Creating a Mutable Data Object
77     \{
78  */
79 CF_EXPORT CFMutableDataRef
80 CFDataCreateMutable (CFAllocatorRef allocator, CFIndex capacity);
81 
82 CF_EXPORT CFMutableDataRef
83 CFDataCreateMutableCopy (CFAllocatorRef allocator, CFIndex capacity,
84                          CFDataRef theData);
85 /** \} */
86 
87 /** \name Accessing Mutable Data
88     \{
89  */
90 CF_EXPORT UInt8 *CFDataGetMutableBytePtr (CFMutableDataRef theData);
91 /** \} */
92 
93 /** \name Modifying a Mutable Data Object
94     \{
95  */
96 CF_EXPORT void
97 CFDataAppendBytes (CFMutableDataRef theData, const UInt8 * bytes,
98                    CFIndex length);
99 
100 CF_EXPORT void CFDataDeleteBytes (CFMutableDataRef theData, CFRange range);
101 
102 CF_EXPORT void
103 CFDataReplaceBytes (CFMutableDataRef theData, CFRange range,
104                     const UInt8 * newBytes, CFIndex newLength);
105 
106 CF_EXPORT void
107 CFDataIncreaseLength (CFMutableDataRef theData, CFIndex extraLength);
108 
109 CF_EXPORT void CFDataSetLength (CFMutableDataRef theData, CFIndex length);
110 /** \} */
111 /** \} */
112 
113 CF_EXTERN_C_END
114 #endif /* __COREFOUNDATION_CFDATA_H__ */
115