From 7a4a2ea10844afd6a58dace46854fae74399f55c Mon Sep 17 00:00:00 2001 From: zxu Date: Tue, 20 Feb 2018 12:25:39 -0500 Subject: replacing FSTGetTokenResult by C++ Token implementation (#805) * replacing Auth/FSTUser by C++ auth implementation * address changes * replacing FSTGetTokenResult by C++ Token implementation * address changes * address changes * fix another const& v.s. dispatch bug * fix more const& v.s. dispatch bug zxu123 committed * fix * passing by value in callback --- Firestore/core/src/firebase/firestore/util/string_apple.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Firestore/core/src/firebase/firestore/util') diff --git a/Firestore/core/src/firebase/firestore/util/string_apple.h b/Firestore/core/src/firebase/firestore/util/string_apple.h index fe2a487..3f6b814 100644 --- a/Firestore/core/src/firebase/firestore/util/string_apple.h +++ b/Firestore/core/src/firebase/firestore/util/string_apple.h @@ -42,7 +42,16 @@ inline NSString* WrapNSStringNoCopy(const absl::string_view str) { return WrapNSStringNoCopy(str.data()); } -// Creates an absl::string_view wrapper for the contents of the given NSString. +// Translates a string_view string to the equivalent NSString by making a copy. +inline NSString* WrapNSString(const absl::string_view str) { + return [[NSString alloc] + initWithBytes:const_cast(static_cast(str.data())) + length:str.length() + encoding:NSUTF8StringEncoding]; +} + +// Creates an absl::string_view wrapper for the contents of the given +// NSString. inline absl::string_view MakeStringView(NSString* str) { return absl::string_view( [str UTF8String], [str lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); -- cgit v1.2.3