/*
- * Copyright 2013 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#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 {
typedef std::vector<dynamic> Array;
public:
typedef Array::const_iterator const_iterator;
+ typedef dynamic value_type;
struct const_key_iterator;
struct const_value_iterator;
struct const_item_iterator;
/*
* 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
int64_t asInt() const;
bool asBool() const;
+ /*
+ * It is occasionally useful to access a string's internal pointer
+ * directly, without the type conversion of `asString()`.
+ *
+ * These will throw a TypeError if the dynamic is not a string.
+ */
+ const char* data() const;
+ const char* c_str() const;
+
/*
* Returns: true if this dynamic is null, an empty array, an empty
* object, or an empty string.
*/
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.
private:
friend struct TypeError;
struct ObjectImpl;
- struct ObjectMaker;
template<class T> struct TypeInfo;
template<class T> struct CompareOp;
template<class T> struct GetAddrImpl;
}
-#include "folly/dynamic-inl.h"
+#include <folly/dynamic-inl.h>
#endif