X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Fexperimental%2FDynamicParser-inl.h;h=106b8f96a9daa85aef04c075adf39646df0a7b92;hb=b229e1a548855e6815f937f84e2c873f358016b9;hp=7620f7214eb063b572493951123439f3e93afcdb;hpb=4785dfe0af27d00755cac61bacec34539bc9878c;p=folly.git diff --git a/folly/experimental/DynamicParser-inl.h b/folly/experimental/DynamicParser-inl.h index 7620f721..106b8f96 100644 --- a/folly/experimental/DynamicParser-inl.h +++ b/folly/experimental/DynamicParser-inl.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,6 @@ */ #pragma once -#include #include #include #include @@ -32,6 +31,8 @@ #include #include +#include + namespace folly { // Auto-conversion of key/value based on callback signature, documented in @@ -77,22 +78,18 @@ using ArgumentTypes = // extended. The comparison deliberately strips cv-qualifieers and // reference, leaving that choice up to the caller. template -constexpr bool hasArgumentTypes() { - using HasArgumentTypes = typename boost::mpl::template equal< - typename boost::mpl::template transform< - typename boost::mpl::template transform< - ArgumentTypes, - typename std::template remove_reference - >::type, - typename std::template remove_cv - >::type, - boost::mpl::vector - >::type; - return HasArgumentTypes::value; -} +struct HasArgumentTypes + : boost::mpl::template equal< + typename boost::mpl::template transform< + typename boost::mpl::template transform< + ArgumentTypes, + typename std::template remove_reference>:: + type, + typename std::template remove_cv>::type, + boost::mpl::vector>::type {}; template using EnableForArgTypes = - typename std::enable_if(), void>::type; + typename std::enable_if::value, void>::type; // No arguments template EnableForArgTypes @@ -125,7 +122,7 @@ invokeForKeyValue(Fn fn, const folly::dynamic&, const folly::dynamic& v) { // std::string template EnableForArgTypes invokeForKeyValue(Fn fn, const folly::dynamic&, const folly::dynamic& v) { - fn(v.asString().toStdString()); + fn(v.asString()); } // @@ -157,7 +154,7 @@ invokeForKeyValue(Fn fn, const folly::dynamic& k, const folly::dynamic& v) { // folly::dynamic, std::string template EnableForArgTypes invokeForKeyValue(Fn fn, const folly::dynamic& k, const folly::dynamic& v) { - fn(k, v.asString().toStdString()); + fn(k, v.asString()); } // Convert the key to std::string. @@ -165,27 +162,27 @@ invokeForKeyValue(Fn fn, const folly::dynamic& k, const folly::dynamic& v) { // std::string, folly::dynamic (no conversion of value) template EnableForArgTypes invokeForKeyValue(Fn fn, const folly::dynamic& k, const folly::dynamic& v) { - fn(k.asString().toStdString(), v); + fn(k.asString(), v); } // std::string, int64_t template EnableForArgTypes invokeForKeyValue(Fn fn, const folly::dynamic& k, const folly::dynamic& v) { - fn(k.asString().toStdString(), v.asInt()); + fn(k.asString(), v.asInt()); } // std::string, bool template EnableForArgTypes invokeForKeyValue(Fn fn, const folly::dynamic& k, const folly::dynamic& v) { - fn(k.asString().toStdString(), v.asBool()); + fn(k.asString(), v.asBool()); } // std::string, double template EnableForArgTypes invokeForKeyValue(Fn fn, const folly::dynamic& k, const folly::dynamic& v) { - fn(k.asString().toStdString(), v.asDouble()); + fn(k.asString(), v.asDouble()); } // std::string, std::string template EnableForArgTypes invokeForKeyValue(Fn fn, const folly::dynamic& k, const folly::dynamic& v) { - fn(k.asString().toStdString(), v.asString().toStdString()); + fn(k.asString(), v.asString()); } // Convert the key to int64_t (good for arrays). @@ -213,7 +210,7 @@ invokeForKeyValue(Fn fn, const folly::dynamic& k, const folly::dynamic& v) { // int64_t, std::string template EnableForArgTypes invokeForKeyValue(Fn fn, const folly::dynamic& k, const folly::dynamic& v) { - fn(k.asInt(), v.asString().toStdString()); + fn(k.asInt(), v.asString()); } } // namespace detail @@ -267,11 +264,11 @@ template void DynamicParser::wrapError(const folly::dynamic* lookup_k, Fn fn) { try { fn(); - } catch (DynamicParserLogicError& ex) { + } catch (DynamicParserLogicError&) { // When the parser is misused, we throw all the way up to the user, // instead of reporting it as if the input is invalid. throw; - } catch (DynamicParserParseError& ex) { + } catch (DynamicParserParseError&) { // We are just bubbling up a parse error for OnError::THROW. throw; } catch (const std::exception& ex) {