Schedule destroyInstances in registrationComplete
[folly.git] / folly / dynamic.h
index 1494a557047feff2c25a36b8376c9dd781ef9b7a..ecdcdaf16829f225793177bfe8f4b0396f313647 100644 (file)
 #ifndef FOLLY_DYNAMIC_H_
 #define FOLLY_DYNAMIC_H_
 
-#include <unordered_map>
+#include <cstdint>
+#include <initializer_list>
 #include <memory>
-#include <string>
-#include <utility>
 #include <ostream>
+#include <string>
 #include <type_traits>
-#include <initializer_list>
+#include <unordered_map>
+#include <utility>
 #include <vector>
-#include <cstdint>
+
 #include <boost/operators.hpp>
 
-#include "folly/Traits.h"
-#include "folly/FBString.h"
+#include <folly/FBString.h>
+#include <folly/Range.h>
+#include <folly/Traits.h>
 
 namespace folly {
 
@@ -143,8 +145,11 @@ public:
   /*
    * String compatibility constructors.
    */
+  /* implicit */ dynamic(StringPiece val);
   /* implicit */ dynamic(char const* val);
   /* implicit */ dynamic(std::string const& val);
+  /* implicit */ dynamic(fbstring const& val);
+  /* implicit */ dynamic(fbstring&& val);
 
   /*
    * This is part of the plumbing for object(), above.  Used to create
@@ -273,6 +278,20 @@ public:
   int64_t  asInt() const;
   bool     asBool() const;
 
+  /*
+   * Extract the value stored in this dynamic without type conversion.
+   *
+   * These will throw a TypeError if the dynamic has a different type.
+   */
+  const fbstring& getString() const;
+  double          getDouble() const;
+  int64_t         getInt() const;
+  bool            getBool() const;
+  fbstring& getString();
+  double&   getDouble();
+  int64_t&  getInt();
+  bool&     getBool();
+
   /*
    * It is occasionally useful to access a string's internal pointer
    * directly, without the type conversion of `asString()`.
@@ -281,6 +300,7 @@ public:
    */
   const char* data()  const;
   const char* c_str() const;
+  StringPiece stringPiece() const;
 
   /*
    * Returns: true if this dynamic is null, an empty array, an empty
@@ -326,7 +346,6 @@ public:
    */
   const_item_iterator find(dynamic const&) const;
 
-
   /*
    * If this is an object, returns whether it contains a field with
    * the given name.  Otherwise throws TypeError.
@@ -520,6 +539,6 @@ private:
 
 }
 
-#include "folly/dynamic-inl.h"
+#include <folly/dynamic-inl.h>
 
 #endif