Fabric: Universal `fromDynamic` for `std::vector<...>`
Summary: Now, if `fromDynamic` is defined for some type, `fromDynamic` for `std::vector` of this type is also will be defined. We need this for parsing `ImageSources` (a vector of `ImageSource`) type. Reviewed By: fkgozali Differential Revision: D8473508 fbshipit-source-id: d8dc8e3a3273f35b76c7132c553130762f768394
This commit is contained in:
parent
d92601be05
commit
310a2850c5
|
@ -24,6 +24,16 @@ inline void fromDynamic(const folly::dynamic &value, int &result) {
|
|||
}
|
||||
inline void fromDynamic(const folly::dynamic &value, std::string &result) { result = value.getString(); }
|
||||
|
||||
template <typename T>
|
||||
inline void fromDynamic(const folly::dynamic &value, std::vector<T> &result) {
|
||||
result.clear();
|
||||
T itemResult;
|
||||
for (auto &itemValue : value) {
|
||||
fromDynamic(itemValue, itemResult);
|
||||
result.push_back(itemResult);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T convertRawProp(
|
||||
const RawProps &rawProps,
|
||||
|
|
Loading…
Reference in New Issue