From 94ddd29dd7b11f3f07f7e1c92e8a57bc2b1f621f Mon Sep 17 00:00:00 2001 From: Chip Turner Date: Tue, 14 May 2013 16:44:27 -0700 Subject: [PATCH] Expose a human-readable type name for a dynamic Summary: Aids in debugging dynamic types, etc. Test Plan: unit tests Reviewed By: delong.j@fb.com FB internal diff: D812385 --- folly/dynamic.cpp | 4 ++++ folly/dynamic.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/folly/dynamic.cpp b/folly/dynamic.cpp index 25ab1032..0278dad9 100644 --- a/folly/dynamic.cpp +++ b/folly/dynamic.cpp @@ -34,6 +34,10 @@ DEF_TYPE(dynamic::ObjectImpl, "object", dynamic::OBJECT); #undef DEF_TYPE +const char* dynamic::typeName() const { + return typeName(type_); +} + ////////////////////////////////////////////////////////////////////// } diff --git a/folly/dynamic.h b/folly/dynamic.h index 88d23d9f..6ab5ca1b 100644 --- a/folly/dynamic.h +++ b/folly/dynamic.h @@ -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 -- 2.34.1