Function get

Summary

#include <toml/get.hpp>

(1) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
    detail::enable_if_t< detail::is_exact_toml_type< T, basic_value< C, M, V > >::value, T > & get(basic_value< C, M, V > &v)

(2) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
    detail::enable_if_t< detail::is_exact_toml_type< T, basic_value< C, M, V > >::value, T > const  & get(const basic_value< C, M, V > &v)

(3) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
    detail::enable_if_t< detail::is_exact_toml_type< T, basic_value< C, M, V > >::value, T > get(basic_value< C, M, V > &&v)

(4) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
    detail::enable_if_t< std::is_same< T, basic_value< C, M, V > >::value, T > & get(basic_value< C, M, V > &v)

(5) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
    detail::enable_if_t< std::is_same< T, basic_value< C, M, V > >::value, T > const  & get(const basic_value< C, M, V > &v)

(6) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
    detail::enable_if_t< std::is_same< T, basic_value< C, M, V > >::value, T > get(basic_value< C, M, V > &&v)

(7) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
    detail::enable_if_t< detail::conjunction< detail::is_basic_value< T >, detail::negation< std::is_same< T, basic_value< C, M, V > > > >::value, T > get(const basic_value< C, M, V > &v)

(8) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
    detail::enable_if_t< detail::conjunction< std::is_integral< T >, detail::negation< std::is_same< T, bool > >, detail::negation< detail::is_exact_toml_type< T, basic_value< C, M, V > > > >::value, T > get(const basic_value< C, M, V > &v)

(9) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
    detail::enable_if_t< detail::conjunction< std::is_floating_point< T >, detail::negation< detail::is_exact_toml_type< T, basic_value< C, M, V > > > >::value, T > get(const basic_value< C, M, V > &v)

(10) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< std::is_same< T, std::string >::value, std::string > & get(basic_value< C, M, V > &v)

(11) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< std::is_same< T, std::string >::value, std::string > const  & get(const basic_value< C, M, V > &v)

(12) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< std::is_same< T, std::string >::value, std::string > get(basic_value< C, M, V > &&v)

(13) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< detail::is_chrono_duration< T >::value, T > get(const basic_value< C, M, V > &v)

(14) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< std::is_same< std::chrono::system_clock::time_point, T >::value, T > get(const basic_value< C, M, V > &v)

(15) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< detail::conjunction< detail::is_container< T >, detail::has_push_back_method< T >, detail::negation< detail::is_exact_toml_type< T, basic_value< C, M, V > > > >::value, T > get(const basic_value< C, M, V > &)

(16) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< detail::conjunction< detail::is_container< T >, detail::negation< detail::has_push_back_method< T > >, detail::negation< detail::is_exact_toml_type< T, basic_value< C, M, V > > > >::value, T > get(const basic_value< C, M, V > &)

(17) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< detail::is_std_pair< T >::value, T > get(const basic_value< C, M, V > &)

(18) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< detail::is_std_tuple< T >::value, T > get(const basic_value< C, M, V > &)

(19) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< detail::conjunction< detail::is_map< T >, detail::negation< detail::is_exact_toml_type< T, basic_value< C, M, V > > > >::value, T > get(const basic_value< C, M, V > &)

(20) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< detail::conjunction< detail::negation< detail::is_exact_toml_type< T, basic_value< C, M, V > > >, detail::has_from_toml_method< T, C, M, V >, std::is_default_constructible< T > >::value, T > get(const basic_value< C, M, V > &)

(21) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< detail::has_specialized_from< T >::value, T > get(const basic_value< C, M, V > &)

(22) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< detail::conjunction< detail::negation< detail::is_basic_value< T > >, std::is_constructible< T, const basic_value< C, M, V > & >, detail::negation< detail::has_from_toml_method< T, C, M, V > >, detail::negation< detail::has_specialized_from< T > > >::value, T > get(const basic_value< C, M, V > &)

(23) template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
     detail::enable_if_t< detail::is_std_forward_list< T >::value, T > get(const basic_value< C, M, V > &v)

Function overload

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::is_exact_toml_type< T, basic_value< C, M, V > >::value, T > & get(basic_value< C, M, V > &v)

Description

No description yet.

Mentioned in

Source

Lines 17-23 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
detail::enable_if_t<detail::is_exact_toml_type<T, basic_value<C, M, V>>::value, T> &
get(basic_value<C, M, V>& v)
{
    return v.template cast<detail::type_to_enum<T, basic_value<C, M, V>>::value>();
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::is_exact_toml_type< T, basic_value< C, M, V > >::value, T > const  & get(const basic_value< C, M, V > &v)

Description

No description yet.

Mentioned in

Source

Lines 25-31 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
detail::enable_if_t<detail::is_exact_toml_type<T, basic_value<C, M, V>>::value, T> const&
get(const basic_value<C, M, V>& v)
{
    return v.template cast<detail::type_to_enum<T, basic_value<C, M, V>>::value>();
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::is_exact_toml_type< T, basic_value< C, M, V > >::value, T > get(basic_value< C, M, V > &&v)

Description

No description yet.

Mentioned in

Source

Lines 33-39 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
detail::enable_if_t<detail::is_exact_toml_type<T, basic_value<C, M, V>>::value, T>
get(basic_value<C, M, V>&& v)
{
    return T(std::move(v).template cast<detail::type_to_enum<T, basic_value<C, M, V>>::value>());
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< std::is_same< T, basic_value< C, M, V > >::value, T > & get(basic_value< C, M, V > &v)

Description

No description yet.

Mentioned in

Source

Lines 44-50 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
inline detail::enable_if_t<std::is_same<T, basic_value<C, M, V>>::value, T>&
get(basic_value<C, M, V>& v)
{
    return v;
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< std::is_same< T, basic_value< C, M, V > >::value, T > const  & get(const basic_value< C, M, V > &v)

Description

No description yet.

Mentioned in

Source

Lines 52-58 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
inline detail::enable_if_t<std::is_same<T, basic_value<C, M, V>>::value, T> const&
get(const basic_value<C, M, V>& v)
{
    return v;
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< std::is_same< T, basic_value< C, M, V > >::value, T > get(basic_value< C, M, V > &&v)

Description

No description yet.

Mentioned in

Source

Lines 60-66 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
inline detail::enable_if_t<std::is_same<T, basic_value<C, M, V>>::value, T>
get(basic_value<C, M, V>&& v)
{
    return basic_value<C, M, V>(std::move(v));
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::conjunction< detail::is_basic_value< T >, detail::negation< std::is_same< T, basic_value< C, M, V > > > >::value, T > get(const basic_value< C, M, V > &v)

Description

No description yet.

Mentioned in

Source

Lines 71-79 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
inline detail::enable_if_t<detail::conjunction<detail::is_basic_value<T>,
    detail::negation<std::is_same<T, basic_value<C, M, V>>>
    >::value, T>
get(const basic_value<C, M, V>& v)
{
    return T(v);
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::conjunction< std::is_integral< T >, detail::negation< std::is_same< T, bool > >, detail::negation< detail::is_exact_toml_type< T, basic_value< C, M, V > > > >::value, T > get(const basic_value< C, M, V > &v)

Description

No description yet.

Mentioned in

Source

Lines 84-95 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
inline detail::enable_if_t<detail::conjunction<
    std::is_integral<T>,                            // T is integral
    detail::negation<std::is_same<T, bool>>,        // but not bool
    detail::negation<                               // but not toml::integer
        detail::is_exact_toml_type<T, basic_value<C, M, V>>>
    >::value, T>
get(const basic_value<C, M, V>& v)
{
    return static_cast<T>(v.as_integer());
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::conjunction< std::is_floating_point< T >, detail::negation< detail::is_exact_toml_type< T, basic_value< C, M, V > > > >::value, T > get(const basic_value< C, M, V > &v)

Description

No description yet.

Mentioned in

Source

Lines 100-110 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
inline detail::enable_if_t<detail::conjunction<
    std::is_floating_point<T>,                      // T is floating_point
    detail::negation<                               // but not toml::floating
        detail::is_exact_toml_type<T, basic_value<C, M, V>>>
    >::value, T>
get(const basic_value<C, M, V>& v)
{
    return static_cast<T>(v.as_floating());
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< std::is_same< T, std::string >::value, std::string > & get(basic_value< C, M, V > &v)

Description

No description yet.

Mentioned in

Source

Lines 116-122 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
inline detail::enable_if_t<std::is_same<T, std::string>::value, std::string>&
get(basic_value<C, M, V>& v)
{
    return v.as_string().str;
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< std::is_same< T, std::string >::value, std::string > const  & get(const basic_value< C, M, V > &v)

Description

No description yet.

Mentioned in

Source

Lines 124-130 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
inline detail::enable_if_t<std::is_same<T, std::string>::value, std::string> const&
get(const basic_value<C, M, V>& v)
{
    return v.as_string().str;
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< std::is_same< T, std::string >::value, std::string > get(basic_value< C, M, V > &&v)

Description

No description yet.

Mentioned in

Source

Lines 132-138 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
inline detail::enable_if_t<std::is_same<T, std::string>::value, std::string>
get(basic_value<C, M, V>&& v)
{
    return std::string(std::move(v.as_string().str));
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::is_chrono_duration< T >::value, T > get(const basic_value< C, M, V > &v)

Description

No description yet.

Mentioned in

Source

Lines 156-163 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
inline detail::enable_if_t<detail::is_chrono_duration<T>::value, T>
get(const basic_value<C, M, V>& v)
{
    return std::chrono::duration_cast<T>(
            std::chrono::nanoseconds(v.as_local_time()));
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< std::is_same< std::chrono::system_clock::time_point, T >::value, T > get(const basic_value< C, M, V > &v)

Description

No description yet.

Mentioned in

Source

Lines 168-196 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
inline detail::enable_if_t<
    std::is_same<std::chrono::system_clock::time_point, T>::value, T>
get(const basic_value<C, M, V>& v)
{
    switch(v.type())
    {
        case value_t::local_date:
        {
            return std::chrono::system_clock::time_point(v.as_local_date());
        }
        case value_t::local_datetime:
        {
            return std::chrono::system_clock::time_point(v.as_local_datetime());
        }
        case value_t::offset_datetime:
        {
            return std::chrono::system_clock::time_point(v.as_offset_datetime());
        }
        default:
        {
            throw type_error(detail::format_underline("toml::value: "
                "bad_cast to std::chrono::system_clock::time_point", {
                    {v.location(), concat_to_string("the actual type is ", v.type())}
                }), v.location());
        }
    }
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::conjunction< detail::is_container< T >, detail::has_push_back_method< T >, detail::negation< detail::is_exact_toml_type< T, basic_value< C, M, V > > > >::value, T > get(const basic_value< C, M, V > &)

Description

No description yet.

Mentioned in

Source

Lines 277-298 in toml/get.hpp. Line 210 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
detail::enable_if_t<detail::conjunction<
    detail::is_container<T>,         // T is a container
    detail::has_push_back_method<T>, // container.push_back(elem) works
    detail::negation<                // but not toml::array
        detail::is_exact_toml_type<T, basic_value<C, M, V>>>
    >::value, T>
get(const basic_value<C, M, V>& v)
{
    using value_type = typename T::value_type;
    const auto& ary = v.as_array();

    T container;
    try_reserve(container, ary.size());

    for(const auto& elem : ary)
    {
        container.push_back(get<value_type>(elem));
    }
    return container;
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::conjunction< detail::is_container< T >, detail::negation< detail::has_push_back_method< T > >, detail::negation< detail::is_exact_toml_type< T, basic_value< C, M, V > > > >::value, T > get(const basic_value< C, M, V > &)

Description

No description yet.

Mentioned in

Source

Lines 322-349 in toml/get.hpp. Line 221 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
detail::enable_if_t<detail::conjunction<
    detail::is_container<T>,                           // T is a container
    detail::negation<detail::has_push_back_method<T>>, // w/o push_back
    detail::negation<                                  // T is not toml::array
        detail::is_exact_toml_type<T, basic_value<C, M, V>>>
    >::value, T>
get(const basic_value<C, M, V>& v)
{
    using value_type = typename T::value_type;
    const auto& ar = v.as_array();

    T container;
    if(ar.size() != container.size())
    {
        throw std::out_of_range(detail::format_underline(concat_to_string(
            "toml::get: specified container size is ", container.size(),
            " but there are ", ar.size(), " elements in toml array."), {
                {v.location(), "here"}
            }));
    }
    for(std::size_t i=0; i<ar.size(); ++i)
    {
        container[i] = ::toml::get<value_type>(ar[i]);
    }
    return container;
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::is_std_pair< T >::value, T > get(const basic_value< C, M, V > &)

Description

No description yet.

Mentioned in

Source

Lines 354-371 in toml/get.hpp. Line 227 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
detail::enable_if_t<detail::is_std_pair<T>::value, T>
get(const basic_value<C, M, V>& v)
{
    using first_type  = typename T::first_type;
    using second_type = typename T::second_type;

    const auto& ar = v.as_array();
    if(ar.size() != 2)
    {
        throw std::out_of_range(detail::format_underline(concat_to_string(
            "toml::get: specified std::pair but there are ", ar.size(),
            " elements in toml array."), {{v.location(), "here"}}));
    }
    return std::make_pair(::toml::get<first_type >(ar.at(0)),
                          ::toml::get<second_type>(ar.at(1)));
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::is_std_tuple< T >::value, T > get(const basic_value< C, M, V > &)

Description

No description yet.

Mentioned in

Source

Lines 386-401 in toml/get.hpp. Line 233 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
detail::enable_if_t<detail::is_std_tuple<T>::value, T>
get(const basic_value<C, M, V>& v)
{
    const auto& ar = v.as_array();
    if(ar.size() != std::tuple_size<T>::value)
    {
        throw std::out_of_range(detail::format_underline(concat_to_string(
            "toml::get: specified std::tuple with ",
            std::tuple_size<T>::value, " elements, but there are ", ar.size(),
            " elements in toml array."), {{v.location(), "here"}}));
    }
    return detail::get_tuple_impl<T>(ar,
            detail::make_index_sequence<std::tuple_size<T>::value>{});
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::conjunction< detail::is_map< T >, detail::negation< detail::is_exact_toml_type< T, basic_value< C, M, V > > > >::value, T > get(const basic_value< C, M, V > &)

Description

No description yet.

Mentioned in

Source

Lines 406-426 in toml/get.hpp. Line 243 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
detail::enable_if_t<detail::conjunction<
    detail::is_map<T>, // T is map
    detail::negation<  // but not toml::array
        detail::is_exact_toml_type<T, basic_value<C, M, V>>>
    >::value, T>
get(const basic_value<C, M, V>& v)
{
    using key_type    = typename T::key_type;
    using mapped_type = typename T::mapped_type;
    static_assert(std::is_convertible<std::string, key_type>::value,
                  "toml::get only supports map type of which key_type is "
                  "convertible from std::string.");
    T map;
    for(const auto& kv : v.as_table())
    {
        map.emplace(key_type(kv.first), get<mapped_type>(kv.second));
    }
    return map;
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::conjunction< detail::negation< detail::is_exact_toml_type< T, basic_value< C, M, V > > >, detail::has_from_toml_method< T, C, M, V >, std::is_default_constructible< T > >::value, T > get(const basic_value< C, M, V > &)

Description

No description yet.

Mentioned in

Source

Lines 431-444 in toml/get.hpp. Line 254 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
detail::enable_if_t<detail::conjunction<
    detail::negation<                         // not a toml::* type
        detail::is_exact_toml_type<T, basic_value<C, M, V>>>,
    detail::has_from_toml_method<T, C, M, V>, // but has from_toml(toml::value) memfn
    std::is_default_constructible<T>          // and default constructible
    >::value, T>
get(const basic_value<C, M, V>& v)
{
    T ud;
    ud.from_toml(v);
    return ud;
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::has_specialized_from< T >::value, T > get(const basic_value< C, M, V > &)

Description

No description yet.

Mentioned in

Source

Lines 445-451 in toml/get.hpp. Line 260 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
detail::enable_if_t<detail::has_specialized_from<T>::value, T>
get(const basic_value<C, M, V>& v)
{
    return ::toml::from<T>::from_toml(v);
}

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::conjunction< detail::negation< detail::is_basic_value< T > >, std::is_constructible< T, const basic_value< C, M, V > & >, detail::negation< detail::has_from_toml_method< T, C, M, V > >, detail::negation< detail::has_specialized_from< T > > >::value, T > get(const basic_value< C, M, V > &)

Description

No description yet.

Mentioned in

Source

Lines 460-464 in toml/get.hpp. Line 272 in toml/get.hpp.

>::value, T>
const basic_value<C, M, V>& v)
return T(v);

Synopsis

#include <toml/get.hpp>

template <typename T, typename C, template< typename ... > class M, template< typename ... > class V>
detail::enable_if_t< detail::is_std_forward_list< T >::value, T > get(const basic_value< C, M, V > &v)

Description

No description yet.

Mentioned in

Source

Lines 304-317 in toml/get.hpp.

template<typename T, typename C,
         template<typename ...> class M, template<typename ...> class V>
detail::enable_if_t<detail::is_std_forward_list<T>::value, T>
get(const basic_value<C, M, V>& v)
{
    using value_type = typename T::value_type;
    T container;
    for(const auto& elem : v.as_array())
    {
        container.push_front(get<value_type>(elem));
    }
    container.reverse();
    return container;
}





Add Discussion as Guest

Log in