15 #ifndef ALEXA_CLIENT_SDK_SETTINGS_INCLUDE_SETTINGS_SETTINGSTRINGCONVERSION_H_ 16 #define ALEXA_CLIENT_SDK_SETTINGS_INCLUDE_SETTINGS_SETTINGSTRINGCONVERSION_H_ 41 template <
typename ValueT>
43 return std::is_same<ValueT, int8_t>::value || std::is_same<ValueT, uint8_t>::value;
51 template <
typename ValueT>
62 template <
typename ValueT,
typename = IntegralByteType<ValueT>>
64 std::stringstream stream;
67 return {!stream.fail(), stream.str()};
79 template <
typename ValueT,
typename = IntegralByteType<ValueT>>
81 int16_t value = defaultValue;
82 std::stringstream stream;
85 return {!stream.fail(), stream.fail() ? defaultValue : value};
96 template <
typename ValueT>
98 return std::is_enum<ValueT>::value || std::is_same<ValueT, std::string>::value;
106 template <
typename ValueT>
119 template <
typename ValueT,
typename = EnumOrString<ValueT>>
121 std::stringstream stream;
122 stream << QUOTE << value <<
QUOTE;
123 return {!stream.fail(), stream.str()};
137 template <
typename ValueT,
typename = EnumOrString<ValueT>>
139 if (str.length() < 2 || str[0] != QUOTE || str[str.length() - 1] !=
QUOTE) {
140 return {
false, defaultValue};
143 ValueT value = defaultValue;
144 std::stringstream stream;
145 stream << str.substr(1, str.length() - 2);
147 return {!stream.fail(), value};
158 template <
typename ValueT>
160 return std::is_same<ValueT, std::set<std::string>>::value ||
161 std::is_same<ValueT, std::vector<std::string>>::value || std::is_same<ValueT, std::list<std::string>>::value;
169 template <
typename ValueT>
180 template <
typename ValueT, StringCollection<ValueT>* =
nullptr>
182 std::vector<std::string> values{value.begin(), value.end()};
184 return std::make_pair(!retValue.empty(), retValue);
198 template <
typename ValueT, StringCollection<ValueT>* =
nullptr>
200 auto values = avsCommon::utils::json::jsonUtils::retrieveStringArray<ValueT>(str);
202 return std::make_pair(
false, defaultValue);
204 ValueT retValue{values.begin(), values.end()};
205 return std::make_pair(
true, retValue);
215 template <
typename ValueT>
217 !isEnumOrString<ValueT>() && !isIntegralByteType<ValueT>() && !isStringCollection<ValueT>(),
230 template <
typename ValueT>
232 std::stringstream stream;
233 stream << std::boolalpha << value;
234 return {!stream.fail(), stream.str()};
248 template <
typename ValueT>
250 ValueT value = defaultValue;
251 std::stringstream stream;
253 stream >> std::boolalpha >> value;
254 return {!stream.fail(), stream.fail() ? defaultValue : value};
260 #endif // ALEXA_CLIENT_SDK_SETTINGS_INCLUDE_SETTINGS_SETTINGSTRINGCONVERSION_H_ std::pair< bool, ValueT > fromSettingString(const std::string &str, const IntegralByteType< ValueT > &defaultValue)
Definition: SettingStringConversion.h:80
typename std::enable_if< !isEnumOrString< ValueT >() &&!isIntegralByteType< ValueT >() &&!isStringCollection< ValueT >(), ValueT >::type OtherTypes
Definition: SettingStringConversion.h:218
static constexpr bool isStringCollection()
Definition: SettingStringConversion.h:159
std::string convertToJsonString(const CollectionT &elements)
Definition: JSONUtils.h:297
::std::string string
Definition: gtest-port.h:1097
static constexpr bool isIntegralByteType()
Definition: SettingStringConversion.h:42
static constexpr bool isEnumOrString()
Definition: SettingStringConversion.h:97
std::pair< bool, std::string > toSettingString(const IntegralByteType< ValueT > &value)
Definition: SettingStringConversion.h:63
typename std::enable_if< isEnumOrString< ValueT >(), ValueT >::type EnumOrString
Definition: SettingStringConversion.h:107
typename std::enable_if< isIntegralByteType< ValueT >(), ValueT >::type IntegralByteType
Definition: SettingStringConversion.h:52
static const std::string EMPTY_JSON_LIST
Definition: SettingStringConversion.h:187
constexpr char QUOTE
Quote used for json string values.
Definition: SettingStringConversion.h:31
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
typename std::enable_if< isStringCollection< ValueT >(), ValueT >::type StringCollection
Definition: SettingStringConversion.h:170
type
Definition: upload.py:443