#ifndef TOML11_LITERAL_IMPL_HPP #define TOML11_LITERAL_IMPL_HPP #include "../fwd/literal_fwd.hpp" #include "../parser.hpp" #include "../syntax.hpp" #include "../version.hpp" namespace toml { inline namespace TOML11_INLINE_VERSION_NAMESPACE { namespace detail { // implementation TOML11_INLINE ::toml::value literal_internal_impl(location loc) { const auto s = ::toml::spec::default_version(); context ctx(s); const auto front = loc; // ------------------------------------------------------------------------ // check if it is a raw value. // skip empty lines and comment lines auto sp = skip_multiline_spacer(loc, ctx); if(loc.eof()) { ::toml::value val; if(sp.has_value()) { for(std::size_t i=0; i(str), reinterpret_cast(str + len), c.begin()); if( ! c.empty() && c.back()) { c.push_back('\n'); // to make it easy to parse comment, we add newline } return literal_internal_impl(::toml::detail::location( std::make_shared(std::move(c)), "TOML literal encoded in a C++ code")); } #if defined(__cpp_char8_t) # if __cpp_char8_t >= 201811L # define TOML11_HAS_CHAR8_T 1 # endif #endif #if defined(TOML11_HAS_CHAR8_T) // value of u8"" literal has been changed from char to char8_t and char8_t is // NOT compatible to char TOML11_INLINE ::toml::value operator"" _toml(const char8_t* str, std::size_t len) { if(len == 0) { return ::toml::value{}; } ::toml::detail::location::container_type c(len); std::copy(reinterpret_cast(str), reinterpret_cast(str + len), c.begin()); if( ! c.empty() && c.back()) { c.push_back('\n'); // to make it easy to parse comment, we add newline } return literal_internal_impl(::toml::detail::location( std::make_shared(std::move(c)), "TOML literal encoded in a C++ code")); } #endif } // toml_literals } // literals } // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_LITERAL_IMPL_HPP