diff options
Diffstat (limited to 'lldb/source/Host/macosx/cfcpp')
| -rw-r--r-- | lldb/source/Host/macosx/cfcpp/CFCMutableArray.cpp | 43 | ||||
| -rw-r--r-- | lldb/source/Host/macosx/cfcpp/CFCMutableArray.h | 5 |
2 files changed, 48 insertions, 0 deletions
diff --git a/lldb/source/Host/macosx/cfcpp/CFCMutableArray.cpp b/lldb/source/Host/macosx/cfcpp/CFCMutableArray.cpp index 3b92f03fa61..c3c0a11193a 100644 --- a/lldb/source/Host/macosx/cfcpp/CFCMutableArray.cpp +++ b/lldb/source/Host/macosx/cfcpp/CFCMutableArray.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "CFCMutableArray.h" +#include "CFCString.h" //---------------------------------------------------------------------- // CFCString constructor @@ -121,3 +122,45 @@ CFCMutableArray::AppendValue(const void *value, bool can_create) } 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; +} diff --git a/lldb/source/Host/macosx/cfcpp/CFCMutableArray.h b/lldb/source/Host/macosx/cfcpp/CFCMutableArray.h index eaadb8d5590..f78cd92ffab 100644 --- a/lldb/source/Host/macosx/cfcpp/CFCMutableArray.h +++ b/lldb/source/Host/macosx/cfcpp/CFCMutableArray.h @@ -29,6 +29,11 @@ public: 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_ |

