diff options
author | miloyip <miloyip@gmail.com> | 2015-05-02 17:08:03 +0300 |
---|---|---|
committer | miloyip <miloyip@gmail.com> | 2015-05-02 17:08:03 +0300 |
commit | d0d18847c5f01fb9378777f25761f54b39b5bdc1 (patch) | |
tree | da8e7c58f7c3e3fcc54e565eced0196a7c280519 /include/rapidjson/pointer.h | |
parent | 32b45f6e6d15b229ea1907e9569e4792bff6e207 (diff) |
Add GetValueByPointerWithDefault() overloads
Diffstat (limited to 'include/rapidjson/pointer.h')
-rw-r--r-- | include/rapidjson/pointer.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/rapidjson/pointer.h b/include/rapidjson/pointer.h index 16d2e602..027d68bf 100644 --- a/include/rapidjson/pointer.h +++ b/include/rapidjson/pointer.h @@ -445,12 +445,47 @@ typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointe return pointer.GetWithDefault(root, defaultValue, a); } +template <typename T> +typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer<typename T::ValueType>& pointer, GenericStringRef<typename T::Ch> defaultValue, typename T::AllocatorType& a) { + return pointer.GetWithDefault(root, defaultValue, a); +} + +template <typename T> +typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer<typename T::ValueType>& pointer, const typename T::Ch* defaultValue, typename T::AllocatorType& a) { + return pointer.GetWithDefault(root, defaultValue, a); +} + +template <typename T, typename T2> +RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename T::ValueType&)) +GetValueByPointerWithDefault(T& root, const GenericPointer<typename T::ValueType>& pointer, T2 defaultValue, typename T::AllocatorType& a) { + return pointer.GetWithDefault(root, defaultValue, a); +} + template <typename T, typename CharType, size_t N> typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::ValueType& defaultValue, typename T::AllocatorType& a) { const GenericPointer<typename T::ValueType> pointer(source, N - 1); return GetValueByPointerWithDefault(root, pointer, defaultValue, a); } +template <typename T, typename CharType, size_t N> +typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], GenericStringRef<typename T::Ch> defaultValue, typename T::AllocatorType& a) { + const GenericPointer<typename T::ValueType> pointer(source, N - 1); + return GetValueByPointerWithDefault(root, pointer, defaultValue, a); +} + +template <typename T, typename CharType, size_t N> +typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::Ch* defaultValue, typename T::AllocatorType& a) { + const GenericPointer<typename T::ValueType> pointer(source, N - 1); + return GetValueByPointerWithDefault(root, pointer, defaultValue, a); +} + +template <typename T, typename CharType, size_t N, typename T2> +RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename T::ValueType&)) +GetValueByPointerWithDefault(T& root, const CharType(&source)[N], T2 defaultValue, typename T::AllocatorType& a) { + const GenericPointer<typename T::ValueType> pointer(source, N - 1); + return GetValueByPointerWithDefault(root, pointer, defaultValue, a); +} + template <typename T> typename T::ValueType& SetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, typename T::ValueType& value, typename T::AllocatorType& a) { return pointer.Set(root, value, a); |