MCPcopy Create free account
hub / github.com/LAStools/LAStools / format_message

Function format_message

LASzip/src/lasmessage.cpp:234–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234void format_message(std::string& messsage, unsigned multiline_ident, bool append_trailing_lf = true) {
235 size_t lines = messsage.find('\n');
236 if (lines == std::string::npos) {
237 lines = 1;
238 }
239 std::string result;
240 result.reserve(messsage.size() + (lines - 1) * multiline_ident + 1);
241
242 const std::string find_str = "\n\t";
243 std::string replace_str((size_t)multiline_ident + 1, ' ');
244 replace_str[0] = '\n';
245 size_t start_pos = 0, pos = messsage.find(find_str, start_pos);
246 while (pos != std::string::npos) {
247 result += messsage.substr(start_pos, pos - start_pos);
248 result += replace_str;
249 start_pos = pos + find_str.size();
250 pos = messsage.find(find_str, start_pos);
251 }
252 result += messsage.substr(start_pos, pos - start_pos);
253
254 if (append_trailing_lf) result += "\n";
255
256 messsage = result;
257}
258
259void las_default_message_handler(LAS_MESSAGE_TYPE type, const char* msg, void* user_data) {
260 std::string prefix;

Callers 1

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected