1 //===-- CFCData.cpp -------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // CFCData constructor
12 CFCData::CFCData(CFDataRef data
) : CFCReleaser
<CFDataRef
>(data
) {}
14 // CFCData copy constructor
15 CFCData::CFCData(const CFCData
&rhs
) = default;
17 // CFCData copy constructor
18 CFCData
&CFCData::operator=(const CFCData
&rhs
)
27 CFCData::~CFCData() = default;
29 CFIndex
CFCData::GetLength() const {
30 CFDataRef data
= get();
32 return CFDataGetLength(data
);
36 const uint8_t *CFCData::GetBytePtr() const {
37 CFDataRef data
= get();
39 return CFDataGetBytePtr(data
);
43 CFDataRef
CFCData::Serialize(CFPropertyListRef plist
,
44 CFPropertyListFormat format
) {
45 CFAllocatorRef alloc
= kCFAllocatorDefault
;
47 CFCReleaser
<CFWriteStreamRef
> stream(
48 ::CFWriteStreamCreateWithAllocatedBuffers(alloc
, alloc
));
49 ::CFWriteStreamOpen(stream
.get());
50 CFIndex len
= ::CFPropertyListWrite(plist
, stream
.get(), format
, 0, nullptr);
52 reset((CFDataRef
)::CFWriteStreamCopyProperty(stream
.get(),
53 kCFStreamPropertyDataWritten
));
54 ::CFWriteStreamClose(stream
.get());