22 #include <type_traits> 24 #include <boost/iterator/iterator_adaptor.hpp> 25 #include <boost/mpl/has_xxx.hpp> 57 namespace dynamicconverter_detail {
59 BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type)
60 BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator)
61 BOOST_MPL_HAS_XXX_TRAIT_DEF(mapped_type)
62 BOOST_MPL_HAS_XXX_TRAIT_DEF(key_type)
106 namespace dynamicconverter_detail {
108 template <
typename T>
113 throw TypeError(
"array", dynamic::Type::OBJECT);
119 mem->
emplace(convertTo<T>(*it));
123 template <
typename F,
typename S>
128 mem->emplace(convertTo<F>(it->first), convertTo<S>(it->second));
132 template <
typename T>
136 mem->
emplace(convertTo<T>(*it));
140 template <
typename T,
typename It>
143 iterator_adaptor<Transformer<T, It>, It, typename T::value_type> {
144 friend class boost::iterator_core_access;
146 typedef typename T::value_type
ttype;
151 ++this->base_reference();
159 return cache_.
value();
167 template <
typename T,
typename It>
183 template <
typename T,
typename Enable =
void>
195 template <
typename T>
198 typename
std::enable_if<
199 std::is_integral<T>::value && !std::is_same<T, bool>::value>
::type> {
201 return folly::to<T>(d.
asInt());
206 template <
typename T>
209 typename
std::enable_if<std::is_enum<T>::value>
::type> {
217 template <
typename T>
220 typename
std::enable_if<std::is_floating_point<T>::value>
::type> {
243 template <
typename F,
typename S>
247 return std::make_pair(convertTo<F>(d[0]), convertTo<S>(d[1]));
249 auto it = d.
items().begin();
250 return std::make_pair(convertTo<F>(it->first), convertTo<S>(it->second));
252 throw TypeError(
"array (size 2) or object (size 1)", d.
type());
258 template <
typename C>
261 typename
std::enable_if<
262 dynamicconverter_detail::is_container<C>::value &&
263 !dynamicconverter_detail::is_associative<C>::value>
::type> {
267 dynamicconverter_detail::conversionIterator<C>(d.
begin()),
268 dynamicconverter_detail::conversionIterator<C>(d.
end()));
271 dynamicconverter_detail::conversionIterator<C>(d.
items().begin()),
272 dynamicconverter_detail::conversionIterator<C>(d.
items().end()));
280 template <
typename C>
283 typename
std::enable_if<
284 dynamicconverter_detail::is_container<C>::value &&
285 dynamicconverter_detail::is_associative<C>::value>
::type> {
291 dynamicconverter_detail::conversionIterator<C>(d.
begin()),
292 dynamicconverter_detail::conversionIterator<C>(d.
end()));
295 dynamicconverter_detail::conversionIterator<C>(d.
items().begin()),
296 dynamicconverter_detail::conversionIterator<C>(d.
items().end()));
313 template <
typename C,
typename Enable =
void>
321 template <
typename C>
324 typename
std::enable_if<std::is_same<C, dynamic>::value>
::type> {
331 template <
typename C>
334 typename
std::enable_if<
335 !std::is_same<C, dynamic>::value &&
336 dynamicconverter_detail::is_map<C>::value>
::type> {
339 for (
const auto&
pair : x) {
347 template <
typename C>
350 typename
std::enable_if<
351 !std::is_same<C, dynamic>::value &&
352 !dynamicconverter_detail::is_map<C>::value &&
353 !std::is_constructible<StringPiece, const C&>::value &&
354 dynamicconverter_detail::is_range<C>::value>
::type> {
357 for (
const auto& item : x) {
365 template <
typename A,
typename B>
383 for (
bool item : x) {
393 template <
typename T>
398 template <
typename T>
static ObjectMaker object()
static T convert(const dynamic &d)
static dynamic construct(const C &x)
std::move_iterator< Transformer< T, It > > conversionIterator(const It &it)
static void derefToCache(Optional< std::pair< F, S >> *mem, const dynamic::const_item_iterator &it)
static std::pair< F, S > convert(const dynamic &d)
static dynamic construct(const C &x)
T convertTo(const dynamic &)
static bool convert(const dynamic &d)
static void derefToCache(Optional< T > *mem, const dynamic::const_iterator &it)
static std::string convert(const dynamic &d)
—— Concurrent Priority Queue Implementation ——
static void derefToCache(Optional< T > *, const dynamic::const_item_iterator &)
static dynamic construct(const C &x)
static dynamic construct(const std::pair< A, B > &x)
static C convert(const dynamic &d)
static C convert(const dynamic &d)
static T convert(const dynamic &d)
std::string asString() const
static dynamic construct(const C &x)
static folly::fbstring convert(const dynamic &d)
static T convert(const dynamic &d)
void insert(K &&, V &&val)
void push_back(dynamic const &)
static const char *const value
static void derefToCache(Optional< T > *mem, const dynamic::const_iterator &it)
Value & emplace(Args &&...args)
std::reverse_iterator< typename T::iterator > some_iterator
IterableProxy< const_item_iterator > items() const
static void array(EmptyArrayTag)
FOLLY_CPP14_CONSTEXPR const Value & value() const &
const_iterator begin() const
Array::const_iterator const_iterator
static dynamic construct(const std::vector< bool > &x)
dynamic toDynamic(const T &)
const_iterator end() const