| 1194 | } |
| 1195 | |
| 1196 | void dump_string_yaml_multiline(FILE * stream, const char * prop_name, const char * data) { |
| 1197 | std::string data_str(data == NULL ? "" : data); |
| 1198 | |
| 1199 | if (data_str.empty()) { |
| 1200 | fprintf(stream, "%s:\n", prop_name); |
| 1201 | return; |
| 1202 | } |
| 1203 | |
| 1204 | size_t pos_start = 0; |
| 1205 | size_t pos_found = 0; |
| 1206 | |
| 1207 | if (!data_str.empty() && (std::isspace(data_str[0]) || std::isspace(data_str.back()))) { |
| 1208 | data_str = std::regex_replace(data_str, std::regex("\n"), "\\n"); |
| 1209 | data_str = std::regex_replace(data_str, std::regex("\""), "\\\""); |
| 1210 | data_str = "\"" + data_str + "\""; |
| 1211 | fprintf(stream, "%s: %s\n", prop_name, data_str.c_str()); |
| 1212 | return; |
| 1213 | } |
| 1214 | |
| 1215 | if (data_str.find('\n') == std::string::npos) { |
| 1216 | fprintf(stream, "%s: %s\n", prop_name, data_str.c_str()); |
| 1217 | return; |
| 1218 | } |
| 1219 | |
| 1220 | fprintf(stream, "%s: |\n", prop_name); |
| 1221 | while ((pos_found = data_str.find('\n', pos_start)) != std::string::npos) { |
| 1222 | fprintf(stream, " %s\n", data_str.substr(pos_start, pos_found-pos_start).c_str()); |
| 1223 | pos_start = pos_found + 1; |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | std::string get_sortable_timestamp() { |
| 1228 | using clock = std::chrono::system_clock; |
no test coverage detected