LLDB  mainline
CFCData.cpp
Go to the documentation of this file.
1 //===-- CFCData.cpp -------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "CFCData.h"
10 
11 // CFCData constructor
12 CFCData::CFCData(CFDataRef data) : CFCReleaser<CFDataRef>(data) {}
13 
14 // CFCData copy constructor
15 CFCData::CFCData(const CFCData &rhs) : CFCReleaser<CFDataRef>(rhs) {}
16 
17 // CFCData copy constructor
19 
20 {
21  if (this != &rhs)
22  *this = rhs;
23  return *this;
24 }
25 
26 // Destructor
27 CFCData::~CFCData() = default;
28 
29 CFIndex CFCData::GetLength() const {
30  CFDataRef data = get();
31  if (data)
32  return CFDataGetLength(data);
33  return 0;
34 }
35 
36 const uint8_t *CFCData::GetBytePtr() const {
37  CFDataRef data = get();
38  if (data)
39  return CFDataGetBytePtr(data);
40  return NULL;
41 }
42 
43 CFDataRef CFCData::Serialize(CFPropertyListRef plist,
44  CFPropertyListFormat format) {
45  CFAllocatorRef alloc = kCFAllocatorDefault;
46  reset();
48  ::CFWriteStreamCreateWithAllocatedBuffers(alloc, alloc));
49  ::CFWriteStreamOpen(stream.get());
50  CFIndex len =
51  ::CFPropertyListWriteToStream(plist, stream.get(), format, NULL);
52  if (len > 0)
53  reset((CFDataRef)::CFWriteStreamCopyProperty(stream.get(),
54  kCFStreamPropertyDataWritten));
55  ::CFWriteStreamClose(stream.get());
56  return get();
57 }
CFCData::GetBytePtr
const uint8_t * GetBytePtr() const
Definition: CFCData.cpp:36
CFCData::Serialize
CFDataRef Serialize(CFPropertyListRef plist, CFPropertyListFormat format)
Definition: CFCData.cpp:43
CFCReleaser
CFCData.h
CFCData::GetLength
CFIndex GetLength() const
Definition: CFCData.cpp:29
CFCData
Definition: CFCData.h:14
CFCData::CFCData
CFCData(CFDataRef data=NULL)
Definition: CFCData.cpp:12
CFCData::~CFCData
virtual ~CFCData()
CFCData::operator=
CFCData & operator=(const CFCData &rhs)
Definition: CFCData.cpp:18