Changed mft_h264_decoder's API to match with video_decode_engine.h. Also changed...
[chromium-blink-merge.git] / base / sys_string_conversions.h
bloba96a687f6cf8dd3dbdc2ad8f57719fc888e6dc84
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_SYS_STRING_CONVERSIONS_H_
6 #define BASE_SYS_STRING_CONVERSIONS_H_
7 #pragma once
9 // Provides system-dependent string type conversions for cases where it's
10 // necessary to not use ICU. Generally, you should not need this in Chrome,
11 // but it is used in some shared code. Dependencies should be minimal.
13 #include <string>
14 #include "base/basictypes.h"
15 #include "base/string16.h"
17 #if defined(OS_MACOSX)
18 #include <CoreFoundation/CoreFoundation.h>
19 #ifdef __OBJC__
20 @class NSString;
21 #else
22 class NSString;
23 #endif
24 #endif // OS_MACOSX
26 namespace base {
28 class StringPiece;
30 // Converts between wide and UTF-8 representations of a string. On error, the
31 // result is system-dependent.
32 std::string SysWideToUTF8(const std::wstring& wide);
33 std::wstring SysUTF8ToWide(const StringPiece& utf8);
35 // Converts between wide and the system multi-byte representations of a string.
36 // DANGER: This will lose information and can change (on Windows, this can
37 // change between reboots).
38 std::string SysWideToNativeMB(const std::wstring& wide);
39 std::wstring SysNativeMBToWide(const StringPiece& native_mb);
41 // Windows-specific ------------------------------------------------------------
43 #if defined(OS_WIN)
45 // Converts between 8-bit and wide strings, using the given code page. The
46 // code page identifier is one accepted by the Windows function
47 // MultiByteToWideChar().
48 std::wstring SysMultiByteToWide(const StringPiece& mb, uint32 code_page);
49 std::string SysWideToMultiByte(const std::wstring& wide, uint32 code_page);
51 #endif // defined(OS_WIN)
53 // Mac-specific ----------------------------------------------------------------
55 #if defined(OS_MACOSX)
57 // Converts between STL strings and CFStringRefs/NSStrings.
59 // Creates a string, and returns it with a refcount of 1. You are responsible
60 // for releasing it. Returns NULL on failure.
61 CFStringRef SysUTF8ToCFStringRef(const std::string& utf8);
62 CFStringRef SysUTF16ToCFStringRef(const string16& utf16);
63 CFStringRef SysWideToCFStringRef(const std::wstring& wide);
65 // Same, but returns an autoreleased NSString.
66 NSString* SysUTF8ToNSString(const std::string& utf8);
67 NSString* SysUTF16ToNSString(const string16& utf16);
68 NSString* SysWideToNSString(const std::wstring& wide);
70 // Converts a CFStringRef to an STL string. Returns an empty string on failure.
71 std::string SysCFStringRefToUTF8(CFStringRef ref);
72 string16 SysCFStringRefToUTF16(CFStringRef ref);
73 std::wstring SysCFStringRefToWide(CFStringRef ref);
75 // Same, but accepts NSString input. Converts nil NSString* to the appropriate
76 // string type of length 0.
77 std::string SysNSStringToUTF8(NSString* ref);
78 string16 SysNSStringToUTF16(NSString* ref);
79 std::wstring SysNSStringToWide(NSString* ref);
81 #endif // defined(OS_MACOSX)
83 } // namespace base
85 #endif // BASE_SYS_STRING_CONVERSIONS_H_