comparison include/core/strings.h @ 405:4562bc8bfdff

strings: add conversion to/from CFString on Mac OS X
author Paper <paper@tflc.us>
date Mon, 19 Jan 2026 22:47:29 -0500
parents df4a027623d0
children
comparison
equal deleted inserted replaced
404:e561b7542b7b 405:4562bc8bfdff
5 #include <sstream> 5 #include <sstream>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include <cstdint> 9 #include <cstdint>
10
11 #if defined(__MACH__) && defined(__APPLE__)
12 # include <CoreFoundation/CoreFoundation.h>
13 #endif
10 14
11 class QString; 15 class QString;
12 class QByteArray; 16 class QByteArray;
13 17
14 namespace Strings { 18 namespace Strings {
42 std::string ToUtf8String(const QByteArray &ba); 46 std::string ToUtf8String(const QByteArray &ba);
43 std::string ToUtf8String(const std::u32string &u32string); 47 std::string ToUtf8String(const std::u32string &u32string);
44 std::u32string ToUcs4String(const std::string &string); 48 std::u32string ToUcs4String(const std::string &string);
45 QString ToQString(const std::string &string); 49 QString ToQString(const std::string &string);
46 QString ToQString(const std::wstring &wstring); 50 QString ToQString(const std::wstring &wstring);
51 #if defined(__APPLE__) && defined(__MACH__)
52 CFStringRef ToCFString(const std::string &string);
53 std::string ToUtf8String(CFStringRef str);
54 #endif
47 55
48 /* not really an "int"... but who cares? */ 56 /* not really an "int"... but who cares? */
49 template<typename T = int, std::enable_if_t<std::is_arithmetic<T>::value, bool> = true> 57 template<typename T = int, std::enable_if_t<std::is_arithmetic<T>::value, bool> = true>
50 T ToInt(const std::string &str, T def = 0) 58 T ToInt(const std::string &str, T def = 0)
51 { 59 {