summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/macosx/cfcpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Host/macosx/cfcpp')
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCBundle.cpp112
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCBundle.h38
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCData.cpp78
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCData.h30
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCMutableArray.cpp214
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCMutableArray.h47
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp856
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCMutableDictionary.h108
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCMutableSet.cpp115
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCMutableSet.h58
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCReleaser.h218
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCString.cpp230
-rw-r--r--lldb/source/Host/macosx/cfcpp/CFCString.h40
-rw-r--r--lldb/source/Host/macosx/cfcpp/CoreFoundationCPP.h4
14 files changed, 965 insertions, 1183 deletions
diff --git a/lldb/source/Host/macosx/cfcpp/CFCBundle.cpp b/lldb/source/Host/macosx/cfcpp/CFCBundle.cpp
index 71b07499366..08f16701c36 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCBundle.cpp
+++ b/lldb/source/Host/macosx/cfcpp/CFCBundle.cpp
@@ -13,87 +13,71 @@
//----------------------------------------------------------------------
// CFCBundle constructor
//----------------------------------------------------------------------
-CFCBundle::CFCBundle(const char *path) :
- CFCReleaser<CFBundleRef>()
-{
- if (path && path[0])
- SetPath(path);
+CFCBundle::CFCBundle(const char *path) : CFCReleaser<CFBundleRef>() {
+ if (path && path[0])
+ SetPath(path);
}
-CFCBundle::CFCBundle(CFURLRef url) :
- CFCReleaser<CFBundleRef>(url ? CFBundleCreate(NULL, url) : NULL)
-{
-}
+CFCBundle::CFCBundle(CFURLRef url)
+ : CFCReleaser<CFBundleRef>(url ? CFBundleCreate(NULL, url) : NULL) {}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-CFCBundle::~CFCBundle()
-{
-}
+CFCBundle::~CFCBundle() {}
//----------------------------------------------------------------------
// Set the path for a bundle by supplying a
//----------------------------------------------------------------------
-bool
-CFCBundle::SetPath (const char *path)
-{
- CFAllocatorRef alloc = kCFAllocatorDefault;
- // Release our old bundle and URL
- reset();
+bool CFCBundle::SetPath(const char *path) {
+ CFAllocatorRef alloc = kCFAllocatorDefault;
+ // Release our old bundle and URL
+ reset();
- // Make a CFStringRef from the supplied path
- CFCString cf_path;
- cf_path.SetFileSystemRepresentation(path);
- if (cf_path.get())
- {
- // Make our Bundle URL
- CFCReleaser<CFURLRef> bundle_url (::CFURLCreateWithFileSystemPath (alloc, cf_path.get(), kCFURLPOSIXPathStyle, true));
- if (bundle_url.get())
- reset (::CFBundleCreate (alloc, bundle_url.get()));
- }
- return get() != NULL;
+ // Make a CFStringRef from the supplied path
+ CFCString cf_path;
+ cf_path.SetFileSystemRepresentation(path);
+ if (cf_path.get()) {
+ // Make our Bundle URL
+ CFCReleaser<CFURLRef> bundle_url(::CFURLCreateWithFileSystemPath(
+ alloc, cf_path.get(), kCFURLPOSIXPathStyle, true));
+ if (bundle_url.get())
+ reset(::CFBundleCreate(alloc, bundle_url.get()));
+ }
+ return get() != NULL;
}
-bool
-CFCBundle::GetPath (char *dst, size_t dst_len)
-{
- CFBundleRef bundle = get();
- if (bundle)
- {
- CFCReleaser<CFURLRef> bundle_url (CFBundleCopyBundleURL (bundle));
- if (bundle_url.get())
- {
- Boolean resolveAgainstBase = 0;
- return ::CFURLGetFileSystemRepresentation (bundle_url.get(), resolveAgainstBase, (UInt8 *)dst, dst_len) != 0;
- }
+bool CFCBundle::GetPath(char *dst, size_t dst_len) {
+ CFBundleRef bundle = get();
+ if (bundle) {
+ CFCReleaser<CFURLRef> bundle_url(CFBundleCopyBundleURL(bundle));
+ if (bundle_url.get()) {
+ Boolean resolveAgainstBase = 0;
+ return ::CFURLGetFileSystemRepresentation(bundle_url.get(),
+ resolveAgainstBase,
+ (UInt8 *)dst, dst_len) != 0;
}
- return false;
-}
+ }
+ return false;
+}
-CFStringRef
-CFCBundle::GetIdentifier () const
-{
- CFBundleRef bundle = get();
- if (bundle != NULL)
- return ::CFBundleGetIdentifier (bundle);
- return NULL;
+CFStringRef CFCBundle::GetIdentifier() const {
+ CFBundleRef bundle = get();
+ if (bundle != NULL)
+ return ::CFBundleGetIdentifier(bundle);
+ return NULL;
}
-CFTypeRef
-CFCBundle::GetValueForInfoDictionaryKey(CFStringRef key) const
-{
- CFBundleRef bundle = get();
- if (bundle != NULL)
- return ::CFBundleGetValueForInfoDictionaryKey(bundle, key);
- return NULL;
+CFTypeRef CFCBundle::GetValueForInfoDictionaryKey(CFStringRef key) const {
+ CFBundleRef bundle = get();
+ if (bundle != NULL)
+ return ::CFBundleGetValueForInfoDictionaryKey(bundle, key);
+ return NULL;
}
-CFURLRef
-CFCBundle::CopyExecutableURL () const
-{
- CFBundleRef bundle = get();
- if (bundle != NULL)
- return CFBundleCopyExecutableURL(bundle);
- return NULL;
+CFURLRef CFCBundle::CopyExecutableURL() const {
+ CFBundleRef bundle = get();
+ if (bundle != NULL)
+ return CFBundleCopyExecutableURL(bundle);
+ return NULL;
}
diff --git a/lldb/source/Host/macosx/cfcpp/CFCBundle.h b/lldb/source/Host/macosx/cfcpp/CFCBundle.h
index 1cd1b681af8..9506b93f653 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCBundle.h
+++ b/lldb/source/Host/macosx/cfcpp/CFCBundle.h
@@ -12,39 +12,31 @@
#include "CFCReleaser.h"
-class CFCBundle : public CFCReleaser<CFBundleRef>
-{
+class CFCBundle : public CFCReleaser<CFBundleRef> {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- CFCBundle (const char *path = NULL);
- CFCBundle (CFURLRef url);
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ CFCBundle(const char *path = NULL);
+ CFCBundle(CFURLRef url);
- virtual
- ~CFCBundle();
+ virtual ~CFCBundle();
- CFURLRef
- CopyExecutableURL () const;
+ CFURLRef CopyExecutableURL() const;
- CFStringRef
- GetIdentifier () const;
+ CFStringRef GetIdentifier() const;
- CFTypeRef
- GetValueForInfoDictionaryKey(CFStringRef key) const;
+ CFTypeRef GetValueForInfoDictionaryKey(CFStringRef key) const;
- bool
- GetPath (char *dst, size_t dst_len);
+ bool GetPath(char *dst, size_t dst_len);
- bool
- SetPath (const char *path);
+ bool SetPath(const char *path);
private:
- // Disallow copy and assignment constructors
- CFCBundle(const CFCBundle&);
+ // Disallow copy and assignment constructors
+ CFCBundle(const CFCBundle &);
- const CFCBundle&
- operator=(const CFCBundle&);
+ const CFCBundle &operator=(const CFCBundle &);
};
#endif // #ifndef CoreFoundationCPP_CFBundle_h_
diff --git a/lldb/source/Host/macosx/cfcpp/CFCData.cpp b/lldb/source/Host/macosx/cfcpp/CFCData.cpp
index 4f49368ad8a..95cadede8ff 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCData.cpp
+++ b/lldb/source/Host/macosx/cfcpp/CFCData.cpp
@@ -12,71 +12,55 @@
//----------------------------------------------------------------------
// CFCData constructor
//----------------------------------------------------------------------
-CFCData::CFCData(CFDataRef data) :
- CFCReleaser<CFDataRef>(data)
-{
-
-}
+CFCData::CFCData(CFDataRef data) : CFCReleaser<CFDataRef>(data) {}
//----------------------------------------------------------------------
// CFCData copy constructor
//----------------------------------------------------------------------
-CFCData::CFCData(const CFCData& rhs) :
- CFCReleaser<CFDataRef>(rhs)
-{
-
-}
+CFCData::CFCData(const CFCData &rhs) : CFCReleaser<CFDataRef>(rhs) {}
//----------------------------------------------------------------------
// CFCData copy constructor
//----------------------------------------------------------------------
-CFCData&
-CFCData::operator=(const CFCData& rhs)
+CFCData &CFCData::operator=(const CFCData &rhs)
{
- if (this != &rhs)
- *this = rhs;
- return *this;
+ if (this != &rhs)
+ *this = rhs;
+ return *this;
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-CFCData::~CFCData()
-{
-}
-
+CFCData::~CFCData() {}
-CFIndex
-CFCData::GetLength() const
-{
- CFDataRef data = get();
- if (data)
- return CFDataGetLength (data);
- return 0;
+CFIndex CFCData::GetLength() const {
+ CFDataRef data = get();
+ if (data)
+ return CFDataGetLength(data);
+ return 0;
}
-
-const uint8_t*
-CFCData::GetBytePtr() const
-{
- CFDataRef data = get();
- if (data)
- return CFDataGetBytePtr (data);
- return NULL;
+const uint8_t *CFCData::GetBytePtr() const {
+ CFDataRef data = get();
+ if (data)
+ return CFDataGetBytePtr(data);
+ return NULL;
}
-CFDataRef
-CFCData::Serialize(CFPropertyListRef plist, CFPropertyListFormat format)
-{
- CFAllocatorRef alloc = kCFAllocatorDefault;
- reset();
- CFCReleaser<CFWriteStreamRef> stream (::CFWriteStreamCreateWithAllocatedBuffers (alloc, alloc));
- ::CFWriteStreamOpen (stream.get());
- CFIndex len = ::CFPropertyListWriteToStream (plist, stream.get(), format, NULL);
- if (len > 0)
- reset((CFDataRef)::CFWriteStreamCopyProperty (stream.get(), kCFStreamPropertyDataWritten));
- ::CFWriteStreamClose (stream.get());
- return get();
+CFDataRef CFCData::Serialize(CFPropertyListRef plist,
+ CFPropertyListFormat format) {
+ CFAllocatorRef alloc = kCFAllocatorDefault;
+ reset();
+ CFCReleaser<CFWriteStreamRef> stream(
+ ::CFWriteStreamCreateWithAllocatedBuffers(alloc, alloc));
+ ::CFWriteStreamOpen(stream.get());
+ CFIndex len =
+ ::CFPropertyListWriteToStream(plist, stream.get(), format, NULL);
+ if (len > 0)
+ reset((CFDataRef)::CFWriteStreamCopyProperty(stream.get(),
+ kCFStreamPropertyDataWritten));
+ ::CFWriteStreamClose(stream.get());
+ return get();
}
-
diff --git a/lldb/source/Host/macosx/cfcpp/CFCData.h b/lldb/source/Host/macosx/cfcpp/CFCData.h
index 6a718f54c05..e89d7bec783 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCData.h
+++ b/lldb/source/Host/macosx/cfcpp/CFCData.h
@@ -12,24 +12,24 @@
#include "CFCReleaser.h"
-class CFCData : public CFCReleaser<CFDataRef>
-{
+class CFCData : public CFCReleaser<CFDataRef> {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- CFCData(CFDataRef data = NULL);
- CFCData(const CFCData& rhs);
- CFCData& operator=(const CFCData& rhs);
- virtual ~CFCData();
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ CFCData(CFDataRef data = NULL);
+ CFCData(const CFCData &rhs);
+ CFCData &operator=(const CFCData &rhs);
+ virtual ~CFCData();
+
+ CFDataRef Serialize(CFPropertyListRef plist, CFPropertyListFormat format);
+ const uint8_t *GetBytePtr() const;
+ CFIndex GetLength() const;
- CFDataRef Serialize(CFPropertyListRef plist, CFPropertyListFormat format);
- const uint8_t* GetBytePtr () const;
- CFIndex GetLength () const;
protected:
- //------------------------------------------------------------------
- // Classes that inherit from CFCData can see and modify these
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // Classes that inherit from CFCData can see and modify these
+ //------------------------------------------------------------------
};
#endif // #ifndef CoreFoundationCPP_CFData_h_
diff --git a/lldb/source/Host/macosx/cfcpp/CFCMutableArray.cpp b/lldb/source/Host/macosx/cfcpp/CFCMutableArray.cpp
index c3c0a11193a..0b6258315eb 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCMutableArray.cpp
+++ b/lldb/source/Host/macosx/cfcpp/CFCMutableArray.cpp
@@ -13,154 +13,128 @@
//----------------------------------------------------------------------
// CFCString constructor
//----------------------------------------------------------------------
-CFCMutableArray::CFCMutableArray(CFMutableArrayRef s) :
- CFCReleaser<CFMutableArrayRef> (s)
-{
-}
+CFCMutableArray::CFCMutableArray(CFMutableArrayRef s)
+ : CFCReleaser<CFMutableArrayRef>(s) {}
//----------------------------------------------------------------------
// CFCMutableArray copy constructor
//----------------------------------------------------------------------
-CFCMutableArray::CFCMutableArray(const CFCMutableArray& rhs) :
- CFCReleaser<CFMutableArrayRef> (rhs) // NOTE: this won't make a copy of the array, just add a new reference to it
-{
-}
+CFCMutableArray::CFCMutableArray(const CFCMutableArray &rhs)
+ : CFCReleaser<CFMutableArrayRef>(rhs) // NOTE: this won't make a copy of the
+ // array, just add a new reference to
+ // it
+{}
//----------------------------------------------------------------------
// CFCMutableArray copy constructor
//----------------------------------------------------------------------
-CFCMutableArray&
-CFCMutableArray::operator=(const CFCMutableArray& rhs)
-{
- if (this != &rhs)
- *this = rhs; // NOTE: this operator won't make a copy of the array, just add a new reference to it
- return *this;
+CFCMutableArray &CFCMutableArray::operator=(const CFCMutableArray &rhs) {
+ if (this != &rhs)
+ *this = rhs; // NOTE: this operator won't make a copy of the array, just add
+ // a new reference to it
+ return *this;
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-CFCMutableArray::~CFCMutableArray()
-{
-}
+CFCMutableArray::~CFCMutableArray() {}
-
-CFIndex
-CFCMutableArray::GetCount() const
-{
- CFMutableArrayRef array = get();
- if (array)
- return ::CFArrayGetCount (array);
- return 0;
+CFIndex CFCMutableArray::GetCount() const {
+ CFMutableArrayRef array = get();
+ if (array)
+ return ::CFArrayGetCount(array);
+ return 0;
}
-CFIndex
-CFCMutableArray::GetCountOfValue(CFRange range, const void *value) const
-{
- CFMutableArrayRef array = get();
- if (array)
- return ::CFArrayGetCountOfValue (array, range, value);
- return 0;
+CFIndex CFCMutableArray::GetCountOfValue(CFRange range,
+ const void *value) const {
+ CFMutableArrayRef array = get();
+ if (array)
+ return ::CFArrayGetCountOfValue(array, range, value);
+ return 0;
}
-CFIndex
-CFCMutableArray::GetCountOfValue(const void *value) const
-{
- CFMutableArrayRef array = get();
- if (array)
- return ::CFArrayGetCountOfValue (array, CFRangeMake(0, GetCount()), value);
- return 0;
+CFIndex CFCMutableArray::GetCountOfValue(const void *value) const {
+ CFMutableArrayRef array = get();
+ if (array)
+ return ::CFArrayGetCountOfValue(array, CFRangeMake(0, GetCount()), value);
+ return 0;
}
-const void *
-CFCMutableArray::GetValueAtIndex(CFIndex idx) const
-{
- CFMutableArrayRef array = get();
- if (array)
- {
- const CFIndex num_array_items = ::CFArrayGetCount (array);
- if (0 <= idx && idx < num_array_items)
- {
- return ::CFArrayGetValueAtIndex (array, idx);
- }
+const void *CFCMutableArray::GetValueAtIndex(CFIndex idx) const {
+ CFMutableArrayRef array = get();
+ if (array) {
+ const CFIndex num_array_items = ::CFArrayGetCount(array);
+ if (0 <= idx && idx < num_array_items) {
+ return ::CFArrayGetValueAtIndex(array, idx);
}
- return NULL;
+ }
+ return NULL;
}
-bool
-CFCMutableArray::SetValueAtIndex(CFIndex idx, const void *value)
-{
- CFMutableArrayRef array = get();
- if (array != NULL)
- {
- const CFIndex num_array_items = ::CFArrayGetCount (array);
- if (0 <= idx && idx < num_array_items)
- {
- ::CFArraySetValueAtIndex (array, idx, value);
- return true;
- }
+bool CFCMutableArray::SetValueAtIndex(CFIndex idx, const void *value) {
+ CFMutableArrayRef array = get();
+ if (array != NULL) {
+ const CFIndex num_array_items = ::CFArrayGetCount(array);
+ if (0 <= idx && idx < num_array_items) {
+ ::CFArraySetValueAtIndex(array, idx, value);
+ return true;
}
- return false;
+ }
+ return false;
}
-
-bool
-CFCMutableArray::AppendValue(const void *value, bool can_create)
-{
- CFMutableArrayRef array = get();
- if (array == NULL)
- {
- if (can_create == false)
- return false;
- array = ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
- reset ( array );
- }
- if (array != NULL)
- {
- ::CFArrayAppendValue(array, value);
- return true;
- }
- return false;
+bool CFCMutableArray::AppendValue(const void *value, bool can_create) {
+ CFMutableArrayRef array = get();
+ if (array == NULL) {
+ if (can_create == false)
+ return false;
+ array =
+ ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
+ reset(array);
+ }
+ if (array != NULL) {
+ ::CFArrayAppendValue(array, value);
+ return true;
+ }
+ return false;
}
-
-bool
-CFCMutableArray::AppendCStringAsCFString (const char *s, CFStringEncoding encoding, bool can_create)
-{
- CFMutableArrayRef array = get();
- if (array == NULL)
- {
- if (can_create == false)
- return false;
- array = ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
- reset ( array );
- }
- if (array != NULL)
- {
- CFCString cf_str (s, encoding);
- ::CFArrayAppendValue (array, cf_str.get());
- return true;
- }
- return false;
+bool CFCMutableArray::AppendCStringAsCFString(const char *s,
+ CFStringEncoding encoding,
+ bool can_create) {
+ CFMutableArrayRef array = get();
+ if (array == NULL) {
+ if (can_create == false)
+ return false;
+ array =
+ ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
+ reset(array);
+ }
+ if (array != NULL) {
+ CFCString cf_str(s, encoding);
+ ::CFArrayAppendValue(array, cf_str.get());
+ return true;
+ }
+ return false;
}
-bool
-CFCMutableArray::AppendFileSystemRepresentationAsCFString (const char *s, bool can_create)
-{
- CFMutableArrayRef array = get();
- if (array == NULL)
- {
- if (can_create == false)
- return false;
- array = ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
- reset ( array );
- }
- if (array != NULL)
- {
- CFCString cf_path;
- cf_path.SetFileSystemRepresentation(s);
- ::CFArrayAppendValue (array, cf_path.get());
- return true;
- }
- return false;
+bool CFCMutableArray::AppendFileSystemRepresentationAsCFString(
+ const char *s, bool can_create) {
+ CFMutableArrayRef array = get();
+ if (array == NULL) {
+ if (can_create == false)
+ return false;
+ array =
+ ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
+ reset(array);
+ }
+ if (array != NULL) {
+ CFCString cf_path;
+ cf_path.SetFileSystemRepresentation(s);
+ ::CFArrayAppendValue(array, cf_path.get());
+ return true;
+ }
+ return false;
}
diff --git a/lldb/source/Host/macosx/cfcpp/CFCMutableArray.h b/lldb/source/Host/macosx/cfcpp/CFCMutableArray.h
index f78cd92ffab..23d1f932bfc 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCMutableArray.h
+++ b/lldb/source/Host/macosx/cfcpp/CFCMutableArray.h
@@ -12,28 +12,35 @@
#include "CFCReleaser.h"
-class CFCMutableArray : public CFCReleaser<CFMutableArrayRef>
-{
+class CFCMutableArray : public CFCReleaser<CFMutableArrayRef> {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- CFCMutableArray(CFMutableArrayRef array = NULL);
- CFCMutableArray(const CFCMutableArray& rhs); // This will copy the array contents into a new array
- CFCMutableArray& operator=(const CFCMutableArray& rhs); // This will re-use the same array and just bump the ref count
- virtual ~CFCMutableArray();
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ CFCMutableArray(CFMutableArrayRef array = NULL);
+ CFCMutableArray(const CFCMutableArray &rhs); // This will copy the array
+ // contents into a new array
+ CFCMutableArray &operator=(const CFCMutableArray &rhs); // This will re-use
+ // the same array and
+ // just bump the ref
+ // count
+ virtual ~CFCMutableArray();
- CFIndex GetCount() const;
- CFIndex GetCountOfValue(const void *value) const;
- CFIndex GetCountOfValue(CFRange range, const void *value) const;
- const void * GetValueAtIndex(CFIndex idx) const;
- bool SetValueAtIndex(CFIndex idx, const void *value);
- bool AppendValue(const void *value, bool can_create = true); // Appends value and optionally creates a CFCMutableArray if this class doesn't contain one
- bool AppendCStringAsCFString (const char *cstr,
- CFStringEncoding encoding = kCFStringEncodingUTF8,
- bool can_create = true);
- bool AppendFileSystemRepresentationAsCFString (const char *s,
- bool can_create = true);
+ CFIndex GetCount() const;
+ CFIndex GetCountOfValue(const void *value) const;
+ CFIndex GetCountOfValue(CFRange range, const void *value) const;
+ const void *GetValueAtIndex(CFIndex idx) const;
+ bool SetValueAtIndex(CFIndex idx, const void *value);
+ bool AppendValue(const void *value,
+ bool can_create = true); // Appends value and optionally
+ // creates a CFCMutableArray if this
+ // class doesn't contain one
+ bool
+ AppendCStringAsCFString(const char *cstr,
+ CFStringEncoding encoding = kCFStringEncodingUTF8,
+ bool can_create = true);
+ bool AppendFileSystemRepresentationAsCFString(const char *s,
+ bool can_create = true);
};
#endif // #ifndef CoreFoundationCPP_CFMutableArray_h_
diff --git a/lldb/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp b/lldb/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp
index bce023bfd61..201ec9a8f5c 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp
+++ b/lldb/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp
@@ -12,518 +12,458 @@
//----------------------------------------------------------------------
// CFCString constructor
//----------------------------------------------------------------------
-CFCMutableDictionary::CFCMutableDictionary(CFMutableDictionaryRef s) :
- CFCReleaser<CFMutableDictionaryRef> (s)
-{
-}
+CFCMutableDictionary::CFCMutableDictionary(CFMutableDictionaryRef s)
+ : CFCReleaser<CFMutableDictionaryRef>(s) {}
//----------------------------------------------------------------------
// CFCMutableDictionary copy constructor
//----------------------------------------------------------------------
-CFCMutableDictionary::CFCMutableDictionary(const CFCMutableDictionary& rhs) :
- CFCReleaser<CFMutableDictionaryRef> (rhs)
-{
-}
+CFCMutableDictionary::CFCMutableDictionary(const CFCMutableDictionary &rhs)
+ : CFCReleaser<CFMutableDictionaryRef>(rhs) {}
//----------------------------------------------------------------------
// CFCMutableDictionary copy constructor
//----------------------------------------------------------------------
-const CFCMutableDictionary&
-CFCMutableDictionary::operator=(const CFCMutableDictionary& rhs)
-{
- if (this != &rhs)
- *this = rhs;
- return *this;
+const CFCMutableDictionary &CFCMutableDictionary::
+operator=(const CFCMutableDictionary &rhs) {
+ if (this != &rhs)
+ *this = rhs;
+ return *this;
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-CFCMutableDictionary::~CFCMutableDictionary()
-{
-}
-
+CFCMutableDictionary::~CFCMutableDictionary() {}
-CFIndex
-CFCMutableDictionary::GetCount() const
-{
- CFMutableDictionaryRef dict = get();
- if (dict)
- return ::CFDictionaryGetCount (dict);
- return 0;
+CFIndex CFCMutableDictionary::GetCount() const {
+ CFMutableDictionaryRef dict = get();
+ if (dict)
+ return ::CFDictionaryGetCount(dict);
+ return 0;
}
-CFIndex
-CFCMutableDictionary::GetCountOfKey(const void *key) const
+CFIndex CFCMutableDictionary::GetCountOfKey(const void *key) const
{
- CFMutableDictionaryRef dict = get();
- if (dict)
- return ::CFDictionaryGetCountOfKey (dict, key);
- return 0;
+ CFMutableDictionaryRef dict = get();
+ if (dict)
+ return ::CFDictionaryGetCountOfKey(dict, key);
+ return 0;
}
-CFIndex
-CFCMutableDictionary::GetCountOfValue(const void *value) const
+CFIndex CFCMutableDictionary::GetCountOfValue(const void *value) const
{
- CFMutableDictionaryRef dict = get();
- if (dict)
- return ::CFDictionaryGetCountOfValue (dict, value);
- return 0;
+ CFMutableDictionaryRef dict = get();
+ if (dict)
+ return ::CFDictionaryGetCountOfValue(dict, value);
+ return 0;
}
-void
-CFCMutableDictionary::GetKeysAndValues(const void **keys, const void **values) const
-{
- CFMutableDictionaryRef dict = get();
- if (dict)
- ::CFDictionaryGetKeysAndValues (dict, keys, values);
+void CFCMutableDictionary::GetKeysAndValues(const void **keys,
+ const void **values) const {
+ CFMutableDictionaryRef dict = get();
+ if (dict)
+ ::CFDictionaryGetKeysAndValues(dict, keys, values);
}
-
-const void *
-CFCMutableDictionary::GetValue(const void *key) const
+const void *CFCMutableDictionary::GetValue(const void *key) const
{
- CFMutableDictionaryRef dict = get();
- if (dict)
- return ::CFDictionaryGetValue (dict, key);
- return NULL;
+ CFMutableDictionaryRef dict = get();
+ if (dict)
+ return ::CFDictionaryGetValue(dict, key);
+ return NULL;
}
Boolean
-CFCMutableDictionary::GetValueIfPresent(const void *key, const void **value_handle) const
-{
- CFMutableDictionaryRef dict = get();
- if (dict)
- return ::CFDictionaryGetValueIfPresent (dict, key, value_handle);
- return false;
-}
-
-
-CFMutableDictionaryRef
-CFCMutableDictionary::Dictionary(bool can_create)
-{
- CFMutableDictionaryRef dict = get();
- if (can_create && dict == NULL)
- {
- dict = ::CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- reset ( dict );
+CFCMutableDictionary::GetValueIfPresent(const void *key,
+ const void **value_handle) const {
+ CFMutableDictionaryRef dict = get();
+ if (dict)
+ return ::CFDictionaryGetValueIfPresent(dict, key, value_handle);
+ return false;
+}
+
+CFMutableDictionaryRef CFCMutableDictionary::Dictionary(bool can_create) {
+ CFMutableDictionaryRef dict = get();
+ if (can_create && dict == NULL) {
+ dict = ::CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ reset(dict);
+ }
+ return dict;
+}
+
+bool CFCMutableDictionary::AddValue(CFStringRef key, const void *value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionaryAddValue(dict, key, value);
+ return true;
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::SetValue(CFStringRef key, const void *value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionarySetValue(dict, key, value);
+ return true;
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::AddValueSInt8(CFStringRef key, int8_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt8Type, &value));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionaryAddValue(dict, key, cf_number.get());
+ return true;
}
- return dict;
-}
-
-bool
-CFCMutableDictionary::AddValue(CFStringRef key, const void *value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- // Let the dictionary own the CFNumber
- ::CFDictionaryAddValue (dict, key, value);
- return true;
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::SetValueSInt8(CFStringRef key, int8_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt8Type, &value));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionarySetValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::SetValue(CFStringRef key, const void *value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- // Let the dictionary own the CFNumber
- ::CFDictionarySetValue (dict, key, value);
- return true;
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::AddValueSInt16(CFStringRef key, int16_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &value));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionaryAddValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::AddValueSInt8(CFStringRef key, int8_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt8Type, &value));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionaryAddValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::SetValueSInt16(CFStringRef key, int16_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &value));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionarySetValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::SetValueSInt8(CFStringRef key, int8_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt8Type, &value));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionarySetValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::AddValueSInt32(CFStringRef key, int32_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionaryAddValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::AddValueSInt16(CFStringRef key, int16_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt16Type, &value));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionaryAddValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::SetValueSInt32(CFStringRef key, int32_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionarySetValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::SetValueSInt16(CFStringRef key, int16_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt16Type, &value));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionarySetValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::AddValueSInt64(CFStringRef key, int64_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionaryAddValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::AddValueSInt32(CFStringRef key, int32_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt32Type, &value));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionaryAddValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::SetValueSInt64(CFStringRef key, int64_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionarySetValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::SetValueSInt32(CFStringRef key, int32_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt32Type, &value));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionarySetValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::AddValueUInt8(CFStringRef key, uint8_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ // Have to promote to the next size type so things don't appear negative of
+ // the MSBit is set...
+ int16_t sval = value;
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &sval));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionaryAddValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::AddValueSInt64(CFStringRef key, int64_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt64Type, &value));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionaryAddValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::SetValueUInt8(CFStringRef key, uint8_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ // Have to promote to the next size type so things don't appear negative of
+ // the MSBit is set...
+ int16_t sval = value;
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &sval));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionarySetValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::SetValueSInt64(CFStringRef key, int64_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt64Type, &value));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionarySetValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::AddValueUInt16(CFStringRef key, uint16_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ // Have to promote to the next size type so things don't appear negative of
+ // the MSBit is set...
+ int32_t sval = value;
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &sval));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionaryAddValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::AddValueUInt8(CFStringRef key, uint8_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- // Have to promote to the next size type so things don't appear negative of the MSBit is set...
- int16_t sval = value;
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt16Type, &sval));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionaryAddValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::SetValueUInt16(CFStringRef key, uint16_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ // Have to promote to the next size type so things don't appear negative of
+ // the MSBit is set...
+ int32_t sval = value;
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &sval));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionarySetValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::SetValueUInt8(CFStringRef key, uint8_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- // Have to promote to the next size type so things don't appear negative of the MSBit is set...
- int16_t sval = value;
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt16Type, &sval));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionarySetValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::AddValueUInt32(CFStringRef key, uint32_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ // Have to promote to the next size type so things don't appear negative of
+ // the MSBit is set...
+ int64_t sval = value;
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &sval));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionaryAddValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-
-bool
-CFCMutableDictionary::AddValueUInt16(CFStringRef key, uint16_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- // Have to promote to the next size type so things don't appear negative of the MSBit is set...
- int32_t sval = value;
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt32Type, &sval));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionaryAddValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::SetValueUInt32(CFStringRef key, uint32_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ // Have to promote to the next size type so things don't appear negative of
+ // the MSBit is set...
+ int64_t sval = value;
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &sval));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionarySetValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::SetValueUInt16(CFStringRef key, uint16_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- // Have to promote to the next size type so things don't appear negative of the MSBit is set...
- int32_t sval = value;
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt32Type, &sval));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionarySetValue (dict, key, cf_number.get());
- return true;
- }
- }
- return false;
-}
-
-bool
-CFCMutableDictionary::AddValueUInt32(CFStringRef key, uint32_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- // Have to promote to the next size type so things don't appear negative of the MSBit is set...
- int64_t sval = value;
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt64Type, &sval));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionaryAddValue (dict, key, cf_number.get());
- return true;
- }
- }
- return false;
-}
-
-bool
-CFCMutableDictionary::SetValueUInt32(CFStringRef key, uint32_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- // Have to promote to the next size type so things don't appear negative of the MSBit is set...
- int64_t sval = value;
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt64Type, &sval));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionarySetValue (dict, key, cf_number.get());
- return true;
- }
- }
- return false;
-}
-
-
-bool
-CFCMutableDictionary::AddValueUInt64(CFStringRef key, uint64_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- // The number may appear negative if the MSBit is set in "value". Due to a limitation of
- // CFNumber, there isn't a way to have it show up otherwise as of this writing.
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt64Type, &value));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionaryAddValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::AddValueUInt64(CFStringRef key, uint64_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ // The number may appear negative if the MSBit is set in "value". Due to a
+ // limitation of
+ // CFNumber, there isn't a way to have it show up otherwise as of this
+ // writing.
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionaryAddValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-
-bool
-CFCMutableDictionary::SetValueUInt64(CFStringRef key, uint64_t value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- // The number may appear negative if the MSBit is set in "value". Due to a limitation of
- // CFNumber, there isn't a way to have it show up otherwise as of this writing.
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt64Type, &value));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionarySetValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::SetValueUInt64(CFStringRef key, uint64_t value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ // The number may appear negative if the MSBit is set in "value". Due to a
+ // limitation of
+ // CFNumber, there isn't a way to have it show up otherwise as of this
+ // writing.
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionarySetValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::AddValueDouble(CFStringRef key, double value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- // The number may appear negative if the MSBit is set in "value". Due to a limitation of
- // CFNumber, there isn't a way to have it show up otherwise as of this writing.
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberDoubleType, &value));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionaryAddValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::AddValueDouble(CFStringRef key, double value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ // The number may appear negative if the MSBit is set in "value". Due to a
+ // limitation of
+ // CFNumber, there isn't a way to have it show up otherwise as of this
+ // writing.
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &value));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionaryAddValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::SetValueDouble(CFStringRef key, double value, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- // The number may appear negative if the MSBit is set in "value". Due to a limitation of
- // CFNumber, there isn't a way to have it show up otherwise as of this writing.
- CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberDoubleType, &value));
- if (cf_number.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionarySetValue (dict, key, cf_number.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::SetValueDouble(CFStringRef key, double value,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ // The number may appear negative if the MSBit is set in "value". Due to a
+ // limitation of
+ // CFNumber, there isn't a way to have it show up otherwise as of this
+ // writing.
+ CFCReleaser<CFNumberRef> cf_number(
+ ::CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &value));
+ if (cf_number.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionarySetValue(dict, key, cf_number.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::AddValueCString(CFStringRef key, const char *cstr, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- CFCString cf_str(cstr, kCFStringEncodingUTF8);
- if (cf_str.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionaryAddValue (dict, key, cf_str.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::AddValueCString(CFStringRef key, const char *cstr,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ CFCString cf_str(cstr, kCFStringEncodingUTF8);
+ if (cf_str.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionaryAddValue(dict, key, cf_str.get());
+ return true;
}
- return false;
-}
-
-bool
-CFCMutableDictionary::SetValueCString(CFStringRef key, const char *cstr, bool can_create)
-{
- CFMutableDictionaryRef dict = Dictionary(can_create);
- if (dict != NULL)
- {
- CFCString cf_str(cstr, kCFStringEncodingUTF8);
- if (cf_str.get())
- {
- // Let the dictionary own the CFNumber
- ::CFDictionarySetValue (dict, key, cf_str.get());
- return true;
- }
+ }
+ return false;
+}
+
+bool CFCMutableDictionary::SetValueCString(CFStringRef key, const char *cstr,
+ bool can_create) {
+ CFMutableDictionaryRef dict = Dictionary(can_create);
+ if (dict != NULL) {
+ CFCString cf_str(cstr, kCFStringEncodingUTF8);
+ if (cf_str.get()) {
+ // Let the dictionary own the CFNumber
+ ::CFDictionarySetValue(dict, key, cf_str.get());
+ return true;
}
- return false;
+ }
+ return false;
}
-
-void
-CFCMutableDictionary::RemoveAllValues()
-{
- CFMutableDictionaryRef dict = get();
- if (dict)
- ::CFDictionaryRemoveAllValues(dict);
+void CFCMutableDictionary::RemoveAllValues() {
+ CFMutableDictionaryRef dict = get();
+ if (dict)
+ ::CFDictionaryRemoveAllValues(dict);
}
-void
-CFCMutableDictionary::RemoveValue(const void *value)
-{
- CFMutableDictionaryRef dict = get();
- if (dict)
- ::CFDictionaryRemoveValue(dict, value);
+void CFCMutableDictionary::RemoveValue(const void *value) {
+ CFMutableDictionaryRef dict = get();
+ if (dict)
+ ::CFDictionaryRemoveValue(dict, value);
}
-void
-CFCMutableDictionary::ReplaceValue(const void *key, const void *value)
-{
- CFMutableDictionaryRef dict = get();
- if (dict)
- ::CFDictionaryReplaceValue (dict, key, value);
+void CFCMutableDictionary::ReplaceValue(const void *key, const void *value) {
+ CFMutableDictionaryRef dict = get();
+ if (dict)
+ ::CFDictionaryReplaceValue(dict, key, value);
}
-
diff --git a/lldb/source/Host/macosx/cfcpp/CFCMutableDictionary.h b/lldb/source/Host/macosx/cfcpp/CFCMutableDictionary.h
index a1cfb68f569..b30a2e616cd 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCMutableDictionary.h
+++ b/lldb/source/Host/macosx/cfcpp/CFCMutableDictionary.h
@@ -12,68 +12,64 @@
#include "CFCReleaser.h"
-class CFCMutableDictionary : public CFCReleaser<CFMutableDictionaryRef>
-{
+class CFCMutableDictionary : public CFCReleaser<CFMutableDictionaryRef> {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- CFCMutableDictionary(CFMutableDictionaryRef s = NULL);
- CFCMutableDictionary(const CFCMutableDictionary& rhs);
- virtual ~CFCMutableDictionary();
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ CFCMutableDictionary(CFMutableDictionaryRef s = NULL);
+ CFCMutableDictionary(const CFCMutableDictionary &rhs);
+ virtual ~CFCMutableDictionary();
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
- const CFCMutableDictionary&
- operator=(const CFCMutableDictionary& rhs);
-
-
- CFIndex GetCount() const;
- CFIndex GetCountOfKey(const void *value) const;
- CFIndex GetCountOfValue(const void *value) const;
- void GetKeysAndValues(const void **keys, const void **values) const;
- const void * GetValue(const void *key) const;
- Boolean GetValueIfPresent(const void *key, const void **value_handle) const;
- bool AddValue(CFStringRef key, const void *value, bool can_create = false);
- bool SetValue(CFStringRef key, const void *value, bool can_create = false);
- bool AddValueSInt8(CFStringRef key, int8_t value, bool can_create = false);
- bool SetValueSInt8(CFStringRef key, int8_t value, bool can_create = false);
- bool AddValueSInt16(CFStringRef key, int16_t value, bool can_create = false);
- bool SetValueSInt16(CFStringRef key, int16_t value, bool can_create = false);
- bool AddValueSInt32(CFStringRef key, int32_t value, bool can_create = false);
- bool SetValueSInt32(CFStringRef key, int32_t value, bool can_create = false);
- bool AddValueSInt64(CFStringRef key, int64_t value, bool can_create = false);
- bool SetValueSInt64(CFStringRef key, int64_t value, bool can_create = false);
- bool AddValueUInt8(CFStringRef key, uint8_t value, bool can_create = false);
- bool SetValueUInt8(CFStringRef key, uint8_t value, bool can_create = false);
- bool AddValueUInt16(CFStringRef key, uint16_t value, bool can_create = false);
- bool SetValueUInt16(CFStringRef key, uint16_t value, bool can_create = false);
- bool AddValueUInt32(CFStringRef key, uint32_t value, bool can_create = false);
- bool SetValueUInt32(CFStringRef key, uint32_t value, bool can_create = false);
- bool AddValueUInt64(CFStringRef key, uint64_t value, bool can_create = false);
- bool SetValueUInt64(CFStringRef key, uint64_t value, bool can_create = false);
- bool AddValueDouble(CFStringRef key, double value, bool can_create = false);
- bool SetValueDouble(CFStringRef key, double value, bool can_create = false);
- bool AddValueCString(CFStringRef key, const char *cstr, bool can_create = false);
- bool SetValueCString(CFStringRef key, const char *cstr, bool can_create = false);
- void RemoveValue(const void *value);
- void ReplaceValue(const void *key, const void *value);
- void RemoveAllValues();
- CFMutableDictionaryRef Dictionary(bool can_create);
+ //------------------------------------------------------------------
+ // Operators
+ //------------------------------------------------------------------
+ const CFCMutableDictionary &operator=(const CFCMutableDictionary &rhs);
+ CFIndex GetCount() const;
+ CFIndex GetCountOfKey(const void *value) const;
+ CFIndex GetCountOfValue(const void *value) const;
+ void GetKeysAndValues(const void **keys, const void **values) const;
+ const void *GetValue(const void *key) const;
+ Boolean GetValueIfPresent(const void *key, const void **value_handle) const;
+ bool AddValue(CFStringRef key, const void *value, bool can_create = false);
+ bool SetValue(CFStringRef key, const void *value, bool can_create = false);
+ bool AddValueSInt8(CFStringRef key, int8_t value, bool can_create = false);
+ bool SetValueSInt8(CFStringRef key, int8_t value, bool can_create = false);
+ bool AddValueSInt16(CFStringRef key, int16_t value, bool can_create = false);
+ bool SetValueSInt16(CFStringRef key, int16_t value, bool can_create = false);
+ bool AddValueSInt32(CFStringRef key, int32_t value, bool can_create = false);
+ bool SetValueSInt32(CFStringRef key, int32_t value, bool can_create = false);
+ bool AddValueSInt64(CFStringRef key, int64_t value, bool can_create = false);
+ bool SetValueSInt64(CFStringRef key, int64_t value, bool can_create = false);
+ bool AddValueUInt8(CFStringRef key, uint8_t value, bool can_create = false);
+ bool SetValueUInt8(CFStringRef key, uint8_t value, bool can_create = false);
+ bool AddValueUInt16(CFStringRef key, uint16_t value, bool can_create = false);
+ bool SetValueUInt16(CFStringRef key, uint16_t value, bool can_create = false);
+ bool AddValueUInt32(CFStringRef key, uint32_t value, bool can_create = false);
+ bool SetValueUInt32(CFStringRef key, uint32_t value, bool can_create = false);
+ bool AddValueUInt64(CFStringRef key, uint64_t value, bool can_create = false);
+ bool SetValueUInt64(CFStringRef key, uint64_t value, bool can_create = false);
+ bool AddValueDouble(CFStringRef key, double value, bool can_create = false);
+ bool SetValueDouble(CFStringRef key, double value, bool can_create = false);
+ bool AddValueCString(CFStringRef key, const char *cstr,
+ bool can_create = false);
+ bool SetValueCString(CFStringRef key, const char *cstr,
+ bool can_create = false);
+ void RemoveValue(const void *value);
+ void ReplaceValue(const void *key, const void *value);
+ void RemoveAllValues();
+ CFMutableDictionaryRef Dictionary(bool can_create);
protected:
- //------------------------------------------------------------------
- // Classes that inherit from CFCMutableDictionary can see and modify these
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // Classes that inherit from CFCMutableDictionary can see and modify these
+ //------------------------------------------------------------------
private:
- //------------------------------------------------------------------
- // For CFCMutableDictionary only
- //------------------------------------------------------------------
-
+ //------------------------------------------------------------------
+ // For CFCMutableDictionary only
+ //------------------------------------------------------------------
};
-
-#endif // CoreFoundationCPP_CFMutableDictionary_h_
+#endif // CoreFoundationCPP_CFMutableDictionary_h_
diff --git a/lldb/source/Host/macosx/cfcpp/CFCMutableSet.cpp b/lldb/source/Host/macosx/cfcpp/CFCMutableSet.cpp
index afc09e180b6..c339e950674 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCMutableSet.cpp
+++ b/lldb/source/Host/macosx/cfcpp/CFCMutableSet.cpp
@@ -17,98 +17,73 @@
//----------------------------------------------------------------------
// CFCString constructor
//----------------------------------------------------------------------
-CFCMutableSet::CFCMutableSet(CFMutableSetRef s) :
- CFCReleaser<CFMutableSetRef> (s)
-{
-}
+CFCMutableSet::CFCMutableSet(CFMutableSetRef s)
+ : CFCReleaser<CFMutableSetRef>(s) {}
//----------------------------------------------------------------------
// CFCMutableSet copy constructor
//----------------------------------------------------------------------
-CFCMutableSet::CFCMutableSet(const CFCMutableSet& rhs) :
- CFCReleaser<CFMutableSetRef> (rhs)
-{
-}
+CFCMutableSet::CFCMutableSet(const CFCMutableSet &rhs)
+ : CFCReleaser<CFMutableSetRef>(rhs) {}
//----------------------------------------------------------------------
// CFCMutableSet copy constructor
//----------------------------------------------------------------------
-const CFCMutableSet&
-CFCMutableSet::operator=(const CFCMutableSet& rhs)
-{
- if (this != &rhs)
- *this = rhs;
- return *this;
+const CFCMutableSet &CFCMutableSet::operator=(const CFCMutableSet &rhs) {
+ if (this != &rhs)
+ *this = rhs;
+ return *this;
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-CFCMutableSet::~CFCMutableSet()
-{
-}
+CFCMutableSet::~CFCMutableSet() {}
-
-CFIndex
-CFCMutableSet::GetCount() const
-{
- CFMutableSetRef set = get();
- if (set)
- return ::CFSetGetCount (set);
- return 0;
+CFIndex CFCMutableSet::GetCount() const {
+ CFMutableSetRef set = get();
+ if (set)
+ return ::CFSetGetCount(set);
+ return 0;
}
-CFIndex
-CFCMutableSet::GetCountOfValue(const void *value) const
-{
- CFMutableSetRef set = get();
- if (set)
- return ::CFSetGetCountOfValue (set, value);
- return 0;
+CFIndex CFCMutableSet::GetCountOfValue(const void *value) const {
+ CFMutableSetRef set = get();
+ if (set)
+ return ::CFSetGetCountOfValue(set, value);
+ return 0;
}
-const void *
-CFCMutableSet::GetValue(const void *value) const
-{
- CFMutableSetRef set = get();
- if (set)
- return ::CFSetGetValue(set, value);
- return NULL;
+const void *CFCMutableSet::GetValue(const void *value) const {
+ CFMutableSetRef set = get();
+ if (set)
+ return ::CFSetGetValue(set, value);
+ return NULL;
}
-
-const void *
-CFCMutableSet::AddValue(const void *value, bool can_create)
-{
- CFMutableSetRef set = get();
- if (set == NULL)
- {
- if (can_create == false)
- return NULL;
- set = ::CFSetCreateMutable(kCFAllocatorDefault, 0, &kCFTypeSetCallBacks);
- reset ( set );
- }
- if (set != NULL)
- {
- ::CFSetAddValue(set, value);
- return value;
- }
- return NULL;
+const void *CFCMutableSet::AddValue(const void *value, bool can_create) {
+ CFMutableSetRef set = get();
+ if (set == NULL) {
+ if (can_create == false)
+ return NULL;
+ set = ::CFSetCreateMutable(kCFAllocatorDefault, 0, &kCFTypeSetCallBacks);
+ reset(set);
+ }
+ if (set != NULL) {
+ ::CFSetAddValue(set, value);
+ return value;
+ }
+ return NULL;
}
-void
-CFCMutableSet::RemoveValue(const void *value)
-{
- CFMutableSetRef set = get();
- if (set)
- ::CFSetRemoveValue(set, value);
+void CFCMutableSet::RemoveValue(const void *value) {
+ CFMutableSetRef set = get();
+ if (set)
+ ::CFSetRemoveValue(set, value);
}
-void
-CFCMutableSet::RemoveAllValues()
-{
- CFMutableSetRef set = get();
- if (set)
- ::CFSetRemoveAllValues(set);
+void CFCMutableSet::RemoveAllValues() {
+ CFMutableSetRef set = get();
+ if (set)
+ ::CFSetRemoveAllValues(set);
}
-
diff --git a/lldb/source/Host/macosx/cfcpp/CFCMutableSet.h b/lldb/source/Host/macosx/cfcpp/CFCMutableSet.h
index 78f7a8be81d..1459b7e4632 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCMutableSet.h
+++ b/lldb/source/Host/macosx/cfcpp/CFCMutableSet.h
@@ -12,42 +12,36 @@
#include "CFCReleaser.h"
-class CFCMutableSet : public CFCReleaser<CFMutableSetRef>
-{
+class CFCMutableSet : public CFCReleaser<CFMutableSetRef> {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- CFCMutableSet(CFMutableSetRef s = NULL);
- CFCMutableSet(const CFCMutableSet& rhs);
- virtual ~CFCMutableSet();
-
- //------------------------------------------------------------------
- // Operators
- //------------------------------------------------------------------
- const CFCMutableSet&
- operator=(const CFCMutableSet& rhs);
-
-
- CFIndex GetCount() const;
- CFIndex GetCountOfValue(const void *value) const;
- const void * GetValue(const void *value) const;
- const void * AddValue(const void *value, bool can_create);
- void RemoveValue(const void *value);
- void RemoveAllValues();
-
-
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ CFCMutableSet(CFMutableSetRef s = NULL);
+ CFCMutableSet(const CFCMutableSet &rhs);
+ virtual ~CFCMutableSet();
+
+ //------------------------------------------------------------------
+ // Operators
+ //------------------------------------------------------------------
+ const CFCMutableSet &operator=(const CFCMutableSet &rhs);
+
+ CFIndex GetCount() const;
+ CFIndex GetCountOfValue(const void *value) const;
+ const void *GetValue(const void *value) const;
+ const void *AddValue(const void *value, bool can_create);
+ void RemoveValue(const void *value);
+ void RemoveAllValues();
protected:
- //------------------------------------------------------------------
- // Classes that inherit from CFCMutableSet can see and modify these
- //------------------------------------------------------------------
+ //------------------------------------------------------------------
+ // Classes that inherit from CFCMutableSet can see and modify these
+ //------------------------------------------------------------------
private:
- //------------------------------------------------------------------
- // For CFCMutableSet only
- //------------------------------------------------------------------
-
+ //------------------------------------------------------------------
+ // For CFCMutableSet only
+ //------------------------------------------------------------------
};
-#endif // CoreFoundationCPP_CFMutableSet_h_
+#endif // CoreFoundationCPP_CFMutableSet_h_
diff --git a/lldb/source/Host/macosx/cfcpp/CFCReleaser.h b/lldb/source/Host/macosx/cfcpp/CFCReleaser.h
index 67dd2ead579..c596d1e1e7e 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCReleaser.h
+++ b/lldb/source/Host/macosx/cfcpp/CFCReleaser.h
@@ -26,133 +26,103 @@
// pointer, it is designed to relinquish ownership of the pointer just
// like std:auto_ptr<T>::release() does.
//----------------------------------------------------------------------
-template <class T>
-class CFCReleaser
-{
+template <class T> class CFCReleaser {
public:
- //----------------------------------------------------------
- // Constructor that takes a pointer to a CF object that is
- // to be released when this object goes out of scope
- //----------------------------------------------------------
- CFCReleaser(T ptr = NULL) :
- _ptr(ptr)
- {
- }
-
- //----------------------------------------------------------
- // Copy constructor
- //
- // Note that copying a CFCReleaser will not transfer
- // ownership of the contained pointer, but it will bump its
- // reference count. This is where this class differs from
- // std::auto_ptr.
- //----------------------------------------------------------
- CFCReleaser(const CFCReleaser& rhs) :
- _ptr(rhs.get())
- {
- if (get())
- ::CFRetain(get());
- }
-
-
- //----------------------------------------------------------
- // The destructor will release the pointer that it contains
- // if it has a valid pointer.
- //----------------------------------------------------------
- virtual ~CFCReleaser()
- {
- reset();
- }
-
- //----------------------------------------------------------
- // Assignment operator.
- //
- // Note that assigning one CFCReleaser to another will
- // not transfer ownership of the contained pointer, but it
- // will bump its reference count. This is where this class
- // differs from std::auto_ptr.
- //----------------------------------------------------------
- CFCReleaser&
- operator= (const CFCReleaser<T>& rhs)
- {
- if (this != &rhs)
- {
- // Replace our owned pointer with the new one
- reset(rhs.get());
- // Retain the current pointer that we own
- if (get())
- ::CFRetain(get());
- }
- return *this;
- }
-
- //----------------------------------------------------------
- // Get the address of the contained type in case it needs
- // to be passed to a function that will fill in a pointer
- // value. The function currently will assert if _ptr is not
- // NULL because the only time this method should be used is
- // if another function will modify the contents, and we
- // could leak a pointer if this is not NULL. If the
- // assertion fires, check the offending code, or call
- // reset() prior to using the "ptr_address()" member to make
- // sure any owned objects has CFRelease called on it.
- // I had to add the "enforce_null" bool here because some
- // API's require the pointer address even though they don't change it.
- //----------------------------------------------------------
- T*
- ptr_address(bool enforce_null = true)
- {
- if (enforce_null)
- assert (_ptr == NULL);
- return &_ptr;
- }
-
- //----------------------------------------------------------
- // Access the pointer itself
- //----------------------------------------------------------
- T
- get()
- {
- return _ptr;
- }
-
- const T
- get() const
- {
- return _ptr;
- }
-
-
- //----------------------------------------------------------
- // Set a new value for the pointer and CFRelease our old
- // value if we had a valid one.
- //----------------------------------------------------------
- void
- reset(T ptr = NULL)
- {
- if ((_ptr != NULL) && (ptr != _ptr))
- ::CFRelease(_ptr);
- _ptr = ptr;
- }
-
- //----------------------------------------------------------
- // Release ownership without calling CFRelease. This class
- // is designed to mimic std::auto_ptr<T>, so the release
- // method releases ownership of the contained pointer
- // and does NOT call CFRelease.
- //----------------------------------------------------------
- T
- release()
- {
- T tmp = _ptr;
- _ptr = NULL;
- return tmp;
+ //----------------------------------------------------------
+ // Constructor that takes a pointer to a CF object that is
+ // to be released when this object goes out of scope
+ //----------------------------------------------------------
+ CFCReleaser(T ptr = NULL) : _ptr(ptr) {}
+
+ //----------------------------------------------------------
+ // Copy constructor
+ //
+ // Note that copying a CFCReleaser will not transfer
+ // ownership of the contained pointer, but it will bump its
+ // reference count. This is where this class differs from
+ // std::auto_ptr.
+ //----------------------------------------------------------
+ CFCReleaser(const CFCReleaser &rhs) : _ptr(rhs.get()) {
+ if (get())
+ ::CFRetain(get());
+ }
+
+ //----------------------------------------------------------
+ // The destructor will release the pointer that it contains
+ // if it has a valid pointer.
+ //----------------------------------------------------------
+ virtual ~CFCReleaser() { reset(); }
+
+ //----------------------------------------------------------
+ // Assignment operator.
+ //
+ // Note that assigning one CFCReleaser to another will
+ // not transfer ownership of the contained pointer, but it
+ // will bump its reference count. This is where this class
+ // differs from std::auto_ptr.
+ //----------------------------------------------------------
+ CFCReleaser &operator=(const CFCReleaser<T> &rhs) {
+ if (this != &rhs) {
+ // Replace our owned pointer with the new one
+ reset(rhs.get());
+ // Retain the current pointer that we own
+ if (get())
+ ::CFRetain(get());
}
+ return *this;
+ }
+
+ //----------------------------------------------------------
+ // Get the address of the contained type in case it needs
+ // to be passed to a function that will fill in a pointer
+ // value. The function currently will assert if _ptr is not
+ // NULL because the only time this method should be used is
+ // if another function will modify the contents, and we
+ // could leak a pointer if this is not NULL. If the
+ // assertion fires, check the offending code, or call
+ // reset() prior to using the "ptr_address()" member to make
+ // sure any owned objects has CFRelease called on it.
+ // I had to add the "enforce_null" bool here because some
+ // API's require the pointer address even though they don't change it.
+ //----------------------------------------------------------
+ T *ptr_address(bool enforce_null = true) {
+ if (enforce_null)
+ assert(_ptr == NULL);
+ return &_ptr;
+ }
+
+ //----------------------------------------------------------
+ // Access the pointer itself
+ //----------------------------------------------------------
+ T get() { return _ptr; }
+
+ const T get() const { return _ptr; }
+
+ //----------------------------------------------------------
+ // Set a new value for the pointer and CFRelease our old
+ // value if we had a valid one.
+ //----------------------------------------------------------
+ void reset(T ptr = NULL) {
+ if ((_ptr != NULL) && (ptr != _ptr))
+ ::CFRelease(_ptr);
+ _ptr = ptr;
+ }
+
+ //----------------------------------------------------------
+ // Release ownership without calling CFRelease. This class
+ // is designed to mimic std::auto_ptr<T>, so the release
+ // method releases ownership of the contained pointer
+ // and does NOT call CFRelease.
+ //----------------------------------------------------------
+ T release() {
+ T tmp = _ptr;
+ _ptr = NULL;
+ return tmp;
+ }
private:
- T _ptr;
+ T _ptr;
};
-#endif // #ifdef __cplusplus
-#endif // #ifndef CoreFoundationCPP_CFReleaser_h_
-
+#endif // #ifdef __cplusplus
+#endif // #ifndef CoreFoundationCPP_CFReleaser_h_
diff --git a/lldb/source/Host/macosx/cfcpp/CFCString.cpp b/lldb/source/Host/macosx/cfcpp/CFCString.cpp
index 81a96b82499..0d3853c60a7 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCString.cpp
+++ b/lldb/source/Host/macosx/cfcpp/CFCString.cpp
@@ -8,151 +8,123 @@
//===----------------------------------------------------------------------===//
#include "CFCString.h"
-#include <string>
#include <glob.h>
+#include <string>
//----------------------------------------------------------------------
// CFCString constructor
//----------------------------------------------------------------------
-CFCString::CFCString(CFStringRef s) :
- CFCReleaser<CFStringRef> (s)
-{
-}
+CFCString::CFCString(CFStringRef s) : CFCReleaser<CFStringRef>(s) {}
//----------------------------------------------------------------------
// CFCString copy constructor
//----------------------------------------------------------------------
-CFCString::CFCString(const CFCString& rhs) :
- CFCReleaser<CFStringRef> (rhs)
-{
-
-}
+CFCString::CFCString(const CFCString &rhs) : CFCReleaser<CFStringRef>(rhs) {}
//----------------------------------------------------------------------
// CFCString copy constructor
//----------------------------------------------------------------------
-CFCString&
-CFCString::operator=(const CFCString& rhs)
-{
- if (this != &rhs)
- *this = rhs;
- return *this;
+CFCString &CFCString::operator=(const CFCString &rhs) {
+ if (this != &rhs)
+ *this = rhs;
+ return *this;
}
-CFCString::CFCString (const char *cstr, CFStringEncoding cstr_encoding) :
- CFCReleaser<CFStringRef> ()
-{
- if (cstr && cstr[0])
- {
- reset(::CFStringCreateWithCString(kCFAllocatorDefault, cstr, cstr_encoding));
- }
+CFCString::CFCString(const char *cstr, CFStringEncoding cstr_encoding)
+ : CFCReleaser<CFStringRef>() {
+ if (cstr && cstr[0]) {
+ reset(
+ ::CFStringCreateWithCString(kCFAllocatorDefault, cstr, cstr_encoding));
+ }
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-CFCString::~CFCString()
-{
-}
+CFCString::~CFCString() {}
-const char *
-CFCString::GetFileSystemRepresentation(std::string& s)
-{
- return CFCString::FileSystemRepresentation(get(), s);
+const char *CFCString::GetFileSystemRepresentation(std::string &s) {
+ return CFCString::FileSystemRepresentation(get(), s);
}
-CFStringRef
-CFCString::SetFileSystemRepresentation (const char *path)
-{
- CFStringRef new_value = NULL;
- if (path && path[0])
- new_value = ::CFStringCreateWithFileSystemRepresentation (kCFAllocatorDefault, path);
- reset(new_value);
- return get();
+CFStringRef CFCString::SetFileSystemRepresentation(const char *path) {
+ CFStringRef new_value = NULL;
+ if (path && path[0])
+ new_value =
+ ::CFStringCreateWithFileSystemRepresentation(kCFAllocatorDefault, path);
+ reset(new_value);
+ return get();
}
-
CFStringRef
-CFCString::SetFileSystemRepresentationFromCFType (CFTypeRef cf_type)
-{
- CFStringRef new_value = NULL;
- if (cf_type != NULL)
- {
- CFTypeID cf_type_id = ::CFGetTypeID(cf_type);
-
- if (cf_type_id == ::CFStringGetTypeID())
- {
- // Retain since we are using the existing object
- new_value = (CFStringRef)::CFRetain(cf_type);
- }
- else if (cf_type_id == ::CFURLGetTypeID())
- {
- new_value = ::CFURLCopyFileSystemPath((CFURLRef)cf_type, kCFURLPOSIXPathStyle);
- }
+CFCString::SetFileSystemRepresentationFromCFType(CFTypeRef cf_type) {
+ CFStringRef new_value = NULL;
+ if (cf_type != NULL) {
+ CFTypeID cf_type_id = ::CFGetTypeID(cf_type);
+
+ if (cf_type_id == ::CFStringGetTypeID()) {
+ // Retain since we are using the existing object
+ new_value = (CFStringRef)::CFRetain(cf_type);
+ } else if (cf_type_id == ::CFURLGetTypeID()) {
+ new_value =
+ ::CFURLCopyFileSystemPath((CFURLRef)cf_type, kCFURLPOSIXPathStyle);
}
- reset(new_value);
- return get();
+ }
+ reset(new_value);
+ return get();
}
CFStringRef
-CFCString::SetFileSystemRepresentationAndExpandTilde (const char *path)
-{
- std::string expanded_path;
- if (CFCString::ExpandTildeInPath(path, expanded_path))
- SetFileSystemRepresentation(expanded_path.c_str());
- else
- reset();
- return get();
+CFCString::SetFileSystemRepresentationAndExpandTilde(const char *path) {
+ std::string expanded_path;
+ if (CFCString::ExpandTildeInPath(path, expanded_path))
+ SetFileSystemRepresentation(expanded_path.c_str());
+ else
+ reset();
+ return get();
}
-const char *
-CFCString::UTF8(std::string& str)
-{
- return CFCString::UTF8(get(), str);
+const char *CFCString::UTF8(std::string &str) {
+ return CFCString::UTF8(get(), str);
}
// Static function that puts a copy of the UTF8 contents of CF_STR into STR
-// and returns the C string pointer that is contained in STR when successful, else
-// NULL is returned. This allows the std::string parameter to own the extracted string,
-// and also allows that string to be returned as a C string pointer that can be used.
-
-const char *
-CFCString::UTF8 (CFStringRef cf_str, std::string& str)
-{
- if (cf_str)
- {
- const CFStringEncoding encoding = kCFStringEncodingUTF8;
- CFIndex max_utf8_str_len = CFStringGetLength (cf_str);
- max_utf8_str_len = CFStringGetMaximumSizeForEncoding (max_utf8_str_len, encoding);
- if (max_utf8_str_len > 0)
- {
- str.resize(max_utf8_str_len);
- if (!str.empty())
- {
- if (CFStringGetCString (cf_str, &str[0], str.size(), encoding))
- {
- str.resize(strlen(str.c_str()));
- return str.c_str();
- }
- }
+// and returns the C string pointer that is contained in STR when successful,
+// else
+// NULL is returned. This allows the std::string parameter to own the extracted
+// string,
+// and also allows that string to be returned as a C string pointer that can be
+// used.
+
+const char *CFCString::UTF8(CFStringRef cf_str, std::string &str) {
+ if (cf_str) {
+ const CFStringEncoding encoding = kCFStringEncodingUTF8;
+ CFIndex max_utf8_str_len = CFStringGetLength(cf_str);
+ max_utf8_str_len =
+ CFStringGetMaximumSizeForEncoding(max_utf8_str_len, encoding);
+ if (max_utf8_str_len > 0) {
+ str.resize(max_utf8_str_len);
+ if (!str.empty()) {
+ if (CFStringGetCString(cf_str, &str[0], str.size(), encoding)) {
+ str.resize(strlen(str.c_str()));
+ return str.c_str();
}
+ }
}
- return NULL;
+ }
+ return NULL;
}
-const char*
-CFCString::ExpandTildeInPath(const char* path, std::string &expanded_path)
-{
- glob_t globbuf;
- if (::glob (path, GLOB_TILDE, NULL, &globbuf) == 0)
- {
- expanded_path = globbuf.gl_pathv[0];
- ::globfree (&globbuf);
- }
- else
- expanded_path.clear();
+const char *CFCString::ExpandTildeInPath(const char *path,
+ std::string &expanded_path) {
+ glob_t globbuf;
+ if (::glob(path, GLOB_TILDE, NULL, &globbuf) == 0) {
+ expanded_path = globbuf.gl_pathv[0];
+ ::globfree(&globbuf);
+ } else
+ expanded_path.clear();
- return expanded_path.c_str();
+ return expanded_path.c_str();
}
// Static function that puts a copy of the file system representation of CF_STR
@@ -161,35 +133,29 @@ CFCString::ExpandTildeInPath(const char* path, std::string &expanded_path)
// to own the extracted string, and also allows that string to be returned as
// a C string pointer that can be used.
-const char *
-CFCString::FileSystemRepresentation (CFStringRef cf_str, std::string& str)
-{
- if (cf_str)
- {
- CFIndex max_length = ::CFStringGetMaximumSizeOfFileSystemRepresentation (cf_str);
- if (max_length > 0)
- {
- str.resize(max_length);
- if (!str.empty())
- {
- if (::CFStringGetFileSystemRepresentation (cf_str, &str[0], str.size()))
- {
- str.erase(::strlen(str.c_str()));
- return str.c_str();
- }
- }
+const char *CFCString::FileSystemRepresentation(CFStringRef cf_str,
+ std::string &str) {
+ if (cf_str) {
+ CFIndex max_length =
+ ::CFStringGetMaximumSizeOfFileSystemRepresentation(cf_str);
+ if (max_length > 0) {
+ str.resize(max_length);
+ if (!str.empty()) {
+ if (::CFStringGetFileSystemRepresentation(cf_str, &str[0],
+ str.size())) {
+ str.erase(::strlen(str.c_str()));
+ return str.c_str();
}
+ }
}
- str.erase();
- return NULL;
+ }
+ str.erase();
+ return NULL;
}
-
-CFIndex
-CFCString::GetLength() const
-{
- CFStringRef str = get();
- if (str)
- return CFStringGetLength (str);
- return 0;
+CFIndex CFCString::GetLength() const {
+ CFStringRef str = get();
+ if (str)
+ return CFStringGetLength(str);
+ return 0;
}
diff --git a/lldb/source/Host/macosx/cfcpp/CFCString.h b/lldb/source/Host/macosx/cfcpp/CFCString.h
index 27c090313ec..a7bb029408f 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCString.h
+++ b/lldb/source/Host/macosx/cfcpp/CFCString.h
@@ -14,28 +14,28 @@
#include "CFCReleaser.h"
-class CFCString : public CFCReleaser<CFStringRef>
-{
+class CFCString : public CFCReleaser<CFStringRef> {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- CFCString (CFStringRef cf_str = NULL);
- CFCString (const char *s, CFStringEncoding encoding = kCFStringEncodingUTF8);
- CFCString (const CFCString& rhs);
- CFCString& operator= (const CFCString& rhs);
- virtual ~CFCString ();
-
- const char * GetFileSystemRepresentation (std::string& str);
- CFStringRef SetFileSystemRepresentation (const char *path);
- CFStringRef SetFileSystemRepresentationFromCFType (CFTypeRef cf_type);
- CFStringRef SetFileSystemRepresentationAndExpandTilde (const char *path);
- const char * UTF8 (std::string& str);
- CFIndex GetLength() const;
- static const char *UTF8 (CFStringRef cf_str, std::string& str);
- static const char *FileSystemRepresentation (CFStringRef cf_str, std::string& str);
- static const char *ExpandTildeInPath(const char* path, std::string &expanded_path);
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ CFCString(CFStringRef cf_str = NULL);
+ CFCString(const char *s, CFStringEncoding encoding = kCFStringEncodingUTF8);
+ CFCString(const CFCString &rhs);
+ CFCString &operator=(const CFCString &rhs);
+ virtual ~CFCString();
+ const char *GetFileSystemRepresentation(std::string &str);
+ CFStringRef SetFileSystemRepresentation(const char *path);
+ CFStringRef SetFileSystemRepresentationFromCFType(CFTypeRef cf_type);
+ CFStringRef SetFileSystemRepresentationAndExpandTilde(const char *path);
+ const char *UTF8(std::string &str);
+ CFIndex GetLength() const;
+ static const char *UTF8(CFStringRef cf_str, std::string &str);
+ static const char *FileSystemRepresentation(CFStringRef cf_str,
+ std::string &str);
+ static const char *ExpandTildeInPath(const char *path,
+ std::string &expanded_path);
};
#endif // #ifndef CoreFoundationCPP_CFString_h_
diff --git a/lldb/source/Host/macosx/cfcpp/CoreFoundationCPP.h b/lldb/source/Host/macosx/cfcpp/CoreFoundationCPP.h
index 6843e2649cd..88d0f5a23f8 100644
--- a/lldb/source/Host/macosx/cfcpp/CoreFoundationCPP.h
+++ b/lldb/source/Host/macosx/cfcpp/CoreFoundationCPP.h
@@ -21,10 +21,10 @@
#include <CoreFoundationCPP/CFCBundle.h>
#include <CoreFoundationCPP/CFCData.h>
-#include <CoreFoundationCPP/CFCReleaser.h>
#include <CoreFoundationCPP/CFCMutableArray.h>
#include <CoreFoundationCPP/CFCMutableDictionary.h>
#include <CoreFoundationCPP/CFCMutableSet.h>
+#include <CoreFoundationCPP/CFCReleaser.h>
#include <CoreFoundationCPP/CFCString.h>
-#endif // CoreFoundationCPP_CoreFoundationCPP_H_
+#endif // CoreFoundationCPP_CoreFoundationCPP_H_
OpenPOWER on IntegriCloud