summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Darwin/CFString.cpp
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Plugins/Process/Darwin/CFString.cpp
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadbcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
Diffstat (limited to 'lldb/source/Plugins/Process/Darwin/CFString.cpp')
-rw-r--r--lldb/source/Plugins/Process/Darwin/CFString.cpp232
1 files changed, 97 insertions, 135 deletions
diff --git a/lldb/source/Plugins/Process/Darwin/CFString.cpp b/lldb/source/Plugins/Process/Darwin/CFString.cpp
index 819024ca3bc..84ad56774d7 100644
--- a/lldb/source/Plugins/Process/Darwin/CFString.cpp
+++ b/lldb/source/Plugins/Process/Darwin/CFString.cpp
@@ -12,136 +12,110 @@
//===----------------------------------------------------------------------===//
#include "CFString.h"
-#include <string>
#include <glob.h>
+#include <string>
//----------------------------------------------------------------------
// CFString constructor
//----------------------------------------------------------------------
-CFString::CFString(CFStringRef s) :
- CFReleaser<CFStringRef> (s)
-{
-}
+CFString::CFString(CFStringRef s) : CFReleaser<CFStringRef>(s) {}
//----------------------------------------------------------------------
// CFString copy constructor
//----------------------------------------------------------------------
-CFString::CFString(const CFString& rhs) :
- CFReleaser<CFStringRef> (rhs)
-{
-
-}
+CFString::CFString(const CFString &rhs) : CFReleaser<CFStringRef>(rhs) {}
//----------------------------------------------------------------------
// CFString copy constructor
//----------------------------------------------------------------------
-CFString&
-CFString::operator=(const CFString& rhs)
-{
- if (this != &rhs)
- *this = rhs;
- return *this;
+CFString &CFString::operator=(const CFString &rhs) {
+ if (this != &rhs)
+ *this = rhs;
+ return *this;
}
-CFString::CFString (const char *cstr, CFStringEncoding cstr_encoding) :
- CFReleaser<CFStringRef> ()
-{
- if (cstr && cstr[0])
- {
- reset(::CFStringCreateWithCString(kCFAllocatorDefault, cstr, cstr_encoding));
- }
+CFString::CFString(const char *cstr, CFStringEncoding cstr_encoding)
+ : CFReleaser<CFStringRef>() {
+ if (cstr && cstr[0]) {
+ reset(
+ ::CFStringCreateWithCString(kCFAllocatorDefault, cstr, cstr_encoding));
+ }
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-CFString::~CFString()
-{
-}
+CFString::~CFString() {}
-const char *
-CFString::GetFileSystemRepresentation(std::string& s)
-{
- return CFString::FileSystemRepresentation(get(), s);
+const char *CFString::GetFileSystemRepresentation(std::string &s) {
+ return CFString::FileSystemRepresentation(get(), s);
}
-CFStringRef
-CFString::SetFileSystemRepresentation (const char *path)
-{
- CFStringRef new_value = NULL;
- if (path && path[0])
- new_value = ::CFStringCreateWithFileSystemRepresentation (kCFAllocatorDefault, path);
- reset(new_value);
- return get();
+CFStringRef CFString::SetFileSystemRepresentation(const char *path) {
+ CFStringRef new_value = NULL;
+ if (path && path[0])
+ new_value =
+ ::CFStringCreateWithFileSystemRepresentation(kCFAllocatorDefault, path);
+ reset(new_value);
+ return get();
}
-
-CFStringRef
-CFString::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);
- }
+CFStringRef CFString::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
-CFString::SetFileSystemRepresentationAndExpandTilde (const char *path)
-{
- std::string expanded_path;
- if (CFString::GlobPath(path, expanded_path))
- SetFileSystemRepresentation(expanded_path.c_str());
- else
- reset();
- return get();
+CFString::SetFileSystemRepresentationAndExpandTilde(const char *path) {
+ std::string expanded_path;
+ if (CFString::GlobPath(path, expanded_path))
+ SetFileSystemRepresentation(expanded_path.c_str());
+ else
+ reset();
+ return get();
}
-const char *
-CFString::UTF8(std::string& str)
-{
- return CFString::UTF8(get(), str);
+const char *CFString::UTF8(std::string &str) {
+ return CFString::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 *
-CFString::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 *CFString::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;
}
// Static function that puts a copy of the file system representation of CF_STR
@@ -150,52 +124,40 @@ CFString::UTF8 (CFStringRef cf_str, std::string& str)
// to own the extracted string, and also allows that string to be returned as
// a C string pointer that can be used.
-const char *
-CFString::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 *CFString::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
-CFString::GetLength() const
-{
- CFStringRef str = get();
- if (str)
- return CFStringGetLength (str);
- return 0;
+CFIndex CFString::GetLength() const {
+ CFStringRef str = get();
+ if (str)
+ return CFStringGetLength(str);
+ return 0;
}
+const char *CFString::GlobPath(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*
-CFString::GlobPath(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();
}
-
OpenPOWER on IntegriCloud