Files
toml11/toml/to_toml.hpp

50 lines
1.0 KiB
C++
Raw Normal View History

2018-12-13 20:44:10 +09:00
// Copyright Toru Niina 2017.
// Distributed under the MIT License.
2017-04-21 13:14:53 +09:00
#ifndef TOML11_TO_TOML
#define TOML11_TO_TOML
#include "value.hpp"
namespace toml
{
2018-12-13 00:38:04 +09:00
template<typename T>
TOML11_MARK_AS_DEPRECATED
2018-12-13 00:38:04 +09:00
inline value to_toml(T&& x)
2018-05-05 13:09:40 +09:00
{
2018-12-13 00:38:04 +09:00
return value(std::forward<T>(x));
2018-05-05 13:09:40 +09:00
}
2018-12-13 00:38:04 +09:00
template<typename T>
TOML11_MARK_AS_DEPRECATED
2018-12-13 00:38:04 +09:00
inline value to_toml(T&& x, string_t kind)
2018-05-05 13:09:40 +09:00
{
2018-12-13 00:38:04 +09:00
return value(std::forward<T>(x), kind);
2017-04-21 13:14:53 +09:00
}
TOML11_MARK_AS_DEPRECATED
2018-12-13 00:38:04 +09:00
inline value to_toml(local_date d, local_time t)
2017-04-21 13:14:53 +09:00
{
2018-12-13 00:38:04 +09:00
return value(local_datetime(d, t));
2017-04-21 13:14:53 +09:00
}
TOML11_MARK_AS_DEPRECATED
2018-12-13 00:38:04 +09:00
inline value to_toml(local_date d, local_time t, time_offset ofs)
2018-05-05 13:09:40 +09:00
{
2018-12-13 00:38:04 +09:00
return value(offset_datetime(d, t, ofs));
2018-05-05 13:09:40 +09:00
}
2018-12-13 00:38:04 +09:00
template<typename ... Ts>
TOML11_MARK_AS_DEPRECATED
2018-12-13 00:38:04 +09:00
inline value to_toml(Ts&& ... xs)
2017-04-21 13:14:53 +09:00
{
2018-12-13 00:38:04 +09:00
return value(toml::array{toml::value(std::forward<Ts>(xs)) ... });
2017-04-21 13:14:53 +09:00
}
TOML11_MARK_AS_DEPRECATED
2018-12-13 00:38:04 +09:00
inline value to_toml(std::initializer_list<std::pair<std::string, toml::value>> xs)
2017-04-21 13:14:53 +09:00
{
2018-12-13 00:38:04 +09:00
return value(toml::table(xs.begin(), xs.end()));
2017-04-21 13:14:53 +09:00
}
} // toml
#endif // TOML11_TO_TOML