mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
fix: use empty quoted string for empty key
This commit is contained in:
@@ -29,6 +29,11 @@ template<typename charT, typename traits, typename Alloc>
|
|||||||
std::basic_string<charT, traits, Alloc>
|
std::basic_string<charT, traits, Alloc>
|
||||||
format_key(const std::basic_string<charT, traits, Alloc>& k)
|
format_key(const std::basic_string<charT, traits, Alloc>& k)
|
||||||
{
|
{
|
||||||
|
if(k.empty())
|
||||||
|
{
|
||||||
|
return std::string("\"\"");
|
||||||
|
}
|
||||||
|
|
||||||
// check the key can be a bare (unquoted) key
|
// check the key can be a bare (unquoted) key
|
||||||
detail::location loc(k, std::vector<char>(k.begin(), k.end()));
|
detail::location loc(k, std::vector<char>(k.begin(), k.end()));
|
||||||
detail::lex_unquoted_key::invoke(loc);
|
detail::lex_unquoted_key::invoke(loc);
|
||||||
@@ -61,9 +66,12 @@ template<typename charT, typename traits, typename Alloc>
|
|||||||
std::basic_string<charT, traits, Alloc>
|
std::basic_string<charT, traits, Alloc>
|
||||||
format_keys(const std::vector<std::basic_string<charT, traits, Alloc>>& keys)
|
format_keys(const std::vector<std::basic_string<charT, traits, Alloc>>& keys)
|
||||||
{
|
{
|
||||||
std::basic_string<charT, traits, Alloc> serialized;
|
if(keys.empty())
|
||||||
if(keys.empty()) {return serialized;}
|
{
|
||||||
|
return std::string("\"\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::basic_string<charT, traits, Alloc> serialized;
|
||||||
for(const auto& ky : keys)
|
for(const auto& ky : keys)
|
||||||
{
|
{
|
||||||
serialized += format_key(ky);
|
serialized += format_key(ky);
|
||||||
|
Reference in New Issue
Block a user