43 void Export(
const std::string& file_path,
const T& data)
45 const toml::basic_value<toml::preserve_comments, std::map> value(data);
46 std::string res_str = toml::format(value);
48 InsertNewLine(&res_str);
50 IndentTable(&res_str);
62 ofs.write(res_str.c_str(), res_str.length());
71 void InsertNewLine(std::string* str)
81 char past_first_char =
' ';
83 for (
const auto& s : split_str)
87 past_first_char !=
'#' &&
88 past_first_char !=
' ')
93 past_first_char = s.size() != 0 ? s[0] :
' ';
103 void IndentTable(std::string* str)
113 bool do_indent =
false;
115 for (
size_t i = 0; i < split_str.size(); i++)
117 std::string past_s = i != 0 ? split_str[i - 1] :
"";
118 std::string next_s = i != split_str.size() - 1 ? split_str[i + 1] :
"";
119 std::string s = split_str[i];
121 if (past_s.size() != 0 && past_s[0] ==
'[')
126 if (next_s.size() != 0 && next_s[0] ==
'[')