summaryrefslogtreecommitdiffstats
path: root/base/sys_string_conversions.h
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-08 21:02:56 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-08 21:02:56 +0000
commit03d95ac0d42dd9eaa7333b068361e4205c28ca7d (patch)
tree8d433e8c73cf002cc1bea78d40f00dec51d6848c /base/sys_string_conversions.h
parent89916bd485d5c6156030f9f4b62db0cadac87c85 (diff)
downloadchromium_src-03d95ac0d42dd9eaa7333b068361e4205c28ca7d.zip
chromium_src-03d95ac0d42dd9eaa7333b068361e4205c28ca7d.tar.gz
chromium_src-03d95ac0d42dd9eaa7333b068361e4205c28ca7d.tar.bz2
Provide converters to and from NSString* in sys_string_conversions
Review URL: http://codereview.chromium.org/6355 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3050 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/sys_string_conversions.h')
-rw-r--r--base/sys_string_conversions.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/base/sys_string_conversions.h b/base/sys_string_conversions.h
index 960f9050..7b56a21 100644
--- a/base/sys_string_conversions.h
+++ b/base/sys_string_conversions.h
@@ -14,7 +14,12 @@
#if defined(OS_MACOSX)
#include <CoreFoundation/CoreFoundation.h>
+#ifdef __OBJC__
+@class NSString;
+#else
+class NSString;
#endif
+#endif // OS_MACOSX
class StringPiece;
@@ -47,20 +52,27 @@ std::string SysWideToMultiByte(const std::wstring& wide, uint32 code_page);
#if defined(OS_MACOSX)
-// Converts between STL strings and CFStringRefs.
+// Converts between STL strings and CFStringRefs/NSStrings.
// Creates a string, and returns it with a refcount of 1. You are responsible
// for releasing it. Returns NULL on failure.
CFStringRef SysUTF8ToCFStringRef(const std::string& utf8);
CFStringRef SysWideToCFStringRef(const std::wstring& wide);
+// Same, but returns an autoreleased NSString.
+NSString* SysUTF8ToNSString(const std::string& utf8);
+NSString* SysWideToNSString(const std::wstring& wide);
+
// Converts a CFStringRef to an STL string. Returns an empty string on failure.
std::string SysCFStringRefToUTF8(CFStringRef ref);
std::wstring SysCFStringRefToWide(CFStringRef ref);
+// Same, but accepts NSString input.
+std::string SysNSStringToUTF8(NSString* ref);
+std::wstring SysNSStringToWide(NSString* ref);
+
#endif // defined(OS_MACOSX)
} // namespace base
#endif // BASE_SYS_STRING_CONVERSIONS_H_
-