aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/core/src/firebase
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-05-23 13:11:20 -0700
committerGravatar GitHub <noreply@github.com>2018-05-23 13:11:20 -0700
commit6f7fc5c4f52afb65ce15be45a46e84b6c7b9913e (patch)
treefe9edc4f465e61536ac9ff3d09f9c634f44b3dab /Firestore/core/src/firebase
parentd3e98192756159fd460d1547d9840e73b473de90 (diff)
Fix Objective-C logging (#1322)
Diffstat (limited to 'Firestore/core/src/firebase')
-rw-r--r--Firestore/core/src/firebase/firestore/util/string_format.h37
1 files changed, 31 insertions, 6 deletions
diff --git a/Firestore/core/src/firebase/firestore/util/string_format.h b/Firestore/core/src/firebase/firestore/util/string_format.h
index f8da785..d691984 100644
--- a/Firestore/core/src/firebase/firestore/util/string_format.h
+++ b/Firestore/core/src/firebase/firestore/util/string_format.h
@@ -67,12 +67,6 @@ class FormatArg : public absl::AlphaNum {
: FormatArg{std::forward<T>(value), internal::FormatChoice<0>{}} {
}
-#if __OBJC__
- FormatArg(NSObject* object) // NOLINT(runtime/explicit)
- : AlphaNum{MakeStringView([object description])} {
- }
-#endif
-
private:
/**
* Creates a FormatArg from a boolean value, representing the string
@@ -87,6 +81,37 @@ class FormatArg : public absl::AlphaNum {
: AlphaNum{bool_value ? "true" : "false"} {
}
+#if __OBJC__
+ /**
+ * Creates a FormatArg from any pointer to an object derived from NSObject.
+ */
+ template <
+ typename T,
+ typename = typename std::enable_if<std::is_base_of<NSObject, T>{}>::type>
+ FormatArg(T* object, internal::FormatChoice<0>)
+ : AlphaNum{MakeStringView([object description])} {
+ }
+
+ /**
+ * Creates a FormatArg from any Objective-C Class type. Objective-C Class
+ * types are a special struct that aren't of a type derived from NSObject.
+ */
+ FormatArg(Class object, internal::FormatChoice<0>)
+ : AlphaNum{MakeStringView(NSStringFromClass(object))} {
+ }
+
+ /**
+ * Creates a FormatArg from any id pointer. Note that instances of `id<Foo>`
+ * (which means "pointer conforming to the protocol Foo") do not match this
+ * without first casting to type `id`. There's no way to express a template of
+ * `id<T>` since `id<Foo>` isn't actually a C++ template and `id` isn't a
+ * parameterized C++ class.
+ */
+ FormatArg(id object, internal::FormatChoice<0>)
+ : AlphaNum{MakeStringView([object description])} {
+ }
+#endif
+
/**
* Creates a FormatArg from a character string literal. This is
* handled specially to avoid ambiguity with generic pointers, which are