Expose a human-readable type name for a dynamic
authorChip Turner <chip@fb.com>
Tue, 14 May 2013 23:44:27 +0000 (16:44 -0700)
committerSara Golemon <sgolemon@fb.com>
Mon, 20 May 2013 18:01:27 +0000 (11:01 -0700)
Summary: Aids in debugging dynamic types, etc.

Test Plan: unit tests

Reviewed By: delong.j@fb.com

FB internal diff: D812385

folly/dynamic.cpp
folly/dynamic.h

index 25ab1032b5ca03ffcbbdadaceb2a3df19229e5e5..0278dad9b9cb2aaecfd7c457fa50717b4b5298a4 100644 (file)
@@ -34,6 +34,10 @@ DEF_TYPE(dynamic::ObjectImpl, "object",  dynamic::OBJECT);
 
 #undef DEF_TYPE
 
+const char* dynamic::typeName() const {
+  return typeName(type_);
+}
+
 //////////////////////////////////////////////////////////////////////
 
 }
index 88d23d9f5afdd4812db80391571f17ffec3bb0df..6ab5ca1bf84543e93be9e1dfd0069303e29196c8 100644 (file)
@@ -253,6 +253,11 @@ public:
    */
   Type type() const;
 
+  /*
+   * Returns the type of this dynamic as a printable string.
+   */
+  const char* typeName() const;
+
   /*
    * Extract a value while trying to convert to the specified type.
    * Throws exceptions if we cannot convert from the real type to the